milestone: coverage make test_full passes

This commit is contained in:
Jeff Epler 2021-07-06 10:37:32 -05:00
parent df56ba207f
commit 0d756066e8
52 changed files with 414 additions and 225 deletions

View File

@ -298,11 +298,13 @@ STATIC const mp_obj_type_t btree_type = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_btree,
.print = btree_print,
.getiter = btree_getiter,
.iternext = btree_iternext,
.binary_op = btree_binary_op,
.subscr = btree_subscr,
.locals_dict = (void *)&btree_locals_dict,
EXTENDED_FIELDS(
.getiter = btree_getiter,
.iternext = btree_iternext,
.binary_op = btree_binary_op,
.subscr = btree_subscr,
),
};
#endif

View File

@ -605,8 +605,10 @@ STATIC const mp_obj_type_t mp_type_framebuf = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_FrameBuffer,
.make_new = framebuf_make_new,
.buffer_p = { .get_buffer = framebuf_get_buffer },
.locals_dict = (mp_obj_dict_t *)&framebuf_locals_dict,
EXTENDED_FIELDS(
.buffer_p = { .get_buffer = framebuf_get_buffer },
),
};
#endif

View File

@ -288,8 +288,10 @@ STATIC const mp_obj_type_t task_type = {
.name = MP_QSTR_Task,
.make_new = task_make_new,
.attr = task_attr,
.getiter = task_getiter,
.iternext = task_iternext,
EXTENDED_FIELDS(
.getiter = task_getiter,
.iternext = task_iternext,
),
};
/******************************************************************************/

View File

@ -627,9 +627,11 @@ STATIC const mp_obj_type_t uctypes_struct_type = {
.print = uctypes_struct_print,
.make_new = uctypes_struct_make_new,
.attr = uctypes_struct_attr,
.subscr = uctypes_struct_subscr,
.unary_op = uctypes_struct_unary_op,
.buffer_p = { .get_buffer = uctypes_get_buffer },
EXTENDED_FIELDS(
.subscr = uctypes_struct_subscr,
.unary_op = uctypes_struct_unary_op,
.buffer_p = { .get_buffer = uctypes_get_buffer },
),
};
STATIC const mp_rom_map_elem_t mp_module_uctypes_globals_table[] = {

View File

@ -196,8 +196,10 @@ STATIC const mp_obj_type_t utimeq_type = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_utimeq,
.make_new = utimeq_make_new,
.unary_op = utimeq_unary_op,
.locals_dict = (void *)&utimeq_locals_dict,
EXTENDED_FIELDS(
.unary_op = utimeq_unary_op,
),
};
STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = {

View File

@ -125,8 +125,10 @@ STATIC const mp_obj_type_t decompio_type = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_DecompIO,
.make_new = decompio_make_new,
.protocol = &decompio_stream_p,
.locals_dict = (void *)&decompio_locals_dict,
EXTENDED_FIELDS(
.protocol = &decompio_stream_p,
),
};
#endif

@ -1 +1 @@
Subproject commit 161a7288482200c884623ed3cb59dd91f53be91a
Subproject commit 73c2764a50ff07c113b9ded5cfeefb16c6158948

View File

@ -477,8 +477,10 @@ const mp_obj_type_t mp_fat_vfs_type = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_VfsFat,
.make_new = fat_vfs_make_new,
.protocol = &fat_vfs_proto,
.locals_dict = (mp_obj_dict_t *)&fat_vfs_locals_dict,
EXTENDED_FIELDS(
.protocol = &fat_vfs_proto,
),
};

View File

@ -248,10 +248,12 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
.name = MP_QSTR_FileIO,
.print = file_obj_print,
.make_new = file_obj_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_fat_fileio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_fat_rawfile_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_fat_fileio_stream_p,
),
};
#endif
@ -265,13 +267,16 @@ STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
const mp_obj_type_t mp_type_vfs_fat_textio = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_TextIOWrapper,
.print = file_obj_print,
.make_new = file_obj_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_fat_textio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_fat_rawfile_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_fat_textio_stream_p,
),
};
// Factory function for I/O stream classes

View File

@ -491,6 +491,8 @@ const mp_obj_type_t MP_TYPE_VFS_LFSx = {
.name = MP_QSTR_VfsLfs2,
#endif
.make_new = MP_VFS_LFSx(make_new),
.protocol = &MP_VFS_LFSx(proto),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(locals_dict),
EXTENDED_FIELDS(
.protocol = &MP_VFS_LFSx(proto),
),
};

View File

