]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Populate gir_namespace/version attributes of external namespaces 96c0d9b19a4c153f960bb094f971c15e912e54be 62/head
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 27 Apr 2019 11:20:28 +0000 (13:20 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 29 Apr 2019 14:58:27 +0000 (16:58 +0200)
codegen/valagirwriter.vala

index 355ef856b3052f7301806552346d46191c3ad166..441c7c5870cbca74dbdaaa1ff2e2fdc5ea7032d4 100644 (file)
@@ -162,6 +162,11 @@ public class Vala.GIRWriter : CodeVisitor {
 
                write_package (package);
 
+               // Make sure to initialize external files with their gir_namespace/version
+               foreach (var file in context.get_source_files ()) {
+                       file.accept (this);
+               }
+
                context.accept (this);
 
                indent--;
@@ -252,6 +257,26 @@ public class Vala.GIRWriter : CodeVisitor {
                buffer.append_printf ("<c:include name=\"%s\"/>\n", name);
        }
 
+       public override void visit_source_file (SourceFile source_file) {
+               if (source_file.file_type != SourceFileType.PACKAGE) {
+                       return;
+               }
+
+               // Populate gir_namespace/version of source-file like in Namespace.check()
+               foreach (var node in source_file.get_nodes ()) {
+                       if (node is Namespace && ((Namespace) node).parent_symbol == context.root) {
+                               var a = node.get_attribute ("CCode");
+                               if (a != null && a.has_argument ("gir_namespace")) {
+                                       source_file.gir_namespace = a.get_string ("gir_namespace");
+                               }
+                               if (a != null && a.has_argument ("gir_version")) {
+                                       source_file.gir_version = a.get_string ("gir_version");
+                               }
+                               break;
+                       }
+               }
+       }
+
        public override void visit_namespace (Namespace ns) {
                if (ns.external_package) {
                        return;