[vala/staging] codegen: Fix support for public fields on GLib.Source subclasses
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Fix support for public fields on GLib.Source subclasses
- Date: Sun, 23 May 2021 16:10:45 +0000 (UTC)
commit bf2f5c1ef74f4f242da35f25e28e1669964c8e97
Author: Ole André Vadla Ravnås <oleavr gmail com>
Date: Sat May 22 23:37:28 2021 +0200
codegen: Fix support for public fields on GLib.Source subclasses
codegen/valagtypemodule.vala | 5 ++---
tests/objects/gsource.vala | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 5930fcc74..a54b32619 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -89,7 +89,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_type_declaration (new CCodeNewline ());
}
- if (cl.is_compact && cl.base_class != null) {
+ if (!(!cl.is_compact || cl.base_class == null || compact_class_has_instance_struct_member
(cl))) {
decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name
(cl.base_class), new CCodeVariableDeclarator (get_ccode_name (cl))));
} else {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf
(get_ccode_name (cl)), new CCodeVariableDeclarator (get_ccode_name (cl))));
@@ -339,8 +339,7 @@ public class Vala.GTypeModule : GErrorModule {
instance_struct.add_field ("int", "dummy");
}
- if (!cl.is_compact || cl.base_class == null) {
- // derived compact classes do not have a struct
+ if (!cl.is_compact || cl.base_class == null || compact_class_has_instance_struct_member (cl))
{
decl_space.add_type_definition (instance_struct);
}
diff --git a/tests/objects/gsource.vala b/tests/objects/gsource.vala
index cb2543979..753d2c4d9 100644
--- a/tests/objects/gsource.vala
+++ b/tests/objects/gsource.vala
@@ -13,6 +13,28 @@ class FooSource : Source {
}
}
+class BarSource : Source {
+ public int custom_timeout;
+
+ public BarSource (int timeout) {
+ custom_timeout = timeout;
+ }
+
+ public override bool prepare (out int timeout) {
+ timeout = custom_timeout;
+ return false;
+ }
+
+ public override bool check () {
+ return false;
+ }
+
+ public override bool dispatch (SourceFunc? callback) {
+ return false;
+ }
+}
+
void main () {
var foo = new FooSource ();
+ var bar = new BarSource (1000);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]