diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-12-01 18:09:48 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-12-01 18:09:48 +0100 |
commit | 6f750884caf851baea27a0bc8e801bedbe94c51c (patch) | |
tree | d99e8ee6b8692928f8a7d5b440b1a32985449d6a /codegen | |
parent | 75b292f461b42765619ad4720ff64e9d985a312f (diff) | |
download | vala-6f750884caf851baea27a0bc8e801bedbe94c51c.tar.gz |
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
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valaccodemethodmodule.vala | 6 | ||||
-rw-r--r-- | codegen/valatyperegisterfunction.vala | 8 |
2 files changed, 10 insertions, 4 deletions
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); |