all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.

In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2021-07-14 14:38:38 +10:00 committed by Damien George
parent cdb880789f
commit 662b9761b3
227 changed files with 2543 additions and 2184 deletions

View File

@ -730,13 +730,14 @@ STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
.transfer = mp_machine_soft_i2c_transfer,
};
const mp_obj_type_t mp_machine_soft_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_SoftI2C,
.print = mp_machine_soft_i2c_print,
.make_new = mp_machine_soft_i2c_make_new,
.protocol = &mp_machine_soft_i2c_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_i2c_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_machine_soft_i2c_type,
MP_QSTR_SoftI2C,
MP_TYPE_FLAG_NONE,
mp_machine_soft_i2c_make_new,
print, mp_machine_soft_i2c_print,
protocol, &mp_machine_soft_i2c_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_i2c_locals_dict
);
#endif // MICROPY_PY_MACHINE_SOFTI2C

View File

@ -101,12 +101,14 @@ STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t va
}
}
const mp_obj_type_t machine_mem_type = {
{ &mp_type_type },
.name = MP_QSTR_mem,
.print = machine_mem_print,
.subscr = machine_mem_subscr,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_mem_type,
MP_QSTR_mem,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, machine_mem_print,
subscr, machine_mem_subscr
);
const machine_mem_obj_t machine_mem8_obj = {{&machine_mem_type}, 1};
const machine_mem_obj_t machine_mem16_obj = {{&machine_mem_type}, 2};

View File

@ -77,11 +77,12 @@ STATIC const mp_pin_p_t pinbase_pin_p = {
.ioctl = pinbase_ioctl,
};
const mp_obj_type_t machine_pinbase_type = {
{ &mp_type_type },
.name = MP_QSTR_PinBase,
.make_new = pinbase_make_new,
.protocol = &pinbase_pin_p,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pinbase_type,
MP_QSTR_PinBase,
MP_TYPE_FLAG_NONE,
pinbase_make_new,
protocol, &pinbase_pin_p
);
#endif // MICROPY_PY_MACHINE

View File

@ -132,12 +132,13 @@ STATIC const mp_rom_map_elem_t machine_pwm_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_pwm_locals_dict, machine_pwm_locals_dict_table);
const mp_obj_type_t machine_pwm_type = {
{ &mp_type_type },
.name = MP_QSTR_PWM,
.print = mp_machine_pwm_print,
.make_new = mp_machine_pwm_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_pwm_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pwm_type,
MP_QSTR_PWM,
MP_TYPE_FLAG_NONE,
mp_machine_pwm_make_new,
print, mp_machine_pwm_print,
locals_dict, &machine_pwm_locals_dict
);
#endif // MICROPY_PY_MACHINE_PWM

View File

@ -172,13 +172,14 @@ STATIC const mp_pin_p_t signal_pin_p = {
.ioctl = signal_ioctl,
};
const mp_obj_type_t machine_signal_type = {
{ &mp_type_type },
.name = MP_QSTR_Signal,
.make_new = signal_make_new,
.call = signal_call,
.protocol = &signal_pin_p,
.locals_dict = (void *)&signal_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_signal_type,
MP_QSTR_Signal,
MP_TYPE_FLAG_NONE,
signal_make_new,
call, signal_call,
protocol, &signal_pin_p,
locals_dict, (void *)&signal_locals_dict
);
#endif // MICROPY_PY_MACHINE

View File

@ -251,13 +251,14 @@ const mp_machine_spi_p_t mp_machine_soft_spi_p = {
.transfer = mp_machine_soft_spi_transfer,
};
const mp_obj_type_t mp_machine_soft_spi_type = {
{ &mp_type_type },
.name = MP_QSTR_SoftSPI,
.print = mp_machine_soft_spi_print,
.make_new = mp_machine_soft_spi_make_new,
.protocol = &mp_machine_soft_spi_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_machine_soft_spi_type,
MP_QSTR_SoftSPI,
MP_TYPE_FLAG_NONE,
mp_machine_soft_spi_make_new,
print, mp_machine_soft_spi_print,
protocol, &mp_machine_soft_spi_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_spi_locals_dict
);
#endif // MICROPY_PY_MACHINE_SOFTSPI

View File

@ -240,16 +240,16 @@ STATIC void ringbuf_get_uuid(ringbuf_t *ringbuf, mp_obj_bluetooth_uuid_t *uuid)
#endif // !MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS
const mp_obj_type_t mp_type_bluetooth_uuid = {
{ &mp_type_type },
.name = MP_QSTR_UUID,
.make_new = bluetooth_uuid_make_new,
.unary_op = bluetooth_uuid_unary_op,
.binary_op = bluetooth_uuid_binary_op,
.locals_dict = NULL,
.print = bluetooth_uuid_print,
.buffer = bluetooth_uuid_get_buffer,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_bluetooth_uuid,
MP_QSTR_UUID,
MP_TYPE_FLAG_NONE,
bluetooth_uuid_make_new,
unary_op, bluetooth_uuid_unary_op,
binary_op, bluetooth_uuid_binary_op,
print, bluetooth_uuid_print,
buffer, bluetooth_uuid_get_buffer
);
// ----------------------------------------------------------------------------
// Bluetooth object: General
@ -976,12 +976,13 @@ STATIC const mp_rom_map_elem_t bluetooth_ble_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(bluetooth_ble_locals_dict, bluetooth_ble_locals_dict_table);
STATIC const mp_obj_type_t mp_type_bluetooth_ble = {
{ &mp_type_type },
.name = MP_QSTR_BLE,
.make_new = bluetooth_ble_make_new,
.locals_dict = (void *)&bluetooth_ble_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_bluetooth_ble,
MP_QSTR_BLE,
MP_TYPE_FLAG_NONE,
bluetooth_ble_make_new,
locals_dict, (void *)&bluetooth_ble_locals_dict
);
STATIC const mp_rom_map_elem_t mp_module_bluetooth_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluetooth) },

View File

@ -319,17 +319,19 @@ STATIC const mp_rom_map_elem_t btree_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(btree_locals_dict, btree_locals_dict_table);
STATIC const mp_obj_type_t btree_type = {
{ &mp_type_type },
STATIC MP_DEFINE_CONST_OBJ_TYPE(
btree_type,
MP_QSTR_btree,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
// Save on qstr's, reuse same as for module
.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,
};
print, btree_print,
getiter, btree_getiter,
iternext, btree_iternext,
binary_op, btree_binary_op,
subscr, btree_subscr,
locals_dict, (void *)&btree_locals_dict
);
#endif
STATIC const FILEVTABLE btree_stream_fvtable = {

View File

@ -829,13 +829,14 @@ STATIC const mp_rom_map_elem_t framebuf_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(framebuf_locals_dict, framebuf_locals_dict_table);
STATIC const mp_obj_type_t mp_type_framebuf = {
{ &mp_type_type },
.name = MP_QSTR_FrameBuffer,
.make_new = framebuf_make_new,
.buffer = framebuf_get_buffer,
.locals_dict = (mp_obj_dict_t *)&framebuf_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_framebuf,
MP_QSTR_FrameBuffer,
MP_TYPE_FLAG_NONE,
framebuf_make_new,
buffer, framebuf_get_buffer,
locals_dict, (mp_obj_dict_t *)&framebuf_locals_dict
);
#endif
// this factory function is provided for backwards compatibility with old FrameBuffer1 class

View File

@ -177,12 +177,13 @@ STATIC const mp_rom_map_elem_t lwip_slip_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(lwip_slip_locals_dict, lwip_slip_locals_dict_table);
STATIC const mp_obj_type_t lwip_slip_type = {
{ &mp_type_type },
.name = MP_QSTR_slip,
.make_new = lwip_slip_make_new,
.locals_dict = (mp_obj_dict_t *)&lwip_slip_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
lwip_slip_type,
MP_QSTR_slip,
MP_TYPE_FLAG_NONE,
lwip_slip_make_new,
locals_dict, (mp_obj_dict_t *)&lwip_slip_locals_dict
);
#endif // MICROPY_PY_LWIP_SLIP
@ -1594,14 +1595,15 @@ STATIC const mp_stream_p_t lwip_socket_stream_p = {
.ioctl = lwip_socket_ioctl,
};
STATIC const mp_obj_type_t lwip_socket_type = {
{ &mp_type_type },
.name = MP_QSTR_socket,
.print = lwip_socket_print,
.make_new = lwip_socket_make_new,
.protocol = &lwip_socket_stream_p,
.locals_dict = (mp_obj_dict_t *)&lwip_socket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
lwip_socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
lwip_socket_make_new,
print, lwip_socket_print,
protocol, &lwip_socket_stream_p,
locals_dict, (mp_obj_dict_t *)&lwip_socket_locals_dict
);
/******************************************************************************/
// Support functions for memory protection. lwIP has its own memory management

View File

@ -144,12 +144,13 @@ STATIC const mp_rom_map_elem_t task_queue_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(task_queue_locals_dict, task_queue_locals_dict_table);
STATIC const mp_obj_type_t task_queue_type = {
{ &mp_type_type },
.name = MP_QSTR_TaskQueue,
.make_new = task_queue_make_new,
.locals_dict = (mp_obj_dict_t *)&task_queue_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
task_queue_type,
MP_QSTR_TaskQueue,
MP_TYPE_FLAG_NONE,
task_queue_make_new,
locals_dict, (mp_obj_dict_t *)&task_queue_locals_dict
);
/******************************************************************************/
// Task class
@ -286,14 +287,15 @@ STATIC mp_obj_t task_iternext(mp_obj_t self_in) {
return mp_const_none;
}
STATIC const mp_obj_type_t task_type = {
{ &mp_type_type },
.name = MP_QSTR_Task,
.make_new = task_make_new,
.attr = task_attr,
.getiter = task_getiter,
.iternext = task_iternext,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
task_type,
MP_QSTR_Task,
MP_TYPE_FLAG_NONE,
task_make_new,
attr, task_attr,
getiter, task_getiter,
iternext, task_iternext
);
/******************************************************************************/
// C-level uasyncio module

View File

@ -348,12 +348,13 @@ STATIC const mp_rom_map_elem_t ucryptolib_aes_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(ucryptolib_aes_locals_dict, ucryptolib_aes_locals_dict_table);
STATIC const mp_obj_type_t ucryptolib_aes_type = {
{ &mp_type_type },
.name = MP_QSTR_aes,
.make_new = ucryptolib_aes_make_new,
.locals_dict = (void *)&ucryptolib_aes_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
ucryptolib_aes_type,
MP_QSTR_aes,
MP_TYPE_FLAG_NONE,
ucryptolib_aes_make_new,
locals_dict, (void *)&ucryptolib_aes_locals_dict
);
STATIC const mp_rom_map_elem_t mp_module_ucryptolib_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucryptolib) },

