]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix GType declaration for structs
authorLevi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>
Wed, 15 Apr 2009 21:02:15 +0000 (23:02 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 15 Apr 2009 21:02:15 +0000 (23:02 +0200)
Fixes bug 578162.

gobject/valaccodestructmodule.vala
gobject/valagtypemodule.vala

index d1cfe5e88820b34785477eb4a32939d6d5038d65..7a61de8522dae4b2996147da606d3337b9d7bb9b 100644 (file)
@@ -34,6 +34,16 @@ internal class Vala.CCodeStructModule : CCodeBaseModule {
                        return;
                }
 
+               if (st.has_type_id) {
+                       decl_space.add_type_declaration (new CCodeNewline ());
+                       var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
+                       decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
+
+                       var type_fun = new StructRegisterFunction (st, context);
+                       type_fun.init_from_type (false);
+                       decl_space.add_type_member_declaration (type_fun.get_declaration ());
+               }
+
                var instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
 
                foreach (Field f in st.get_fields ()) {
index 8b6be984f2e4302e61854f4f019d7c92319f1723..7a7acbb15035be8dd5db43b97b06b990d5094f06 100644 (file)
@@ -1760,13 +1760,10 @@ internal class Vala.GTypeModule : GErrorModule {
        public override void visit_struct (Struct st) {
                base.visit_struct (st);
 
-               source_declarations.add_type_declaration (new CCodeNewline ());
-               var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
-               source_declarations.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
-
-               var type_fun = new StructRegisterFunction (st, context);
-               type_fun.init_from_type (false);
-               source_declarations.add_type_member_declaration (type_fun.get_declaration ());
-               source_type_member_definition.append (type_fun.get_definition ());
+               if (st.has_type_id) {
+                       var type_fun = new StructRegisterFunction (st, context);
+                       type_fun.init_from_type (false);
+                       source_type_member_definition.append (type_fun.get_definition ());
+               }
        }
 }