Skip to content
Discussion options

You must be logged in to vote

I've already taken care of it, I feel at ease now~~
It's actually very simple, just fill in the attr element, as follows:

const mp_obj_type_t class_b_type = {
    { &mp_type_type },
    .name = MP_QSTR_B,
    .make_new = &class_b_make_new,
    .locals_dict =  (mp_obj_dict_t *)&class_b_local_dict,
    .parent = &class_a_type,
    .attr = call_parent_methods,
};

void call_parent_methods(mp_obj_t obj, qstr attr, mp_obj_t *dest)
{
    const mp_obj_type_t *type = mp_obj_get_type(obj);
    while (type->locals_dict != NULL) {
        // generic method lookup
        // this is a lookup in the object (ie not class or type)
        assert(type->locals_dict->base.type == &mp_type_dict); // MicroPy…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@Mars-CN
Comment options

@jimmo
Comment options

Comment options

You must be logged in to vote
1 reply
@Mars-CN
Comment options

Answer selected by Mars-CN
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
3 participants