Commit eebec1fd authored by Jürg Billeter's avatar Jürg Billeter

Add CCodeFile.add_function_declaration and CCodeFunction.is_declaration

parent 548b6d6e
......@@ -73,6 +73,12 @@ public class Vala.CCodeFile {
type_member_definition.append (node);
}
public void add_function_declaration (CCodeFunction func) {
var decl = func.copy ();
decl.is_declaration = true;
type_member_declaration.append (decl);
}
public void add_function (CCodeFunction func) {
type_member_definition.append (func);
}
......
......@@ -43,16 +43,19 @@ public class Vala.CCodeFunction : CCodeNode {
public string attributes { get; set; }
public bool is_declaration { get; set; }
/**
* The function body.
*/
public CCodeBlock block { get; set; }
private List<CCodeFormalParameter> parameters = new ArrayList<CCodeFormalParameter> ();
public CCodeFunction (string name, string return_type = "void") {
this.name = name;
this.return_type = return_type;
this.block = new CCodeBlock ();
}
/**
......@@ -85,6 +88,7 @@ public class Vala.CCodeFunction : CCodeNode {
func.parameters.add (param);
}
func.is_declaration = is_declaration;
func.block = block;
return func;
}
......@@ -121,7 +125,7 @@ public class Vala.CCodeFunction : CCodeNode {
writer.write_string (" G_GNUC_DEPRECATED");
}
if (block == null) {
if (is_declaration) {
if (attributes != null) {
writer.write_string (" ");
writer.write_string (attributes);
......
......@@ -487,7 +487,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("array", "%s*".printf (st.get_cname ())));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
var cdofree = new CCodeBlock ();
......@@ -540,7 +540,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
fun.add_parameter (new CCodeFormalParameter ("destroy_func", "GDestroyNotify"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
var cdofree = new CCodeBlock ();
......@@ -565,7 +565,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
fun.add_parameter (new CCodeFormalParameter ("destroy_func", "GDestroyNotify"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
// call _vala_array_destroy to free the array elements
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_destroy"));
......@@ -595,7 +595,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("src", "gint"));
fun.add_parameter (new CCodeFormalParameter ("dest", "gint"));
fun.add_parameter (new CCodeFormalParameter ("length", "gint"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
var array = new CCodeCastExpression (new CCodeIdentifier ("array"), "char*");
var element_size = new CCodeIdentifier ("element_size");
......@@ -637,7 +637,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var fun = new CCodeFunction ("_vala_array_length", "gint");
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
var block = new CCodeBlock ();
......@@ -805,7 +805,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -869,7 +869,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -941,7 +941,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......
......@@ -552,7 +552,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("str1", "const char *"));
fun.add_parameter (new CCodeFormalParameter ("str2", "const char *"));
cfile.add_type_member_declaration (fun.copy ());
cfile.add_function_declaration (fun);
// (str1 != str2)
var cineq = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("str1"), new CCodeIdentifier ("str2"));
......@@ -700,7 +700,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
regfun.attributes = "G_GNUC_UNUSED";
}
decl_space.add_type_member_declaration (regfun);
decl_space.add_function_declaration (regfun);
return true;
}
......@@ -1315,7 +1315,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
if (prop.is_private_symbol () || (!acc.readable && !acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
function.modifiers |= CCodeModifiers.STATIC;
}
decl_space.add_type_member_declaration (function);
decl_space.add_function_declaration (function);
}
public override void visit_property_accessor (PropertyAccessor acc) {
......@@ -1845,7 +1845,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
var ref_fun = new CCodeFunction ("block%d_data_ref".printf (block_id), struct_name + "*");
ref_fun.add_parameter (new CCodeFormalParameter ("_data%d_".printf (block_id), struct_name + "*"));
ref_fun.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (ref_fun.copy ());
cfile.add_function_declaration (ref_fun);
ref_fun.block = new CCodeBlock ();
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_atomic_int_inc"));
......@@ -1857,7 +1857,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
var unref_fun = new CCodeFunction ("block%d_data_unref".printf (block_id), "void");
unref_fun.add_parameter (new CCodeFormalParameter ("_data%d_".printf (block_id), struct_name + "*"));
unref_fun.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (unref_fun.copy ());
cfile.add_function_declaration (unref_fun);
unref_fun.block = new CCodeBlock ();
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_atomic_int_dec_and_test"));
......@@ -2513,7 +2513,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = cblock;
cfile.add_function (function);
......@@ -2569,7 +2569,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = cblock;
cfile.add_function (function);
......@@ -2640,7 +2640,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2677,7 +2677,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2737,7 +2737,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2861,7 +2861,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
free_call.add_argument (new CCodeMemberAccess.pointer(new CCodeIdentifier("node"), "data"));
wrapper_block.add_statement (new CCodeExpressionStatement (free_call));
wrapper_block.add_statement (new CCodeReturnStatement (new CCodeConstant ("FALSE")));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
wrapper.block = wrapper_block;
cfile.add_function (wrapper);
......@@ -2893,7 +2893,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -4592,7 +4592,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
block.add_statement (fragment);
block.add_statement (new CCodeReturnStatement (result));
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
cfunc.block = block;
cfile.add_function (cfunc);
......@@ -4989,7 +4989,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
block.add_statement (cloop);
block.add_statement (new CCodeReturnStatement (new CCodeConstant ("FALSE")));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -5211,7 +5211,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
block.add_statement (fragment);
block.add_statement (new CCodeReturnStatement (sink));
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
cfunc.block = block;
cfile.add_function (cfunc);
......@@ -5644,7 +5644,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = cblock;
cfile.add_function (function);
}
......@@ -5712,7 +5712,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
pop_context ();
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = cblock;
cfile.add_function (function);
}
......
......@@ -600,7 +600,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
// append to file
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......
......@@ -188,7 +188,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
if (!(m is CreationMethod && cl != null && cl.is_abstract)) {
generate_cparameters (m, decl_space, cparam_map, function, null, carg_map, new CCodeFunctionCall (new CCodeIdentifier ("fake")));
decl_space.add_type_member_declaration (function);
decl_space.add_function_declaration (function);
}
if (m is CreationMethod && cl != null) {
......@@ -202,7 +202,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
cparam_map = new HashMap<int,CCodeFormalParameter> (direct_hash, direct_equal);
generate_cparameters (m, decl_space, cparam_map, function);
decl_space.add_type_member_declaration (function);
decl_space.add_function_declaration (function);
}
}
......@@ -351,7 +351,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
if (m.base_method != null || m.base_interface_method != null) {
// declare *_real_* function
function.modifiers |= CCodeModifiers.STATIC;
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
} else if (m.is_private_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
}
......@@ -371,7 +371,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
function.add_parameter (new CCodeFormalParameter ("data", Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data*"));
function.modifiers |= CCodeModifiers.STATIC;
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
}
}
}
......
......@@ -112,14 +112,14 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
function.modifiers = CCodeModifiers.STATIC;
}
function.add_parameter (new CCodeFormalParameter ("self", "const " + st.get_cname () + "*"));
decl_space.add_type_member_declaration (function);
decl_space.add_function_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);
decl_space.add_function_declaration (function);
if (st.is_disposable ()) {
function = new CCodeFunction (st.get_copy_function (), "void");
......@@ -128,14 +128,14 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
}
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);
decl_space.add_function_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);
decl_space.add_function_declaration (function);
}
}
......
......@@ -91,7 +91,7 @@ public class Vala.DBusClientModule : DBusModule {
}
// append to C source file
cfile.add_type_member_declaration (func.copy ());
cfile.add_function_declaration (func);
func.block = block;
cfile.add_function (func);
......@@ -648,7 +648,7 @@ public class Vala.DBusClientModule : DBusModule {
generate_dbus_property_getter_wrapper (prop, block);
// append to C source file
cfile.add_type_member_declaration (func.copy ());
cfile.add_function_declaration (func);
func.block = block;
cfile.add_function (func);
......@@ -678,7 +678,7 @@ public class Vala.DBusClientModule : DBusModule {
generate_dbus_property_setter_wrapper (prop, block);
// append to C source file
cfile.add_type_member_declaration (func.copy ());
cfile.add_function_declaration (func);
func.block = block;
cfile.add_function (func);
......@@ -819,7 +819,7 @@ public class Vala.DBusClientModule : DBusModule {
generate_dbus_connect_wrapper (sig, block);
// append to C source file
cfile.add_type_member_declaration (func.copy ());
cfile.add_function_declaration (func);
func.block = block;
cfile.add_function (func);
......@@ -842,7 +842,7 @@ public class Vala.DBusClientModule : DBusModule {
generate_dbus_disconnect_wrapper (sig, block);
// append to C source file
cfile.add_type_member_declaration (func.copy ());
cfile.add_function_declaration (func);
func.block = block;
cfile.add_function (func);
......@@ -975,7 +975,7 @@ public class Vala.DBusClientModule : DBusModule {
}
proxy_iface_init.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (proxy_iface_init.copy ());
cfile.add_function_declaration (proxy_iface_init);
proxy_iface_init.block = iface_block;
cfile.add_function (proxy_iface_init);
}
......@@ -1049,7 +1049,7 @@ public class Vala.DBusClientModule : DBusModule {
proxy_new.add_parameter (new CCodeFormalParameter ("name", "const char*"));
proxy_new.add_parameter (new CCodeFormalParameter ("path", "const char*"));
decl_space.add_type_member_declaration (proxy_new);
decl_space.add_function_declaration (proxy_new);
}
public override void visit_interface (Interface iface) {
......@@ -1080,7 +1080,7 @@ public class Vala.DBusClientModule : DBusModule {
var type_fun = new CCodeFunction(lower_cname + "_get_type", "GType");
type_fun.attributes = "G_GNUC_CONST";
cfile.add_type_member_declaration (type_fun);
cfile.add_function_declaration (type_fun);
var define_type = new CCodeFunctionCall (new CCodeIdentifier ("G_DEFINE_TYPE_EXTENDED"));
define_type.add_argument (new CCodeIdentifier (cname));
......@@ -1283,7 +1283,7 @@ public class Vala.DBusClientModule : DBusModule {
get_prop.add_parameter (new CCodeFormalParameter ("property_id", "guint"));
get_prop.add_parameter (new CCodeFormalParameter ("value", "GValue *"));
get_prop.add_parameter (new CCodeFormalParameter ("pspec", "GParamSpec *"));
cfile.add_type_member_declaration (get_prop.copy ());
cfile.add_function_declaration (get_prop);
get_prop.block = new CCodeBlock ();
cfile.add_function (get_prop);
......@@ -1293,7 +1293,7 @@ public class Vala.DBusClientModule : DBusModule {
set_prop.add_parameter (new CCodeFormalParameter ("property_id", "guint"));
set_prop.add_parameter (new CCodeFormalParameter ("value", "const GValue *"));
set_prop.add_parameter (new CCodeFormalParameter ("pspec", "GParamSpec *"));
cfile.add_type_member_declaration (set_prop.copy ());
cfile.add_function_declaration (set_prop);
set_prop.block = new CCodeBlock ();
cfile.add_function (set_prop);
}
......@@ -1389,7 +1389,7 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("_result")));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1486,7 +1486,7 @@ public class Vala.DBusClientModule : DBusModule {
filter_block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("DBUS_HANDLER_RESULT_NOT_YET_HANDLED")));
cfile.add_type_member_declaration (proxy_filter.copy ());
cfile.add_function_declaration (proxy_filter);
proxy_filter.block = filter_block;
cfile.add_function (proxy_filter);
}
......@@ -1594,7 +1594,7 @@ public class Vala.DBusClientModule : DBusModule {
cdecl.add_declarator (new CCodeVariableDeclarator ("reply"));
block.add_statement (cdecl);
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1911,7 +1911,7 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("_result")));
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2006,7 +2006,7 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (postfragment);
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2185,7 +2185,7 @@ public class Vala.DBusClientModule : DBusModule {
pending.add_argument (new CCodeConstant ("NULL"));
block.add_statement (new CCodeExpressionStatement (pending));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2248,7 +2248,7 @@ public class Vala.DBusClientModule : DBusModule {
pendingfree.add_argument (new CCodeIdentifier ("pending"));
block.add_statement (new CCodeExpressionStatement (pendingfree));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2370,7 +2370,7 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("_result")));
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2656,7 +2656,7 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("_result")));
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -2803,7 +2803,7 @@ public class Vala.DBusClientModule : DBusModule {
reply_unref.add_argument (new CCodeIdentifier ("_reply"));
block.add_statement (new CCodeExpressionStatement (reply_unref));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......
......@@ -170,8 +170,8 @@ public class Vala.DBusModule : GAsyncModule {
public override bool generate_enum_declaration (Enum en, CCodeFile decl_space) {
if (base.generate_enum_declaration (en, decl_space)) {
if (is_string_marshalled_enum (en)) {
decl_space.add_type_member_declaration (generate_enum_from_string_function_declaration (en));
decl_space.add_type_member_declaration (generate_enum_to_string_function_declaration (en));
decl_space.add_function_declaration (generate_enum_from_string_function_declaration (en));
decl_space.add_function_declaration (generate_enum_to_string_function_declaration (en));
}
return true;
}
......@@ -1006,7 +1006,7 @@ public class Vala.DBusModule : GAsyncModule {
cfunc.add_parameter (new CCodeFormalParameter ("object", "void*"));
cfunc.modifiers |= CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
var block = new CCodeBlock ();
cfunc.block = block;
......@@ -1049,7 +1049,7 @@ public class Vala.DBusModule : GAsyncModule {
cfunc.add_parameter (new CCodeFormalParameter ("object", "GObject*"));
cfunc.modifiers |= CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
block = new CCodeBlock ();
cfunc.block = block;
......
......@@ -406,13 +406,13 @@ public class Vala.DBusServerModule : DBusClientModule {
ready_block.add_statement (new CCodeExpressionStatement (free_call));
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
if (m.coroutine) {
cfile.add_type_member_declaration (ready_function.copy ());
cfile.add_function_declaration (ready_function);
ready_function.block = ready_block;
cfile.add_function (ready_function);
......@@ -552,7 +552,7 @@ public class Vala.DBusServerModule : DBusClientModule {
message_unref.add_argument (new CCodeIdentifier ("_message"));
block.add_statement (new CCodeExpressionStatement (message_unref));
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -576,7 +576,7 @@ public class Vala.DBusServerModule : DBusClientModule {
cfunc.modifiers |= CCodeModifiers.STATIC;
}
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
var block = new CCodeBlock ();
cfunc.block = block;
......@@ -638,7 +638,7 @@ public class Vala.DBusServerModule : DBusClientModule {
cfunc.add_parameter (new CCodeFormalParameter ("connection", "DBusConnection*"));
cfunc.add_parameter (new CCodeFormalParameter ("_user_data_", "void*"));
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
var block = new CCodeBlock ();
cfunc.block = block;
......@@ -865,7 +865,7 @@ public class Vala.DBusServerModule : DBusClientModule {
handle_reply (block);
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1079,7 +1079,7 @@ public class Vala.DBusServerModule : DBusClientModule {
handle_reply (block);
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1253,7 +1253,7 @@ public class Vala.DBusServerModule : DBusClientModule {
handle_reply (block);
}
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1464,7 +1464,7 @@ public class Vala.DBusServerModule : DBusClientModule {
handle_reply (block);
cfile.add_type_member_declaration (function.copy ());
cfile.add_function_declaration (function);
function.block = block;
cfile.add_function (function);
......@@ -1509,7 +1509,7 @@ public class Vala.DBusServerModule : DBusClientModule {
cfunc.modifiers |= CCodeModifiers.STATIC;
}
cfile.add_type_member_declaration (cfunc.copy ());
cfile.add_function_declaration (cfunc);
var block = new CCodeBlock ();
cfunc.block = block;
......
......@@ -814,7 +814,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
// create type_get/finalize functions
var type_get_fun = new CCodeFunction ("block%d_data_type_get".printf (block_id), "DovaType*");
type_get_fun.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (type_get_fun.copy ());
cfile.add_function_declaration (type_get_fun);
type_get_fun.block = new CCodeBlock ();
var cdecl = new CCodeDeclaration ("int");
......@@ -852,7 +852,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
var unref_fun = new CCodeFunction ("block%d_data_finalize".printf (block_id), "void");
unref_fun.add_parameter (new CCodeFormalParameter ("_data%d_".printf (block_id), struct_name + "*"));
unref_fun.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (unref_fun.copy ());
cfile.add_function_declaration (unref_fun);
unref_fun.block = free_block;
cfile.add_function (unref_fun);
......
......@@ -40,24 +40,24 @@ public class Vala.DovaDelegateModule : DovaValueModule {
if (d.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
decl_space.add_type_member_declaration (type_fun);
decl_space.add_function_declaration (type_fun);
var type_init_fun = new CCodeFunction ("%s_type_init".printf (d.get_lower_case_cname ()));
if (d.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
type_init_fun.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
decl_space.add_type_member_declaration (type_init_fun);
decl_space.add_function_declaration (type_init_fun);
generate_type_declaration (d.return_type, decl_space);
var function = generate_new_function (d, decl_space);
function.block = null;
decl_space.add_type_member_declaration (function);
decl_space.add_function_declaration (function);
function = generate_invoke_function (d, decl_space);
function.block = null;
decl_space.add_type_member_declaration (function);
decl_space.add_function_declaration (function);
}
CCodeFunction generate_new_function (Delegate d, CCodeFile decl_space) {
......
......@@ -49,7 +49,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
value_copy_function.add_parameter (new CCodeFormalParameter ("src", "void *"));
value_copy_function.add_parameter (new CCodeFormalParameter ("src_index", "int32_t"));
cfile.add_type_member_declaration (value_copy_function);
cfile.add_function_declaration (value_copy_function);
var value_equals_function = new CCodeFunction ("dova_type_value_equals", "bool");
value_equals_function.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
......@@ -58,14 +58,14 @@ public class Vala.DovaObjectModule : DovaArrayModule {
value_equals_function.add_parameter (new CCodeFormalParameter ("other", "void *"));
value_equals_function.add_parameter (new CCodeFormalParameter ("other_index", "int32_t"));
cfile.add_type_member_declaration (value_equals_function);
cfile.add_function_declaration (value_equals_function);
var value_hash_function = new CCodeFunction ("dova_type_value_hash", "uint32_t");
value_hash_function.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
value_hash_function.add_parameter (new CCodeFormalParameter ("value", "void *"));
value_hash_function.add_parameter (new CCodeFormalParameter ("value_index", "int32_t"));
cfile.add_type_member_declaration (value_hash_function);
cfile.add_function_declaration (value_hash_function);
}
if (cl.base_class != null) {
......@@ -82,7 +82,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
foreach (var type_param in cl.get_type_parameters ()) {
type_fun.add_parameter (new CCodeFormalParameter ("%s_type".printf (type_param.name.down ()), "DovaType *"));
}
decl_space.add_type_member_declaration (type_fun);
decl_space.add_function_declaration (type_fun);