From b3e178b00ea77e2734f81262263e4ea1aab1e362 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Thu, 1 Dec 2016 18:09:48 +0100 Subject: [PATCH] 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 --- codegen/valaccodemethodmodule.vala | 6 ++++++ codegen/valatyperegisterfunction.vala | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index fc5ffc7..0f051f5 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -267,6 +267,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 b7c18f8..79ae1b3 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -80,6 +80,10 @@ public abstract class Vala.TypeRegisterFunction { // avoid C warning as this function is not always used fun.attributes += " G_GNUC_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 *")); @@ -252,10 +256,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); -- 2.9.3