Commit 79b4d15b authored by Levi Bard's avatar Levi Bard Committed by Jürg Billeter

Fix GType declaration for structs

Fixes bug 578162.
parent dbdb5df5
......@@ -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 ()) {
......
......@@ -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 ());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment