From 6b8190b4083b01a8d37eb34087bde29b176d121a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 12 Jul 2021 07:03:52 -0500 Subject: [PATCH] Rename mp_type_binary_op -> mp_type_get_binary_op_slot --- py/obj.c | 4 ++-- py/obj.h | 4 ++-- py/opmethods.c | 2 +- py/runtime.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/py/obj.c b/py/obj.c index 854e9a4f7a..b7b1d35adf 100644 --- a/py/obj.c +++ b/py/obj.c @@ -288,7 +288,7 @@ mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2) { const mp_obj_type_t *type = mp_obj_get_type(o1); // If a full equality test is not needed and the other object is a different // type then we don't need to bother trying the comparison. - mp_binary_op_fun_t binary_op = mp_type_binary_op(type); + mp_binary_op_fun_t binary_op = mp_type_get_binary_op_slot(type); if (binary_op != NULL && ((type->flags & MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE) || mp_obj_get_type(o2) == type)) { // CPython is asymmetric: it will try __eq__ if there's no __ne__ but not the @@ -693,7 +693,7 @@ mp_unary_op_fun_t mp_type_get_unary_op_slot(const mp_obj_type_t *type) { } -mp_binary_op_fun_t mp_type_binary_op(const mp_obj_type_t *type) { +mp_binary_op_fun_t mp_type_get_binary_op_slot(const mp_obj_type_t *type) { if (!(type->flags & MP_TYPE_FLAG_EXTENDED)) { return NULL; } diff --git a/py/obj.h b/py/obj.h index 234e776f0c..70891fb768 100644 --- a/py/obj.h +++ b/py/obj.h @@ -664,7 +664,7 @@ struct _mp_obj_full_type_t { #define MP_TYPE_PROTOCOL ext[0].protocol extern mp_call_fun_t mp_type_get_call_slot(const mp_obj_type_t *); extern mp_unary_op_fun_t mp_type_get_unary_op_slot(const mp_obj_type_t *); -extern mp_binary_op_fun_t mp_type_binary_op(const mp_obj_type_t *); +extern mp_binary_op_fun_t mp_type_get_binary_op_slot(const mp_obj_type_t *); extern mp_subscr_fun_t mp_type_subscr(const mp_obj_type_t *); extern mp_getiter_fun_t mp_type_getiter(const mp_obj_type_t *); extern mp_fun_1_t mp_type_iternext(const mp_obj_type_t *); @@ -814,7 +814,7 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; #endif #define mp_obj_is_int(o) (mp_obj_is_small_int(o) || mp_obj_is_type(o, &mp_type_int)) #define mp_obj_is_str(o) (mp_obj_is_qstr(o) || mp_obj_is_type(o, &mp_type_str)) -#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && mp_type_binary_op(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type) == mp_obj_str_binary_op)) +#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && mp_type_get_binary_op_slot(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type) == mp_obj_str_binary_op)) #define mp_obj_is_dict_or_ordereddict(o) (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->make_new == mp_obj_dict_make_new) #define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function)) // type check is done on getiter method to allow tuple, namedtuple, attrtuple diff --git a/py/opmethods.c b/py/opmethods.c index 48925f1100..6ebd469113 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -47,7 +47,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) { const mp_obj_type_t *type = mp_obj_get_type(lhs_in); - mp_binary_op_fun_t binary_op = mp_type_binary_op(type); + mp_binary_op_fun_t binary_op = mp_type_get_binary_op_slot(type); return binary_op(MP_BINARY_OP_CONTAINS, lhs_in, rhs_in); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_contains_obj, op_contains); diff --git a/py/runtime.c b/py/runtime.c index 6c8c4e5fb5..7d148359c8 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -572,7 +572,7 @@ mp_obj_t PLACE_IN_ITCM(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t r const mp_obj_type_t *type; generic_binary_op: type = mp_obj_get_type(lhs); - mp_binary_op_fun_t binary_op = mp_type_binary_op(type); + mp_binary_op_fun_t binary_op = mp_type_get_binary_op_slot(type); if (binary_op != NULL) { mp_obj_t result = binary_op(op, lhs, rhs); if (result != MP_OBJ_NULL) {