]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always use G_TYPE_INSTANCE_GET_CLASS/INTERFACE for external symbols
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jan 2021 20:17:25 +0000 (21:17 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jan 2021 20:17:25 +0000 (21:17 +0100)
and get_ccode_type_get_function() for SourceFileType.SOURCE symbols.

codegen/valaccodememberaccessmodule.vala
codegen/valaccodemethodcallmodule.vala

index 0a85a058d12eb459bb6daccc523574860b3c8b45..bdd34d9e9382b37a5255bc8a7d8a72e45ca67cf2 100644 (file)
@@ -68,8 +68,16 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                if (m.base_method.get_attribute ("NoWrapper") != null) {
                                        var base_class = (Class) m.base_method.parent_symbol;
                                        if (!base_class.is_compact) {
-                                               var vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class)));
-                                               vclass.add_argument (pub_inst);
+                                               CCodeFunctionCall vclass;
+                                               if (base_class.external_package) {
+                                                       vclass = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_CLASS"));
+                                                       vclass.add_argument (pub_inst);
+                                                       vclass.add_argument (new CCodeIdentifier (get_ccode_type_id (base_class)));
+                                                       vclass.add_argument (new CCodeIdentifier (get_ccode_type_name (base_class)));
+                                               } else {
+                                                       vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class)));
+                                                       vclass.add_argument (pub_inst);
+                                               }
                                                set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, get_ccode_vfunc_name (m)));
                                        } else {
                                                set_cvalue (expr, new CCodeMemberAccess.pointer (pub_inst, get_ccode_vfunc_name (m)));
@@ -80,8 +88,16 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                        } else if (m.base_interface_method != null) {
                                if (m.base_interface_method.get_attribute ("NoWrapper") != null) {
                                        var base_iface = (Interface) m.base_interface_method.parent_symbol;
-                                       var vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface)));
-                                       vclass.add_argument (pub_inst);
+                                       CCodeFunctionCall vclass;
+                                       if (base_iface.external_package) {
+                                               vclass = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_INTERFACE"));
+                                               vclass.add_argument (pub_inst);
+                                               vclass.add_argument (new CCodeIdentifier (get_ccode_type_id (base_iface)));
+                                               vclass.add_argument (new CCodeIdentifier (get_ccode_type_name (base_iface)));
+                                       } else {
+                                               vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface)));
+                                               vclass.add_argument (pub_inst);
+                                       }
                                        set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, get_ccode_vfunc_name (m)));
                                } else {
                                        set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m.base_interface_method)));
index 7506e6a521afd13560f3e9dd4639fb314931bb97..407a30685ccc1382f55b1bfbd7e61c6302a1b63a 100644 (file)
@@ -119,12 +119,26 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                CCodeFunctionCall? vcast = null;
                                if (m.parent_symbol is Class) {
                                        unowned Class base_class = (Class) m.parent_symbol;
-                                       vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class)));
-                                       vcast.add_argument (pub_inst);
+                                       if (base_class.external_package) {
+                                               vcast = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_CLASS"));
+                                               vcast.add_argument (pub_inst);
+                                               vcast.add_argument (new CCodeIdentifier (get_ccode_type_id (base_class)));
+                                               vcast.add_argument (new CCodeIdentifier (get_ccode_type_name (base_class)));
+                                       } else {
+                                               vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class)));
+                                               vcast.add_argument (pub_inst);
+                                       }
                                } else if (m.parent_symbol is Interface) {
                                        unowned Interface base_iface = (Interface) m.parent_symbol;
-                                       vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface)));
-                                       vcast.add_argument (pub_inst);
+                                       if (base_iface.external_package) {
+                                               vcast = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_INTERFACE"));
+                                               vcast.add_argument (pub_inst);
+                                               vcast.add_argument (new CCodeIdentifier (get_ccode_type_id (base_iface)));
+                                               vcast.add_argument (new CCodeIdentifier (get_ccode_type_name (base_iface)));
+                                       } else {
+                                               vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface)));
+                                               vcast.add_argument (pub_inst);
+                                       }
                                }
                                if (vcast != null) {
                                        async_call.call = new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m));