From: Rico Tzschichholz Date: Wed, 7 Apr 2021 16:14:16 +0000 (+0200) Subject: codegen: Emit external creation methods in bindings X-Git-Tag: 0.53.1~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=472765b90cd98c1a628975d20005c46352d665f8;p=thirdparty%2Fvala.git codegen: Emit external creation methods in bindings These must be chained up to an existing constructor of the parent symbol --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 415522c42..cf12c4ecd 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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)) { diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index df3b8b274..83a248e01 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -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; }