[vala/0.50] 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.50] codegen/vala: Improve check for GLib.Source derived classes
- Date: Fri, 4 Jun 2021 07:28:03 +0000 (UTC)
commit 15411dad2b63ddb82c12b700415a9edd38171f3a
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 a7e61c221..3b4d03b24 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);
@@ -979,7 +979,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 7ab1b2d84..4f0ea8670 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");
@@ -638,7 +638,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);
}
@@ -778,7 +778,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);
}
@@ -1620,7 +1620,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
@@ -1766,7 +1766,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;
@@ -1860,7 +1860,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 a8b352eef..6768f26bd 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -702,7 +702,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]