Code: Select all
mp_obj_type_t*
Code: Select all
(mp_obj_type_t*)o->type
o->type
Code: Select all
mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
if (MP_OBJ_IS_SMALL_INT(o_in)) {
return (mp_obj_type_t*)&mp_type_int;
} else if (MP_OBJ_IS_QSTR(o_in)) {
return (mp_obj_type_t*)&mp_type_str;
#if MICROPY_PY_BUILTINS_FLOAT
} else if (mp_obj_is_float(o_in)) {
return (mp_obj_type_t*)&mp_type_float;
#endif
} else {
const mp_obj_base_t *o = MP_OBJ_TO_PTR(o_in);
return (mp_obj_type_t*)o->type;
}
}
Code: Select all
// This mp_obj_type_t struct is a concrete MicroPython object which holds info
// about a type. See below for actual definition of the struct.
typedef struct _mp_obj_type_t mp_obj_type_t;
// Anything that wants to be a concrete MicroPython object must have mp_obj_base_t
// as its first member (small ints, qstr objs and inline floats are not concrete).
struct _mp_obj_base_t {
const mp_obj_type_t *type MICROPY_OBJ_BASE_ALIGNMENT;
};
typedef struct _mp_obj_base_t mp_obj_base_t;