View File

@ -634,16 +634,17 @@ STATIC mp_obj_t uctypes_struct_bytes_at(mp_obj_t ptr, mp_obj_t size) {
}
MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytes_at_obj, uctypes_struct_bytes_at);
STATIC const mp_obj_type_t uctypes_struct_type = {
{ &mp_type_type },
.name = MP_QSTR_struct,
.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 = uctypes_get_buffer,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
uctypes_struct_type,
MP_QSTR_struct,
MP_TYPE_FLAG_NONE,
uctypes_struct_make_new,
print, uctypes_struct_print,
attr, uctypes_struct_attr,
subscr, uctypes_struct_subscr,
unary_op, uctypes_struct_unary_op,
buffer, uctypes_get_buffer
);
STATIC const mp_rom_map_elem_t mp_module_uctypes_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uctypes) },

View File

@ -157,12 +157,13 @@ STATIC const mp_rom_map_elem_t uhashlib_sha256_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(uhashlib_sha256_locals_dict, uhashlib_sha256_locals_dict_table);
STATIC const mp_obj_type_t uhashlib_sha256_type = {
{ &mp_type_type },
.name = MP_QSTR_sha256,
.make_new = uhashlib_sha256_make_new,
.locals_dict = (void *)&uhashlib_sha256_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_sha256_type,
MP_QSTR_sha256,
MP_TYPE_FLAG_NONE,
uhashlib_sha256_make_new,
locals_dict, (void *)&uhashlib_sha256_locals_dict
);
#endif
#if MICROPY_PY_UHASHLIB_SHA1
@ -250,12 +251,13 @@ STATIC const mp_rom_map_elem_t uhashlib_sha1_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(uhashlib_sha1_locals_dict, uhashlib_sha1_locals_dict_table);
STATIC const mp_obj_type_t uhashlib_sha1_type = {
{ &mp_type_type },
.name = MP_QSTR_sha1,
.make_new = uhashlib_sha1_make_new,
.locals_dict = (void *)&uhashlib_sha1_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_sha1_type,
MP_QSTR_sha1,
MP_TYPE_FLAG_NONE,
uhashlib_sha1_make_new,
locals_dict, (void *)&uhashlib_sha1_locals_dict
);
#endif
#if MICROPY_PY_UHASHLIB_MD5
@ -343,12 +345,13 @@ STATIC const mp_rom_map_elem_t uhashlib_md5_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(uhashlib_md5_locals_dict, uhashlib_md5_locals_dict_table);
STATIC const mp_obj_type_t uhashlib_md5_type = {
{ &mp_type_type },
.name = MP_QSTR_md5,
.make_new = uhashlib_md5_make_new,
.locals_dict = (void *)&uhashlib_md5_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_md5_type,
MP_QSTR_md5,
MP_TYPE_FLAG_NONE,
uhashlib_md5_make_new,
locals_dict, (void *)&uhashlib_md5_locals_dict
);
#endif // MICROPY_PY_UHASHLIB_MD5
STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = {

View File

@ -179,12 +179,14 @@ STATIC const mp_rom_map_elem_t match_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(match_locals_dict, match_locals_dict_table);
STATIC const mp_obj_type_t match_type = {
{ &mp_type_type },
.name = MP_QSTR_match,
.print = match_print,
.locals_dict = (void *)&match_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
match_type,
MP_QSTR_match,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, match_print,
locals_dict, (void *)&match_locals_dict
);
#endif
STATIC void re_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@ -411,12 +413,14 @@ STATIC const mp_rom_map_elem_t re_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(re_locals_dict, re_locals_dict_table);
STATIC const mp_obj_type_t re_type = {
{ &mp_type_type },
.name = MP_QSTR_ure,
.print = re_print,
.locals_dict = (void *)&re_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
re_type,
MP_QSTR_ure,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, re_print,
locals_dict, (void *)&re_locals_dict
);
#endif
STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {

View File

@ -336,13 +336,15 @@ STATIC const mp_rom_map_elem_t poll_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table);
STATIC const mp_obj_type_t mp_type_poll = {
{ &mp_type_type },
.name = MP_QSTR_poll,
.getiter = mp_identity_getiter,
.iternext = poll_iternext,
.locals_dict = (void *)&poll_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_poll,
MP_QSTR_poll,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, mp_identity_getiter,
iternext, poll_iternext,
locals_dict, (void *)&poll_locals_dict
);
// poll()
STATIC mp_obj_t select_poll(void) {

View File

@ -528,14 +528,15 @@ STATIC const mp_stream_p_t socket_stream_p = {
.is_text = false,
};
STATIC const mp_obj_type_t socket_type = {
{ &mp_type_type },
.name = MP_QSTR_socket,
.print = socket_print,
.make_new = socket_make_new,
.protocol = &socket_stream_p,
.locals_dict = (mp_obj_dict_t *)&socket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
socket_make_new,
protocol, &socket_stream_p,
locals_dict, (mp_obj_dict_t *)&socket_locals_dict,
print, socket_print
);
/******************************************************************************/
// usocket module

View File

@ -314,16 +314,18 @@ STATIC const mp_stream_p_t ussl_socket_stream_p = {
.ioctl = ussl_socket_ioctl,
};
STATIC const mp_obj_type_t ussl_socket_type = {
{ &mp_type_type },
STATIC MP_DEFINE_CONST_OBJ_TYPE(
ussl_socket_type,
MP_QSTR_ussl,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
// Save on qstr's, reuse same as for module
.name = MP_QSTR_ussl,
.print = ussl_socket_print,
.getiter = NULL,
.iternext = NULL,
.protocol = &ussl_socket_stream_p,
.locals_dict = (void *)&ussl_socket_locals_dict,
};
print, ussl_socket_print,
getiter, NULL,
iternext, NULL,
protocol, &ussl_socket_stream_p,
locals_dict, (void *)&ussl_socket_locals_dict
);
STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// TODO: Implement more args

View File

@ -392,16 +392,18 @@ STATIC const mp_stream_p_t ussl_socket_stream_p = {
.ioctl = socket_ioctl,
};
STATIC const mp_obj_type_t ussl_socket_type = {
{ &mp_type_type },
STATIC MP_DEFINE_CONST_OBJ_TYPE(
ussl_socket_type,
MP_QSTR_ussl,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
// Save on qstr's, reuse same as for module
.name = MP_QSTR_ussl,
.print = socket_print,
.getiter = NULL,
.iternext = NULL,
.protocol = &ussl_socket_stream_p,
.locals_dict = (void *)&ussl_socket_locals_dict,
};
print, socket_print,
getiter, NULL,
iternext, NULL,
protocol, &ussl_socket_stream_p,
locals_dict, (void *)&ussl_socket_locals_dict
);
STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// TODO: Implement more args

View File

@ -209,13 +209,14 @@ STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table);
STATIC const mp_obj_type_t utimeq_type = {
{ &mp_type_type },
.name = MP_QSTR_utimeq,
.make_new = utimeq_make_new,
.unary_op = utimeq_unary_op,
.locals_dict = (void *)&utimeq_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
utimeq_type,
MP_QSTR_utimeq,
MP_TYPE_FLAG_NONE,
utimeq_make_new,
unary_op, utimeq_unary_op,
locals_dict, (void *)&utimeq_locals_dict
);
STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) },

View File

@ -290,13 +290,14 @@ STATIC const mp_stream_p_t websocket_stream_p = {
.ioctl = websocket_ioctl,
};
STATIC const mp_obj_type_t websocket_type = {
{ &mp_type_type },
.name = MP_QSTR_websocket,
.make_new = websocket_make_new,
.protocol = &websocket_stream_p,
.locals_dict = (void *)&websocket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
websocket_type,
MP_QSTR_websocket,
MP_TYPE_FLAG_NONE,
websocket_make_new,
protocol, &websocket_stream_p,
locals_dict, (void *)&websocket_locals_dict
);
STATIC const mp_rom_map_elem_t uwebsocket_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uwebsocket) },

View File

@ -140,13 +140,14 @@ STATIC const mp_stream_p_t decompio_stream_p = {
};
#if !MICROPY_ENABLE_DYNRUNTIME
STATIC const mp_obj_type_t decompio_type = {
{ &mp_type_type },
.name = MP_QSTR_DecompIO,
.make_new = decompio_make_new,
.protocol = &decompio_stream_p,
.locals_dict = (void *)&decompio_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
decompio_type,
MP_QSTR_DecompIO,
MP_TYPE_FLAG_NONE,
decompio_make_new,
protocol, &decompio_stream_p,
locals_dict, (void *)&decompio_locals_dict
);
#endif
STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {

View File

@ -342,13 +342,14 @@ STATIC const mp_stream_p_t webrepl_stream_p = {
.ioctl = webrepl_ioctl,
};
STATIC const mp_obj_type_t webrepl_type = {
{ &mp_type_type },
.name = MP_QSTR__webrepl,
.make_new = webrepl_make_new,
.protocol = &webrepl_stream_p,
.locals_dict = (mp_obj_dict_t *)&webrepl_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
webrepl_type,
MP_QSTR__webrepl,
MP_TYPE_FLAG_NONE,
webrepl_make_new,
protocol, &webrepl_stream_p,
locals_dict, (mp_obj_dict_t *)&webrepl_locals_dict
);
STATIC const mp_rom_map_elem_t webrepl_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__webrepl) },

View File

