[vala] Genie: Fixed comments for copyright statements



commit 8ccc4ebba62a315243fa05d9e19c97071681d9dd
Author: Jamie McCracken <jamiemcc gnome org>
Date:   Sun Sep 27 13:50:17 2009 -0400

    Genie: Fixed comments for copyright statements
    
    Copyright comments at top of genie files now have those
    comments propgated to the generated c files

 vala/valagenieparser.vala  |    1 +
 vala/valageniescanner.vala |   29 +++++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 0741593..f982744 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 718a70b..d36ec35 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]