[vala] Support using GClosure for delegate parameters
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Support using GClosure for delegate parameters
- Date: Mon, 28 Jun 2010 21:35:27 +0000 (UTC)
commit fd46d7fe19b7926adf7d1118810abca3a0c49e76
Author: Jürg Billeter <j bitron ch>
Date: Mon Jun 28 23:32:07 2010 +0200
Support using GClosure for delegate parameters
codegen/valaccodemethodcallmodule.vala | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index e6218fa..85816ee 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -387,11 +387,20 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (d.has_target) {
CCodeExpression delegate_target_destroy_notify;
var delegate_target = get_delegate_target_cexpression (arg, out delegate_target_destroy_notify);
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), delegate_target);
- if (deleg_type.value_owned) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), delegate_target_destroy_notify);
+ if (param.ctype == "GClosure*") {
+ // one single GClosure parameter
+ var closure_new = new CCodeFunctionCall (new CCodeIdentifier ("g_cclosure_new"));
+ closure_new.add_argument (new CCodeCastExpression (cexpr, "GCallback"));
+ closure_new.add_argument (delegate_target);
+ closure_new.add_argument (delegate_target_destroy_notify);
+ cexpr = closure_new;
+ } else {
+ carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), delegate_target);
+ if (deleg_type.value_owned) {
+ carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), delegate_target_destroy_notify);
+ }
+ multiple_cargs = true;
}
- multiple_cargs = true;
}
} else if (param.parameter_type is MethodType) {
// callbacks in dynamic method calls
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]