From: Jürg Billeter Date: Sun, 26 Apr 2009 18:48:37 +0000 (+0200) Subject: Fix declarations of struct copy and free functions X-Git-Tag: 0.7.2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=507767eee6ab6ef3f34a5053c2cfb824d1008113;p=thirdparty%2Fvala.git Fix declarations of struct copy and free functions --- diff --git a/gobject/valaccodestructmodule.vala b/gobject/valaccodestructmodule.vala index 7a61de852..8132c7438 100644 --- a/gobject/valaccodestructmodule.vala +++ b/gobject/valaccodestructmodule.vala @@ -87,6 +87,37 @@ internal class Vala.CCodeStructModule : CCodeBaseModule { decl_space.add_type_definition (new CCodeComment (st.source_reference.comment)); } decl_space.add_type_definition (instance_struct); + + var function = new CCodeFunction (st.get_dup_function (), st.get_cname () + "*"); + if (st.is_private_symbol ()) { + function.modifiers = CCodeModifiers.STATIC; + } + function.add_parameter (new CCodeFormalParameter ("self", "const " + st.get_cname () + "*")); + decl_space.add_type_member_declaration (function); + + function = new CCodeFunction (st.get_free_function (), "void"); + if (st.is_private_symbol ()) { + function.modifiers = CCodeModifiers.STATIC; + } + function.add_parameter (new CCodeFormalParameter ("self", st.get_cname () + "*")); + decl_space.add_type_member_declaration (function); + + if (st.is_disposable ()) { + function = new CCodeFunction (st.get_copy_function (), "void"); + if (st.is_private_symbol ()) { + function.modifiers = CCodeModifiers.STATIC; + } + function.add_parameter (new CCodeFormalParameter ("self", "const " + st.get_cname () + "*")); + function.add_parameter (new CCodeFormalParameter ("dest", st.get_cname () + "*")); + decl_space.add_type_member_declaration (function); + + function = new CCodeFunction (st.get_destroy_function (), "void"); + if (st.is_private_symbol ()) { + function.modifiers = CCodeModifiers.STATIC; + } + function.add_parameter (new CCodeFormalParameter ("self", st.get_cname () + "*")); + decl_space.add_type_member_declaration (function); + } } public override void visit_struct (Struct st) { @@ -124,8 +155,6 @@ internal class Vala.CCodeStructModule : CCodeBaseModule { function.add_parameter (new CCodeFormalParameter ("self", "const " + st.get_cname () + "*")); - source_declarations.add_type_member_declaration (function.copy ()); - var cblock = new CCodeBlock (); var cdecl = new CCodeDeclaration (st.get_cname () + "*"); @@ -170,8 +199,6 @@ internal class Vala.CCodeStructModule : CCodeBaseModule { function.add_parameter (new CCodeFormalParameter ("self", st.get_cname () + "*")); - source_declarations.add_type_member_declaration (function.copy ()); - var cblock = new CCodeBlock (); if (st.is_disposable ()) { @@ -198,8 +225,6 @@ internal class Vala.CCodeStructModule : CCodeBaseModule { function.add_parameter (new CCodeFormalParameter ("self", "const " + st.get_cname () + "*")); function.add_parameter (new CCodeFormalParameter ("dest", st.get_cname () + "*")); - source_declarations.add_type_member_declaration (function.copy ()); - var cblock = new CCodeBlock (); var cfrag = new CCodeFragment (); cblock.add_statement (cfrag); @@ -261,8 +286,6 @@ internal class Vala.CCodeStructModule : CCodeBaseModule { function.add_parameter (new CCodeFormalParameter ("self", st.get_cname () + "*")); - source_declarations.add_type_member_declaration (function.copy ()); - var cblock = new CCodeBlock (); cblock.add_statement (instance_finalize_fragment);