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

@@ -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)