]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Emit struct declaration typedef before resolving its fields
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 10 Jan 2019 19:02:39 +0000 (20:02 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 28 Feb 2019 17:25:40 +0000 (18:25 +0100)
This a regression when compiling a circular dependency of delegates with
structs.

Regression of 7adb3a45bb8d663c0cfca55af26b7e6f7292b14a

See https://gitlab.gnome.org/GNOME/vala/issues/318

codegen/valaccodestructmodule.vala

index b1f160c1df56e5371010c95fe26d4a9046d391f4..66b8fe33abf9c56f77dc6f511330166088bfa12e 100644 (file)
@@ -64,6 +64,12 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                        decl_space.add_type_member_declaration (type_fun.get_declaration ());
                }
 
+               if (st.base_struct == null) {
+                       decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (st)), new CCodeVariableDeclarator (get_ccode_name (st))));
+               } else {
+                       decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
+               }
+
                var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (st)));
                instance_struct.modifiers |= (st.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
 
@@ -107,11 +113,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                }
 
                if (st.base_struct == null) {
-                       decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (st)), new CCodeVariableDeclarator (get_ccode_name (st))));
-
                        decl_space.add_type_definition (instance_struct);
-               } else {
-                       decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
                }
 
                var function = new CCodeFunction (get_ccode_dup_function (st), get_ccode_name (st) + "*");