[vala/staging: 4/10] codegen: Only emit declaration of *_register_type if needed
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 4/10] codegen: Only emit declaration of *_register_type if needed
- Date: Sat, 23 Feb 2019 21:57:34 +0000 (UTC)
commit 5d7b6a1e59dc330b2bdcf0ff8ff38a85adda8edc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Feb 23 20:19:31 2019 +0100
codegen: Only emit declaration of *_register_type if needed
This allows to add a test case for ModuleInit with -Werror=redundant-decls
codegen/valaccodemethodmodule.vala | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 4adf1f4b3..bc7a3b2a1 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -289,10 +289,13 @@ 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);
+ if (type_symbol.source_reference.file != cfile.file) {
+ // TODO Duplicated source with TypeRegisterFunction.init_from_type()
+ 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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]