@ -229,10 +229,12 @@ const mp_obj_type_t MP_TYPE_VFS_LFSx_(_fileio) = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_FileIO,
.print = MP_VFS_LFSx(file_print),
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(fileio_stream_p),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(fileio_stream_p),
),
};
#endif
@ -246,10 +248,13 @@ STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
const mp_obj_type_t MP_TYPE_VFS_LFSx_(_textio) = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_TextIOWrapper,
.print = MP_VFS_LFSx(file_print),
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(textio_stream_p),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(textio_stream_p),
),
};

View File

@ -354,9 +354,11 @@ const mp_obj_type_t mp_type_vfs_posix = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_VfsPosix,
.make_new = vfs_posix_make_new,
.protocol = &vfs_posix_proto,
.locals_dict = (mp_obj_dict_t *)&vfs_posix_locals_dict,
.make_new = vfs_posix_make_new,
EXTENDED_FIELDS(
.protocol = &vfs_posix_proto,
),
};
#endif // MICROPY_VFS_POSIX

View File

@ -217,10 +217,12 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
.name = MP_QSTR_FileIO,
.print = vfs_posix_file_print,
.make_new = vfs_posix_file_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_posix_fileio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_posix_rawfile_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_posix_fileio_stream_p,
),
};
#endif
@ -234,13 +236,16 @@ STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
const mp_obj_type_t mp_type_vfs_posix_textio = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_TextIOWrapper,
.print = vfs_posix_file_print,
.make_new = vfs_posix_file_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_posix_textio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_posix_rawfile_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &vfs_posix_textio_stream_p,
),
};
const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_textio}, STDIN_FILENO};

View File

@ -108,8 +108,11 @@ STATIC const mp_stream_p_t fileio_stream_p = {
STATIC const mp_obj_type_t mp_type_stest_fileio = {
{ &mp_type_type },
.protocol = &fileio_stream_p,
.flags = MP_TYPE_FLAG_FULL,
.locals_dict = (mp_obj_dict_t *)&rawfile_locals_dict,
EXTENDED_FIELDS(
.protocol = &fileio_stream_p,
),
};
// stream read returns non-blocking error
@ -136,8 +139,11 @@ STATIC const mp_stream_p_t textio_stream_p2 = {
STATIC const mp_obj_type_t mp_type_stest_textio2 = {
{ &mp_type_type },
.protocol = &textio_stream_p2,
.flags = MP_TYPE_FLAG_FULL,
.locals_dict = (mp_obj_dict_t *)&rawfile_locals_dict2,
EXTENDED_FIELDS(
.protocol = &textio_stream_p2,
),
};
// str/bytes objects without a valid hash

View File

@ -485,9 +485,12 @@ error:
STATIC const mp_obj_type_t ffifunc_type = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_ffifunc,
.print = ffifunc_print,
.call = ffifunc_call,
EXTENDED_FIELDS(
.call = ffifunc_call,
),
};
// FFI callback for Python function

View File

@ -313,10 +313,13 @@ STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table);
STATIC const mp_obj_type_t mp_type_poll = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_poll,
.getiter = mp_identity_getiter,
.iternext = poll_iternext,
.locals_dict = (void *)&poll_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = poll_iternext,
),
};
STATIC mp_obj_t select_poll(size_t n_args, const mp_obj_t *args) {

View File

@ -103,9 +103,12 @@ STATIC const mp_stream_p_t iobase_p = {
STATIC const mp_obj_type_t mp_type_iobase = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_IOBase,
.make_new = iobase_make_new,
.protocol = &iobase_p,
EXTENDED_FIELDS(
.protocol = &iobase_p,
),
};
#endif // MICROPY_PY_IO_IOBASE
@ -199,10 +202,13 @@ STATIC const mp_stream_p_t bufwriter_stream_p = {
STATIC const mp_obj_type_t mp_type_bufwriter = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_BufferedWriter,
.make_new = bufwriter_make_new,
.protocol = &bufwriter_stream_p,
.locals_dict = (mp_obj_dict_t *)&bufwriter_locals_dict,
EXTENDED_FIELDS(
.protocol = &bufwriter_stream_p,
),
};
#endif // MICROPY_PY_IO_BUFFEREDWRITER

View File

@ -101,6 +101,12 @@ const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
#endif
}
const mp_obj_full_type_t *mp_obj_get_full_type(mp_const_obj_t o_in) {
const mp_obj_type_t *type = mp_obj_get_type(o_in);
assert(type->flags & MP_TYPE_FLAG_FULL);
return (mp_obj_full_type_t *)type;
}
const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
return qstr_str(mp_obj_get_type_qstr(o_in));
}
@ -623,10 +629,10 @@ typedef struct {
STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) {
mp_obj_generic_it_t *self = MP_OBJ_TO_PTR(self_in);
const mp_obj_type_t *type = mp_obj_get_type(self->obj);
mp_obj_t current_length = mp_type_unary_op(type)(MP_UNARY_OP_LEN, self->obj);
const mp_obj_full_type_t *type = mp_obj_get_full_type(self->obj);
mp_obj_t current_length = type->MP_TYPE_UNARY_OP(MP_UNARY_OP_LEN, self->obj);
if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) {
mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL);
mp_obj_t o_out = type->ext[0].subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL);
self->cur += 1;
return o_out;
} else {
@ -673,16 +679,25 @@ mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
}
mp_call_fun_t mp_type_call(const mp_obj_type_t *type) {
return type->call;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->ext[0].call;
}
mp_unary_op_fun_t mp_type_unary_op(const mp_obj_type_t *type) {
return type->unary_op;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->ext[0].unary_op;
}
mp_binary_op_fun_t mp_type_binary_op(const mp_obj_type_t *type) {
return type->binary_op;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->ext[0].binary_op;
}
@ -692,27 +707,42 @@ mp_attr_fun_t mp_type_attr(const mp_obj_type_t *type) {
mp_subscr_fun_t mp_type_subscr(const mp_obj_type_t *type) {
return type->subscr;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->MP_TYPE_SUBSCR;
}
mp_getiter_fun_t mp_type_getiter(const mp_obj_type_t *type) {
return type->getiter;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->MP_TYPE_GETITER;
}
mp_fun_1_t mp_type_iternext(const mp_obj_type_t *type) {
return type->iternext;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->MP_TYPE_ITERNEXT;
}
mp_getbuffer_fun_t mp_type_getbuffer(const mp_obj_type_t *type) {
return type->buffer_p.get_buffer;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->MP_TYPE_GET_BUFFER;
}
const void *mp_type_protocol(const mp_obj_type_t *type) {
return type->protocol;
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return NULL;
}
return type->MP_TYPE_PROTOCOL;
}
@ -721,5 +751,8 @@ const void *mp_type_parent(const mp_obj_type_t *type) {
}
size_t mp_type_size(const mp_obj_type_t *type) {
return sizeof(mp_obj_type_t);
if (!(type->flags & MP_TYPE_FLAG_FULL)) {
return sizeof(mp_obj_type_t);
}
return sizeof(mp_obj_full_type_t);
}

