[vala/0.40] codegen: Skip StructRegisterFunction for boolean/integer/floating types



commit d5f552a509c8f18c1d754bded85e91bdd3f2d1e0
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 ++++++
 2 files changed, 7 insertions(+)
---
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 759817e81..620a07e3f 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 cb4efa213..5072f0e69 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2316,6 +2316,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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]