[vala] Handle struct equality for simple types and opaque structures.



commit 604bf2b5871d9d06334844bc5949c0cbaaa66dff
Author: Luca Bruno <lethalman88 gmail com>
Date:   Sat Jun 5 14:21:16 2010 +0200

    Handle struct equality for simple types and opaque structures.
    
    Fixes bug 618217.

 codegen/valaccodebasemodule.vala |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 24b0fb5..d2f47ab 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]