[vala] Support casting nullable structs to non-nullable structs
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Support casting nullable structs to non-nullable structs
- Date: Mon, 18 Jan 2010 21:55:41 +0000 (UTC)
commit a0eb82a01828f8b6bd867886d734ad7eeeed2a72
Author: Luca Bruno <lethalman88 gmail com>
Date: Sun Jan 17 23:07:49 2010 +0100
Support casting nullable structs to non-nullable structs
Fixes bug 588832.
codegen/valaccodebasemodule.vala | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 06f1dda..32f1b4a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4225,7 +4225,13 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
}
- expr.ccodenode = new CCodeCastExpression ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.get_cname ());
+ var innercexpr = (CCodeExpression) expr.inner.ccodenode;
+ if (expr.type_reference.data_type is Struct && !expr.type_reference.nullable &&
+ expr.inner.value_type.data_type is Struct && expr.inner.value_type.nullable) {
+ // nullable integer or float or boolean or struct cast to non-nullable
+ innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, innercexpr);
+ }
+ expr.ccodenode = new CCodeCastExpression (innercexpr, expr.type_reference.get_cname ());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]