[vala/0.50] codegen: Always use G_TYPE_INSTANCE_GET_CLASS/INTERFACE for external symbols
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] codegen: Always use G_TYPE_INSTANCE_GET_CLASS/INTERFACE for external symbols
- Date: Sun, 28 Feb 2021 08:58:21 +0000 (UTC)
commit 68c16cc4a8e372b35d2977f07e24858b4b1ce6c3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 30 21:17:25 2021 +0100
codegen: Always use G_TYPE_INSTANCE_GET_CLASS/INTERFACE for external symbols
and get_ccode_type_get_function() for SourceFileType.SOURCE symbols.
codegen/valaccodememberaccessmodule.vala | 24 ++++++++++++++++++++----
codegen/valaccodemethodcallmodule.vala | 22 ++++++++++++++++++----
2 files changed, 38 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 0e995d3c9..a3d8ef0f8 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -68,8 +68,16 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (!method_has_wrapper (m.base_method)) {
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)));
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 358a9896b..48d11eb67 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]