Rename mp_type_getiter -> mp_type_get_getiter_slot

This commit is contained in:
Jeff Epler 2021-07-12 07:03:57 -05:00
parent 0efdf4a549
commit 9f6132b2ba
4 changed files with 5 additions and 5 deletions

View File

@ -714,7 +714,7 @@ mp_subscr_fun_t mp_type_get_subscr_slot(const mp_obj_type_t *type) {
}
mp_getiter_fun_t mp_type_getiter(const mp_obj_type_t *type) {
mp_getiter_fun_t mp_type_get_getiter_slot(const mp_obj_type_t *type) {
if (!(type->flags & MP_TYPE_FLAG_EXTENDED)) {
return NULL;
}

View File

@ -666,7 +666,7 @@ 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_get_binary_op_slot(const mp_obj_type_t *);
extern mp_subscr_fun_t mp_type_get_subscr_slot(const mp_obj_type_t *);
extern mp_getiter_fun_t mp_type_getiter(const mp_obj_type_t *);
extern mp_getiter_fun_t mp_type_get_getiter_slot(const mp_obj_type_t *);
extern mp_fun_1_t mp_type_iternext(const mp_obj_type_t *);
extern mp_getbuffer_fun_t mp_type_getbuffer(const mp_obj_type_t *);
extern const void *mp_type_protocol(const mp_obj_type_t *);
@ -818,7 +818,7 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
#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
#define mp_obj_is_tuple_compatible(o) (mp_type_getiter(mp_obj_get_type(o)) == mp_obj_tuple_getiter)
#define mp_obj_is_tuple_compatible(o) (mp_type_get_getiter_slot(mp_obj_get_type(o)) == mp_obj_tuple_getiter)
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
static inline mp_obj_t mp_obj_new_bool(mp_int_t x) {

View File

@ -108,7 +108,7 @@ STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t anothe
mp_check_self(mp_obj_is_tuple_compatible(self_in));
const mp_obj_type_t *another_type = mp_obj_get_type(another_in);
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
if (mp_type_getiter(another_type) != mp_obj_tuple_getiter) {
if (mp_type_get_getiter_slot(another_type) != mp_obj_tuple_getiter) {
// Slow path for user subclasses
another_in = mp_obj_cast_to_native_base(another_in, MP_OBJ_FROM_PTR(&mp_type_tuple));
if (another_in == MP_OBJ_NULL) {

View File

@ -1230,7 +1230,7 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
assert(o_in);
const mp_obj_type_t *type = mp_obj_get_type(o_in);
mp_getiter_fun_t getiter = mp_type_getiter(type);
mp_getiter_fun_t getiter = mp_type_get_getiter_slot(type);
// Check for native getiter which is the identity. We handle this case explicitly
// so we don't unnecessarily allocate any RAM for the iter_buf, which won't be used.
if (getiter == mp_identity_getiter) {