[vala/0.52] codegen/vala: Improve check for GLib.Source derived classes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.52] codegen/vala: Improve check for GLib.Source derived classes
- Date: Thu, 27 May 2021 07:19:26 +0000 (UTC)
commit e55f4341f5c994f78f27e0e3fa6685f1578f4962
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu May 20 21:24:38 2021 +0200
codegen/vala: Improve check for GLib.Source derived classes
codegen/valaccodemethodcallmodule.vala | 4 ++--
codegen/valagtypemodule.vala | 12 ++++++------
vala/valaclass.vala | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 50fdbbd69..439afdab6 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -202,7 +202,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
type_param_index++;
}
}
- } else if (current_class.base_class == gsource_type) {
+ } else if (current_class.is_subtype_of (gsource_type)) {
// g_source_new
string class_prefix = get_ccode_lower_case_name (current_class);
@@ -990,7 +990,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
}
- if (m is CreationMethod && m.parent_symbol is Class && ((current_class.is_compact &&
current_class.base_class != null) || current_class.base_class == gsource_type)) {
+ if (m is CreationMethod && m.parent_symbol is Class && ((current_class.is_compact &&
current_class.base_class != null) || current_class.is_subtype_of (gsource_type))) {
var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf
(get_ccode_lower_case_name (current_class, null))));
cinitcall.add_argument (get_this_cexpression ());
if (!current_class.is_compact) {
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 1fea214bb..e7938dc28 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -63,7 +63,7 @@ public class Vala.GTypeModule : GErrorModule {
bool is_gtypeinstance = !cl.is_compact;
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
- bool is_gsource = cl.base_class == gsource_type;
+ bool is_gsource = cl.is_subtype_of (gsource_type);
if (is_gtypeinstance) {
decl_space.add_include ("glib-object.h");
@@ -642,7 +642,7 @@ public class Vala.GTypeModule : GErrorModule {
begin_class_finalize_function (cl);
begin_finalize_function (cl);
} else {
- if (cl.is_compact || cl.base_class == null || cl.base_class == gsource_type) {
+ if (cl.is_compact || cl.base_class == null || cl.is_subtype_of (gsource_type)) {
begin_instance_init_function (cl);
begin_finalize_function (cl);
}
@@ -782,7 +782,7 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_function (unref_fun);
}
} else {
- if (cl.is_compact || cl.base_class == null || cl.base_class == gsource_type) {
+ if (cl.is_compact || cl.base_class == null || cl.is_subtype_of (gsource_type)) {
add_instance_init_function (cl);
add_finalize_function (cl);
}
@@ -1624,7 +1624,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (func);
- bool is_gsource = cl.base_class == gsource_type;
+ bool is_gsource = cl.is_subtype_of (gsource_type);
if (cl.is_compact) {
// Add declaration, since the instance_init function is explicitly called
@@ -1770,7 +1770,7 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_finalize_function (Class cl) {
push_context (instance_finalize_context);
- bool is_gsource = cl.base_class == gsource_type;
+ bool is_gsource = cl.is_subtype_of (gsource_type);
if (!cl.is_compact || is_gsource) {
var fundamental_class = cl;
@@ -1864,7 +1864,7 @@ public class Vala.GTypeModule : GErrorModule {
pop_context ();
cfile.add_function (instance_finalize_context.ccode);
- } else if (cl.base_class == gsource_type) {
+ } else if (cl.is_subtype_of (gsource_type)) {
cfile.add_function (instance_finalize_context.ccode);
}
}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 88339dec1..b6bd63773 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -708,7 +708,7 @@ public class Vala.Class : ObjectTypeSymbol {
}
}
- if (!external && !external_package && base_class != null && base_class !=
context.analyzer.gsource_type) {
+ if (!external && !external_package && base_class != null && !base_class.is_subtype_of
(context.analyzer.gsource_type)) {
foreach (Field f in get_fields ()) {
if (f.binding == MemberBinding.INSTANCE) {
error = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]