py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other methods. This is a marginal code size improvement because most types have a make_new (100/138 on PYBV11), however it improves consistency in how types are declared, removing the special case for make_new. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
6da41b5900
commit
94beeabd2e
@@ -93,7 +93,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_adc_type,
|
||||
MP_QSTR_ADC,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_adc_make_new,
|
||||
make_new, machine_adc_make_new,
|
||||
print, machine_adc_print,
|
||||
locals_dict, &machine_adc_locals_dict
|
||||
);
|
||||
|
||||
@@ -179,7 +179,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_hspi_type,
|
||||
MP_QSTR_HSPI,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_hspi_make_new,
|
||||
make_new, machine_hspi_make_new,
|
||||
print, machine_hspi_print,
|
||||
protocol, &machine_hspi_p,
|
||||
locals_dict, &mp_machine_spi_locals_dict
|
||||
|
||||
@@ -454,7 +454,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pyb_pin_type,
|
||||
MP_QSTR_Pin,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
mp_pin_make_new,
|
||||
make_new, mp_pin_make_new,
|
||||
print, pyb_pin_print,
|
||||
call, pyb_pin_call,
|
||||
protocol, &pin_pin_p,
|
||||
@@ -514,7 +514,6 @@ 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, &pin_irq_locals_dict
|
||||
);
|
||||
|
||||
@@ -266,6 +266,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pyb_rtc_type,
|
||||
MP_QSTR_RTC,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
pyb_rtc_make_new,
|
||||
make_new, pyb_rtc_make_new,
|
||||
locals_dict, &pyb_rtc_locals_dict
|
||||
);
|
||||
|
||||
@@ -347,7 +347,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pyb_uart_type,
|
||||
MP_QSTR_UART,
|
||||
MP_TYPE_FLAG_ITER_IS_STREAM,
|
||||
pyb_uart_make_new,
|
||||
make_new, pyb_uart_make_new,
|
||||
print, pyb_uart_print,
|
||||
protocol, &uart_stream_p,
|
||||
locals_dict, &pyb_uart_locals_dict
|
||||
|
||||
@@ -73,6 +73,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
esp_wdt_type,
|
||||
MP_QSTR_WDT,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_wdt_make_new,
|
||||
make_new, machine_wdt_make_new,
|
||||
locals_dict, &machine_wdt_locals_dict
|
||||
);
|
||||
|
||||
@@ -68,7 +68,7 @@ STATIC void mp_reset(void) {
|
||||
mp_obj_t args[2];
|
||||
args[0] = MP_OBJ_NEW_SMALL_INT(0);
|
||||
args[1] = MP_OBJ_NEW_SMALL_INT(115200);
|
||||
args[0] = pyb_uart_type.make_new(&pyb_uart_type, 2, 0, args);
|
||||
args[0] = MP_OBJ_TYPE_GET_SLOT(&pyb_uart_type, make_new)(&pyb_uart_type, 2, 0, args);
|
||||
args[1] = MP_OBJ_NEW_SMALL_INT(1);
|
||||
mp_uos_dupterm_obj.fun.var(2, args);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
esp_timer_type,
|
||||
MP_QSTR_Timer,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
esp_timer_make_new,
|
||||
make_new, esp_timer_make_new,
|
||||
print, esp_timer_print,
|
||||
locals_dict, &esp_timer_locals_dict
|
||||
);
|
||||
|
||||
@@ -514,7 +514,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
wlan_if_type,
|
||||
MP_QSTR_WLAN,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
locals_dict, &wlan_if_locals_dict
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user