View File

@ -50,6 +50,7 @@ typedef const void *mp_const_obj_t;
// 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;
typedef struct _mp_obj_full_type_t mp_obj_full_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).
@ -564,14 +565,14 @@ void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flag
struct _mp_obj_type_ext {
// Corresponds to __call__ special method, ie T(...).
#define MP_TYPE_CALL(o) ext[0].call = o
#define MP_TYPE_CALL ext[0].call
mp_call_fun_t call;
// Implements unary and binary operations.
// Can return MP_OBJ_NULL if the operation is not supported.
#define MP_TYPE_UNARY_OP(o) ext[0].unary_op = (o)
#define MP_TYPE_UNARY_OP ext[0].unary_op
mp_unary_op_fun_t unary_op;
#define MP_TYPE_BINARY_OP(o) ext[0].binary_op = (o)
#define MP_TYPE_BINARY_OP ext[0].binary_op
mp_binary_op_fun_t binary_op;
// Implements load, store and delete subscripting:
@ -579,26 +580,26 @@ struct _mp_obj_type_ext {
// - value = MP_OBJ_NULL means delete
// - all other values mean store the value
// Can return MP_OBJ_NULL if operation not supported.
#define MP_TYPE_SUBSCR(o) ext[0].subscr = (o)
#define MP_TYPE_SUBSCR ext[0].subscr
mp_subscr_fun_t subscr;
// Corresponds to __iter__ special method.
// Can use the given mp_obj_iter_buf_t to store iterator object,
// otherwise can return a pointer to an object on the heap.
#define MP_TYPE_GETITER(o) ext[0].getiter = (o)
#define MP_TYPE_GETITER ext[0].getiter
mp_getiter_fun_t getiter;
// Corresponds to __next__ special method. May return MP_OBJ_STOP_ITERATION
// as an optimisation instead of raising StopIteration() with no args.
#define MP_TYPE_ITERNEXT(o) ext[0].iternext = (o)
#define MP_TYPE_ITERNEXT ext[0].iternext
mp_fun_1_t iternext;
// Implements the buffer protocol if supported by this type.
#define MP_TYPE_GETBUFFER(o) ext[0].buffer_p.getbuffer = (o)
#define MP_TYPE_GET_BUFFER ext[0].buffer_p.get_buffer
mp_buffer_p_t buffer_p;
// One of disjoint protocols (interfaces), like mp_stream_p_t, etc.
#define MP_TYPE_PROTOCOL(o) ext[0].protocol = (o)
#define MP_TYPE_PROTOCOL ext[0].protocol
const void *protocol;
};
@ -608,7 +609,6 @@ struct _mp_obj_type_t {
// Flags associated with this type.
uint16_t flags;
// The name of this type, a qstr.
uint16_t name;
@ -640,6 +640,7 @@ struct _mp_obj_type_t {
// - 2 or more parents: pointer to a tuple object containing the parent types
const void *parent;
#define EXTENDED_FIELDS(...) .ext[0] = { __VA_ARGS__ }
struct _mp_obj_type_ext ext[];
};
@ -894,6 +895,7 @@ mp_obj_t mp_obj_new_module(qstr module_name);
mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items);
const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in);
const mp_obj_full_type_t *mp_obj_get_full_type(mp_const_obj_t o_in);
const char *mp_obj_get_type_str(mp_const_obj_t o_in);
#define mp_obj_get_type_qstr(o_in) (mp_obj_get_type((o_in))->name)
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects

