]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix interfaces in GTypeModule-based plugins
authorRob Powell <rob@yorba.org>
Wed, 6 Jan 2010 22:08:36 +0000 (23:08 +0100)
committerJürg Billeter <j@bitron.ch>
Wed, 6 Jan 2010 22:08:36 +0000 (23:08 +0100)
Fixes bug 601343.

codegen/valaclassregisterfunction.vala
codegen/valadbusinterfaceregisterfunction.vala
codegen/valagtypemodule.vala
codegen/valainterfaceregisterfunction.vala
codegen/valastructregisterfunction.vala
codegen/valatyperegisterfunction.vala

index 1e299e780adfe080ca439b6d028c1cea2c290250..f73e960e84089c8fd8cb90ea972989c3db96ec36 100644 (file)
@@ -171,7 +171,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
                return frag;
        }
 
-       public override CCodeFragment get_type_interface_init_statements () {
+       public override CCodeFragment get_type_interface_init_statements (bool plugin) {
                var frag = new CCodeFragment ();
                
                foreach (DataType base_type in class_reference.get_base_types ()) {
@@ -182,12 +182,20 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
                        var iface = (Interface) base_type.data_type;
                        
                        var iface_info_name = "%s_info".printf (iface.get_lower_case_cname (null));
-                       
-                       var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_interface_static"));
-                       reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
-                       reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
-                       reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
-                       frag.append (new CCodeExpressionStatement (reg_call));
+                       if (!plugin) {
+                               var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_interface_static"));
+                               reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
+                               reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
+                               reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
+                               frag.append (new CCodeExpressionStatement (reg_call));
+                       } else {
+                               var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_module_add_interface"));
+                               reg_call.add_argument (new CCodeIdentifier ("module"));
+                               reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
+                               reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
+                               reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
+                               frag.append (new CCodeExpressionStatement (reg_call));
+                       }
                }
                
                return frag;
index 2eec9488ddff171c389aecd234c37a65045ca0aa..9aa2ec329e9feffce8989f9c9afb53908c53903b 100644 (file)
@@ -31,8 +31,8 @@ public class Vala.DBusInterfaceRegisterFunction : InterfaceRegisterFunction {
                base(iface, context);
        }
 
-       public override CCodeFragment get_type_interface_init_statements () {
-               var frag = base.get_type_interface_init_statements ();
+       public override CCodeFragment get_type_interface_init_statements (bool plugin) {
+               var frag = base.get_type_interface_init_statements (plugin);
                
                var quark_dbus_proxy = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_string"));
                quark_dbus_proxy.add_argument (new CCodeConstant ("\"ValaDBusInterfaceProxyType\""));
index 0acde87f382043219e00bb21da02d7709587111e..a7c69ae24057818e81f1d381c4dbb25af37d5a20 100644 (file)
@@ -1822,7 +1822,7 @@ internal class Vala.GTypeModule : GErrorModule {
                decl_space.add_type_definition (type_struct);
 
                var type_fun = create_interface_register_function (iface);
-               type_fun.init_from_type ();
+               type_fun.init_from_type (in_plugin);
                decl_space.add_type_member_declaration (type_fun.get_declaration ());
        }
 
@@ -1849,7 +1849,8 @@ internal class Vala.GTypeModule : GErrorModule {
                add_interface_base_init_function (iface);
 
                var type_fun = create_interface_register_function (iface);
-               type_fun.init_from_type ();
+               type_fun.init_from_type (in_plugin);
+               source_declarations.add_type_member_declaration (type_fun.get_source_declaration ());
                source_type_member_definition.append (type_fun.get_definition ());
 
                current_symbol = old_symbol;
index a3dd1a25b4e6e068ecc1ae891a4fe0252705c9d3..500e7ee3b23b796ed34ab03d2afe741734dbc327 100644 (file)
@@ -77,7 +77,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
                return interface_reference.access;
        }
 
-       public override CCodeFragment get_type_interface_init_statements () {
+       public override CCodeFragment get_type_interface_init_statements (bool plugin) {
                var frag = new CCodeFragment ();
                
                /* register all prerequisites */
index 210a995e451110974c8c964c8aa6a62ce1a5794d..1f79fdb47baf1a1d27e691a9992bd8633f676feb 100644 (file)
@@ -50,7 +50,7 @@ public class Vala.StructRegisterFunction : TypeRegisterFunction {
                return struct_reference.access;
        }
 
-       public override CCodeFragment get_type_interface_init_statements () {
+       public override CCodeFragment get_type_interface_init_statements (bool plugin) {
                return new CCodeFragment ();
        }
 }
index 736883fabc4cb70dcf00a4624f7e0b03714a07ab..4b4ffcb1d018b4ea3c6d9359f926334207dcf336 100644 (file)
@@ -35,7 +35,7 @@ public abstract class Vala.TypeRegisterFunction {
        /**
         * Constructs the C function from the specified type.
         */
-       public void init_from_type (bool plugin = false) {
+       public void init_from_type (bool plugin) {
                bool use_thread_safe = context.require_glib_version (2, 14);
 
                bool fundamental = false;
@@ -169,7 +169,7 @@ public abstract class Vala.TypeRegisterFunction {
                        type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (type_id_name), reg_call)));
                }
                
-               type_init.add_statement (get_type_interface_init_statements ());
+               type_init.add_statement (get_type_interface_init_statements (plugin));
 
                if (!plugin) {
                        CCodeExpression condition; // the condition that guards the type initialisation
@@ -364,7 +364,7 @@ public abstract class Vala.TypeRegisterFunction {
         *
         * @return C statements
         */
-       public abstract CCodeFragment get_type_interface_init_statements ();
+       public abstract CCodeFragment get_type_interface_init_statements (bool plugin);
        
        public CCodeFragment get_source_declaration () {
                return source_declaration_fragment;