[vala] Fix delegate out parameters
- From: JĂźrg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Fix delegate out parameters
- Date: Thu, 7 May 2009 10:01:09 -0400 (EDT)
commit 956f8bec01b81820ce18595a9b619ee685f4c8ae
Author: Levi Bard <taktaktaktaktaktaktaktaktaktak gmail com>
Date: Thu May 7 15:59:22 2009 +0200
Fix delegate out parameters
Fixes bug 578412.
---
gobject/valaccodedelegatemodule.vala | 6 ++++--
tests/delegates/delegates.test | 7 +++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gobject/valaccodedelegatemodule.vala b/gobject/valaccodedelegatemodule.vala
index 1eab032..7975204 100644
--- a/gobject/valaccodedelegatemodule.vala
+++ b/gobject/valaccodedelegatemodule.vala
@@ -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));
diff --git a/tests/delegates/delegates.test b/tests/delegates/delegates.test
index 504ff08..0885f3e 100644
--- a/tests/delegates/delegates.test
+++ b/tests/delegates/delegates.test
@@ -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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]