@ -496,12 +496,13 @@ STATIC const mp_rom_map_elem_t network_cyw43_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(network_cyw43_locals_dict, network_cyw43_locals_dict_table);
const mp_obj_type_t mp_network_cyw43_type = {
{ &mp_type_type },
.name = MP_QSTR_CYW43,
.print = network_cyw43_print,
.make_new = network_cyw43_make_new,
.locals_dict = (mp_obj_dict_t *)&network_cyw43_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_network_cyw43_type,
MP_QSTR_CYW43,
MP_TYPE_FLAG_NONE,
network_cyw43_make_new,
print, network_cyw43_print,
locals_dict, (mp_obj_dict_t *)&network_cyw43_locals_dict
);
#endif // MICROPY_PY_NETWORK_CYW43

View File

@ -774,13 +774,16 @@ static const mp_rom_map_elem_t nina_locals_dict_table[] = {
static MP_DEFINE_CONST_DICT(nina_locals_dict, nina_locals_dict_table);
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mod_network_nic_type_nina_base,
MP_QSTR_nina,
MP_TYPE_FLAG_NONE,
network_ninaw10_make_new,
locals_dict, &nina_locals_dict
);
const mod_network_nic_type_t mod_network_nic_type_nina = {
.base = {
{ &mp_type_type },
.name = MP_QSTR_nina,
.make_new = network_ninaw10_make_new,
.locals_dict = (mp_obj_t)&nina_locals_dict,
},
.base = mod_network_nic_type_nina_base,
.gethostbyname = network_ninaw10_gethostbyname,
.socket = network_ninaw10_socket_socket,
.close = network_ninaw10_socket_close,

View File

@ -1016,20 +1016,24 @@ STATIC const mp_rom_map_elem_t wiznet5k_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(wiznet5k_locals_dict, wiznet5k_locals_dict_table);
#if WIZNET5K_WITH_LWIP_STACK
const mp_obj_type_t mod_network_nic_type_wiznet5k = {
{ &mp_type_type },
.name = MP_QSTR_WIZNET5K,
.make_new = wiznet5k_make_new,
.locals_dict = (mp_obj_dict_t *)&wiznet5k_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mod_network_nic_type_wiznet5k,
MP_QSTR_WIZNET5K,
MP_TYPE_FLAG_NONE,
wiznet5k_make_new,
locals_dict, &wiznet5k_locals_dict
);
#else // WIZNET5K_PROVIDED_STACK
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mod_network_nic_type_wiznet5k_base,
MP_QSTR_WIZNET5K,
MP_TYPE_FLAG_NONE,
wiznet5k_make_new,
locals_dict, &wiznet5k_locals_dict
);
const mod_network_nic_type_t mod_network_nic_type_wiznet5k = {
.base = {
{ &mp_type_type },
.name = MP_QSTR_WIZNET5K,
.make_new = wiznet5k_make_new,
.locals_dict = (mp_obj_dict_t *)&wiznet5k_locals_dict,
},
.base = mod_network_nic_type_wiznet5k_base,
.gethostbyname = wiznet5k_gethostbyname,
.socket = wiznet5k_socket_socket,
.close = wiznet5k_socket_close,

View File

@ -431,12 +431,13 @@ STATIC const mp_vfs_proto_t fat_vfs_proto = {
.import_stat = fat_vfs_import_stat,
};
const mp_obj_type_t mp_fat_vfs_type = {
{ &mp_type_type },
.name = MP_QSTR_VfsFat,
.make_new = fat_vfs_make_new,
.protocol = &fat_vfs_proto,
.locals_dict = (mp_obj_dict_t *)&fat_vfs_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_fat_vfs_type,
MP_QSTR_VfsFat,
MP_TYPE_FLAG_NONE,
fat_vfs_make_new,
protocol, &fat_vfs_proto,
locals_dict, (mp_obj_dict_t *)&fat_vfs_locals_dict
);
#endif // MICROPY_VFS_FAT

View File

@ -176,15 +176,17 @@ STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = {
.ioctl = file_obj_ioctl,
};
const mp_obj_type_t mp_type_vfs_fat_fileio = {
{ &mp_type_type },
.name = MP_QSTR_FileIO,
.print = file_obj_print,
.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,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_vfs_fat_fileio,
MP_QSTR_FileIO,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, file_obj_print,
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
);
STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
.read = file_obj_read,
@ -193,15 +195,17 @@ STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
.is_text = true,
};
const mp_obj_type_t mp_type_vfs_fat_textio = {
{ &mp_type_type },
.name = MP_QSTR_TextIOWrapper,
.print = file_obj_print,
.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,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_vfs_fat_textio,
MP_QSTR_TextIOWrapper,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, file_obj_print,
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
);
// Factory function for I/O stream classes
STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_in) {

View File

@ -502,14 +502,15 @@ STATIC const mp_vfs_proto_t MP_VFS_LFSx(proto) = {
.import_stat = MP_VFS_LFSx(import_stat),
};
const mp_obj_type_t MP_TYPE_VFS_LFSx = {
{ &mp_type_type },
MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_VFS_LFSx,
#if LFS_BUILD_VERSION == 1
.name = MP_QSTR_VfsLfs1,
MP_QSTR_VfsLfs1,
#else
.name = MP_QSTR_VfsLfs2,
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),
};
MP_TYPE_FLAG_NONE,
MP_VFS_LFSx(make_new),
protocol, &MP_VFS_LFSx(proto),
locals_dict, (mp_obj_dict_t *)&MP_VFS_LFSx(locals_dict)
);

View File

@ -220,15 +220,17 @@ STATIC const mp_stream_p_t MP_VFS_LFSx(fileio_stream_p) = {
.ioctl = MP_VFS_LFSx(file_ioctl),
};
const mp_obj_type_t MP_TYPE_VFS_LFSx_(_fileio) = {
{ &mp_type_type },
.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),
};
MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_VFS_LFSx_(_fileio),
MP_QSTR_FileIO,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
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)
);
STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
.read = MP_VFS_LFSx(file_read),
@ -237,12 +239,14 @@ STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
.is_text = true,
};
const mp_obj_type_t MP_TYPE_VFS_LFSx_(_textio) = {
{ &mp_type_type },
.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),
};
MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_VFS_LFSx_(_textio),
MP_QSTR_TextIOWrapper,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
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)
);

View File

@ -398,12 +398,13 @@ STATIC const mp_vfs_proto_t vfs_posix_proto = {
.import_stat = mp_vfs_posix_import_stat,
};
const mp_obj_type_t mp_type_vfs_posix = {
{ &mp_type_type },
.name = MP_QSTR_VfsPosix,
.make_new = vfs_posix_make_new,
.protocol = &vfs_posix_proto,
.locals_dict = (mp_obj_dict_t *)&vfs_posix_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_vfs_posix,
MP_QSTR_VfsPosix,
MP_TYPE_FLAG_NONE,
vfs_posix_make_new,
protocol, &vfs_posix_proto,
locals_dict, (mp_obj_dict_t *)&vfs_posix_locals_dict
);
#endif // MICROPY_VFS_POSIX

View File

@ -249,15 +249,17 @@ STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = {
.ioctl = vfs_posix_file_ioctl,
};
const mp_obj_type_t mp_type_vfs_posix_fileio = {
{ &mp_type_type },
.name = MP_QSTR_FileIO,
.print = vfs_posix_file_print,
.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,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_vfs_posix_fileio,
MP_QSTR_FileIO,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, vfs_posix_file_print,
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
);
STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
.read = vfs_posix_file_read,
@ -266,15 +268,17 @@ STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
.is_text = true,
};
const mp_obj_type_t mp_type_vfs_posix_textio = {
{ &mp_type_type },
.name = MP_QSTR_TextIOWrapper,
.print = vfs_posix_file_print,
.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,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_vfs_posix_textio,
MP_QSTR_TextIOWrapper,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, vfs_posix_file_print,
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
);
const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_vfs_posix_textio}, STDIN_FILENO};
const mp_obj_vfs_posix_file_t mp_sys_stdout_obj = {{&mp_type_vfs_posix_textio}, STDOUT_FILENO};

View File

@ -190,11 +190,13 @@ STATIC const mp_rom_map_elem_t mp_irq_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mp_irq_locals_dict, mp_irq_locals_dict_table);
const mp_obj_type_t mp_irq_type = {
{ &mp_type_type },
.name = MP_QSTR_irq,
.call = mp_irq_call,
.locals_dict = (mp_obj_t)&mp_irq_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mp_irq_type,
MP_QSTR_irq,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
call, mp_irq_call,
locals_dict, (mp_obj_t)&mp_irq_locals_dict
);
MP_REGISTER_ROOT_POINTER(mp_obj_list_t mp_irq_obj_list);

View File

@ -171,10 +171,11 @@ STATIC const mp_rom_map_elem_t network_server_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(network_server_locals_dict, network_server_locals_dict_table);
STATIC const mp_obj_type_t network_server_type = {
{ &mp_type_type },
.name = MP_QSTR_Server,
.make_new = network_server_make_new,
.locals_dict = (mp_obj_t)&network_server_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
network_server_type,
MP_QSTR_Server,
MP_TYPE_FLAG_NONE,
network_server_make_new,
locals_dict, (mp_obj_t)&network_server_locals_dict
);
#endif

View File

@ -177,19 +177,21 @@ STATIC MP_DEFINE_CONST_DICT(hash_locals_dict, hash_locals_dict_table);
// .locals_dict = (mp_obj_t)&hash_locals_dict,
//};
STATIC const mp_obj_type_t sha1_type = {
{ &mp_type_type },
.name = MP_QSTR_sha1,
.make_new = hash_make_new,
.locals_dict = (mp_obj_t)&hash_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
sha1_type,
MP_QSTR_sha1,
MP_TYPE_FLAG_NONE,
hash_make_new,
locals_dict, (mp_obj_t)&hash_locals_dict
);
STATIC const mp_obj_type_t sha256_type = {
{ &mp_type_type },
.name = MP_QSTR_sha256,
.make_new = hash_make_new,
.locals_dict = (mp_obj_t)&hash_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
sha256_type,
MP_QSTR_sha256,
MP_TYPE_FLAG_NONE,
hash_make_new,
locals_dict, (mp_obj_t)&hash_locals_dict
);
STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) },

View File

@ -759,13 +759,14 @@ const mp_stream_p_t socket_stream_p = {
.is_text = false,
};
STATIC const mp_obj_type_t socket_type = {
{ &mp_type_type },
.name = MP_QSTR_socket,
.make_new = socket_make_new,
.protocol = &socket_stream_p,
.locals_dict = (mp_obj_t)&socket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
socket_make_new,
protocol, &socket_stream_p,
locals_dict, (mp_obj_t)&socket_locals_dict
);
/******************************************************************************/
// usocket module

