]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Genie: Fixed comments for copyright statements
authorJamie McCracken <jamiemcc gnome org>
Sun, 27 Sep 2009 17:50:17 +0000 (13:50 -0400)
committerJamie McCracken <jamiemcc gnome org>
Sun, 27 Sep 2009 17:50:54 +0000 (13:50 -0400)
Copyright comments at top of genie files now have those
comments propgated to the generated c files

vala/valagenieparser.vala
vala/valageniescanner.vala

index 0741593f8b33fa905582a5ae459253d0ab398890..f982744d8b4f01eb89f069155e8673f30ff9280a 100644 (file)
@@ -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;
index 718a70b96a0323ca29888259ecf893466a96106c..d36ec3504cb9d6148939f6c7cd20ade576b801d2 100644 (file)
@@ -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);