[vala/0.34] codegen: Add destroy out-param when invoking delegate returned by delegate
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.34] codegen: Add destroy out-param when invoking delegate returned by delegate
- Date: Tue, 16 Jan 2018 17:29:15 +0000 (UTC)
commit a8b50a925ee2191bfca505960ba2437bd6512c19
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 6 09:53:48 2018 +0100
codegen: Add destroy out-param when invoking delegate returned by delegate
https://bugzilla.gnome.org/show_bug.cgi?id=792077
codegen/valaccodemethodcallmodule.vala | 11 +++++++++++
tests/Makefile.am | 1 +
tests/delegates/bug792077.vala | 16 ++++++++++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 376e82a..3c3b732 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -588,6 +588,17 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (deleg)), new
CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
set_delegate_target (expr, temp_ref);
+
+ if (deleg_type.is_disposable ()) {
+ temp_var = get_temp_variable (gdestroynotify_type);
+ temp_ref = get_variable_cexpression (temp_var.name);
+
+ emit_temp_var (temp_var);
+
+ out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (deleg)
+ 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+
+ set_delegate_target_destroy_notify (expr, temp_ref);
+ }
}
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 270ba36..0391a45 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -145,6 +145,7 @@ TESTS = \
delegates/bug659778.vala \
delegates/bug683925.vala \
delegates/bug703804.vala \
+ delegates/bug792077.vala \
objects/chainup.vala \
objects/classes.vala \
objects/constructors.vala \
diff --git a/tests/delegates/bug792077.vala b/tests/delegates/bug792077.vala
new file mode 100644
index 0000000..4c29822
--- /dev/null
+++ b/tests/delegates/bug792077.vala
@@ -0,0 +1,16 @@
+delegate void FooFunc (int i);
+delegate FooFunc BarFunc ();
+
+int result = 0;
+
+void main () {
+ BarFunc func_gen = () => {
+ return (data) => {
+ result = data;
+ };
+ };
+
+ FooFunc func = func_gen ();
+ func (42);
+ assert (result == 42);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]