View File

@ -744,31 +744,36 @@ STATIC MP_DEFINE_CONST_DICT(bytearray_locals_dict, bytearray_locals_dict_table);
#if MICROPY_PY_ARRAY
const mp_obj_type_t mp_type_array = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_array,
.print = array_print,
.make_new = array_make_new,
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
.locals_dict = (mp_obj_dict_t *)&array_locals_dict,
EXTENDED_FIELDS(
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
),
};
#endif
#if MICROPY_PY_BUILTINS_BYTEARRAY
const mp_obj_type_t mp_type_bytearray = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE,
.flags = MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_bytearray,
.print = array_print,
.make_new = bytearray_make_new,
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
.locals_dict = (mp_obj_dict_t *)&bytearray_locals_dict,
EXTENDED_FIELDS(
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
),
};
#endif
@ -784,20 +789,22 @@ STATIC MP_DEFINE_CONST_DICT(memoryview_locals_dict, memoryview_locals_dict_table
const mp_obj_type_t mp_type_memoryview = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE,
.flags = MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_memoryview,
.make_new = memoryview_make_new,
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
#if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
.attr = memoryview_attr,
#endif
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
#if MICROPY_CPYTHON_COMPAT
.locals_dict = (mp_obj_dict_t *)&memoryview_locals_dict,
#endif
#if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
.attr = memoryview_attr,
#endif
EXTENDED_FIELDS(
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.binary_op = array_binary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
),
};
#endif
@ -853,9 +860,12 @@ STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t mp_type_array_it = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = array_it_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = array_it_iternext,
),
};
STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {

View File

@ -86,11 +86,13 @@ const mp_obj_type_t mp_type_attrtuple = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_tuple, // reuse tuple to save on a qstr
.print = mp_obj_attrtuple_print,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.attr = mp_obj_attrtuple_attr,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
EXTENDED_FIELDS(
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
),
};
#endif // MICROPY_PY_ATTRTUPLE

View File

@ -90,8 +90,10 @@ const mp_obj_type_t mp_type_bool = {
.name = MP_QSTR_bool,
.print = bool_print,
.make_new = bool_make_new,
.unary_op = bool_unary_op,
.binary_op = bool_binary_op,
EXTENDED_FIELDS(
.unary_op = bool_unary_op,
.binary_op = bool_binary_op,
),
};
#if !MICROPY_OBJ_IMMEDIATE_OBJS

View File

@ -102,7 +102,9 @@ STATIC const mp_obj_type_t mp_type_bound_meth = {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
.print = bound_meth_print,
#endif
.call = bound_meth_call,
EXTENDED_FIELDS(
.call = bound_meth_call,
),
#if MICROPY_PY_FUNCTION_ATTRS
.attr = bound_meth_attr,
#endif

View File

@ -85,7 +85,9 @@ const mp_obj_type_t mp_type_closure = {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
.print = closure_print,
#endif
.call = closure_call,
EXTENDED_FIELDS(
.call = closure_call,
)
};
mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) {

View File

@ -161,9 +161,11 @@ const mp_obj_type_t mp_type_complex = {
.name = MP_QSTR_complex,
.print = complex_print,
.make_new = complex_make_new,
.unary_op = complex_unary_op,
.binary_op = complex_binary_op,
.attr = complex_attr,
EXTENDED_FIELDS(
.unary_op = complex_unary_op,
.binary_op = complex_binary_op,
),
};
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag) {

View File

@ -163,8 +163,10 @@ const mp_obj_type_t mp_type_deque = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_deque,
.make_new = deque_make_new,
.unary_op = deque_unary_op,
.locals_dict = (mp_obj_dict_t *)&deque_locals_dict,
EXTENDED_FIELDS(
.unary_op = deque_unary_op,
),
};
#endif // MICROPY_PY_COLLECTIONS_DEQUE