View File

@ -60,14 +60,16 @@ STATIC const mp_obj_type_t ssl_socket_type;
// ssl sockets inherit from normal socket, so we take its
// locals and stream methods
STATIC const mp_obj_type_t ssl_socket_type = {
{ &mp_type_type },
.name = MP_QSTR_ussl,
.getiter = NULL,
.iternext = NULL,
.protocol = &socket_stream_p,
.locals_dict = (mp_obj_t)&socket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
ssl_socket_type,
MP_QSTR_ussl,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, NULL,
iternext, NULL,
protocol, &socket_stream_p,
locals_dict, (mp_obj_t)&socket_locals_dict
);
STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
STATIC const mp_arg_t allowed_args[] = {

View File

@ -1285,13 +1285,16 @@ STATIC const mp_rom_map_elem_t wlan_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(wlan_locals_dict, wlan_locals_dict_table);
STATIC MP_DEFINE_CONST_OBJ_TYPE(
mod_network_nic_type_wlan_base,
MP_QSTR_WLAN,
MP_TYPE_FLAG_NONE,
wlan_make_new,
locals_dict, (mp_obj_t)&wlan_locals_dict
);
const mod_network_nic_type_t mod_network_nic_type_wlan = {
.base = {
{ &mp_type_type },
.name = MP_QSTR_WLAN,
.make_new = wlan_make_new,
.locals_dict = (mp_obj_t)&wlan_locals_dict,
},
.base = mod_network_nic_type_wlan_base,
};
STATIC const mp_irq_methods_t wlan_irq_methods = {

View File

@ -233,13 +233,14 @@ STATIC const mp_rom_map_elem_t adc_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(adc_locals_dict, adc_locals_dict_table);
const mp_obj_type_t pyb_adc_type = {
{ &mp_type_type },
.name = MP_QSTR_ADC,
.print = adc_print,
.make_new = adc_make_new,
.locals_dict = (mp_obj_t)&adc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_adc_type,
MP_QSTR_ADC,
MP_TYPE_FLAG_NONE,
adc_make_new,
print, adc_print,
locals_dict, (mp_obj_t)&adc_locals_dict
);
STATIC void adc_channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_adc_channel_obj_t *self = self_in;
@ -300,10 +301,12 @@ STATIC const mp_rom_map_elem_t adc_channel_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(adc_channel_locals_dict, adc_channel_locals_dict_table);
STATIC const mp_obj_type_t pyb_adc_channel_type = {
{ &mp_type_type },
.name = MP_QSTR_ADCChannel,
.print = adc_channel_print,
.call = adc_channel_call,
.locals_dict = (mp_obj_t)&adc_channel_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
pyb_adc_channel_type,
MP_QSTR_ADCChannel,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, adc_channel_print,
call, adc_channel_call,
locals_dict, (mp_obj_t)&adc_channel_locals_dict
);

View File

@ -84,12 +84,13 @@ STATIC const mp_rom_map_elem_t pyb_flash_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pyb_flash_locals_dict, pyb_flash_locals_dict_table);
const mp_obj_type_t pyb_flash_type = {
{ &mp_type_type },
.name = MP_QSTR_Flash,
.make_new = pyb_flash_make_new,
.locals_dict = (mp_obj_t)&pyb_flash_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_flash_type,
MP_QSTR_Flash,
MP_TYPE_FLAG_NONE,
pyb_flash_make_new,
locals_dict, (mp_obj_t)&pyb_flash_locals_dict
);
void pyb_flash_init_vfs(fs_user_mount_t *vfs) {
vfs->base.type = &mp_fat_vfs_type;

View File

@ -521,10 +521,11 @@ STATIC const mp_rom_map_elem_t pyb_i2c_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pyb_i2c_locals_dict, pyb_i2c_locals_dict_table);
const mp_obj_type_t pyb_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_I2C,
.print = pyb_i2c_print,
.make_new = pyb_i2c_make_new,
.locals_dict = (mp_obj_t)&pyb_i2c_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_i2c_type,
MP_QSTR_I2C,
MP_TYPE_FLAG_NONE,
pyb_i2c_make_new,
print, pyb_i2c_print,
locals_dict, (mp_obj_t)&pyb_i2c_locals_dict
);

View File

@ -931,14 +931,15 @@ STATIC const mp_rom_map_elem_t pin_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pin_locals_dict, pin_locals_dict_table);
const mp_obj_type_t pin_type = {
{ &mp_type_type },
.name = MP_QSTR_Pin,
.print = pin_print,
.make_new = pin_make_new,
.call = pin_call,
.locals_dict = (mp_obj_t)&pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pin_type,
MP_QSTR_Pin,
MP_TYPE_FLAG_NONE,
pin_make_new,
print, pin_print,
call, pin_call,
locals_dict, (mp_obj_t)&pin_locals_dict
);
STATIC const mp_irq_methods_t pin_irq_methods = {
.init = pin_irq,
@ -952,10 +953,12 @@ STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in,
mp_printf(print, "<Pin.%q>", self->name);
}
const mp_obj_type_t pin_board_pins_obj_type = {
{ &mp_type_type },
.name = MP_QSTR_board,
.print = pin_named_pins_obj_print,
.locals_dict = (mp_obj_t)&pin_board_pins_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pin_board_pins_obj_type,
MP_QSTR_board,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, pin_named_pins_obj_print,
locals_dict, (mp_obj_t)&pin_board_pins_locals_dict
);

View File

@ -469,12 +469,13 @@ STATIC const mp_rom_map_elem_t pyb_rtc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pyb_rtc_locals_dict, pyb_rtc_locals_dict_table);
const mp_obj_type_t pyb_rtc_type = {
{ &mp_type_type },
.name = MP_QSTR_RTC,
.make_new = pyb_rtc_make_new,
.locals_dict = (mp_obj_t)&pyb_rtc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_rtc_type,
MP_QSTR_RTC,
MP_TYPE_FLAG_NONE,
pyb_rtc_make_new,
locals_dict, (mp_obj_t)&pyb_rtc_locals_dict
);
STATIC const mp_irq_methods_t pyb_rtc_irq_methods = {
.init = pyb_rtc_irq,

View File

@ -212,9 +212,10 @@ STATIC const mp_rom_map_elem_t pyb_sd_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pyb_sd_locals_dict, pyb_sd_locals_dict_table);
const mp_obj_type_t pyb_sd_type = {
{ &mp_type_type },
.name = MP_QSTR_SD,
.make_new = pyb_sd_make_new,
.locals_dict = (mp_obj_t)&pyb_sd_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_sd_type,
MP_QSTR_SD,
MP_TYPE_FLAG_NONE,
pyb_sd_make_new,
locals_dict, (mp_obj_t)&pyb_sd_locals_dict
);

View File

