Commit 956f8bec authored by Levi Bard's avatar Levi Bard Committed by Jürg Billeter

Fix delegate out parameters

Fixes bug 578412.
parent 6735572a
......@@ -400,9 +400,11 @@ internal class Vala.CCodeDelegateModule : CCodeArrayModule {
}
string ctypename = param.parameter_type.get_cname ();
string target_ctypename = "void*";
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
target_ctypename += "*";
}
param.ccodenode = new CCodeFormalParameter (get_variable_cname (param.name), ctypename);
......@@ -419,7 +421,7 @@ internal class Vala.CCodeDelegateModule : CCodeArrayModule {
generate_delegate_declaration (d, decl_space);
if (d.has_target) {
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), "void*");
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), target_ctypename);
cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
if (carg_map != null) {
carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_variable_cexpression (cparam.name));
......@@ -433,7 +435,7 @@ internal class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
} else if (param.parameter_type is MethodType) {
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), "void*");
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), target_ctypename);
cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
if (carg_map != null) {
carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_variable_cexpression (cparam.name));
......
......@@ -41,6 +41,10 @@ class Maman.Bar : Object, Foo {
instance_cb (42);
}
void assign_instance_delegate (out InstanceCallback instance_cb) {
instance_cb = foo_method;
}
static void test_function_pointers () {
stdout.printf ("testing function pointers:");
var table = new HashTable<string, Bar>.full (str_hash, str_equal, g_free, Object.unref);
......@@ -82,6 +86,9 @@ class Maman.Bar : Object, Foo {
InstanceCallback instance_cb = bar.do_instance_action;
call_instance_delegate (instance_cb);
bar.assign_instance_delegate (out instance_cb);
call_instance_delegate (instance_cb);
stdout.printf (" 7\n");
test_function_pointers ();
......
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