[vala] GValue: Fix cast from nullable GLib.Value
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] GValue: Fix cast from nullable GLib.Value
- Date: Thu, 7 Jan 2010 17:31:07 +0000 (UTC)
commit 0c0ec3b013e5f266425c65b5a0743bb1bb655e63
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Fri Oct 30 00:39:05 2009 +0100
GValue: Fix cast from nullable GLib.Value
Fixes bug 585050.
codegen/valaccodebasemodule.vala | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 7a1b455..2266fb6 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4005,7 +4005,15 @@ internal class Vala.CCodeBaseModule : CCodeModule {
&& expr.type_reference.get_type_id () != null) {
// explicit conversion from GValue
var ccall = new CCodeFunctionCall (get_value_getter_function (expr.type_reference));
- ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) expr.inner.ccodenode));
+ CCodeExpression gvalue;
+ if (expr.inner.value_type.nullable) {
+ // cast from Value?, no need to get address
+ gvalue = (CCodeExpression) expr.inner.ccodenode;
+ } else {
+ // value getter function expects pointer to GValue, get address of non-null Value
+ gvalue = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) expr.inner.ccodenode);
+ }
+ ccall.add_argument (gvalue);
expr.ccodenode = ccall;
if (expr.type_reference is ArrayType) {
// null-terminated string array
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]