@ -125,10 +125,12 @@ STATIC pybsleep_data_t pybsleep_data = {NULL, NULL, NULL};
volatile arm_cm4_core_regs_t vault_arm_registers;
STATIC pybsleep_reset_cause_t pybsleep_reset_cause = PYB_SLP_PWRON_RESET;
STATIC pybsleep_wake_reason_t pybsleep_wake_reason = PYB_SLP_WAKED_PWRON;
STATIC const mp_obj_type_t pyb_sleep_type = {
{ &mp_type_type },
.name = MP_QSTR_sleep,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
pyb_sleep_type,
MP_QSTR_sleep,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW
);
/******************************************************************************
DECLARE PRIVATE FUNCTIONS

View File

@ -377,10 +377,11 @@ STATIC const mp_rom_map_elem_t pyb_spi_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pyb_spi_locals_dict, pyb_spi_locals_dict_table);
const mp_obj_type_t pyb_spi_type = {
{ &mp_type_type },
.name = MP_QSTR_SPI,
.print = pyb_spi_print,
.make_new = pyb_spi_make_new,
.locals_dict = (mp_obj_t)&pyb_spi_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_spi_type,
MP_QSTR_SPI,
MP_TYPE_FLAG_NONE,
pyb_spi_make_new,
print, pyb_spi_print,
locals_dict, (mp_obj_t)&pyb_spi_locals_dict
);

View File

@ -459,13 +459,14 @@ STATIC const mp_rom_map_elem_t pyb_timer_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pyb_timer_locals_dict, pyb_timer_locals_dict_table);
const mp_obj_type_t pyb_timer_type = {
{ &mp_type_type },
.name = MP_QSTR_Timer,
.print = pyb_timer_print,
.make_new = pyb_timer_make_new,
.locals_dict = (mp_obj_t)&pyb_timer_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_timer_type,
MP_QSTR_Timer,
MP_TYPE_FLAG_NONE,
pyb_timer_make_new,
print, pyb_timer_print,
locals_dict, (mp_obj_t)&pyb_timer_locals_dict
);
STATIC const mp_irq_methods_t pyb_timer_channel_irq_methods = {
.init = pyb_timer_channel_irq,
@ -721,11 +722,13 @@ STATIC const mp_rom_map_elem_t pyb_timer_channel_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pyb_timer_channel_locals_dict, pyb_timer_channel_locals_dict_table);
STATIC const mp_obj_type_t pyb_timer_channel_type = {
{ &mp_type_type },
.name = MP_QSTR_TimerChannel,
.print = pyb_timer_channel_print,
.locals_dict = (mp_obj_t)&pyb_timer_channel_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
pyb_timer_channel_type,
MP_QSTR_TimerChannel,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, pyb_timer_channel_print,
locals_dict, (mp_obj_t)&pyb_timer_channel_locals_dict
);
MP_REGISTER_ROOT_POINTER(mp_obj_list_t pyb_timer_channel_obj_list);

View File

@ -685,15 +685,16 @@ STATIC const mp_irq_methods_t uart_irq_methods = {
.flags = uart_irq_flags
};
const mp_obj_type_t pyb_uart_type = {
{ &mp_type_type },
.name = MP_QSTR_UART,
.print = pyb_uart_print,
.make_new = pyb_uart_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &uart_stream_p,
.locals_dict = (mp_obj_t)&pyb_uart_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_uart_type,
MP_QSTR_UART,
MP_TYPE_FLAG_NONE,
pyb_uart_make_new,
print, pyb_uart_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &uart_stream_p,
locals_dict, (mp_obj_t)&pyb_uart_locals_dict
);
MP_REGISTER_ROOT_POINTER(struct _pyb_uart_obj_t *pyb_uart_objs[2]);

View File

@ -150,10 +150,11 @@ STATIC const mp_rom_map_elem_t pybwdt_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pybwdt_locals_dict, pybwdt_locals_dict_table);
const mp_obj_type_t pyb_wdt_type = {
{ &mp_type_type },
.name = MP_QSTR_WDT,
.make_new = pyb_wdt_make_new,
.locals_dict = (mp_obj_t)&pybwdt_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_wdt_type,
MP_QSTR_WDT,
MP_TYPE_FLAG_NONE,
pyb_wdt_make_new,
locals_dict, (mp_obj_t)&pybwdt_locals_dict
);

View File

@ -141,10 +141,11 @@ STATIC const mp_rom_map_elem_t esp32_nvs_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(esp32_nvs_locals_dict, esp32_nvs_locals_dict_table);
const mp_obj_type_t esp32_nvs_type = {
{ &mp_type_type },
.name = MP_QSTR_NVS,
.print = esp32_nvs_print,
.make_new = esp32_nvs_make_new,
.locals_dict = (mp_obj_dict_t *)&esp32_nvs_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp32_nvs_type,
MP_QSTR_NVS,
MP_TYPE_FLAG_NONE,
esp32_nvs_make_new,
print, esp32_nvs_print,
locals_dict, (mp_obj_dict_t *)&esp32_nvs_locals_dict
);

View File

@ -284,10 +284,11 @@ STATIC const mp_rom_map_elem_t esp32_partition_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(esp32_partition_locals_dict, esp32_partition_locals_dict_table);
const mp_obj_type_t esp32_partition_type = {
{ &mp_type_type },
.name = MP_QSTR_Partition,
.print = esp32_partition_print,
.make_new = esp32_partition_make_new,
.locals_dict = (mp_obj_dict_t *)&esp32_partition_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp32_partition_type,
MP_QSTR_Partition,
MP_TYPE_FLAG_NONE,
esp32_partition_make_new,
print, esp32_partition_print,
locals_dict, (mp_obj_dict_t *)&esp32_partition_locals_dict
);

View File

@ -372,10 +372,11 @@ STATIC const mp_rom_map_elem_t esp32_rmt_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(esp32_rmt_locals_dict, esp32_rmt_locals_dict_table);
const mp_obj_type_t esp32_rmt_type = {
{ &mp_type_type },
.name = MP_QSTR_RMT,
.print = esp32_rmt_print,
.make_new = esp32_rmt_make_new,
.locals_dict = (mp_obj_dict_t *)&esp32_rmt_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp32_rmt_type,
MP_QSTR_RMT,
MP_TYPE_FLAG_NONE,
esp32_rmt_make_new,
print, esp32_rmt_print,
locals_dict, (mp_obj_dict_t *)&esp32_rmt_locals_dict
);

View File

@ -91,11 +91,12 @@ STATIC const mp_rom_map_elem_t esp32_ulp_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(esp32_ulp_locals_dict, esp32_ulp_locals_dict_table);
const mp_obj_type_t esp32_ulp_type = {
{ &mp_type_type },
.name = MP_QSTR_ULP,
.make_new = esp32_ulp_make_new,
.locals_dict = (mp_obj_t)&esp32_ulp_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp32_ulp_type,
MP_QSTR_ULP,
MP_TYPE_FLAG_NONE,
esp32_ulp_make_new,
locals_dict, (mp_obj_t)&esp32_ulp_locals_dict
);
#endif // CONFIG_IDF_TARGET_ESP32

View File

@ -256,10 +256,11 @@ STATIC const mp_rom_map_elem_t madc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(madc_locals_dict, madc_locals_dict_table);
const mp_obj_type_t machine_adc_type = {
{ &mp_type_type },
.name = MP_QSTR_ADC,
.print = madc_print,
.make_new = madc_make_new,
.locals_dict = (mp_obj_t)&madc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_adc_type,
MP_QSTR_ADC,
MP_TYPE_FLAG_NONE,
madc_make_new,
print, madc_print,
locals_dict, (mp_obj_t)&madc_locals_dict
);

View File

@ -194,10 +194,11 @@ STATIC const mp_rom_map_elem_t madcblock_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(madcblock_locals_dict, madcblock_locals_dict_table);
const mp_obj_type_t machine_adcblock_type = {
{ &mp_type_type },
.name = MP_QSTR_ADCBlock,
.print = madcblock_print,
.make_new = madcblock_make_new,
.locals_dict = (mp_obj_t)&madcblock_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_adcblock_type,
MP_QSTR_ADCBlock,
MP_TYPE_FLAG_NONE,
madcblock_make_new,
print, madcblock_print,
locals_dict, (mp_obj_dict_t *)&madcblock_locals_dict
);

View File

@ -104,12 +104,13 @@ STATIC const mp_rom_map_elem_t mdac_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mdac_locals_dict, mdac_locals_dict_table);
const mp_obj_type_t machine_dac_type = {
{ &mp_type_type },
.name = MP_QSTR_DAC,
.print = mdac_print,
.make_new = mdac_make_new,
.locals_dict = (mp_obj_t)&mdac_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_dac_type,
MP_QSTR_DAC,
MP_TYPE_FLAG_NONE,
mdac_make_new,
print, mdac_print,
locals_dict, (mp_obj_t)&mdac_locals_dict
);
#endif // MICROPY_PY_MACHINE_DAC

View File

@ -545,11 +545,12 @@ STATIC const mp_machine_spi_p_t machine_hw_spi_p = {
.transfer = machine_hw_spi_transfer,
};
const mp_obj_type_t machine_hw_spi_type = {
{ &mp_type_type },
.name = MP_QSTR_SPI,
.print = machine_hw_spi_print,
.make_new = machine_hw_spi_make_new,
.protocol = &machine_hw_spi_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hw_spi_type,
MP_QSTR_SPI,
MP_TYPE_FLAG_NONE,
machine_hw_spi_make_new,
print, machine_hw_spi_print,
protocol, &machine_hw_spi_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_spi_locals_dict
);

View File

@ -192,11 +192,12 @@ STATIC const mp_machine_i2c_p_t machine_hw_i2c_p = {
.transfer = machine_hw_i2c_transfer,
};
const mp_obj_type_t machine_hw_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_I2C,
.print = machine_hw_i2c_print,
.make_new = machine_hw_i2c_make_new,
.protocol = &machine_hw_i2c_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_i2c_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hw_i2c_type,
MP_QSTR_I2C,
MP_TYPE_FLAG_NONE,
machine_hw_i2c_make_new,
print, machine_hw_i2c_print,
protocol, &machine_hw_i2c_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_i2c_locals_dict
);

View File

@ -829,16 +829,17 @@ STATIC const mp_stream_p_t i2s_stream_p = {
.is_text = false,
};
const mp_obj_type_t machine_i2s_type = {
{ &mp_type_type },
.name = MP_QSTR_I2S,
.print = machine_i2s_print,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &i2s_stream_p,
.make_new = machine_i2s_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_i2s_type,
MP_QSTR_I2S,
MP_TYPE_FLAG_NONE,
machine_i2s_make_new,
print, machine_i2s_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &i2s_stream_p,
locals_dict, (mp_obj_dict_t *)&machine_i2s_locals_dict
);
MP_REGISTER_ROOT_POINTER(struct _machine_i2s_obj_t *machine_i2s_obj[I2S_NUM_MAX]);

View File

@ -529,15 +529,16 @@ STATIC const mp_pin_p_t pin_pin_p = {
.ioctl = pin_ioctl,
};
const mp_obj_type_t machine_pin_type = {
{ &mp_type_type },
.name = MP_QSTR_Pin,
.print = machine_pin_print,
.make_new = mp_pin_make_new,
.call = machine_pin_call,
.protocol = &pin_pin_p,
.locals_dict = (mp_obj_t)&machine_pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_type,
MP_QSTR_Pin,
MP_TYPE_FLAG_NONE,
mp_pin_make_new,
print, machine_pin_print,
call, machine_pin_call,
protocol, &pin_pin_p,
locals_dict, (mp_obj_t)&machine_pin_locals_dict
);
/******************************************************************************/
// Pin IRQ object
@ -723,11 +724,13 @@ STATIC const mp_rom_map_elem_t machine_pin_irq_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_pin_irq_locals_dict, machine_pin_irq_locals_dict_table);
STATIC const mp_obj_type_t machine_pin_irq_type = {
{ &mp_type_type },
.name = MP_QSTR_IRQ,
.call = machine_pin_irq_call,
.locals_dict = (mp_obj_dict_t *)&machine_pin_irq_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_irq_type,
MP_QSTR_IRQ,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
call, machine_pin_irq_call,
locals_dict, (mp_obj_dict_t *)&machine_pin_irq_locals_dict
);
MP_REGISTER_ROOT_POINTER(mp_obj_t machine_pin_irq_handler[40]);

View File

@ -173,9 +173,10 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
const mp_obj_type_t machine_rtc_type = {
{ &mp_type_type },
.name = MP_QSTR_RTC,
.make_new = machine_rtc_make_new,
.locals_dict = (mp_obj_t)&machine_rtc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_rtc_type,
MP_QSTR_RTC,
MP_TYPE_FLAG_NONE,
machine_rtc_make_new,
locals_dict, (mp_obj_t)&machine_rtc_locals_dict
);

View File

@ -399,11 +399,12 @@ STATIC const mp_rom_map_elem_t machine_sdcard_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(machine_sdcard_locals_dict, machine_sdcard_locals_dict_table);
const mp_obj_type_t machine_sdcard_type = {
{ &mp_type_type },
.name = MP_QSTR_SDCard,
.make_new = machine_sdcard_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_sdcard_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_sdcard_type,
MP_QSTR_SDCard,
MP_TYPE_FLAG_NONE,
machine_sdcard_make_new,
locals_dict, (mp_obj_dict_t *)&machine_sdcard_locals_dict
);
#endif // MICROPY_HW_ENABLE_SDCARD

View File

