all: Convert mp_uint_t to mp_unary_op_t/mp_binary_op_t where appropriate
The unary-op/binary-op enums are already defined, and there are no
arithmetic tricks used with these types, so it makes sense to use the
correct enum type for arguments that take these values. It also reduces
code size quite a bit for nan-boxing builds.
diff --git a/extmod/modbtree.c b/extmod/modbtree.c
index 229daaf..5017079 100644
--- a/extmod/modbtree.c
+++ b/extmod/modbtree.c
@@ -281,7 +281,7 @@
}
}
-STATIC mp_obj_t btree_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t btree_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_btree_t *self = MP_OBJ_TO_PTR(lhs_in);
switch (op) {
case MP_BINARY_OP_IN: {
diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c
index a19b3fd..faa5895 100644
--- a/extmod/modutimeq.c
+++ b/extmod/modutimeq.c
@@ -189,7 +189,7 @@
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump);
#endif
-STATIC mp_obj_t utimeq_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
diff --git a/py/obj.c b/py/obj.c
index 515a95b..0dab5f2 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -505,7 +505,7 @@
}
}
-mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in) {
+mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
switch (op) {
case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
default: return MP_OBJ_NULL; // op not supported
diff --git a/py/obj.h b/py/obj.h
index 22bfda0..2adcab1 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -30,6 +30,7 @@
#include "py/misc.h"
#include "py/qstr.h"
#include "py/mpprint.h"
+#include "py/runtime0.h"
// This is the definition of the opaque MicroPython object type.
// All concrete objects have an encoding within this type and the
@@ -429,8 +430,8 @@
typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind);
typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args);
-typedef mp_obj_t (*mp_unary_op_fun_t)(mp_uint_t op, mp_obj_t);
-typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_t op, mp_obj_t, mp_obj_t);
+typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t);
+typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t);
typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
@@ -694,7 +695,7 @@
mp_obj_t mp_obj_len(mp_obj_t o_in);
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
-mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in);
+mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in);
// cell
mp_obj_t mp_obj_cell_get(mp_obj_t self_in);
@@ -734,11 +735,11 @@
#else
static inline mp_int_t mp_float_hash(mp_float_t val) { return (mp_int_t)val; }
#endif
-mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported
+mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported
// complex
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
-mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
+mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
#else
#define mp_obj_is_float(o) (false)
#endif
diff --git a/py/objarray.c b/py/objarray.c
index a31c536..d51cc65 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -231,7 +231,7 @@
}
#endif
-STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) {
+STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->len != 0);
@@ -240,7 +240,7 @@
}
}
-STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
switch (op) {
case MP_BINARY_OP_ADD: {
diff --git a/py/objbool.c b/py/objbool.c
index e5bc3c2..b94c57f 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -63,7 +63,7 @@
}
}
-STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
+STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
if (op == MP_UNARY_OP_LEN) {
return MP_OBJ_NULL;
}
@@ -71,7 +71,7 @@
return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(self->value));
}
-STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_bool_t *self = MP_OBJ_TO_PTR(lhs_in);
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in);
}
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 55627af..07b9d5d 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -117,7 +117,7 @@
}
}
-STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) {
+STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0);
@@ -128,7 +128,7 @@
}
}
-STATIC mp_obj_t complex_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in);
return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
}
@@ -171,7 +171,7 @@
*imag = self->imag;
}
-mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) {
mp_float_t rhs_real, rhs_imag;
mp_obj_get_complex(rhs_in, &rhs_real, &rhs_imag); // can be any type, this function will convert to float (if possible)
switch (op) {
diff --git a/py/objdict.c b/py/objdict.c
index f6357a9..6bb2435 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -100,7 +100,7 @@
return dict_out;
}
-STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0);
@@ -115,7 +115,7 @@
}
}
-STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in);
switch (op) {
case MP_BINARY_OP_IN: {
@@ -482,7 +482,7 @@
mp_print_str(print, "])");
}
-STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
// only supported for the 'keys' kind until sets and dicts are refactored
mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in);
if (o->kind != MP_DICT_VIEW_KEYS) {
diff --git a/py/objfloat.c b/py/objfloat.c
index 15edd81..b1900b2 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -155,7 +155,7 @@
}
}
-STATIC mp_obj_t float_unary_op(mp_uint_t op, mp_obj_t o_in) {
+STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_float_t val = mp_obj_float_get(o_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(val != 0);
@@ -166,7 +166,7 @@
}
}
-STATIC mp_obj_t float_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_float_t lhs_val = mp_obj_float_get(lhs_in);
#if MICROPY_PY_BUILTINS_COMPLEX
if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) {
@@ -239,7 +239,7 @@
*y = mod;
}
-mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t rhs_in) {
mp_float_t rhs_val = mp_obj_get_float(rhs_in); // can be any type, this function will convert to float (if possible)
switch (op) {
case MP_BINARY_OP_ADD:
diff --git a/py/objint.c b/py/objint.c
index 29d8896..6a73b43 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -325,12 +325,12 @@
}
// This is called for operations on SMALL_INT that are not handled by mp_unary_op
-mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
+mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
return MP_OBJ_NULL; // op not supported
}
// This is called for operations on SMALL_INT that are not handled by mp_binary_op
-mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
}
@@ -382,7 +382,7 @@
// This dispatcher function is expected to be independent of the implementation of long int
// It handles the extra cases for integer-like arithmetic
-mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
if (rhs_in == mp_const_false) {
// false acts as 0
return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(0));
diff --git a/py/objint.h b/py/objint.h
index 394c237..a4d4ff3 100644
--- a/py/objint.h
+++ b/py/objint.h
@@ -58,9 +58,9 @@
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);
int mp_obj_int_sign(mp_obj_t self_in);
mp_obj_t mp_obj_int_abs(mp_obj_t self_in);
-mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in);
-mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
-mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
+mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in);
+mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
+mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus);
#endif // MICROPY_INCLUDED_PY_OBJINT_H
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 02c005d..ddfdae7 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -118,7 +118,7 @@
}
}
-mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
+mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_obj_int_t *o = o_in;
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->val != 0);
@@ -134,7 +134,7 @@
}
}
-mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
long long lhs_val;
long long rhs_val;
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 0791a8a..148446f 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -162,7 +162,7 @@
}
}
-mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
+mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_obj_int_t *o = MP_OBJ_TO_PTR(o_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(!mpz_is_zero(&o->mpz));
@@ -174,7 +174,7 @@
}
}
-mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
const mpz_t *zlhs;
const mpz_t *zrhs;
mpz_t z_int;
diff --git a/py/objlist.c b/py/objlist.c
index 86d4300..6ac33e8 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -99,7 +99,7 @@
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
}
-STATIC mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
@@ -114,7 +114,7 @@
}
}
-STATIC mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
+STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs);
switch (op) {
case MP_BINARY_OP_ADD: {
diff --git a/py/objrange.c b/py/objrange.c
index 33b07a9..fa99c4c 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -130,7 +130,7 @@
return len;
}
-STATIC mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t len = range_len(self);
switch (op) {
diff --git a/py/objset.c b/py/objset.c
index 376439b..d4a8a1a 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -455,7 +455,7 @@
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
-STATIC mp_obj_t set_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->set.used != 0);
@@ -480,7 +480,7 @@
}
}
-STATIC mp_obj_t set_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
+STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_t args[] = {lhs, rhs};
#if MICROPY_PY_BUILTINS_FROZENSET
bool update = MP_OBJ_IS_TYPE(lhs, &mp_type_set);
diff --git a/py/objstr.c b/py/objstr.c
index f04bd90..4c287af 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -280,7 +280,7 @@
// Note: this function is used to check if an object is a str or bytes, which
// works because both those types use it as their binary_op method. Revisit
// MP_OBJ_IS_STR_OR_BYTES if this fact changes.
-mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
// check for modulo
if (op == MP_BINARY_OP_MODULO) {
mp_obj_t *args = &rhs_in;
@@ -380,9 +380,10 @@
case MP_BINARY_OP_MORE:
case MP_BINARY_OP_MORE_EQUAL:
return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_data, lhs_len, rhs_data, rhs_len));
- }
- return MP_OBJ_NULL; // op not supported
+ default:
+ return MP_OBJ_NULL; // op not supported
+ }
}
#if !MICROPY_PY_BUILTINS_STR_UNICODE
diff --git a/py/objstr.h b/py/objstr.h
index 3aef8c6..82501a7 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -67,7 +67,7 @@
mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args);
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len);
-mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
+mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len,
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 036f7f3..7853174 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -100,7 +100,7 @@
}
}
-STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
GET_STR_DATA_LEN(self_in, str_data, str_len);
switch (op) {
case MP_UNARY_OP_BOOL:
diff --git a/py/objtuple.c b/py/objtuple.c
index 765edb9..079b5cb 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -118,7 +118,7 @@
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
}
-mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) {
+mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
@@ -135,7 +135,7 @@
}
}
-mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
+mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_tuple_t *o = MP_OBJ_TO_PTR(lhs);
switch (op) {
case MP_BINARY_OP_ADD:
diff --git a/py/objtuple.h b/py/objtuple.h
index 05c6490..74cde88 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -41,8 +41,8 @@
} mp_rom_obj_tuple_t;
void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
-mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in);
-mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
+mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in);
+mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf);
diff --git a/py/objtype.c b/py/objtype.c
index e1a24da..08e276d 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -345,7 +345,7 @@
[MP_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size
};
-STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
#if MICROPY_PY_SYS_GETSIZEOF
@@ -452,7 +452,7 @@
[MP_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, // not implemented, used to make sure array has full size
};
-STATIC mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+STATIC mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
// Note: For ducktyping, CPython does not look in the instance members or use
// __getattr__ or __getattribute__. It only looks in the class dictionary.
mp_obj_instance_t *lhs = MP_OBJ_TO_PTR(lhs_in);
diff --git a/py/runtime.c b/py/runtime.c
index eb12988..1db6c93 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -209,7 +209,7 @@
mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst));
}
-mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) {
+mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) {
DEBUG_OP_printf("unary " UINT_FMT " %p\n", op, arg);
if (op == MP_UNARY_OP_NOT) {
@@ -261,7 +261,7 @@
}
}
-mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
+mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
DEBUG_OP_printf("binary " UINT_FMT " %p %p\n", op, lhs, rhs);
// TODO correctly distinguish inplace operators for mutable objects
diff --git a/py/runtime.h b/py/runtime.h
index 428e257..4abdea5 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -96,8 +96,8 @@
void mp_delete_name(qstr qst);
void mp_delete_global(qstr qst);
-mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg);
-mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
+mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg);
+mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_call_function_0(mp_obj_t fun);
mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg);
diff --git a/unix/modjni.c b/unix/modjni.c
index df9cd9d..85fc891 100644
--- a/unix/modjni.c
+++ b/unix/modjni.c
@@ -293,7 +293,7 @@
return MP_OBJ_NULL;
}
-STATIC mp_obj_t jobject_unary_op(mp_uint_t op, mp_obj_t self_in) {
+STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_jobject_t *self = self_in;
switch (op) {
case MP_UNARY_OP_BOOL: