]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add function-prototypes for all register-type calls
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 1 Dec 2016 17:09:48 +0000 (18:09 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 1 Dec 2016 17:09:48 +0000 (18:09 +0100)
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
codegen/valatyperegisterfunction.vala

index 991b57a734805a9178354ebacd51e302b6ec4903..3a89c7e41ea662138f5184fd12513ea17acf91a5 100644 (file)
@@ -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);
index 9617f8240e254172bd9a81ff586edb573d241f33..5f8d2be0f6966daf1077933205e8fbd56cd3cc96 100644 (file)
@@ -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);