View File

@ -461,8 +461,10 @@ STATIC const mp_obj_type_t mp_type_dict_view_it = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = dict_view_it_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = dict_view_it_iternext,
),
};
STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
@ -514,8 +516,10 @@ STATIC const mp_obj_type_t mp_type_dict_view = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_dict_view,
.print = dict_view_print,
.binary_op = dict_view_binary_op,
.getiter = dict_view_getiter,
EXTENDED_FIELDS(
.binary_op = dict_view_binary_op,
.getiter = dict_view_getiter,
),
};
STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
@ -590,11 +594,13 @@ const mp_obj_type_t mp_type_dict = {
.name = MP_QSTR_dict,
.print = dict_print,
.make_new = mp_obj_dict_make_new,
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
.subscr = dict_subscr,
.getiter = dict_getiter,
.locals_dict = (mp_obj_dict_t *)&dict_locals_dict,
EXTENDED_FIELDS(
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
.subscr = dict_subscr,
.getiter = dict_getiter,
),
};
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
@ -604,12 +610,14 @@ const mp_obj_type_t mp_type_ordereddict = {
.name = MP_QSTR_OrderedDict,
.print = dict_print,
.make_new = mp_obj_dict_make_new,
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
.subscr = dict_subscr,
.getiter = dict_getiter,
.parent = &mp_type_dict,
.locals_dict = (mp_obj_dict_t *)&dict_locals_dict,
EXTENDED_FIELDS(
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
.subscr = dict_subscr,
.getiter = dict_getiter,
),
};
#endif

View File

@ -74,8 +74,10 @@ const mp_obj_type_t mp_type_enumerate = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_enumerate,
.make_new = enumerate_make_new,
.iternext = enumerate_iternext,
.getiter = mp_identity_getiter,
EXTENDED_FIELDS(
.iternext = enumerate_iternext,
.getiter = mp_identity_getiter,
)
};
STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {

View File

@ -630,12 +630,14 @@ STATIC const mp_obj_namedtuple_type_t code_type_obj = {
.name = MP_QSTR_code,
.print = namedtuple_print,
.make_new = namedtuple_make_new,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.attr = namedtuple_attr,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
.parent = &mp_type_tuple,
.attr = namedtuple_attr,
EXTENDED_FIELDS(
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
),
},
.n_fields = 15,
.fields = {
@ -687,12 +689,14 @@ STATIC const mp_obj_namedtuple_type_t frame_type_obj = {
.name = MP_QSTR_frame,
.print = namedtuple_print,
.make_new = namedtuple_make_new,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.attr = namedtuple_attr,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
.parent = &mp_type_tuple,
.attr = namedtuple_attr,
EXTENDED_FIELDS(
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
),
},
.n_fields = 8,
.fields = {
@ -731,12 +735,14 @@ STATIC const mp_obj_namedtuple_type_t traceback_type_obj = {
.name = MP_QSTR_traceback,
.print = namedtuple_print,
.make_new = namedtuple_make_new,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.attr = namedtuple_attr,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
.parent = &mp_type_tuple,
.attr = namedtuple_attr,
EXTENDED_FIELDS(
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
),
},
.n_fields = 4,
.fields = {

View File

@ -66,8 +66,10 @@ const mp_obj_type_t mp_type_filter = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_filter,
.make_new = filter_make_new,
.getiter = mp_identity_getiter,
.iternext = filter_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = filter_iternext,
),
};
#endif // MICROPY_PY_BUILTINS_FILTER

View File

@ -185,8 +185,10 @@ const mp_obj_type_t mp_type_float = {
.name = MP_QSTR_float,
.print = float_print,
.make_new = float_make_new,
.unary_op = float_unary_op,
.binary_op = float_binary_op,
EXTENDED_FIELDS(
.unary_op = float_unary_op,
.binary_op = float_binary_op,
),
};
#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D

View File

@ -62,8 +62,10 @@ const mp_obj_type_t mp_type_fun_builtin_0 = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_builtin_0_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_builtin_0_call,
.unary_op = mp_generic_unary_op,
),
};
STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@ -75,10 +77,12 @@ STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
const mp_obj_type_t mp_type_fun_builtin_1 = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_builtin_1_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_builtin_1_call,
.unary_op = mp_generic_unary_op,
),
};
STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@ -90,10 +94,12 @@ STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
const mp_obj_type_t mp_type_fun_builtin_2 = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_builtin_2_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_builtin_2_call,
.unary_op = mp_generic_unary_op,
),
};
STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@ -105,10 +111,12 @@ STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
const mp_obj_type_t mp_type_fun_builtin_3 = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_builtin_3_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_builtin_3_call,
.unary_op = mp_generic_unary_op,
),
};
STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@ -136,10 +144,12 @@ STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_k
const mp_obj_type_t mp_type_fun_builtin_var = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_builtin_var_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_builtin_var_call,
.unary_op = mp_generic_unary_op,
),
};
/******************************************************************************/
@ -362,16 +372,18 @@ void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
const mp_obj_type_t mp_type_fun_bc = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
#if MICROPY_CPYTHON_COMPAT
.print = fun_bc_print,
#endif
.call = fun_bc_call,
.unary_op = mp_generic_unary_op,
#if MICROPY_PY_FUNCTION_ATTRS
.attr = mp_obj_fun_bc_attr,
#endif
EXTENDED_FIELDS(
.call = fun_bc_call,
.unary_op = mp_generic_unary_op,
),
};
mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) {
@ -414,10 +426,12 @@ STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, co
const mp_obj_type_t mp_type_fun_native = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_native_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_native_call,
.unary_op = mp_generic_unary_op,
),
};
mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table) {
@ -522,10 +536,12 @@ STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
STATIC const mp_obj_type_t mp_type_fun_asm = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF,
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = fun_asm_call,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.call = fun_asm_call,
.unary_op = mp_generic_unary_op,
),
};
mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {

View File

@ -159,11 +159,13 @@ const mp_obj_type_t mp_type_gen_wrap = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_generator,
.call = gen_wrap_call,
.unary_op = mp_generic_unary_op,
#if MICROPY_PY_FUNCTION_ATTRS
.attr = gen_attr,
#endif
EXTENDED_FIELDS(
.call = gen_wrap_call,
.unary_op = mp_generic_unary_op,
),
};
@ -415,8 +417,10 @@ const mp_obj_type_t mp_type_gen_instance = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_generator,
.print = gen_instance_print,
.unary_op = mp_generic_unary_op,
.getiter = mp_identity_getiter,
.iternext = gen_instance_iternext,
.locals_dict = (mp_obj_dict_t *)&gen_instance_locals_dict,
EXTENDED_FIELDS(
.unary_op = mp_generic_unary_op,
.getiter = mp_identity_getiter,
.iternext = gen_instance_iternext,
),
};

