]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Emit external creation methods in bindings
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 7 Apr 2021 16:14:16 +0000 (18:14 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Apr 2021 19:31:27 +0000 (21:31 +0200)
These must be chained up to an existing constructor of the parent symbol

codegen/valaccodebasemodule.vala
codegen/valaccodemethodmodule.vala

index 415522c42fe89698d8ccdb751f4b841a0f47582e..cf12c4ecde0c4ac98f14d4b88c701a04c538c613 100644 (file)
@@ -4905,6 +4905,18 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        generate_method_declaration (m, cfile);
 
+                       if (m is CreationMethod && !m.external && m.external_package) {
+                               unowned CreationMethod cm = (CreationMethod) m;
+                               if (!cm.chain_up) {
+                                       Report.error (cm.source_reference, "internal: Creation method implementation in binding must be chained up");
+                               }
+                               // internal VAPI creation methods
+                               // only add them once per source file
+                               if (add_generated_external_symbol (cm)) {
+                                       visit_creation_method (cm);
+                               }
+                       }
+
                        unowned Class? cl = expr.type_reference.type_symbol as Class;
 
                        if (!get_ccode_has_new_function (m)) {
index df3b8b274b4e45a74d9678de22069e323b1ac284..83a248e0121b62b77e631771d99909204d14638b 100644 (file)
@@ -1232,7 +1232,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                visit_method (m);
                ellipses_to_valist = false;
 
-               if (m.source_type == SourceFileType.FAST) {
+               if ((!m.external && m.external_package) || m.source_type == SourceFileType.FAST) {
                        pop_line ();
                        return;
                }