[vala/0.36] 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.36] codegen: Add destroy out-param when invoking delegate returned by delegate
- Date: Tue, 16 Jan 2018 17:15:43 +0000 (UTC)
commit 33a0ab74945458865922fe159174d068698d04a1
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 69d6802..90bb214 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -596,6 +596,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 3d5507d..05be0df 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -172,6 +172,7 @@ TESTS = \
delegates/bug703804.vala \
delegates/bug761360.vala \
delegates/bug772204.test \
+ 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]