]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix comparison of nullable and non-nullable values
authorJürg Billeter <j@bitron.ch>
Mon, 15 Dec 2008 09:43:40 +0000 (09:43 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 15 Dec 2008 09:43:40 +0000 (09:43 +0000)
2008-12-15  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodebasemodule.vala:

Fix comparison of nullable and non-nullable values

svn path=/trunk/; revision=2156

ChangeLog
gobject/valaccodebasemodule.vala

index 3a478ef0bdf3994611dd8cf817972d962bc9b804..53161ad5579b311b8c950598e76effa56c7ec240 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-15  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodebasemodule.vala:
+
+       Fix comparison of nullable and non-nullable values
+
 2008-12-15  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valaccodestructmodule.vala:
index 313386f4ca2f665fb3c16825d6c6fb0d49046d8d..758187f0d881a6ecbe3c59d8c39a7642f0032399 100644 (file)
@@ -2987,12 +2987,17 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                                cright = new InstanceCast (cright, left_cl);
                                        }
                                }
-                       } else if (left_type_as_struct != null && !expr.left.value_type.nullable
-                                  && expr.right.value_type is NullType) {
-                               cleft = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cleft);
-                       } else if (right_type_as_struct != null && !expr.right.value_type.nullable
-                                  && expr.left.value_type is NullType) {
-                               cright = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cright);
+                       } else if (left_type_as_struct != null && right_type_as_struct != null) {
+                               // FIXME generate and use compare/equal function for real structs
+                               if (expr.left.value_type.nullable && expr.right.value_type.nullable) {
+                                       // FIXME also compare contents, not just address
+                               } else if (expr.left.value_type.nullable) {
+                                       // FIXME check left value is not null
+                                       cleft = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, cleft);
+                               } else if (expr.right.value_type.nullable) {
+                                       // FIXME check right value is not null
+                                       cright = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, cright);
+                               }
                        }
                }