]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Handle struct equality for simple types and opaque structures.
authorLuca Bruno <lethalman88@gmail.com>
Sat, 5 Jun 2010 12:21:16 +0000 (14:21 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 16 Jun 2010 19:34:51 +0000 (21:34 +0200)
Fixes bug 618217.

codegen/valaccodebasemodule.vala

index 24b0fb50a339e3a40a6c63624b616499f28144d5..d2f47abcedc32e76c11e10ef9a3dc6dd930ee032 100644 (file)
@@ -2563,7 +2563,17 @@ public class Vala.CCodeBaseModule : CCodeModule {
                        cblock.add_statement (cif);
                }
 
-               cblock.add_statement (new CCodeReturnStatement (new CCodeConstant ("TRUE")));
+               if (st.get_fields().size == 0) {
+                       // either opaque structure or simple type
+                       if (st.is_simple_type ()) {
+                               var cexp = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("s1")), new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("s2")));
+                               cblock.add_statement (new CCodeReturnStatement (cexp));
+                       } else {
+                               cblock.add_statement (new CCodeReturnStatement (new CCodeConstant ("FALSE")));
+                       }
+               } else {
+                       cblock.add_statement (new CCodeReturnStatement (new CCodeConstant ("TRUE")));
+               }
 
                // append to file