diff options
Diffstat (limited to 'py')
48 files changed, 119 insertions, 141 deletions
diff --git a/py/builtinevex.c b/py/builtinevex.c index 403cd95a9d..173978ef52 100644 --- a/py/builtinevex.c +++ b/py/builtinevex.c @@ -41,8 +41,7 @@ typedef struct _mp_obj_code_t { STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_code, MP_QSTR_code, - MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW + MP_TYPE_FLAG_NONE ); STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { diff --git a/py/dynruntime.h b/py/dynruntime.h index be573bde2a..8564715c0b 100644 --- a/py/dynruntime.h +++ b/py/dynruntime.h @@ -105,7 +105,7 @@ static inline void *m_realloc_dyn(void *ptr, size_t new_num_bytes) { #define mp_const_none ((mp_obj_t)mp_fun_table.const_none) #define mp_const_false ((mp_obj_t)mp_fun_table.const_false) #define mp_const_true ((mp_obj_t)mp_fun_table.const_true) -#define mp_const_empty_bytes (mp_type_bytes.make_new(NULL, 0, 0, NULL)) +#define mp_const_empty_bytes (MP_OBJ_TYPE_GET_SLOT(&mp_type_bytes, make_new)(NULL, 0, 0, NULL)) #define mp_const_empty_tuple (mp_fun_table.new_tuple(0, NULL)) #define mp_obj_new_bool(b) ((b) ? (mp_obj_t)mp_fun_table.const_true : (mp_obj_t)mp_fun_table.const_false) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 152323b5ca..06e9f1acb5 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -547,7 +547,7 @@ STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t if (n_args > 1) { mp_raise_TypeError(MP_ERROR_TEXT("must use keyword argument for key function")); } - mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); + mp_obj_t self = mp_obj_list_make_new(&mp_type_list, 1, 0, args); mp_obj_list_sort(1, &self, kwargs); return self; diff --git a/py/modio.c b/py/modio.c index a1e04e4cac..9ec6bbcc4e 100644 --- a/py/modio.c +++ b/py/modio.c @@ -101,7 +101,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_iobase, MP_QSTR_IOBase, MP_TYPE_FLAG_NONE, - iobase_make_new, + make_new, iobase_make_new, protocol, &iobase_p ); @@ -196,7 +196,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_bufwriter, MP_QSTR_BufferedWriter, MP_TYPE_FLAG_NONE, - bufwriter_make_new, + make_new, bufwriter_make_new, protocol, &bufwriter_stream_p, locals_dict, &bufwriter_locals_dict ); diff --git a/py/modthread.c b/py/modthread.c index 3116fe6bd9..51d63e4703 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -120,7 +120,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_thread_lock, MP_QSTR_lock, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, locals_dict, &thread_lock_locals_dict ); @@ -594,15 +594,15 @@ struct _mp_obj_type_t { // The name of this type, a qstr. uint16_t name; - // Corresponds to __new__ and __init__ special methods, to make an instance of the type. - mp_make_new_fun_t make_new; - // Slots: For the rest of the fields, the slot index points to the // relevant function in the variable-length "slots" field. Ideally these // would be only 4 bits, but the extra overhead of accessing them adds // more code, and we also need to be able to take the address of them for // mp_obj_class_lookup. + // Corresponds to __new__ and __init__ special methods, to make an instance of the type. + uint8_t slot_index_make_new; + // Corresponds to __repr__ and __str__ special methods. uint8_t slot_index_print; @@ -673,8 +673,8 @@ typedef struct _mp_obj_empty_type_t { mp_obj_base_t base; uint16_t flags; uint16_t name; - mp_make_new_fun_t make_new; + uint8_t slot_index_make_new; uint8_t slot_index_print; uint8_t slot_index_call; uint8_t slot_index_unary_op; @@ -694,8 +694,8 @@ typedef struct _mp_obj_full_type_t { mp_obj_base_t base; uint16_t flags; uint16_t name; - mp_make_new_fun_t make_new; + uint8_t slot_index_make_new; uint8_t slot_index_print; uint8_t slot_index_call; uint8_t slot_index_unary_op; @@ -712,8 +712,7 @@ typedef struct _mp_obj_full_type_t { const void *slots[11]; } mp_obj_full_type_t; -#define MP_TYPE_NULL_MAKE_NEW (NULL) - +#define _MP_OBJ_TYPE_SLOT_TYPE_make_new (mp_make_new_fun_t) #define _MP_OBJ_TYPE_SLOT_TYPE_print (mp_print_fun_t) #define _MP_OBJ_TYPE_SLOT_TYPE_call (mp_call_fun_t) #define _MP_OBJ_TYPE_SLOT_TYPE_unary_op (mp_unary_op_fun_t) @@ -730,42 +729,41 @@ typedef struct _mp_obj_full_type_t { // Do not use these directly, instead use MP_DEFINE_CONST_OBJ_TYPE. // Generated with: // for i in range(13): -// print(f"#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_{i}(_struct_type, _typename, _name, _flags, _make_new{''.join(f', f{j+1}, v{j+1}' for j in range(i))}) const _struct_type _typename = {{ .base = {{ &mp_type_type }}, .name = _name, .flags = _flags, .make_new = _make_new{''.join(f', .slot_index_##f{j+1} = {j+1}' for j in range(i))}{', .slots = { ' + ''.join(f'v{j+1}, ' for j in range(i)) + '}' if i else '' } }}") -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_0(_struct_type, _typename, _name, _flags, _make_new) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_1(_struct_type, _typename, _name, _flags, _make_new, f1, v1) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slots = { v1, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_2(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slots = { v1, v2, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_3(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slots = { v1, v2, v3, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_4(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slots = { v1, v2, v3, v4, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_5(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slots = { v1, v2, v3, v4, v5, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_6(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slots = { v1, v2, v3, v4, v5, v6, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_7(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slots = { v1, v2, v3, v4, v5, v6, v7, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_8(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_9(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_10(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_11(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, } } -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_12(_struct_type, _typename, _name, _flags, _make_new, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11, f12, v12) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .make_new = _make_new, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slot_index_##f12 = 12, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, } } +// print(f"#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_{i}(_struct_type, _typename, _name, _flags{''.join(f', f{j+1}, v{j+1}' for j in range(i))}) const _struct_type _typename = {{ .base = {{ &mp_type_type }}, .name = _name, .flags = _flags{''.join(f', .slot_index_##f{j+1} = {j+1}' for j in range(i))}{', .slots = { ' + ''.join(f'v{j+1}, ' for j in range(i)) + '}' if i else '' } }}") +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_0(_struct_type, _typename, _name, _flags) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_1(_struct_type, _typename, _name, _flags, f1, v1) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slots = { v1, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_2(_struct_type, _typename, _name, _flags, f1, v1, f2, v2) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slots = { v1, v2, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_3(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slots = { v1, v2, v3, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_4(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slots = { v1, v2, v3, v4, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_5(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slots = { v1, v2, v3, v4, v5, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_6(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slots = { v1, v2, v3, v4, v5, v6, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_7(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slots = { v1, v2, v3, v4, v5, v6, v7, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_8(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_9(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_10(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_11(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, } } +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_12(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11, f12, v12) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slot_index_##f12 = 12, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, } } #define MP_OBJ_TYPE_HAS_SLOT(t, f) ((t)->slot_index_##f) #define MP_OBJ_TYPE_GET_SLOT(t, f) (_MP_OBJ_TYPE_SLOT_TYPE_##f(t)->slots[(t)->slot_index_##f - 1]) #define MP_OBJ_TYPE_GET_SLOT_OR_NULL(t, f) (_MP_OBJ_TYPE_SLOT_TYPE_##f(MP_OBJ_TYPE_HAS_SLOT(t, f) ? MP_OBJ_TYPE_GET_SLOT(t, f) : NULL)) #define MP_OBJ_TYPE_SET_SLOT(t, f, v, n) ((t)->slot_index_##f = (n) + 1, (t)->slots[(t)->slot_index_##f - 1] = (void *)v) #define MP_OBJ_TYPE_OFFSETOF_SLOT(f) (offsetof(mp_obj_type_t, slot_index_##f)) -// For everything except make_new, the offset is to the uint8_t index. For make_new, we need to check the pointer. -#define MP_OBJ_TYPE_HAS_SLOT_BY_OFFSET(t, offset) (*(uint8_t *)((char *)(t) + (offset)) != 0 || (offset == offsetof(mp_obj_type_t, make_new) && t->make_new)) +#define MP_OBJ_TYPE_HAS_SLOT_BY_OFFSET(t, offset) (*(uint8_t *)((char *)(t) + (offset)) != 0) // Workaround for https://docs.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-160#macro-arguments-are-unpacked #define MP_DEFINE_CONST_OBJ_TYPE_EXPAND(x) x // This macro evaluates to MP_DEFINE_CONST_OBJ_TYPE_NARGS_##N, where N is the value -// of the 30th argument (30 is 13*2 + 4). -#define MP_DEFINE_CONST_OBJ_TYPE_NARGS(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, N, ...) MP_DEFINE_CONST_OBJ_TYPE_NARGS_##N +// of the 29th argument (29 is 13*2 + 3). +#define MP_DEFINE_CONST_OBJ_TYPE_NARGS(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, N, ...) MP_DEFINE_CONST_OBJ_TYPE_NARGS_##N // These macros are used to define a object type in ROM. // Invoke as MP_DEFINE_CONST_OBJ_TYPE(_typename, _name, _flags, _make_new [, slot, func]*) // They use the number of arguments to select which MP_DEFINE_CONST_OBJ_TYPE_* // macro to use based on the number of arguments. It works by shifting the // numeric values 12, 11, ... 0 by the number of arguments, such that the -// 30th argument ends up being the number to use. The _INV values are +// 29th argument ends up being the number to use. The _INV values are // placeholders because the slot arguments come in pairs. #define MP_DEFINE_CONST_OBJ_TYPE(...) MP_DEFINE_CONST_OBJ_TYPE_EXPAND(MP_DEFINE_CONST_OBJ_TYPE_NARGS(__VA_ARGS__, _INV, 12, _INV, 11, _INV, 10, _INV, 9, _INV, 8, _INV, 7, _INV, 6, _INV, 5, _INV, 4, _INV, 3, _INV, 2, _INV, 1, _INV, 0)(mp_obj_type_t, __VA_ARGS__)) #define MP_DEFINE_CONST_OBJ_FULL_TYPE(...) MP_DEFINE_CONST_OBJ_TYPE_EXPAND(MP_DEFINE_CONST_OBJ_TYPE_NARGS(__VA_ARGS__, _INV, 12, _INV, 11, _INV, 10, _INV, 9, _INV, 8, _INV, 7, _INV, 6, _INV, 5, _INV, 4, _INV, 3, _INV, 2, _INV, 1, _INV, 0)(mp_obj_full_type_t, __VA_ARGS__)) @@ -916,7 +914,7 @@ void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type); #define mp_obj_is_int(o) (mp_obj_is_small_int(o) || mp_obj_is_exact_type(o, &mp_type_int)) #define mp_obj_is_str(o) (mp_obj_is_qstr(o) || mp_obj_is_exact_type(o, &mp_type_str)) #define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type, binary_op) == 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_dict_or_ordereddict(o) (mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((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)) mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); @@ -1032,7 +1030,7 @@ mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); mp_uint_t mp_obj_int_get_uint_checked(mp_const_obj_t self_in); // exception -#define mp_obj_is_native_exception_instance(o) (mp_obj_get_type(o)->make_new == mp_obj_exception_make_new) +#define mp_obj_is_native_exception_instance(o) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(o), make_new) == mp_obj_exception_make_new) bool mp_obj_is_exception_type(mp_obj_t self_in); bool mp_obj_is_exception_instance(mp_obj_t self_in); bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type); @@ -1044,7 +1042,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); void mp_init_emergency_exception_buf(void); static inline mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { - assert(exc_type->make_new == mp_obj_exception_make_new); + assert(MP_OBJ_TYPE_GET_SLOT_OR_NULL(exc_type, make_new) == mp_obj_exception_make_new); return mp_obj_exception_make_new(exc_type, 1, 0, &arg); } diff --git a/py/objarray.c b/py/objarray.c index 0d1032929f..42fc0749d2 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -575,7 +575,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_array, MP_QSTR_array, MP_TYPE_FLAG_ITER_IS_GETITER, - array_make_new, + make_new, array_make_new, print, array_print, iter, array_iterator_new, unary_op, array_unary_op, @@ -591,7 +591,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_bytearray, MP_QSTR_bytearray, MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE | MP_TYPE_FLAG_ITER_IS_GETITER, - bytearray_make_new, + make_new, bytearray_make_new, print, array_print, iter, array_iterator_new, unary_op, array_unary_op, @@ -619,7 +619,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_memoryview, MP_QSTR_memoryview, MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE | MP_TYPE_FLAG_ITER_IS_GETITER, - memoryview_make_new, + make_new, memoryview_make_new, iter, array_iterator_new, unary_op, array_unary_op, binary_op, array_binary_op, @@ -677,7 +677,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_array_it, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, array_it_iternext ); diff --git a/py/objattrtuple.c b/py/objattrtuple.c index 2e207f4cf0..fbe04bedb8 100644 --- a/py/objattrtuple.c +++ b/py/objattrtuple.c @@ -84,7 +84,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_attrtuple, MP_QSTR_tuple, MP_TYPE_FLAG_ITER_IS_GETITER, - MP_TYPE_NULL_MAKE_NEW, // reuse tuple to save on a qstr print, mp_obj_attrtuple_print, unary_op, mp_obj_tuple_unary_op, diff --git a/py/objbool.c b/py/objbool.c index 5d014bbb8e..3267ff98bb 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -89,7 +89,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_bool, MP_QSTR_bool, MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE, - bool_make_new, + make_new, bool_make_new, print, bool_print, unary_op, bool_unary_op, binary_op, bool_binary_op diff --git a/py/objboundmeth.c b/py/objboundmeth.c index f4b3b9b7df..8486f876f9 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -111,7 +111,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_bound_meth, MP_QSTR_bound_method, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, BOUND_METH_TYPE_PRINT BOUND_METH_TYPE_ATTR call, bound_meth_call diff --git a/py/objcell.c b/py/objcell.c index b100fae4fe..0a74e29d20 100644 --- a/py/objcell.c +++ b/py/objcell.c @@ -48,7 +48,7 @@ STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k STATIC MP_DEFINE_CONST_OBJ_TYPE( // cell representation is just value in < > - mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE, MP_TYPE_NULL_MAKE_NEW + mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE CELL_TYPE_PRINT ); diff --git a/py/objclosure.c b/py/objclosure.c index 45a3e83c46..6059d18100 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -99,7 +99,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_closure, MP_QSTR_closure, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, CLOSURE_TYPE_ATTR CLOSURE_TYPE_PRINT call, closure_call diff --git a/py/objcomplex.c b/py/objcomplex.c index cf213d718a..ddd103eeb4 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -152,7 +152,8 @@ STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_complex, MP_QSTR_complex, MP_TYPE_FLAG_EQ_NOT_REFLEXIVE | MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE, complex_make_new, + mp_type_complex, MP_QSTR_complex, MP_TYPE_FLAG_EQ_NOT_REFLEXIVE | MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE, + make_new, complex_make_new, print, complex_print, unary_op, complex_unary_op, binary_op, complex_binary_op, diff --git a/py/objdeque.c b/py/objdeque.c index 1a8f76ca11..8b52b8d387 100644 --- a/py/objdeque.c +++ b/py/objdeque.c @@ -159,7 +159,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_deque, MP_QSTR_deque, MP_TYPE_FLAG_NONE, - deque_make_new, + make_new, deque_make_new, unary_op, deque_unary_op, locals_dict, &deque_locals_dict ); diff --git a/py/objdict.c b/py/objdict.c index 7755d7b786..68c33961c7 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -465,7 +465,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_dict_view_it, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, dict_view_it_iternext ); @@ -517,7 +516,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_dict_view, MP_QSTR_dict_view, MP_TYPE_FLAG_ITER_IS_GETITER, - MP_TYPE_NULL_MAKE_NEW, print, dict_view_print, binary_op, dict_view_binary_op, iter, dict_view_getiter @@ -592,7 +590,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_dict, MP_QSTR_dict, MP_TYPE_FLAG_ITER_IS_GETITER, - mp_obj_dict_make_new, + make_new, mp_obj_dict_make_new, print, dict_print, unary_op, dict_unary_op, binary_op, dict_binary_op, @@ -606,7 +604,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_ordereddict, MP_QSTR_OrderedDict, MP_TYPE_FLAG_ITER_IS_GETITER, - mp_obj_dict_make_new, + make_new, mp_obj_dict_make_new, print, dict_print, unary_op, dict_unary_op, binary_op, dict_binary_op, diff --git a/py/objenumerate.c b/py/objenumerate.c index eea9e3e381..40bed919ed 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -71,7 +71,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_enumerate, MP_QSTR_enumerate, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - enumerate_make_new, + make_new, enumerate_make_new, iter, enumerate_iternext ); diff --git a/py/objexcept.c b/py/objexcept.c index 190213e12f..3b76ae62cc 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -288,7 +288,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_BaseException, MP_QSTR_BaseException, MP_TYPE_FLAG_NONE, - mp_obj_exception_make_new, + make_new, mp_obj_exception_make_new, print, mp_obj_exception_print, attr, mp_obj_exception_attr ); @@ -375,12 +375,12 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) // *FORMAT-ON* mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { - assert(exc_type->make_new == mp_obj_exception_make_new); + assert(MP_OBJ_TYPE_GET_SLOT_OR_NULL(exc_type, make_new) == mp_obj_exception_make_new); return mp_obj_exception_make_new(exc_type, 0, 0, NULL); } mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { - assert(exc_type->make_new == mp_obj_exception_make_new); + assert(MP_OBJ_TYPE_GET_SLOT_OR_NULL(exc_type, make_new) == mp_obj_exception_make_new); return mp_obj_exception_make_new(exc_type, n_args, 0, args); } @@ -388,7 +388,7 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, mp_rom_error_text_t msg) { // Check that the given type is an exception type - assert(exc_type->make_new == mp_obj_exception_make_new); + assert(MP_OBJ_TYPE_GET_SLOT_OR_NULL(exc_type, make_new) == mp_obj_exception_make_new); // Try to allocate memory for the message mp_obj_str_t *o_str = m_new_obj_maybe(mp_obj_str_t); @@ -467,7 +467,7 @@ mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, mp_rom_er assert(fmt != NULL); // Check that the given type is an exception type - assert(exc_type->make_new == mp_obj_exception_make_new); + assert(MP_OBJ_TYPE_GET_SLOT_OR_NULL(exc_type, make_new) == mp_obj_exception_make_new); // Try to allocate memory for the message mp_obj_str_t *o_str = m_new_obj_maybe(mp_obj_str_t); @@ -538,7 +538,7 @@ bool mp_obj_is_exception_type(mp_obj_t self_in) { if (mp_obj_is_type(self_in, &mp_type_type)) { // optimisation when self_in is a builtin exception mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - if (self->make_new == mp_obj_exception_make_new) { + if (MP_OBJ_TYPE_GET_SLOT_OR_NULL(self, make_new) == mp_obj_exception_make_new) { return true; } } diff --git a/py/objexcept.h b/py/objexcept.h index 5d56d67d73..d532f66609 100644 --- a/py/objexcept.h +++ b/py/objexcept.h @@ -41,7 +41,8 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); #define MP_DEFINE_EXCEPTION(exc_name, base_name) \ - MP_DEFINE_CONST_OBJ_TYPE(mp_type_##exc_name, MP_QSTR_##exc_name, MP_TYPE_FLAG_NONE, mp_obj_exception_make_new, \ + MP_DEFINE_CONST_OBJ_TYPE(mp_type_##exc_name, MP_QSTR_##exc_name, MP_TYPE_FLAG_NONE, \ + make_new, mp_obj_exception_make_new, \ print, mp_obj_exception_print, \ attr, mp_obj_exception_attr, \ parent, &mp_type_##base_name \ diff --git a/py/objfilter.c b/py/objfilter.c index bfe651f40d..2a657fde4b 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -64,7 +64,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_filter, MP_QSTR_filter, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - filter_make_new, + make_new, filter_make_new, iter, filter_iternext ); diff --git a/py/objfloat.c b/py/objfloat.c index 9ecbab7a4d..c862b4843b 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -183,7 +183,8 @@ STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_float, MP_QSTR_float, MP_TYPE_FLAG_EQ_NOT_REFLEXIVE | MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE, float_make_new, + mp_type_float, MP_QSTR_float, MP_TYPE_FLAG_EQ_NOT_REFLEXIVE | MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE, + make_new, float_make_new, print, float_print, unary_op, float_unary_op, binary_op, float_binary_op diff --git a/py/objfun.c b/py/objfun.c index d6ff354575..390ddaa2d2 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -57,7 +57,7 @@ STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_fun_builtin_0, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, MP_TYPE_NULL_MAKE_NEW, + mp_type_fun_builtin_0, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, call, fun_builtin_0_call, unary_op, mp_generic_unary_op ); @@ -70,7 +70,7 @@ STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_fun_builtin_1, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, MP_TYPE_NULL_MAKE_NEW, + mp_type_fun_builtin_1, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, call, fun_builtin_1_call, unary_op, mp_generic_unary_op ); @@ -83,7 +83,7 @@ STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_fun_builtin_2, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, MP_TYPE_NULL_MAKE_NEW, + mp_type_fun_builtin_2, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, call, fun_builtin_2_call, unary_op, mp_generic_unary_op ); @@ -96,7 +96,7 @@ STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_fun_builtin_3, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, MP_TYPE_NULL_MAKE_NEW, + mp_type_fun_builtin_3, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, call, fun_builtin_3_call, unary_op, mp_generic_unary_op ); @@ -125,7 +125,7 @@ STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_k } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_fun_builtin_var, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, MP_TYPE_NULL_MAKE_NEW, + mp_type_fun_builtin_var, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN, call, fun_builtin_var_call, unary_op, mp_generic_unary_op ); @@ -368,7 +368,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_fun_bc, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, FUN_BC_TYPE_PRINT FUN_BC_TYPE_ATTR call, fun_bc_call, @@ -431,7 +430,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_fun_native, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, FUN_BC_TYPE_PRINT FUN_BC_TYPE_ATTR call, fun_native_call, @@ -542,7 +540,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_fun_asm, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, call, fun_asm_call, unary_op, mp_generic_unary_op ); diff --git a/py/objgenerator.c b/py/objgenerator.c index d8515c13ce..8175dbd683 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -80,7 +80,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_gen_wrap, MP_QSTR_generator, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, GEN_WRAP_TYPE_ATTR call, gen_wrap_call, unary_op, mp_generic_unary_op @@ -146,7 +145,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_native_gen_wrap, MP_QSTR_generator, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, call, native_gen_wrap_call, NATIVE_GEN_WRAP_TYPE_ATTR unary_op, mp_generic_unary_op @@ -371,7 +369,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_gen_instance, MP_QSTR_generator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, print, gen_instance_print, unary_op, mp_generic_unary_op, iter, gen_instance_iternext, diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c index 134cbcd629..c598d1daac 100644 --- a/py/objgetitemiter.c +++ b/py/objgetitemiter.c @@ -60,7 +60,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_it, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, it_iternext ); diff --git a/py/objint.c b/py/objint.c index f06bc441f1..1a3ad86947 100644 --- a/py/objint.c +++ b/py/objint.c @@ -461,7 +461,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_int, MP_QSTR_int, MP_TYPE_FLAG_NONE, - mp_obj_int_make_new, + make_new, mp_obj_int_make_new, print, mp_obj_int_print, unary_op, mp_obj_int_unary_op, binary_op, mp_obj_int_binary_op, diff --git a/py/objlist.c b/py/objlist.c index 8d18344ea8..18da91ba3a 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -71,7 +71,7 @@ STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { return list; } -STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); @@ -456,7 +456,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_list, MP_QSTR_list, MP_TYPE_FLAG_ITER_IS_GETITER, - list_make_new, + make_new, mp_obj_list_make_new, print, list_print, unary_op, list_unary_op, binary_op, list_binary_op, diff --git a/py/objlist.h b/py/objlist.h index a43663db76..a3bba68028 100644 --- a/py/objlist.h +++ b/py/objlist.h @@ -36,5 +36,6 @@ typedef struct _mp_obj_list_t { } mp_obj_list_t; void mp_obj_list_init(mp_obj_list_t *o, size_t n); +mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); #endif // MICROPY_INCLUDED_PY_OBJLIST_H diff --git a/py/objmap.c b/py/objmap.c index 115832e387..e7e594cd2c 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -67,6 +67,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_map, MP_QSTR_map, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - map_make_new, + make_new, map_make_new, iter, map_iternext ); diff --git a/py/objmodule.c b/py/objmodule.c index 6fc3653e6a..d14a59b863 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -134,7 +134,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_module, MP_QSTR_module, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, print, module_print, attr, module_attr ); diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index 3b45d8f76f..75e21494b4 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -157,14 +157,14 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t type->base.type = &mp_type_type; type->flags = MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE; // can match tuple type->name = name; - type->make_new = namedtuple_make_new; - MP_OBJ_TYPE_SET_SLOT(type, print, namedtuple_print, 0); - MP_OBJ_TYPE_SET_SLOT(type, unary_op, mp_obj_tuple_unary_op, 1); - MP_OBJ_TYPE_SET_SLOT(type, binary_op, mp_obj_tuple_binary_op, 2); - MP_OBJ_TYPE_SET_SLOT(type, attr, namedtuple_attr, 3); - MP_OBJ_TYPE_SET_SLOT(type, subscr, mp_obj_tuple_subscr, 4); - MP_OBJ_TYPE_SET_SLOT(type, iter, mp_obj_tuple_getiter, 5); - MP_OBJ_TYPE_SET_SLOT(type, parent, &mp_type_tuple, 6); + MP_OBJ_TYPE_SET_SLOT(type, make_new, namedtuple_make_new, 0); + MP_OBJ_TYPE_SET_SLOT(type, print, namedtuple_print, 1); + MP_OBJ_TYPE_SET_SLOT(type, unary_op, mp_obj_tuple_unary_op, 2); + MP_OBJ_TYPE_SET_SLOT(type, binary_op, mp_obj_tuple_binary_op, 3); + MP_OBJ_TYPE_SET_SLOT(type, attr, namedtuple_attr, 4); + MP_OBJ_TYPE_SET_SLOT(type, subscr, mp_obj_tuple_subscr, 5); + MP_OBJ_TYPE_SET_SLOT(type, iter, mp_obj_tuple_getiter, 6); + MP_OBJ_TYPE_SET_SLOT(type, parent, &mp_type_tuple, 7); return MP_OBJ_FROM_PTR(o); } diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index db4a3d87d8..c4f4149fd6 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -29,9 +29,9 @@ #include "py/objtuple.h" typedef struct _mp_obj_namedtuple_type_t { - // This is a mp_obj_type_t with seven slots. + // This is a mp_obj_type_t with eight slots. mp_obj_empty_type_t base; - void *slots[7]; + void *slots[8]; size_t n_fields; qstr fields[]; } mp_obj_namedtuple_type_t; diff --git a/py/objnone.c b/py/objnone.c index 4fffbc997e..4f8996e897 100644 --- a/py/objnone.c +++ b/py/objnone.c @@ -47,7 +47,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_NoneType, MP_QSTR_NoneType, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, print, none_print, unary_op, mp_generic_unary_op ); diff --git a/py/objobject.c b/py/objobject.c index ffad610707..1acae6d00b 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -121,6 +121,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_object, MP_QSTR_object, MP_TYPE_FLAG_NONE, - object_make_new + make_new, object_make_new OBJECT_TYPE_LOCALS_DICT ); diff --git a/py/objpolyiter.c b/py/objpolyiter.c index 7a45b6b73f..78b600abac 100644 --- a/py/objpolyiter.c +++ b/py/objpolyiter.c @@ -49,7 +49,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_polymorph_iter, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, polymorph_it_iternext ); @@ -81,7 +80,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_polymorph_iter_with_finaliser, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, polymorph_it_iternext, locals_dict, &mp_obj_polymorph_iter_locals_dict ); diff --git a/py/objproperty.c b/py/objproperty.c index ce3b572591..2d3af10e8c 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -94,7 +94,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_property, MP_QSTR_property, MP_TYPE_FLAG_NONE, - property_make_new, + make_new, property_make_new, locals_dict, &property_locals_dict ); diff --git a/py/objrange.c b/py/objrange.c index 1ad8f6031f..f0fe56d9db 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -54,7 +54,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_range_it, MP_QSTR_iterator, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - MP_TYPE_NULL_MAKE_NEW, iter, range_it_iternext ); @@ -225,7 +224,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_range, MP_QSTR_range, MP_TYPE_FLAG_NONE, - range_make_new, + make_new, range_make_new, RANGE_TYPE_BINOP RANGE_TYPE_ATTR print, range_print, diff --git a/py/objreversed.c b/py/objreversed.c index e265266d3f..c66698f028 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -72,7 +72,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_reversed, MP_QSTR_reversed, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - reversed_make_new, + make_new, reversed_make_new, iter, reversed_iternext ); diff --git a/py/objset.c b/py/objset.c index b827f49f40..906807889a 100644 --- a/py/objset.c +++ b/py/objset.c @@ -543,7 +543,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_set, MP_QSTR_set, MP_TYPE_FLAG_ITER_IS_GETITER, - set_make_new, + make_new, set_make_new, print, set_print, unary_op, set_unary_op, binary_op, set_binary_op, @@ -569,7 +569,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_frozenset, MP_QSTR_frozenset, MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE | MP_TYPE_FLAG_ITER_IS_GETITER, - set_make_new, + make_new, set_make_new, print, set_print, unary_op, set_unary_op, binary_op, set_binary_op, diff --git a/py/objsingleton.c b/py/objsingleton.c index 4a099657d4..dc73d28c27 100644 --- a/py/objsingleton.c +++ b/py/objsingleton.c @@ -44,7 +44,7 @@ STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ } MP_DEFINE_CONST_OBJ_TYPE( - mp_type_singleton, MP_QSTR_, MP_TYPE_FLAG_NONE, MP_TYPE_NULL_MAKE_NEW, + mp_type_singleton, MP_QSTR_, MP_TYPE_FLAG_NONE, print, singleton_print, unary_op, mp_generic_unary_op ); diff --git a/py/objslice.c b/py/objslice.c index d1dbb24586..01d4da0dbd 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -104,7 +104,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_slice, MP_QSTR_slice, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, SLICE_TYPE_ATTR_OR_LOCALS_DICT print, slice_print ); diff --git a/py/objstr.c b/py/objstr.c index 12f6e15d04..50ab0018ed 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -482,7 +482,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { if (!mp_obj_is_type(arg, &mp_type_list) && !mp_obj_is_type(arg, &mp_type_tuple)) { // arg is not a list nor a tuple, try to convert it to a list // TODO: Try to optimize? - arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); + arg = mp_obj_list_make_new(&mp_type_list, 1, 0, &arg); } mp_obj_get_array(arg, &seq_len, &seq_items); @@ -2147,7 +2147,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_str, MP_QSTR_str, MP_TYPE_FLAG_NONE, - mp_obj_str_make_new, + make_new, mp_obj_str_make_new, print, str_print, binary_op, mp_obj_str_binary_op, subscr, bytes_subscr, @@ -2162,7 +2162,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_bytes, MP_QSTR_bytes, MP_TYPE_FLAG_NONE, - bytes_make_new, + make_new, bytes_make_new, print, str_print, binary_op, mp_obj_str_binary_op, subscr, bytes_subscr, diff --git a/py/objstringio.c b/py/objstringio.c index 4e19b83999..1a083449ba 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -248,7 +248,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_stringio, MP_QSTR_StringIO, MP_TYPE_FLAG_ITER_IS_STREAM, - stringio_make_new, + make_new, stringio_make_new, print, stringio_print, protocol, &stringio_stream_p, locals_dict, &stringio_locals_dict @@ -265,7 +265,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_bytesio, MP_QSTR_BytesIO, MP_TYPE_FLAG_ITER_IS_STREAM, - stringio_make_new, + make_new, stringio_make_new, print, stringio_print, protocol, &bytesio_stream_p, locals_dict, &stringio_locals_dict diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 9b28841ecd..93383b3c19 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -233,7 +233,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_str, MP_QSTR_str, MP_TYPE_FLAG_ITER_IS_GETITER, - mp_obj_str_make_new, + make_new, mp_obj_str_make_new, print, uni_print, unary_op, uni_unary_op, binary_op, mp_obj_str_binary_op, diff --git a/py/objtuple.c b/py/objtuple.c index 485d44c52a..9d6797b4ff 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -228,7 +228,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_tuple, MP_QSTR_tuple, MP_TYPE_FLAG_ITER_IS_GETITER, - mp_obj_tuple_make_new, + make_new, mp_obj_tuple_make_new, print, mp_obj_tuple_print, unary_op, mp_obj_tuple_unary_op, binary_op, mp_obj_tuple_binary_op, diff --git a/py/objtype.c b/py/objtype.c index 183dce071e..db364e0e5a 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -88,7 +88,7 @@ STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(args[0]); const mp_obj_type_t *native_base = NULL; instance_count_native_bases(self->base.type, &native_base); - self->subobj[0] = native_base->make_new(native_base, n_args - 1, 0, args + 1); + self->subobj[0] = MP_OBJ_TYPE_GET_SLOT(native_base, make_new)(native_base, n_args - 1, 0, args + 1); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper); @@ -285,7 +285,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size struct class_lookup_data lookup = { .obj = NULL, .attr = MP_QSTR___new__, - .slot_offset = offsetof(mp_obj_type_t, make_new), + .slot_offset = MP_OBJ_TYPE_OFFSETOF_SLOT(make_new), .dest = init_fn, .is_type = false, }; @@ -362,7 +362,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size // If the type had a native base that was not explicitly initialised // (constructed) by the Python __init__() method then construct it now. if (native_base != NULL && o->subobj[0] == MP_OBJ_FROM_PTR(&native_base_init_wrapper_obj)) { - o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); + o->subobj[0] = MP_OBJ_TYPE_GET_SLOT(native_base, make_new)(native_base, n_args, n_kw, args); } return MP_OBJ_FROM_PTR(o); @@ -998,7 +998,7 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - if (self->make_new == NULL) { + if (!MP_OBJ_TYPE_HAS_SLOT(self, make_new)) { #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(MP_ERROR_TEXT("can't create instance")); #else @@ -1007,7 +1007,7 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp } // make new instance - mp_obj_t o = self->make_new(self, n_args, n_kw, args); + mp_obj_t o = MP_OBJ_TYPE_GET_SLOT(self, make_new)(self, n_args, n_kw, args); // return new instance return o; @@ -1109,7 +1109,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_type, MP_QSTR_type, MP_TYPE_FLAG_NONE, - type_make_new, + make_new, type_make_new, print, type_print, call, type_call, unary_op, mp_generic_unary_op, @@ -1141,7 +1141,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) } mp_obj_type_t *t = MP_OBJ_TO_PTR(bases_items[i]); // TODO: Verify with CPy, tested on function type - if (t->make_new == NULL) { + if (!MP_OBJ_TYPE_HAS_SLOT(t, make_new)) { #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(MP_ERROR_TEXT("type isn't an acceptable base type")); #else @@ -1163,35 +1163,35 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) } // Allocate a variable-sized mp_obj_type_t with as many slots as we need - // (currently 9, plus 1 for base, plus 1 for base-protocol). - // Note: 11 slots pushes it from 4 to 5 GC blocks. - mp_obj_type_t *o = m_new_obj_var0(mp_obj_type_t, void *, 9 + (bases_len ? 1 : 0) + (base_protocol ? 1 : 0)); + // (currently 10, plus 1 for base, plus 1 for base-protocol). + // Note: mp_obj_type_t is (2 + 3 + #slots) words, so going from 11 to 12 slots + // moves from 4 to 5 gc blocks. + mp_obj_type_t *o = m_new_obj_var0(mp_obj_type_t, void *, 10 + (bases_len ? 1 : 0) + (base_protocol ? 1 : 0)); o->base.type = &mp_type_type; o->flags = base_flags; o->name = name; - o->make_new = mp_obj_instance_make_new; - MP_OBJ_TYPE_SET_SLOT(o, print, instance_print, 0); - MP_OBJ_TYPE_SET_SLOT(o, call, mp_obj_instance_call, 1); - MP_OBJ_TYPE_SET_SLOT(o, unary_op, instance_unary_op, 2); - MP_OBJ_TYPE_SET_SLOT(o, binary_op, instance_binary_op, 3); - MP_OBJ_TYPE_SET_SLOT(o, attr, mp_obj_instance_attr, 4); - MP_OBJ_TYPE_SET_SLOT(o, subscr, instance_subscr, 5); - MP_OBJ_TYPE_SET_SLOT(o, iter, mp_obj_instance_getiter, 6); - // MP_OBJ_TYPE_SET_SLOT(o, iternext, not implemented) - MP_OBJ_TYPE_SET_SLOT(o, buffer, instance_get_buffer, 7); + MP_OBJ_TYPE_SET_SLOT(o, make_new, mp_obj_instance_make_new, 0); + MP_OBJ_TYPE_SET_SLOT(o, print, instance_print, 1); + MP_OBJ_TYPE_SET_SLOT(o, call, mp_obj_instance_call, 2); + MP_OBJ_TYPE_SET_SLOT(o, unary_op, instance_unary_op, 3); + MP_OBJ_TYPE_SET_SLOT(o, binary_op, instance_binary_op, 4); + MP_OBJ_TYPE_SET_SLOT(o, attr, mp_obj_instance_attr, 5); + MP_OBJ_TYPE_SET_SLOT(o, subscr, instance_subscr, 6); + MP_OBJ_TYPE_SET_SLOT(o, iter, mp_obj_instance_getiter, 7); + MP_OBJ_TYPE_SET_SLOT(o, buffer, instance_get_buffer, 8); mp_obj_dict_t *locals_ptr = MP_OBJ_TO_PTR(locals_dict); - MP_OBJ_TYPE_SET_SLOT(o, locals_dict, locals_ptr, 8); + MP_OBJ_TYPE_SET_SLOT(o, locals_dict, locals_ptr, 9); if (bases_len > 0) { if (bases_len >= 2) { #if MICROPY_MULTIPLE_INHERITANCE - MP_OBJ_TYPE_SET_SLOT(o, parent, MP_OBJ_TO_PTR(bases_tuple), 9); + MP_OBJ_TYPE_SET_SLOT(o, parent, MP_OBJ_TO_PTR(bases_tuple), 10); #else mp_raise_NotImplementedError(MP_ERROR_TEXT("multiple inheritance not supported")); #endif } else { - MP_OBJ_TYPE_SET_SLOT(o, parent, MP_OBJ_TO_PTR(bases_items[0]), 9); + MP_OBJ_TYPE_SET_SLOT(o, parent, MP_OBJ_TO_PTR(bases_items[0]), 10); } // Inherit protocol from a base class. This allows to define an @@ -1199,7 +1199,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) // Python method calls, and any subclass inheriting from it will // support this feature. if (base_protocol) { - MP_OBJ_TYPE_SET_SLOT(o, protocol, base_protocol, 10); + MP_OBJ_TYPE_SET_SLOT(o, protocol, base_protocol, 11); } } @@ -1292,7 +1292,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { // Allow a call super().__init__() to reach any native base classes. if (attr == MP_QSTR___init__) { - lookup.slot_offset = offsetof(mp_obj_type_t, make_new); + lookup.slot_offset = MP_OBJ_TYPE_OFFSETOF_SLOT(make_new); } if (!MP_OBJ_TYPE_HAS_SLOT(type, parent)) { @@ -1340,7 +1340,7 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_super, MP_QSTR_super, MP_TYPE_FLAG_NONE, - super_make_new, + make_new, super_make_new, print, super_print, attr, super_attr ); @@ -1463,12 +1463,12 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_staticmethod, MP_QSTR_staticmethod, MP_TYPE_FLAG_NONE, - static_class_method_make_new + make_new, static_class_method_make_new ); MP_DEFINE_CONST_OBJ_TYPE( mp_type_classmethod, MP_QSTR_classmethod, MP_TYPE_FLAG_NONE, - static_class_method_make_new + make_new, static_class_method_make_new ); diff --git a/py/objtype.h b/py/objtype.h index 2c613b9045..76a290760c 100644 --- a/py/objtype.h +++ b/py/objtype.h @@ -46,8 +46,8 @@ mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *cls, const mp_obj_ty bool mp_obj_instance_is_callable(mp_obj_t self_in); mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -#define mp_obj_is_instance_type(type) ((type)->make_new == mp_obj_instance_make_new) -#define mp_obj_is_native_type(type) ((type)->make_new != mp_obj_instance_make_new) +#define mp_obj_is_instance_type(type) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, make_new) == mp_obj_instance_make_new) +#define mp_obj_is_native_type(type) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, make_new) != mp_obj_instance_make_new) // this needs to be exposed for the above macros to work correctly mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); diff --git a/py/objzip.c b/py/objzip.c index 34d73465ef..3c3138180a 100644 --- a/py/objzip.c +++ b/py/objzip.c @@ -70,6 +70,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_zip, MP_QSTR_zip, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - zip_make_new, + make_new, zip_make_new, iter, zip_iternext ); diff --git a/py/profile.c b/py/profile.c index 2b9531e245..fd2d61caa9 100644 --- a/py/profile.c +++ b/py/profile.c @@ -176,7 +176,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_settrace_codeobj, MP_QSTR_code, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, print, code_print, unary_op, mp_generic_unary_op, attr, code_attr @@ -247,7 +246,6 @@ MP_DEFINE_CONST_OBJ_TYPE( mp_type_frame, MP_QSTR_frame, MP_TYPE_FLAG_NONE, - MP_TYPE_NULL_MAKE_NEW, print, frame_print, unary_op, mp_generic_unary_op, attr, frame_attr diff --git a/py/runtime.c b/py/runtime.c index ec628bfe14..da6c86d971 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1076,7 +1076,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( mp_type_checked_fun, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF, - MP_TYPE_NULL_MAKE_NEW, call, checked_fun_call ); |