[vala/staging] girparser: Delay adding of "GLib.Object" prerequisite to interfaces



commit 7109dd0a0c5823e04659d986a5e00b92bd0dfae8
Author: Princeton Ferro <princetonferro gmail com>
Date:   Mon Feb 3 03:26:34 2020 -0500

    girparser: Delay adding of "GLib.Object" prerequisite to interfaces

 vala/valagirparser.vala | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 1e0d9a939..88f874d8f 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -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);
                }
        }
 


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