Rename mp_type_parent -> mp_type_get_parent_slot
This commit is contained in:
parent
75e995f372
commit
88434c53c7
@ -1 +1 @@
|
||||
Subproject commit 75c7e05eacb22a9f6fef9c4381fe23c138565172
|
||||
Subproject commit e2e91111e41b1bb840f64be69107f7fd3aa6e737
|
@ -141,7 +141,7 @@ static inline mp_obj_t mp_obj_cast_to_native_base_dyn(mp_obj_t self_in, mp_const
|
||||
if (MP_OBJ_FROM_PTR(self_type) == native_type) {
|
||||
return self_in;
|
||||
}
|
||||
mp_parent_t parent = mp_type_parent(self_type);
|
||||
mp_parent_t parent = mp_type_get_parent_slot(self_type);
|
||||
if (parent != native_type) {
|
||||
// The self_in object is not a direct descendant of native_type, so fail the cast.
|
||||
// This is a very simple version of mp_obj_is_subclass_fast that could be improved.
|
||||
|
2
py/obj.c
2
py/obj.c
@ -746,7 +746,7 @@ const void *mp_type_get_protocol_slot(const mp_obj_type_t *type) {
|
||||
}
|
||||
|
||||
|
||||
const void *mp_type_parent(const mp_obj_type_t *type) {
|
||||
const void *mp_type_get_parent_slot(const mp_obj_type_t *type) {
|
||||
return type->parent;
|
||||
}
|
||||
|
||||
|
2
py/obj.h
2
py/obj.h
@ -674,7 +674,7 @@ extern const void *mp_type_get_protocol_slot(const mp_obj_type_t *);
|
||||
// These fields ended up not being placed in the extended area, but accessors
|
||||
// were created for them anyway.
|
||||
extern mp_attr_fun_t mp_type_attr(const mp_obj_type_t *);
|
||||
extern const void *mp_type_parent(const mp_obj_type_t *);
|
||||
extern const void *mp_type_get_parent_slot(const mp_obj_type_t *);
|
||||
|
||||
// Return the size of a type object, which can be one of two lengths depending whether it has
|
||||
// the extended fields or not.
|
||||
|
10
py/objtype.c
10
py/objtype.c
@ -65,7 +65,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
|
||||
*last_native_base = type;
|
||||
return count + 1;
|
||||
}
|
||||
const void *parent = mp_type_parent(type);
|
||||
const void *parent = mp_type_get_parent_slot(type);
|
||||
if (parent == NULL) {
|
||||
// No parents so end search here.
|
||||
return count;
|
||||
@ -215,7 +215,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_t
|
||||
|
||||
// attribute not found, keep searching base classes
|
||||
|
||||
const void *parent = mp_type_parent(type);
|
||||
const void *parent = mp_type_get_parent_slot(type);
|
||||
if (parent == NULL) {
|
||||
DEBUG_printf("mp_obj_class_lookup: No more parents\n");
|
||||
return;
|
||||
@ -1085,7 +1085,7 @@ STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
dest[0] = mp_const_empty_tuple;
|
||||
return;
|
||||
}
|
||||
const void *parent = mp_type_parent(self);
|
||||
const void *parent = mp_type_get_parent_slot(self);
|
||||
mp_obj_t parent_obj = parent ? MP_OBJ_FROM_PTR(parent) : MP_OBJ_FROM_PTR(&mp_type_object);
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
if (mp_obj_is_type(parent_obj, &mp_type_tuple)) {
|
||||
@ -1334,7 +1334,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
lookup.meth_offset = offsetof(mp_obj_type_t, make_new);
|
||||
}
|
||||
|
||||
const void *parent = mp_type_parent(type);
|
||||
const void *parent = mp_type_get_parent_slot(type);
|
||||
if (parent == NULL) {
|
||||
// no parents, do nothing
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
@ -1430,7 +1430,7 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
|
||||
}
|
||||
|
||||
const mp_obj_type_t *self = MP_OBJ_TO_PTR(object);
|
||||
const void *parent = mp_type_parent(self);
|
||||
const void *parent = mp_type_get_parent_slot(self);
|
||||
|
||||
if (parent == NULL) {
|
||||
// type has no parents
|
||||
|
Loading…
x
Reference in New Issue
Block a user