@ -277,12 +277,13 @@ STATIC const mp_rom_map_elem_t machine_timer_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_timer_locals_dict, machine_timer_locals_dict_table);
const mp_obj_type_t machine_timer_type = {
{ &mp_type_type },
.name = MP_QSTR_Timer,
.print = machine_timer_print,
.make_new = machine_timer_make_new,
.locals_dict = (mp_obj_t)&machine_timer_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_timer_type,
MP_QSTR_Timer,
MP_TYPE_FLAG_NONE,
machine_timer_make_new,
print, machine_timer_print,
locals_dict, (mp_obj_t)&machine_timer_locals_dict
);
MP_REGISTER_ROOT_POINTER(struct _machine_timer_obj_t *machine_timer_obj_head);

View File

@ -134,11 +134,12 @@ STATIC const mp_rom_map_elem_t mtp_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mtp_locals_dict, mtp_locals_dict_table);
const mp_obj_type_t machine_touchpad_type = {
{ &mp_type_type },
.name = MP_QSTR_TouchPad,
.make_new = mtp_make_new,
.locals_dict = (mp_obj_t)&mtp_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_touchpad_type,
MP_QSTR_TouchPad,
MP_TYPE_FLAG_NONE,
mtp_make_new,
locals_dict, (mp_obj_t)&mtp_locals_dict
);
#endif // CONFIG_IDF_TARGET_ESP32

View File

@ -530,13 +530,14 @@ STATIC const mp_stream_p_t uart_stream_p = {
.is_text = false,
};
const mp_obj_type_t machine_uart_type = {
{ &mp_type_type },
.name = MP_QSTR_UART,
.print = machine_uart_print,
.make_new = machine_uart_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &uart_stream_p,
.locals_dict = (mp_obj_dict_t *)&machine_uart_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_uart_type,
MP_QSTR_UART,
MP_TYPE_FLAG_NONE,
machine_uart_make_new,
print, machine_uart_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &uart_stream_p,
locals_dict, (mp_obj_dict_t *)&machine_uart_locals_dict
);

View File

@ -83,9 +83,10 @@ STATIC const mp_rom_map_elem_t machine_wdt_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_wdt_locals_dict, machine_wdt_locals_dict_table);
const mp_obj_type_t machine_wdt_type = {
{ &mp_type_type },
.name = MP_QSTR_WDT,
.make_new = machine_wdt_make_new,
.locals_dict = (mp_obj_t)&machine_wdt_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_wdt_type,
MP_QSTR_WDT,
MP_TYPE_FLAG_NONE,
machine_wdt_make_new,
locals_dict, (mp_obj_t)&machine_wdt_locals_dict
);

View File

@ -785,13 +785,14 @@ STATIC const mp_stream_p_t socket_stream_p = {
.ioctl = socket_stream_ioctl
};
STATIC const mp_obj_type_t socket_type = {
{ &mp_type_type },
.name = MP_QSTR_socket,
.make_new = socket_make_new,
.protocol = &socket_stream_p,
.locals_dict = (mp_obj_t)&socket_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
socket_make_new,
protocol, &socket_stream_p,
locals_dict, (mp_obj_t)&socket_locals_dict
);
STATIC mp_obj_t esp_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
// TODO support additional args beyond the first two

View File

@ -302,10 +302,12 @@ STATIC const mp_rom_map_elem_t lan_if_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(lan_if_locals_dict, lan_if_locals_dict_table);
const mp_obj_type_t lan_if_type = {
{ &mp_type_type },
.name = MP_QSTR_LAN,
.locals_dict = (mp_obj_dict_t *)&lan_if_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
lan_if_type,
MP_QSTR_LAN,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_dict_t *)&lan_if_locals_dict
);
#endif

View File

@ -278,8 +278,10 @@ STATIC const mp_rom_map_elem_t ppp_if_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(ppp_if_locals_dict, ppp_if_locals_dict_table);
const mp_obj_type_t ppp_if_type = {
{ &mp_type_type },
.name = MP_QSTR_PPP,
.locals_dict = (mp_obj_dict_t *)&ppp_if_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
ppp_if_type,
MP_QSTR_PPP,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_dict_t *)&ppp_if_locals_dict
);

View File

@ -47,9 +47,8 @@
#error WIFI_MODE_STA and WIFI_MODE_AP are supposed to be bitfields!
#endif
STATIC const mp_obj_type_t wlan_if_type;
STATIC const wlan_if_obj_t wlan_sta_obj = {{&wlan_if_type}, WIFI_IF_STA};
STATIC const wlan_if_obj_t wlan_ap_obj = {{&wlan_if_type}, WIFI_IF_AP};
STATIC const wlan_if_obj_t wlan_sta_obj;
STATIC const wlan_if_obj_t wlan_ap_obj;
// Set to "true" if esp_wifi_start() was called
static bool wifi_started = false;
@ -616,10 +615,15 @@ STATIC const mp_rom_map_elem_t wlan_if_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(wlan_if_locals_dict, wlan_if_locals_dict_table);
STATIC const mp_obj_type_t wlan_if_type = {
{ &mp_type_type },
.name = MP_QSTR_WLAN,
.locals_dict = (mp_obj_t)&wlan_if_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
wlan_if_type,
MP_QSTR_WLAN,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_dict_t *)&wlan_if_locals_dict
);
STATIC const wlan_if_obj_t wlan_sta_obj = {{&wlan_if_type}, WIFI_IF_STA};
STATIC const wlan_if_obj_t wlan_ap_obj = {{&wlan_if_type}, WIFI_IF_AP};
#endif // MICROPY_PY_NETWORK_WLAN

View File

@ -89,10 +89,11 @@ STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
const mp_obj_type_t machine_adc_type = {
{ &mp_type_type },
.name = MP_QSTR_ADC,
.print = machine_adc_print,
.make_new = machine_adc_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_adc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_adc_type,
MP_QSTR_ADC,
MP_TYPE_FLAG_NONE,
machine_adc_make_new,
print, machine_adc_print,
locals_dict, (mp_obj_dict_t *)&machine_adc_locals_dict
);

View File

@ -175,13 +175,14 @@ STATIC const mp_machine_spi_p_t machine_hspi_p = {
.transfer = machine_hspi_transfer,
};
const mp_obj_type_t machine_hspi_type = {
{ &mp_type_type },
.name = MP_QSTR_HSPI,
.print = machine_hspi_print,
.make_new = machine_hspi_make_new,
.protocol = &machine_hspi_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hspi_type,
MP_QSTR_HSPI,
MP_TYPE_FLAG_NONE,
machine_hspi_make_new,
print, machine_hspi_print,
protocol, &machine_hspi_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_spi_locals_dict
);
#endif // MICROPY_PY_MACHINE_SPI

View File

@ -450,15 +450,16 @@ STATIC const mp_pin_p_t pin_pin_p = {
.ioctl = pin_ioctl,
};
const mp_obj_type_t pyb_pin_type = {
{ &mp_type_type },
.name = MP_QSTR_Pin,
.print = pyb_pin_print,
.make_new = mp_pin_make_new,
.call = pyb_pin_call,
.protocol = &pin_pin_p,
.locals_dict = (mp_obj_dict_t *)&pyb_pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_pin_type,
MP_QSTR_Pin,
MP_TYPE_FLAG_NONE,
mp_pin_make_new,
print, pyb_pin_print,
call, pyb_pin_call,
protocol, &pin_pin_p,
locals_dict, (mp_obj_dict_t *)&pyb_pin_locals_dict
);
/******************************************************************************/
// Pin IRQ object
@ -509,11 +510,13 @@ STATIC const mp_rom_map_elem_t pin_irq_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pin_irq_locals_dict, pin_irq_locals_dict_table);
STATIC const mp_obj_type_t pin_irq_type = {
{ &mp_type_type },
.name = MP_QSTR_IRQ,
.call = pin_irq_call,
.locals_dict = (mp_obj_dict_t *)&pin_irq_locals_dict,
};
STATIC MP_DEFINE_CONST_OBJ_TYPE(
pin_irq_type,
MP_QSTR_IRQ,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
call, pin_irq_call,
locals_dict, (mp_obj_dict_t *)&pin_irq_locals_dict
);
MP_REGISTER_ROOT_POINTER(mp_obj_t pin_irq_handler[16]);

View File

@ -262,9 +262,10 @@ STATIC const mp_rom_map_elem_t pyb_rtc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pyb_rtc_locals_dict, pyb_rtc_locals_dict_table);
const mp_obj_type_t pyb_rtc_type = {
{ &mp_type_type },
.name = MP_QSTR_RTC,
.make_new = pyb_rtc_make_new,
.locals_dict = (mp_obj_dict_t *)&pyb_rtc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_rtc_type,
MP_QSTR_RTC,
MP_TYPE_FLAG_NONE,
pyb_rtc_make_new,
locals_dict, (mp_obj_dict_t *)&pyb_rtc_locals_dict
);

View File

@ -343,15 +343,16 @@ STATIC const mp_stream_p_t uart_stream_p = {
.is_text = false,
};
const mp_obj_type_t pyb_uart_type = {
{ &mp_type_type },
.name = MP_QSTR_UART,
.print = pyb_uart_print,
.make_new = pyb_uart_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &uart_stream_p,
.locals_dict = (mp_obj_dict_t *)&pyb_uart_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pyb_uart_type,
MP_QSTR_UART,
MP_TYPE_FLAG_NONE,
pyb_uart_make_new,
print, pyb_uart_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &uart_stream_p,
locals_dict, (mp_obj_dict_t *)&pyb_uart_locals_dict
);
MP_REGISTER_ROOT_POINTER(byte * uart0_rxbuf);

View File

@ -69,9 +69,10 @@ STATIC const mp_rom_map_elem_t machine_wdt_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_wdt_locals_dict, machine_wdt_locals_dict_table);
const mp_obj_type_t esp_wdt_type = {
{ &mp_type_type },
.name = MP_QSTR_WDT,
.make_new = machine_wdt_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_wdt_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp_wdt_type,
MP_QSTR_WDT,
MP_TYPE_FLAG_NONE,
machine_wdt_make_new,
locals_dict, (mp_obj_dict_t *)&machine_wdt_locals_dict
);

View File

