From: Rico Tzschichholz Date: Thu, 1 Dec 2016 17:09:48 +0000 (+0100) Subject: codegen: Add function-prototypes for all register-type calls X-Git-Tag: 0.35.2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f750884caf851baea27a0bc8e801bedbe94c51c;p=thirdparty%2Fvala.git codegen: Add function-prototypes for all register-type calls Make sure to match the list of called register-type calls and include implemented classes and interfaces. https://bugzilla.gnome.org/show_bug.cgi?id=775446 --- diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 991b57a73..3a89c7e41 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -297,6 +297,12 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } } + // Add function prototypes for required register-type-calls which are likely external + var register_func = new CCodeFunction ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null)), "GType"); + register_func.add_parameter (new CCodeParameter ("module", "GTypeModule *")); + register_func.is_declaration = true; + cfile.add_function_declaration (register_func); + var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null)))); register_call.add_argument (new CCodeIdentifier (module_init_param_name)); ccode.add_expression (register_call); diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index 9617f8240..5f8d2be0f 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -78,6 +78,10 @@ public abstract class Vala.TypeRegisterFunction { // avoid C warning as this function is not always used fun.modifiers |= CCodeModifiers.INTERNAL | CCodeModifiers.UNUSED; } + + fun.is_declaration = true; + declaration_fragment.append (fun.copy ()); + fun.is_declaration = false; } else { fun = new CCodeFunction ("%s_register_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType"); fun.add_parameter (new CCodeParameter ("module", "GTypeModule *")); @@ -250,10 +254,6 @@ public abstract class Vala.TypeRegisterFunction { type_block.add_statement (new CCodeReturnStatement (new CCodeIdentifier (type_id_name))); } - fun.is_declaration = true; - declaration_fragment.append (fun.copy ()); - fun.is_declaration = false; - fun.block = type_block; definition_fragment.append (fun);