[vala] codegen: Support calling methods that return modified pointer on properties
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Support calling methods that return modified pointer on properties
- Date: Mon, 27 Jun 2011 12:36:20 +0000 (UTC)
commit 1b49651bc6512f3ac4f01e6e1b33ee6da78af0b8
Author: Luca Bruno <lucabru src gnome org>
Date: Mon Jun 27 14:25:54 2011 +0200
codegen: Support calling methods that return modified pointer on properties
Fixes bug 589928.
codegen/valaccodemethodcallmodule.vala | 8 +++++++-
tests/Makefile.am | 1 +
tests/objects/bug589928.vala | 9 +++++++++
3 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 4f8ce16..845d928 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -688,7 +688,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) {
- ccall_expr = new CCodeAssignment (instance, ccall_expr);
+ if (ma != null && ma.inner.symbol_reference is Property && ma.inner is MemberAccess) {
+ var prop = (Property) ma.inner.symbol_reference;
+ store_property (prop, ((MemberAccess) ma.inner).inner, new GLibValue (expr.value_type, ccall_expr));
+ ccall_expr = null;
+ } else {
+ ccall_expr = new CCodeAssignment (instance, ccall_expr);
+ }
}
if (m is ArrayResizeMethod) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1ba9c9c..e3d6a5a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -81,6 +81,7 @@ TESTS = \
objects/test-034.vala \
objects/bug566909.vala \
objects/bug588203.vala \
+ objects/bug589928.vala \
objects/bug593260.vala \
objects/bug596621.vala \
objects/bug597155.vala \
diff --git a/tests/objects/bug589928.vala b/tests/objects/bug589928.vala
new file mode 100644
index 0000000..f235ba7
--- /dev/null
+++ b/tests/objects/bug589928.vala
@@ -0,0 +1,9 @@
+class Foo {
+ public List<string> bar { get; owned set; default = new List<string> (); }
+}
+
+void main () {
+ Foo foo = new Foo ();
+ foo.bar.append ("1");
+ assert (foo.bar.nth_data (0) == "1");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]