View File

@ -61,8 +61,10 @@ STATIC const mp_obj_type_t mp_type_it = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = it_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = it_iternext,
),
};
// args are those returned from mp_load_method_maybe (ie either an attribute or a method)

View File

@ -574,7 +574,9 @@ const mp_obj_type_t mp_type_int = {
.flags = MP_TYPE_FLAG_FULL,
.print = mp_obj_int_print,
.make_new = mp_obj_int_make_new,
.unary_op = mp_obj_int_unary_op,
.binary_op = mp_obj_int_binary_op,
.locals_dict = (mp_obj_dict_t *)&int_locals_dict,
EXTENDED_FIELDS(
.unary_op = mp_obj_int_unary_op,
.binary_op = mp_obj_int_binary_op,
),
};

View File

@ -465,11 +465,13 @@ const mp_obj_type_t mp_type_list = {
.name = MP_QSTR_list,
.print = list_print,
.make_new = list_make_new,
.unary_op = list_unary_op,
.binary_op = list_binary_op,
.subscr = list_subscr,
.getiter = list_getiter,
.locals_dict = (mp_obj_dict_t *)&list_locals_dict,
EXTENDED_FIELDS(
.unary_op = list_unary_op,
.binary_op = list_binary_op,
.subscr = list_subscr,
.getiter = list_getiter,
),
};
void mp_obj_list_init(mp_obj_list_t *o, size_t n) {

View File

@ -69,6 +69,8 @@ const mp_obj_type_t mp_type_map = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_map,
.make_new = map_make_new,
.getiter = mp_identity_getiter,
.iternext = map_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = map_iternext,
),
};

View File

@ -172,11 +172,11 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t
o->base.name = name;
o->base.print = namedtuple_print;
o->base.make_new = namedtuple_make_new;
o->base.unary_op = mp_obj_tuple_unary_op;
o->base.binary_op = mp_obj_tuple_binary_op;
o->base.MP_TYPE_UNARY_OP = mp_obj_tuple_unary_op;
o->base.MP_TYPE_BINARY_OP = mp_obj_tuple_binary_op;
o->base.attr = namedtuple_attr;
o->base.subscr = mp_obj_tuple_subscr;
o->base.getiter = mp_obj_tuple_getiter;
o->base.MP_TYPE_SUBSCR = mp_obj_tuple_subscr;
o->base.MP_TYPE_GETITER = mp_obj_tuple_getiter;
o->base.parent = &mp_type_tuple;
return MP_OBJ_FROM_PTR(o);
}

