diff options
author | Damien George <damien.p.george@gmail.com> | 2014-08-26 09:31:26 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-08-26 09:31:26 +0100 |
commit | 779794a68085eda5176694437523d43b953a8651 (patch) | |
tree | 59e40a02781a6137bdd388635d073e48f6cd2083 /py | |
parent | fa1a9bc9fd1683f1fb68739efc1aef303c8a1d2d (diff) | |
download | micropython-779794a68085eda5176694437523d43b953a8651.tar.gz micropython-779794a68085eda5176694437523d43b953a8651.zip |
py: Add dispatch for user defined ==, >, <=, >=.
Addresses issue #827.
Diffstat (limited to 'py')
-rw-r--r-- | py/objtype.c | 11 | ||||
-rw-r--r-- | py/qstrdefs.h | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/py/objtype.c b/py/objtype.c index b760b3240c..ed323ed1d2 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -381,11 +381,12 @@ STATIC const qstr binary_op_method_name[] = { MP_BINARY_OP_INPLACE_MODULO, MP_BINARY_OP_INPLACE_POWER,*/ [MP_BINARY_OP_LESS] = MP_QSTR___lt__, - /*MP_BINARY_OP_MORE, - MP_BINARY_OP_EQUAL, - MP_BINARY_OP_LESS_EQUAL, - MP_BINARY_OP_MORE_EQUAL, - MP_BINARY_OP_NOT_EQUAL, + [MP_BINARY_OP_MORE] = MP_QSTR___gt__, + [MP_BINARY_OP_EQUAL] = MP_QSTR___eq__, + [MP_BINARY_OP_LESS_EQUAL] = MP_QSTR___le__, + [MP_BINARY_OP_MORE_EQUAL] = MP_QSTR___ge__, + /* + MP_BINARY_OP_NOT_EQUAL, // a != b calls a == b and inverts result */ [MP_BINARY_OP_IN] = MP_QSTR___contains__, /* diff --git a/py/qstrdefs.h b/py/qstrdefs.h index c83b54c241..2574443662 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -64,6 +64,10 @@ Q(__getattr__) Q(__del__) Q(__call__) Q(__lt__) +Q(__gt__) +Q(__eq__) +Q(__le__) +Q(__ge__) Q(micropython) Q(bytecode) |