[vala/wip/issue/901: 1/2] codegen: Skip StructRegisterFunction for boolean/integer/floating types
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/901: 1/2] codegen: Skip StructRegisterFunction for boolean/integer/floating types
- Date: Fri, 24 Jan 2020 22:37:13 +0000 (UTC)
commit 1cff550dd4975d156546a3a01750c878cfc4ed8a
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 2cd56bb67..c2882047d 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 72007249b..cbb38398e 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2242,6 +2242,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 24f9d1622..81cde2fe9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -241,6 +241,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]