View File

@ -38,7 +38,7 @@
#if MICROPY_PY_COLLECTIONS
typedef struct _mp_obj_namedtuple_type_t {
mp_obj_type_t base;
mp_obj_full_type_t base;
size_t n_fields;
qstr fields[];
} mp_obj_namedtuple_type_t;

View File

@ -48,7 +48,9 @@ const mp_obj_type_t mp_type_NoneType = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_NoneType,
.print = none_print,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.unary_op = mp_generic_unary_op,
),
};
#if !MICROPY_OBJ_IMMEDIATE_OBJS

View File

@ -49,6 +49,8 @@ const mp_obj_type_t mp_type_polymorph_iter = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = polymorph_it_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = polymorph_it_iternext,
),
};

View File

@ -56,8 +56,10 @@ STATIC const mp_obj_type_t mp_type_range_it = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = range_it_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = range_it_iternext,
),
};
STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
@ -215,16 +217,19 @@ STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
const mp_obj_type_t mp_type_range = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_range,
.print = range_print,
.make_new = range_make_new,
.unary_op = range_unary_op,
#if MICROPY_PY_BUILTINS_RANGE_BINOP
.binary_op = range_binary_op,
#endif
.subscr = range_subscr,
.getiter = range_getiter,
#if MICROPY_PY_BUILTINS_RANGE_ATTRS
.attr = range_attr,
#endif
EXTENDED_FIELDS(
.unary_op = range_unary_op,
#if MICROPY_PY_BUILTINS_RANGE_BINOP
.binary_op = range_binary_op,
#endif
.subscr = range_subscr,
.getiter = range_getiter,
),
};

View File

@ -74,8 +74,10 @@ const mp_obj_type_t mp_type_reversed = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_reversed,
.make_new = reversed_make_new,
.getiter = mp_identity_getiter,
.iternext = reversed_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = reversed_iternext,
),
};
#endif // MICROPY_PY_BUILTINS_REVERSED

View File

@ -549,10 +549,12 @@ const mp_obj_type_t mp_type_set = {
.name = MP_QSTR_set,
.print = set_print,
.make_new = set_make_new,
.unary_op = set_unary_op,
.binary_op = set_binary_op,
.getiter = set_getiter,
.locals_dict = (mp_obj_dict_t *)&set_locals_dict,
EXTENDED_FIELDS(
.unary_op = set_unary_op,
.binary_op = set_binary_op,
.getiter = set_getiter,
),
};
#if MICROPY_PY_BUILTINS_FROZENSET
@ -575,10 +577,12 @@ const mp_obj_type_t mp_type_frozenset = {
.name = MP_QSTR_frozenset,
.print = set_print,
.make_new = set_make_new,
.unary_op = set_unary_op,
.binary_op = set_binary_op,
.getiter = set_getiter,
.locals_dict = (mp_obj_dict_t *)&frozenset_locals_dict,
EXTENDED_FIELDS(
.unary_op = set_unary_op,
.binary_op = set_binary_op,
.getiter = set_getiter,
),
};
#endif

View File

@ -48,7 +48,9 @@ const mp_obj_type_t mp_type_singleton = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_,
.print = singleton_print,
.unary_op = mp_generic_unary_op,
EXTENDED_FIELDS(
.unary_op = mp_generic_unary_op,
),
};
const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis};

View File

@ -2039,11 +2039,13 @@ const mp_obj_type_t mp_type_bytes = {
.name = MP_QSTR_bytes,
.print = str_print,
.make_new = bytes_make_new,
.binary_op = mp_obj_str_binary_op,
.subscr = bytes_subscr,
.getiter = mp_obj_new_bytes_iterator,
.buffer_p = { .get_buffer = mp_obj_str_get_buffer },
.locals_dict = (mp_obj_dict_t *)&str8_locals_dict,
EXTENDED_FIELDS(
.binary_op = mp_obj_str_binary_op,
.subscr = bytes_subscr,
.getiter = mp_obj_new_bytes_iterator,
.buffer_p = { .get_buffer = mp_obj_str_get_buffer },
),
};
// The zero-length bytes object, with data that includes a null-terminating byte

View File

@ -250,10 +250,12 @@ const mp_obj_type_t mp_type_stringio = {
.name = MP_QSTR_StringIO,
.print = stringio_print,
.make_new = stringio_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &stringio_stream_p,
.locals_dict = (mp_obj_dict_t *)&stringio_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &stringio_stream_p,
),
};
#if MICROPY_PY_IO_BYTESIO
@ -270,10 +272,12 @@ const mp_obj_type_t mp_type_bytesio = {
.name = MP_QSTR_BytesIO,
.print = stringio_print,
.make_new = stringio_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &bytesio_stream_p,
.locals_dict = (mp_obj_dict_t *)&stringio_locals_dict,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &bytesio_stream_p,
),
};
#endif

