vala r1455 - in trunk: . vala



Author: jamiemcc
Date: Tue May 27 04:07:32 2008
New Revision: 1455
URL: http://svn.gnome.org/viewvc/vala?rev=1455&view=rev

Log:
2008-05-27  Jamie McCracken  <jamiemcc gnome org>

	* vala/valagenieparser.vala: 
	
	Made GLib using directive optional 
	


Modified:
   trunk/ChangeLog
   trunk/vala/valagenieparser.vala

Modified: trunk/vala/valagenieparser.vala
==============================================================================
--- trunk/vala/valagenieparser.vala	(original)
+++ trunk/vala/valagenieparser.vala	Tue May 27 04:07:32 2008
@@ -2146,15 +2146,19 @@
 	}
 
 
-	void add_uses_clause () throws ParseError {
+	bool add_uses_clause () throws ParseError {
 		var begin = get_location ();
 		var sym = parse_symbol_name ();
 		var ns_ref = new NamespaceReference (sym.name, get_src (begin));
 
 		scanner.source_file.add_using_directive (ns_ref);
+		
+		return (sym.name == "GLib");
 	}
 
 	void parse_using_directives () throws ParseError {
+		var has_glib = false;
+		var begin = get_location ();
 		while (accept (TokenType.USES)) {
 			var begin = get_location ();
 
@@ -2162,7 +2166,9 @@
 				expect (TokenType.INDENT);
 
 				while (current () != TokenType.DEDENT && current () != TokenType.EOF) {
-					add_uses_clause ();
+					if (add_uses_clause ()) {
+						has_glib = true;
+					}
 					expect (TokenType.EOL);	
 				}
 
@@ -2175,6 +2181,12 @@
 				expect_terminator ();
 			}
 		}
+		
+		if (!has_glib) {
+			var ns_ref = new NamespaceReference ("GLib", get_src (begin));
+			scanner.source_file.add_using_directive (ns_ref);
+		}
+		
 	}
 
 	Symbol parse_class_declaration (Gee.List<Attribute>? attrs) throws ParseError {



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