]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Map all gir namespaces before parsing gir files
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 3 Aug 2011 23:05:32 +0000 (01:05 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 3 Aug 2011 23:24:59 +0000 (01:24 +0200)
vala/valagirparser.vala

index 9a71429855d5eab7c0d6bc2f7fe1be623f2f845d..c8a74463422980b008fc13d9200804280d20acb9 100644 (file)
@@ -1035,6 +1035,8 @@ public class Vala.GirParser : CodeVisitor {
                tree_stack = new ArrayList<Node> ();
                current = root;
 
+               map_vala_to_gir ();
+
                context.accept (this);
 
                resolve_gir_symbols ();
@@ -1047,23 +1049,26 @@ public class Vala.GirParser : CodeVisitor {
                }
        }
 
-       public override void visit_source_file (SourceFile source_file) {
-               // collect gir namespaces
-               foreach (var node in source_file.get_nodes ()) {
-                       if (node is Namespace) {
-                               var ns = (Namespace) node;
-                               var gir_namespace = source_file.gir_namespace;
-                               if (gir_namespace == null) {
-                                       gir_namespace = ns.get_attribute_string ("CCode", "gir_namespace");
-                               }
-                               if (gir_namespace != null && gir_namespace != ns.name) {
-                                       var map_from = new UnresolvedSymbol (null, gir_namespace);
-                                       set_symbol_mapping (map_from, ns);
-                                       break;
+       void map_vala_to_gir () {
+               foreach (var source_file in context.get_source_files ()) {
+                       foreach (var node in source_file.get_nodes ()) {
+                               if (node is Namespace) {
+                                       var ns = (Namespace) node;
+                                       var gir_namespace = source_file.gir_namespace;
+                                       if (gir_namespace == null) {
+                                               gir_namespace = ns.get_attribute_string ("CCode", "gir_namespace");
+                                       }
+                                       if (gir_namespace != null && gir_namespace != ns.name) {
+                                               var map_from = new UnresolvedSymbol (null, gir_namespace);
+                                               set_symbol_mapping (map_from, ns);
+                                               break;
+                                       }
                                }
                        }
                }
+       }
 
+       public override void visit_source_file (SourceFile source_file) {
                if (source_file.filename.has_suffix (".gir")) {
                        parse_file (source_file);
                }