]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Delay adding of "GLib.Object" prerequisite to interfaces
authorPrinceton Ferro <princetonferro@gmail.com>
Mon, 3 Feb 2020 08:26:34 +0000 (03:26 -0500)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 3 Mar 2020 09:28:30 +0000 (10:28 +0100)
vala/valagirparser.vala

index 1e0d9a939f1b2ac1c85bdfd6d0920447a3b261a9..88f874d8f4f3507d2ccdeba51e3fe3fda9875b31 100644 (file)
@@ -1309,7 +1309,6 @@ public class Vala.GirParser : CodeVisitor {
        MarkupReader reader;
 
        CodeContext context;
-       Namespace glib_ns;
 
        SourceFile current_source_file;
        Node root;
@@ -1331,6 +1330,7 @@ public class Vala.GirParser : CodeVisitor {
        HashMap<UnresolvedSymbol,Symbol> unresolved_symbols_map = new HashMap<UnresolvedSymbol,Symbol> (unresolved_symbol_hash, unresolved_symbol_equal);
        ArrayList<UnresolvedSymbol> unresolved_gir_symbols = new ArrayList<UnresolvedSymbol> ();
        HashMap<UnresolvedType,Node> unresolved_type_arguments = new HashMap<UnresolvedType,Node> ();
+       ArrayList<Interface> ifaces_needing_object_prereq = new ArrayList<Interface> ();
 
        /**
         * Parses all .gir source files in the specified code
@@ -1340,7 +1340,6 @@ public class Vala.GirParser : CodeVisitor {
         */
        public void parse (CodeContext context) {
                this.context = context;
-               glib_ns = context.root.scope.lookup ("GLib") as Namespace;
 
                root = new Node (null);
                root.symbol = context.root;
@@ -1357,6 +1356,16 @@ public class Vala.GirParser : CodeVisitor {
 
                root.process (this);
 
+               /* Temporarily workaround G-I bug not adding GLib.Object prerequisite:
+                  ensure we have at least one instantiable prerequisite */
+               var glib_ns = context.root.scope.lookup ("GLib") as Namespace;
+               if (glib_ns != null) {
+                       var object_type = (Class) glib_ns.scope.lookup ("Object");
+                       foreach (var iface in ifaces_needing_object_prereq) {
+                               iface.add_prerequisite (new ObjectType (object_type));
+                       }
+               }
+
                foreach (var metadata in metadata_roots) {
                        report_unused_metadata (metadata);
                }
@@ -3742,7 +3751,7 @@ public class Vala.GirParser : CodeVisitor {
                }
 
                if (!has_instantiable_prereq) {
-                       iface.add_prerequisite (new ObjectType ((ObjectTypeSymbol) glib_ns.scope.lookup ("Object")));
+                       ifaces_needing_object_prereq.add (iface);
                }
        }