[vala/0.46] codegen: Skip StructRegisterFunction for boolean/integer/floating types
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] codegen: Skip StructRegisterFunction for boolean/integer/floating types
- Date: Wed, 5 Feb 2020 10:04:36 +0000 (UTC)
commit a966b4f530d156b6e1aee04be7d9245aec73ae0e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Jan 24 23:29:01 2020 +0100
codegen: Skip StructRegisterFunction for boolean/integer/floating types
Fixes https://gitlab.gnome.org/GNOME/vala/issues/901
codegen/valaccodestructmodule.vala | 1 +
codegen/valagtypemodule.vala | 6 ++++++
tests/Makefile.am | 1 +
tests/structs/struct-no-gtype-inherit.vala | 11 +++++++++++
4 files changed, 19 insertions(+)
---
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 83c1a67a3..e5d6fac35 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -31,6 +31,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
+ // See GTypeModule.visit_struct()
if (st.base_struct != null) {
generate_struct_declaration (st.base_struct, decl_space);
decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name
(st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 3cf797526..ff0be7e08 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2346,6 +2346,12 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_struct (Struct st) {
base.visit_struct (st);
+ if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
+ // Skip GType handling for these struct types,
+ // like in CCodeStructModule.generate_struct_declaration()
+ return;
+ }
+
if (get_ccode_has_type_id (st)) {
push_line (st.source_reference);
var type_fun = new StructRegisterFunction (st);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f83f58027..facea05e5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -234,6 +234,7 @@ TESTS = \
structs/struct-base-types.vala \
structs/struct-empty-still.test \
structs/struct-no-gtype.vala \
+ structs/struct-no-gtype-inherit.vala \
structs/struct-static-field-initializer.vala \
structs/struct-static-field-initializer.test \
structs/struct-static-property-initializer.test \
diff --git a/tests/structs/struct-no-gtype-inherit.vala b/tests/structs/struct-no-gtype-inherit.vala
new file mode 100644
index 000000000..3dc3e8c0a
--- /dev/null
+++ b/tests/structs/struct-no-gtype-inherit.vala
@@ -0,0 +1,11 @@
+[SimpleType]
+[IntegerType (rank = 6, signed = true, width = 32)]
+[CCode (has_type_id = false)]
+struct foo_t {
+}
+
+struct bar_t : foo_t {
+}
+
+void main () {
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]