diff options
author | Alistair Thomas <astavale@yahoo.co.uk> | 2015-10-27 18:23:09 +0000 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-08-18 09:26:29 +0200 |
commit | 20ac260375477f7447b76dc5cce35fdcc1cc672d (patch) | |
tree | 9ab5681f465bb3cca86b05fd32dbc5fd8519e725 | |
parent | 00c752c51e176714e58fa7a5b6422524b6ae41bb (diff) | |
download | vala-20ac260375477f7447b76dc5cce35fdcc1cc672d.tar.gz |
codegen: Always include base_struct declaration if available
This fixes inheritance of structs across source files while not using
a header file.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/464
-rw-r--r-- | codegen/valaccodestructmodule.vala | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala index c2882047d..66593a212 100644 --- a/codegen/valaccodestructmodule.vala +++ b/codegen/valaccodestructmodule.vala @@ -30,27 +30,30 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule { return; } + if (st.base_struct != null) { + generate_struct_declaration (st.base_struct, decl_space); + } + if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) { + string typename; // 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)))); + typename = get_ccode_name (st.base_struct); + } else if (st.is_boolean_type ()) { + // typedef for boolean types + decl_space.add_include ("stdbool.h"); + typename = "bool"; + } else if (st.is_integer_type ()) { + // typedef for integral types + decl_space.add_include ("stdint.h"); + typename = "%sint%d_t".printf (st.signed ? "" : "u", st.width); + } else if (st.is_floating_type ()) { + // typedef for floating types + typename = (st.width == 64 ? "double" : "float"); } else { - string typename = null; - if (st.is_boolean_type ()) { - // typedef for boolean types - decl_space.add_include ("stdbool.h"); - typename = "bool"; - } else if (st.is_integer_type ()) { - // typedef for integral types - decl_space.add_include ("stdint.h"); - typename = "%sint%d_t".printf (st.signed ? "" : "u", st.width); - } else if (st.is_floating_type ()) { - // typedef for floating types - typename = (st.width == 64 ? "double" : "float"); - } - decl_space.add_type_declaration (new CCodeTypeDefinition (typename, new CCodeVariableDeclarator (get_ccode_name (st)))); + assert_not_reached (); } + decl_space.add_type_declaration (new CCodeTypeDefinition (typename, new CCodeVariableDeclarator (get_ccode_name (st)))); return; } |