GNOME Bugzilla – Bug 530605
[PATCH] implement struct comparison
Last modified: 2010-01-07 20:05:19 UTC
using GLib; struct A { int a; int cmp (A? other) { if (this == other) return 1; return 0; } }
Confirming.
This appears to be fixed as of 0.6.0.
No, it's not fixed yet.
Created attachment 145112 [details] [review] accept recusive nullable struct fields
Created attachment 145113 [details] [review] fix
Created attachment 146235 [details] [review] Bug 530605 - invalid operands to binary == That should make this kind of test work. struct Test { Test? a; Test* b; void test() { bool aa = (&this != b); bool bb = (this != a); } } static void main() { Test t = new Test(); Test* tp = &t; Test? tn = t; bool a = tn == t; bool b = t == tn; } codegen: implement struct_cmp
Review of attachment 146235 [details] [review]: ::: codegen/valaccodebasemodule.vala @@ +2326,3 @@ + var right_type_as_struct = right_type.data_type as Struct; + var left_type_as_struct = left_type.data_type as Struct; + private void make_comparable_cexpression(DataType left_type, ref CCodeExpression cleft, DataType right_type, ref CCodeExpression cright) { I guess we should keep the FIXME to check if cleft/cright are NULL before INDIRECTION @@ +2401,3 @@ + ccall.add_argument (s2); + cexp = ccall; + } else { What about arrays? do we compare content or reference?
commit a04d18379da5c4cd4f4e860f68cad6647e20b4a0 Author: Jürg Billeter <j@bitron.ch> Date: Fri Oct 9 12:29:00 2009 +0200 Support struct comparison Based on patch by Marc-André Lureau, fixes bug 530605.