@ -337,13 +337,14 @@ STATIC const mp_rom_map_elem_t esp_timer_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(esp_timer_locals_dict, esp_timer_locals_dict_table);
const mp_obj_type_t esp_timer_type = {
{ &mp_type_type },
.name = MP_QSTR_Timer,
.print = esp_timer_print,
.make_new = esp_timer_make_new,
.locals_dict = (mp_obj_dict_t *)&esp_timer_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
esp_timer_type,
MP_QSTR_Timer,
MP_TYPE_FLAG_NONE,
esp_timer_make_new,
print, esp_timer_print,
locals_dict, (mp_obj_dict_t *)&esp_timer_locals_dict
);
// this bit is unused in the Xtensa PS register
#define ETS_LOOP_ITER_BIT (12)

View File

@ -510,11 +510,13 @@ STATIC const mp_rom_map_elem_t wlan_if_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(wlan_if_locals_dict, wlan_if_locals_dict_table);
const mp_obj_type_t wlan_if_type = {
{ &mp_type_type },
.name = MP_QSTR_WLAN,
.locals_dict = (mp_obj_dict_t *)&wlan_if_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
wlan_if_type,
MP_QSTR_WLAN,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_dict_t *)&wlan_if_locals_dict
);
STATIC mp_obj_t esp_phy_mode(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {

View File

@ -117,13 +117,14 @@ STATIC const mp_rom_map_elem_t adc_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(adc_locals_dict, adc_locals_dict_table);
const mp_obj_type_t machine_adc_type = {
{&mp_type_type},
.name = MP_QSTR_ADC,
.print = adc_obj_print,
.make_new = adc_obj_make_new,
.locals_dict = (mp_obj_dict_t *)&adc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_adc_type,
MP_QSTR_ADC,
MP_TYPE_FLAG_NONE,
adc_obj_make_new,
print, adc_obj_print,
locals_dict, (mp_obj_dict_t *)&adc_locals_dict
);
void machine_adc_init(void) {
for (int i = 1; i < sizeof(adc_bases) / sizeof(ADC_Type *); ++i) {

View File

@ -197,11 +197,12 @@ STATIC const mp_machine_i2c_p_t machine_i2c_p = {
.transfer_single = machine_i2c_transfer_single,
};
const mp_obj_type_t machine_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_I2C,
.print = machine_i2c_print,
.make_new = machine_i2c_make_new,
.protocol = &machine_i2c_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_i2c_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_i2c_type,
MP_QSTR_I2C,
MP_TYPE_FLAG_NONE,
machine_i2c_make_new,
print, machine_i2c_print,
protocol, &machine_i2c_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_i2c_locals_dict
);

View File

@ -1213,16 +1213,17 @@ STATIC const mp_stream_p_t i2s_stream_p = {
.is_text = false,
};
const mp_obj_type_t machine_i2s_type = {
{ &mp_type_type },
.name = MP_QSTR_I2S,
.print = machine_i2s_print,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &i2s_stream_p,
.make_new = machine_i2s_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_i2s_type,
MP_QSTR_I2S,
MP_TYPE_FLAG_NONE,
machine_i2s_make_new,
print, machine_i2s_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &i2s_stream_p,
locals_dict, (mp_obj_dict_t *)&machine_i2s_locals_dict
);
MP_REGISTER_ROOT_POINTER(struct _machine_i2s_obj_t *machine_i2s_obj[MICROPY_HW_I2S_NUM]);

View File

@ -80,12 +80,13 @@ STATIC const mp_rom_map_elem_t led_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(led_locals_dict, led_locals_dict_table);
const mp_obj_type_t machine_led_type = {
{&mp_type_type},
.name = MP_QSTR_LED,
.print = led_obj_print,
.make_new = led_obj_make_new,
.locals_dict = (mp_obj_dict_t *)&led_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_led_type,
MP_QSTR_LED,
MP_TYPE_FLAG_NONE,
led_obj_make_new,
print, led_obj_print,
locals_dict, (mp_obj_dict_t *)&led_locals_dict
);
#endif

View File

@ -58,17 +58,21 @@ enum {
};
// Pin mapping dictionaries
const mp_obj_type_t machine_pin_cpu_pins_obj_type = {
{ &mp_type_type },
.name = MP_QSTR_cpu,
.locals_dict = (mp_obj_t)&machine_pin_cpu_pins_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_cpu_pins_obj_type,
MP_QSTR_cpu,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_t)&machine_pin_cpu_pins_locals_dict
);
const mp_obj_type_t machine_pin_board_pins_obj_type = {
{ &mp_type_type },
.name = MP_QSTR_board,
.locals_dict = (mp_obj_t)&machine_pin_board_pins_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_board_pins_obj_type,
MP_QSTR_board,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_t)&machine_pin_board_pins_locals_dict
);
STATIC const mp_irq_methods_t machine_pin_irq_methods;
@ -396,7 +400,6 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_pin_locals_dict, machine_pin_locals_dict_table);
STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
machine_pin_obj_t *self = self_in;
@ -417,24 +420,26 @@ STATIC const mp_pin_p_t machine_pin_obj_protocol = {
.ioctl = machine_pin_ioctl,
};
const mp_obj_type_t machine_pin_type = {
{&mp_type_type},
.name = MP_QSTR_Pin,
.print = machine_pin_obj_print,
.call = machine_pin_obj_call,
.make_new = mp_pin_make_new,
.protocol = &machine_pin_obj_protocol,
.locals_dict = (mp_obj_dict_t *)&machine_pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_type,
MP_QSTR_Pin,
MP_TYPE_FLAG_NONE,
mp_pin_make_new,
print, machine_pin_obj_print,
call, machine_pin_obj_call,
protocol, &machine_pin_obj_protocol,
locals_dict, (mp_obj_dict_t *)&machine_pin_locals_dict
);
// FIXME: Create actual pin_af type!!!
const mp_obj_type_t machine_pin_af_type = {
{&mp_type_type},
.name = MP_QSTR_PinAF,
.print = machine_pin_obj_print,
.make_new = mp_pin_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_pin_af_type,
MP_QSTR_PinAF,
MP_TYPE_FLAG_NONE,
mp_pin_make_new,
print, machine_pin_obj_print,
locals_dict, (mp_obj_dict_t *)&machine_pin_locals_dict
);
STATIC mp_uint_t machine_pin_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);

View File

@ -166,9 +166,10 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
const mp_obj_type_t machine_rtc_type = {
{ &mp_type_type },
.name = MP_QSTR_RTC,
.make_new = machine_rtc_make_new,
.locals_dict = (mp_obj_t)&machine_rtc_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_rtc_type,
MP_QSTR_RTC,
MP_TYPE_FLAG_NONE,
machine_rtc_make_new,
locals_dict, (mp_obj_t)&machine_rtc_locals_dict
);

View File

@ -208,12 +208,13 @@ STATIC const mp_rom_map_elem_t sdcard_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(sdcard_locals_dict, sdcard_locals_dict_table);
const mp_obj_type_t machine_sdcard_type = {
{ &mp_type_type },
.name = MP_QSTR_SDCard,
.make_new = sdcard_obj_make_new,
.locals_dict = (mp_obj_dict_t *)&sdcard_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_sdcard_type,
MP_QSTR_SDCard,
MP_TYPE_FLAG_NONE,
sdcard_obj_make_new,
locals_dict, (mp_obj_dict_t *)&sdcard_locals_dict
);
void machine_sdcard_init0(void) {
return;

View File

@ -251,11 +251,12 @@ STATIC const mp_machine_spi_p_t machine_spi_p = {
.transfer = machine_spi_transfer,
};
const mp_obj_type_t machine_spi_type = {
{ &mp_type_type },
.name = MP_QSTR_SPI,
.print = machine_spi_print,
.make_new = machine_spi_make_new,
.protocol = &machine_spi_p,
.locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_spi_type,
MP_QSTR_SPI,
MP_TYPE_FLAG_NONE,
machine_spi_make_new,
print, machine_spi_print,
protocol, &machine_spi_p,
locals_dict, (mp_obj_dict_t *)&mp_machine_spi_locals_dict
);

View File

@ -211,12 +211,13 @@ STATIC const mp_rom_map_elem_t machine_timer_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_timer_locals_dict, machine_timer_locals_dict_table);
const mp_obj_type_t machine_timer_type = {
{ &mp_type_type },
.name = MP_QSTR_Timer,
.print = machine_timer_print,
.make_new = machine_timer_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_timer_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_timer_type,
MP_QSTR_Timer,
MP_TYPE_FLAG_NONE,
machine_timer_make_new,
print, machine_timer_print,
locals_dict, (mp_obj_dict_t *)&machine_timer_locals_dict
);
MP_REGISTER_ROOT_POINTER(struct _machine_timer_obj_t *timer_table[MICROPY_HW_PIT_NUM_CHANNELS]);

View File

@ -469,13 +469,14 @@ STATIC const mp_stream_p_t uart_stream_p = {
.is_text = false,
};
const mp_obj_type_t machine_uart_type = {
{ &mp_type_type },
.name = MP_QSTR_UART,
.print = machine_uart_print,
.make_new = machine_uart_make_new,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &uart_stream_p,
.locals_dict = (mp_obj_dict_t *)&machine_uart_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_uart_type,
MP_QSTR_UART,
MP_TYPE_FLAG_NONE,
machine_uart_make_new,
print, machine_uart_print,
getiter, mp_identity_getiter,
iternext, mp_stream_unbuffered_iter,
protocol, &uart_stream_p,
locals_dict, (mp_obj_dict_t *)&machine_uart_locals_dict
);

View File

@ -99,9 +99,10 @@ STATIC const mp_rom_map_elem_t machine_wdt_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(machine_wdt_locals_dict, machine_wdt_locals_dict_table);
const mp_obj_type_t machine_wdt_type = {
{ &mp_type_type },
.name = MP_QSTR_WDT,
.make_new = machine_wdt_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_wdt_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_wdt_type,
MP_QSTR_WDT,
MP_TYPE_FLAG_NONE,
machine_wdt_make_new,
locals_dict, (mp_obj_dict_t *)&machine_wdt_locals_dict
);

View File

