From: Jamie McCracken Date: Sun, 27 Sep 2009 17:50:17 +0000 (-0400) Subject: Genie: Fixed comments for copyright statements X-Git-Tag: 0.7.7~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8ccc4ebba62a315243fa05d9e19c97071681d9dd;p=thirdparty%2Fvala.git Genie: Fixed comments for copyright statements Copyright comments at top of genie files now have those comments propgated to the generated c files --- diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala index 0741593f8..f982744d8 100644 --- a/vala/valagenieparser.vala +++ b/vala/valagenieparser.vala @@ -358,6 +358,7 @@ public class Vala.Genie.Parser : CodeVisitor { public void parse_file (SourceFile source_file) { scanner = new Scanner (source_file); + scanner.parse_file_comments (); scanner.indent_spaces = 0; index = -1; size = 0; diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala index 718a70b96..d36ec3504 100644 --- a/vala/valageniescanner.vala +++ b/vala/valageniescanner.vala @@ -1052,15 +1052,22 @@ public class Vala.Genie.Scanner { return new_lines; } - bool comment () { + bool comment (bool file_comment = false) { if (current > end - 2 || current[0] != '/' || (current[1] != '/' && current[1] != '*')) { return false; } + if (current[1] == '/') { // single-line comment + + SourceReference source_reference = null; + if (file_comment) { + source_reference = new SourceReference (source_file, line, column, line, column); + } + current += 2; // skip until end of line or end of file @@ -1075,17 +1082,25 @@ public class Vala.Genie.Scanner { column = 1; current_indent_level = 0; } + + if (source_reference != null) { + push_comment (((string) begin).ndup ((long) (current - begin)), source_reference, file_comment); + } + } else { // delimited comment SourceReference source_reference = null; + if (file_comment && current[2] == '*') { + return false; + } - if (current[2] == '*') { + if (current[2] == '*' || file_comment) { source_reference = new SourceReference (source_file, line, column, line, column); } current += 2; char* begin = current; - int begin_line = line; + while (current < end - 1 && (current[0] != '*' || current[1] != '/')) { if (current[0] == '\n') { @@ -1102,7 +1117,7 @@ public class Vala.Genie.Scanner { if (source_reference != null) { string comment = ((string) begin).ndup ((long) (current - begin)); - push_comment (comment, source_reference, begin_line == 1 && comment[0] != '*'); + push_comment (comment, source_reference, file_comment); } current += 2; @@ -1134,6 +1149,12 @@ public class Vala.Genie.Scanner { } } + public void parse_file_comments () { + while (whitespace () || comment (true)) { + } + + } + void push_comment (string comment_item, SourceReference source_reference, bool file_comment) { if (comment_item[0] == '*') { _comment = new Comment (comment_item, source_reference);