Commit 7adb3a45 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Emit delegate/enum typedefs to type-declaration section

This fixes compilation of circular dependency of delegates with enums,
structs, classes and interfaces.

Resolve interface prerequisites after writing forward declarations to
fix entagled delegate dependencies in them.

Fixes #318
parent 34dd7196
......@@ -847,8 +847,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile = current_cfile;
decl_space.add_type_definition (cenum);
decl_space.add_type_definition (new CCodeNewline ());
decl_space.add_type_declaration (cenum);
decl_space.add_type_declaration (new CCodeNewline ());
if (context.profile != Profile.GOBJECT || !get_ccode_has_type_id (en)) {
return true;
......
......@@ -124,7 +124,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
var ctypedef = new CCodeTypeDefinition (return_type_cname, cfundecl);
ctypedef.modifiers |= (d.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
decl_space.add_type_definition (ctypedef);
decl_space.add_type_declaration (ctypedef);
}
public override void visit_delegate (Delegate d) {
......
......@@ -2074,16 +2074,6 @@ public class Vala.GTypeModule : GErrorModule {
return;
}
foreach (DataType prerequisite in iface.get_prerequisites ()) {
var prereq_cl = prerequisite.data_type as Class;
var prereq_iface = prerequisite.data_type as Interface;
if (prereq_cl != null) {
generate_class_declaration (prereq_cl, decl_space);
} else if (prereq_iface != null) {
generate_interface_declaration (prereq_iface, decl_space);
}
}
decl_space.add_include ("glib-object.h");
var type_struct = new CCodeStruct ("_%s".printf (get_ccode_type_name (iface)));
......@@ -2105,6 +2095,16 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (iface)), new CCodeVariableDeclarator (get_ccode_name (iface))));
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_struct.name), new CCodeVariableDeclarator (get_ccode_type_name (iface))));
foreach (DataType prerequisite in iface.get_prerequisites ()) {
var prereq_cl = prerequisite.data_type as Class;
var prereq_iface = prerequisite.data_type as Interface;
if (prereq_cl != null) {
generate_class_declaration (prereq_cl, decl_space);
} else if (prereq_iface != null) {
generate_interface_declaration (prereq_iface, decl_space);
}
}
type_struct.add_field ("GTypeInterface", "parent_iface");
if (iface.get_attribute ("GenericAccessors") != null) {
......
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