Rename mp_type_binary_op -> mp_type_get_binary_op_slot

This commit is contained in:
Jeff Epler 2021-07-12 07:03:52 -05:00
parent 46b5ed33ed
commit 6b8190b408
4 changed files with 6 additions and 6 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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) {