@ -215,9 +215,10 @@ STATIC const mp_rom_map_elem_t mimxrt_flash_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(mimxrt_flash_locals_dict, mimxrt_flash_locals_dict_table);
const mp_obj_type_t mimxrt_flash_type = {
{ &mp_type_type },
.name = MP_QSTR_Flash,
.make_new = mimxrt_flash_make_new,
.locals_dict = (mp_obj_dict_t *)&mimxrt_flash_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
mimxrt_flash_type,
MP_QSTR_Flash,
MP_TYPE_FLAG_NONE,
mimxrt_flash_make_new,
locals_dict, (mp_obj_dict_t *)&mimxrt_flash_locals_dict
);

View File

@ -220,12 +220,14 @@ STATIC const mp_rom_map_elem_t network_lan_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(network_lan_locals_dict, network_lan_locals_dict_table);
const mp_obj_type_t network_lan_type = {
{ &mp_type_type },
.name = MP_QSTR_LAN,
.print = network_lan_print,
.make_new = network_lan_make_new,
.locals_dict = (mp_obj_dict_t *)&network_lan_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
network_lan_type,
MP_QSTR_LAN,
MP_TYPE_FLAG_NONE,
network_lan_make_new,
print, network_lan_print,
locals_dict, (mp_obj_dict_t *)&network_lan_locals_dict
);
#endif // defined(MICROPY_HW_ETH_MDC)

View File

@ -43,12 +43,14 @@ static mp_obj_t microbit_repeat_iter_next(mp_obj_t iter_in) {
return mp_obj_subscr(iter->iterable, MP_OBJ_NEW_SMALL_INT(iter->index), MP_OBJ_SENTINEL);
}
const mp_obj_type_t microbit_repeat_iterator_type = {
{ &mp_type_type },
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = microbit_repeat_iter_next,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_repeat_iterator_type,
MP_QSTR_iterator,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, mp_identity_getiter,
iternext, microbit_repeat_iter_next
);
mp_obj_t microbit_repeat_iterator(mp_obj_t iterable) {
repeat_iterator_t *result = mp_obj_malloc(repeat_iterator_t, &microbit_repeat_iterator_type);

View File

@ -542,11 +542,13 @@ STATIC const mp_rom_map_elem_t microbit_display_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(microbit_display_locals_dict, microbit_display_locals_dict_table);
const mp_obj_type_t microbit_display_type = {
{ &mp_type_type },
.name = MP_QSTR_MicroBitDisplay,
.locals_dict = (mp_obj_dict_t*)&microbit_display_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_display_type,
MP_QSTR_MicroBitDisplay,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
locals_dict, (mp_obj_dict_t*)&microbit_display_locals_dict
);
microbit_display_obj_t microbit_display_obj = {
{&microbit_display_type},

View File

@ -678,14 +678,15 @@ STATIC mp_obj_t image_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
}
const mp_obj_type_t microbit_image_type = {
{ &mp_type_type },
.name = MP_QSTR_MicroBitImage,
.print = microbit_image_print,
.make_new = microbit_image_make_new,
.binary_op = image_binary_op,
.locals_dict = (mp_obj_dict_t*)&microbit_image_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_image_type,
MP_QSTR_MicroBitImage,
MP_TYPE_FLAG_NONE,
microbit_image_make_new,
print, microbit_image_print,
binary_op, image_binary_op,
locals_dict, (mp_obj_dict_t*)&microbit_image_locals_dict
);
typedef struct _scrolling_string_t {
mp_obj_base_t base;
@ -820,18 +821,22 @@ STATIC mp_obj_t microbit_scrolling_string_iter_next(mp_obj_t o_in) {
return iter->img;
}
const mp_obj_type_t microbit_scrolling_string_type = {
{ &mp_type_type },
.name = MP_QSTR_ScrollingString,
.getiter = get_microbit_scrolling_string_iter,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_scrolling_string_type,
MP_QSTR_ScrollingString,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, get_microbit_scrolling_string_iter
);
const mp_obj_type_t microbit_scrolling_string_iterator_type = {
{ &mp_type_type },
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = microbit_scrolling_string_iter_next,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_scrolling_string_iterator_type,
MP_QSTR_iterator,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, mp_identity_getiter,
iternext, microbit_scrolling_string_iter_next
);
/** Facade types to present a string as a sequence of images.
* These are necessary to avoid allocation during iteration,
@ -869,13 +874,15 @@ static mp_obj_t facade_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
static mp_obj_t microbit_facade_iterator(mp_obj_t iterable_in, mp_obj_iter_buf_t *iter_buf);
const mp_obj_type_t string_image_facade_type = {
{ &mp_type_type },
.name = MP_QSTR_Facade,
.unary_op = facade_unary_op,
.subscr = string_image_facade_subscr,
.getiter = microbit_facade_iterator,
};
MP_DEFINE_CONST_OBJ_TYPE(
string_image_facade_type,
MP_QSTR_Facade,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
unary_op, facade_unary_op,
subscr, string_image_facade_subscr,
getiter, microbit_facade_iterator
);
typedef struct _facade_iterator_t {
@ -904,12 +911,14 @@ static mp_obj_t microbit_facade_iter_next(mp_obj_t iter_in) {
return iter->image;
}
const mp_obj_type_t microbit_facade_iterator_type = {
{ &mp_type_type },
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = microbit_facade_iter_next,
};
MP_DEFINE_CONST_OBJ_TYPE(
microbit_facade_iterator_type,
MP_QSTR_iterator,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
getiter, mp_identity_getiter,
iternext, microbit_facade_iter_next
);
mp_obj_t microbit_facade_iterator(mp_obj_t iterable_in, mp_obj_iter_buf_t *iter_buf) {
(void)iter_buf;

View File

@ -194,13 +194,14 @@ STATIC const mp_rom_map_elem_t led_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(led_locals_dict, led_locals_dict_table);
const mp_obj_type_t board_led_type = {
{ &mp_type_type },
.name = MP_QSTR_LED,
.print = led_obj_print,
.make_new = led_obj_make_new,
.locals_dict = (mp_obj_dict_t*)&led_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
board_led_type,
MP_QSTR_LED,
MP_TYPE_FLAG_NONE,
led_obj_make_new,
print, led_obj_print,
locals_dict, (mp_obj_dict_t*)&led_locals_dict
);
#else
// For boards with no LEDs, we leave an empty function here so that we don't

View File

@ -294,12 +294,13 @@ STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
const mp_obj_type_t machine_adc_type = {
{ &mp_type_type },
.name = MP_QSTR_ADC,
.make_new = machine_adc_make_new,
.locals_dict = (mp_obj_dict_t*)&machine_adc_locals_dict,
.print = machine_adc_print,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_adc_type,
MP_QSTR_ADC,
MP_TYPE_FLAG_NONE,
machine_adc_make_new,
locals_dict, (mp_obj_dict_t*)&machine_adc_locals_dict,
print, machine_adc_print
);
#endif // MICROPY_PY_MACHINE_ADC

View File

@ -161,13 +161,14 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
.transfer_single = machine_hard_i2c_transfer_single,
};
const mp_obj_type_t machine_hard_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_I2C,
.print = machine_hard_i2c_print,
.make_new = machine_hard_i2c_make_new,
.protocol = &machine_hard_i2c_p,
.locals_dict = (mp_obj_dict_t*)&mp_machine_i2c_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_i2c_type,
MP_QSTR_I2C,
MP_TYPE_FLAG_NONE,
machine_hard_i2c_make_new,
print, machine_hard_i2c_print,
protocol, &machine_hard_i2c_p,
locals_dict, (mp_obj_dict_t*)&mp_machine_i2c_locals_dict
);
#endif // MICROPY_PY_MACHINE_I2C

View File

@ -596,14 +596,15 @@ STATIC const mp_rom_map_elem_t pin_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pin_locals_dict, pin_locals_dict_table);
const mp_obj_type_t pin_type = {
{ &mp_type_type },
.name = MP_QSTR_Pin,
.print = pin_print,
.make_new = pin_make_new,
.call = pin_call,
.locals_dict = (mp_obj_dict_t*)&pin_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pin_type,
MP_QSTR_Pin,
MP_TYPE_FLAG_NONE,
pin_make_new,
print, pin_print,
call, pin_call,
locals_dict, (mp_obj_dict_t*)&pin_locals_dict
);
/// \moduleref machine
/// \class PinAF - Pin Alternate Functions
@ -671,12 +672,14 @@ STATIC const mp_rom_map_elem_t pin_af_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(pin_af_locals_dict, pin_af_locals_dict_table);
const mp_obj_type_t pin_af_type = {
{ &mp_type_type },
.name = MP_QSTR_PinAF,
.print = pin_af_obj_print,
.locals_dict = (mp_obj_dict_t*)&pin_af_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
pin_af_type,
MP_QSTR_PinAF,
MP_TYPE_FLAG_NONE,
MP_TYPE_NULL_MAKE_NEW,
print, pin_af_obj_print,
locals_dict, (mp_obj_dict_t*)&pin_af_locals_dict
);
MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_mapper);
MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_map_dict);

View File

@ -339,12 +339,13 @@ STATIC mp_obj_t machine_hard_pwm_freq(mp_obj_t self_in, mp_arg_val_t *args) {
return mp_const_none;
}
const mp_obj_type_t machine_hard_pwm_type = {
{ &mp_type_type },
.name = MP_QSTR_PWM,
.print = machine_pwm_print,
.make_new = machine_pwm_make_new,
.locals_dict = (mp_obj_dict_t*)&machine_pwm_locals_dict,
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_pwm_type,
MP_QSTR_PWM,
MP_TYPE_FLAG_NONE,
machine_pwm_make_new,
print, machine_pwm_print,
locals_dict, (mp_obj_dict_t*)&machine_pwm_locals_dict
);
#endif // MICROPY_PY_MACHINE_HW_PWM

View File

@ -262,12 +262,13 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
const mp_obj_type_t machine_rtcounter_type = {
{ &mp_type_type },
.name = MP_QSTR_RTCounter,
.print = rtc_print,
.make_new = machine_rtc_make_new,
.locals_dict = (mp_obj_dict_t*)&machine_rtc_locals_dict
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_rtcounter_type,
MP_QSTR_RTCounter,
MP_TYPE_FLAG_NONE,
machine_rtc_make_new,
print, rtc_print,
locals_dict, (mp_obj_dict_t*)&machine_rtc_locals_dict
);
#endif // MICROPY_PY_MACHINE_RTCOUNTER

Some files were not shown because too many files have changed in this diff Show More