[vala/0.10: 21/38] Support implicit GValue conversion when assigning to properties
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.10: 21/38] Support implicit GValue conversion when assigning to properties
- Date: Sat, 4 Sep 2010 15:03:12 +0000 (UTC)
commit 5600b43e1932626632e298b0b63eb91ba9443fd7
Author: Luca Bruno <lethalman88 gmail com>
Date: Thu Jun 10 11:00:13 2010 +0200
Support implicit GValue conversion when assigning to properties
Thanks to Michal Hruby for the test case.
Fixes bug 620706.
codegen/valaccodebasemodule.vala | 14 +++++++++++++-
tests/Makefile.am | 1 +
tests/objects/bug620706.vala | 13 +++++++++++++
3 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index bf7703e..6a17886 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5484,6 +5484,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
* from a vala to C point of view all expressions denoting locals, fields and
* parameters are eligable to an ADDRESS_OF operator */
public bool is_address_of_possible (Expression e) {
+ if (gvalue_type != null && e.target_type.data_type == gvalue_type && e.value_type.data_type != gvalue_type) {
+ // implicit conversion to GValue is not addressable
+ return false;
+ }
+
var ma = e as MemberAccess;
if (ma == null) {
@@ -5502,7 +5507,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
var ccomma = new CCodeCommaExpression ();
- var temp_decl = get_temp_variable (e.value_type, true, null, false);
+ DataType address_of_type;
+ if (gvalue_type != null && e.target_type != null && e.target_type.data_type == gvalue_type) {
+ // implicit conversion to GValue
+ address_of_type = e.target_type;
+ } else {
+ address_of_type = e.value_type;
+ }
+ var temp_decl = get_temp_variable (address_of_type, true, null, false);
var ctemp = get_variable_cexpression (temp_decl.name);
temp_vars.add (temp_decl);
ccomma.append_expression (new CCodeAssignment (ctemp, ce));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2430407..b24ea23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -69,6 +69,7 @@ TESTS = \
objects/bug597155.vala \
objects/bug597161.vala \
objects/bug613486.vala \
+ objects/bug620706.vala \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
diff --git a/tests/objects/bug620706.vala b/tests/objects/bug620706.vala
new file mode 100644
index 0000000..7ac4bc9
--- /dev/null
+++ b/tests/objects/bug620706.vala
@@ -0,0 +1,13 @@
+class Foo : Object {
+ public Value val { get; set; }
+}
+
+struct Bar {
+ int dummy;
+}
+
+void main () {
+ var f = new Foo ();
+ var b = Bar ();
+ f.val = b;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]