summaryrefslogtreecommitdiff
path: root/py/obj.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-12 04:58:25 -0800
committerDamien George <damien.p.george@gmail.com>2014-01-12 04:58:25 -0800
commit97eb73cf84876ec0c5fcf51ffc1190aaf2ee5780 (patch)
tree91f282b8436daa77fb895bc6bc7004063df95315 /py/obj.c
parent022630213a7ea494546e8fb24c9ff35d9363b798 (diff)
parent1945e60aeb1099e7cd0ab0ccd9c427c2c68ead99 (diff)
Merge pull request #148 from pfalcon/list-cmp
Implement type virtual equality method support and implement comparisons for lists
Diffstat (limited to 'py/obj.c')
-rw-r--r--py/obj.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/obj.c b/py/obj.c
index 81b5c69f7..2759437fd 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -117,6 +117,13 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
} else if (MP_OBJ_IS_TYPE(o1, &str_type) && MP_OBJ_IS_TYPE(o2, &str_type)) {
return mp_obj_str_get(o1) == mp_obj_str_get(o2);
} else {
+ mp_obj_base_t *o = o1;
+ if (o->type->binary_op != NULL) {
+ mp_obj_t r = o->type->binary_op(RT_COMPARE_OP_EQUAL, o1, o2);
+ if (r != MP_OBJ_NULL) {
+ return r == mp_const_true ? true : false;
+ }
+ }
// TODO: Debugging helper
printf("Equality for '%s' and '%s' types not yet implemented\n", mp_obj_get_type_str(o1), mp_obj_get_type_str(o2));
assert(0);