From 604bf2b5871d9d06334844bc5949c0cbaaa66dff Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sat, 5 Jun 2010 14:21:16 +0200 Subject: [PATCH] Handle struct equality for simple types and opaque structures. Fixes bug 618217. --- codegen/valaccodebasemodule.vala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 24b0fb50..d2f47abc 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 -- 2.11.4.GIT