[vala/staging] 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/staging] codegen: Add destroy out-param when invoking delegate returned by delegate
- Date: Sat, 6 Jan 2018 13:31:08 +0000 (UTC)
commit ecb8a6fb7fcc1b1c92ce464720cc29179929b9d9
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 acca4ed..007bcbd 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -598,6 +598,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 10a62d5..33750cb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -177,6 +177,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]