View File

@ -295,12 +295,14 @@ const mp_obj_type_t mp_type_str = {
.name = MP_QSTR_str,
.print = uni_print,
.make_new = mp_obj_str_make_new,
.unary_op = uni_unary_op,
.binary_op = mp_obj_str_binary_op,
.subscr = str_subscr,
.getiter = mp_obj_new_str_iterator,
.buffer_p = { .get_buffer = mp_obj_str_get_buffer },
.locals_dict = (mp_obj_dict_t *)&struni_locals_dict,
EXTENDED_FIELDS(
.unary_op = uni_unary_op,
.binary_op = mp_obj_str_binary_op,
.subscr = str_subscr,
.getiter = mp_obj_new_str_iterator,
.buffer_p = { .get_buffer = mp_obj_str_get_buffer },
),
};
/******************************************************************************/

View File

@ -233,11 +233,13 @@ const mp_obj_type_t mp_type_tuple = {
.name = MP_QSTR_tuple,
.print = mp_obj_tuple_print,
.make_new = mp_obj_tuple_make_new,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
.locals_dict = (mp_obj_dict_t *)&tuple_locals_dict,
EXTENDED_FIELDS(
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
),
};
// the zero-length tuple

View File

@ -1150,9 +1150,11 @@ const mp_obj_type_t mp_type_type = {
.name = MP_QSTR_type,
.print = type_print,
.make_new = type_make_new,
.call = type_call,
.unary_op = mp_generic_unary_op,
.attr = type_attr,
EXTENDED_FIELDS(
.call = type_call,
.unary_op = mp_generic_unary_op,
),
};
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) {
@ -1194,27 +1196,27 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
#endif
}
mp_obj_type_t *o = m_new0_ll(mp_obj_type_t, 1);
mp_obj_full_type_t *o = m_new0_ll(mp_obj_full_type_t, 1);
o->base.type = &mp_type_type;
o->flags = base_flags;
o->name = name;
o->print = instance_print;
o->make_new = mp_obj_instance_make_new;
o->call = mp_obj_instance_call;
o->unary_op = instance_unary_op;
o->binary_op = instance_binary_op;
o->attr = mp_obj_instance_attr;
o->subscr = instance_subscr;
o->getiter = mp_obj_instance_getiter;
o->MP_TYPE_CALL = mp_obj_instance_call;
o->MP_TYPE_UNARY_OP = instance_unary_op;
o->MP_TYPE_BINARY_OP = instance_binary_op;
o->MP_TYPE_SUBSCR = instance_subscr;
o->MP_TYPE_GETITER = mp_obj_instance_getiter;
// o->iternext = ; not implemented
o->buffer_p.get_buffer = instance_get_buffer;
o->MP_TYPE_GET_BUFFER = instance_get_buffer;
if (bases_len > 0) {
// Inherit protocol from a base class. This allows to define an
// abstract base class which would translate C-level protocol to
// Python method calls, and any subclass inheriting from it will
// support this feature.
o->protocol = ((mp_obj_type_t *)MP_OBJ_TO_PTR(bases_items[0]))->protocol;
o->MP_TYPE_PROTOCOL = mp_type_protocol((mp_obj_type_t *)MP_OBJ_TO_PTR(bases_items[0]));
if (bases_len >= 2) {
#if MICROPY_MULTIPLE_INHERITANCE
@ -1245,7 +1247,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
#endif
const mp_obj_type_t *native_base;
size_t num_native_bases = instance_count_native_bases(o, &native_base);
size_t num_native_bases = instance_count_native_bases((mp_obj_type_t *)o, &native_base);
if (num_native_bases > 1) {
mp_raise_TypeError(MP_ERROR_TEXT("multiple bases have instance lay-out conflict"));
}

View File

@ -72,6 +72,8 @@ const mp_obj_type_t mp_type_zip = {
.flags = MP_TYPE_FLAG_FULL,
.name = MP_QSTR_zip,
.make_new = zip_make_new,
.getiter = mp_identity_getiter,
.iternext = zip_iternext,
EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = zip_iternext,
),
};

View File

@ -1005,7 +1005,9 @@ STATIC const mp_obj_type_t mp_type_checked_fun = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_FULL,
.name = MP_QSTR_function,
.call = checked_fun_call,
EXTENDED_FIELDS(
.call = checked_fun_call,
)
};
STATIC mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) {