Skip to content

Commit

Permalink
py/obj: Convert make_new into a mp_obj_type_t slot.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jimmo authored and dpgeorge committed Sep 19, 2022
1 parent 6da41b5 commit 94beeab
Show file tree
Hide file tree
Showing 248 changed files with 316 additions and 397 deletions.
2 changes: 1 addition & 1 deletion drivers/ninaw10/nina_wifi_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int nina_bsp_init(void) {
MP_OBJ_NEW_SMALL_INT(MICROPY_HW_WIFI_SPI_BAUDRATE),
};

MP_STATE_PORT(mp_wifi_spi) = machine_spi_type.make_new((mp_obj_t)&machine_spi_type, 2, 0, args);
MP_STATE_PORT(mp_wifi_spi) = MP_OBJ_TYPE_GET_SLOT(&machine_spi_type, make_new)((mp_obj_t)&machine_spi_type, 2, 0, args);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/natmod/framebuf/framebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a

mp_type_framebuf.base.type = (void*)&mp_type_type;
mp_type_framebuf.name = MP_QSTR_FrameBuffer;
mp_type_framebuf.make_new = framebuf_make_new;
MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, buffer, framebuf_get_buffer, 0);
MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, make_new, framebuf_make_new, 0);
MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, buffer, framebuf_get_buffer, 1);
framebuf_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_fill), MP_OBJ_FROM_PTR(&framebuf_fill_obj) };
framebuf_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_fill_rect), MP_OBJ_FROM_PTR(&framebuf_fill_rect_obj) };
framebuf_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_pixel), MP_OBJ_FROM_PTR(&framebuf_pixel_obj) };
Expand All @@ -33,7 +33,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a
framebuf_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_blit), MP_OBJ_FROM_PTR(&framebuf_blit_obj) };
framebuf_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_scroll), MP_OBJ_FROM_PTR(&framebuf_scroll_obj) };
framebuf_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_text), MP_OBJ_FROM_PTR(&framebuf_text_obj) };
MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, locals_dict, (void*)&framebuf_locals_dict, 1);
MP_OBJ_TYPE_SET_SLOT(&mp_type_framebuf, locals_dict, (void*)&framebuf_locals_dict, 2);

mp_store_global(MP_QSTR_FrameBuffer, MP_OBJ_FROM_PTR(&mp_type_framebuf));
mp_store_global(MP_QSTR_FrameBuffer1, MP_OBJ_FROM_PTR(&legacy_framebuffer1_obj));
Expand Down
6 changes: 3 additions & 3 deletions examples/natmod/uzlib/uzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a

decompio_type.base.type = mp_fun_table.type_type;
decompio_type.name = MP_QSTR_DecompIO;
decompio_type.make_new = &decompio_make_new;
MP_OBJ_TYPE_SET_SLOT(&decompio_type, protocol, &decompio_stream_p, 0);
MP_OBJ_TYPE_SET_SLOT(&decompio_type, make_new, &decompio_make_new, 0);
MP_OBJ_TYPE_SET_SLOT(&decompio_type, protocol, &decompio_stream_p, 1);
decompio_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_read), MP_OBJ_FROM_PTR(&mp_stream_read_obj) };
decompio_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_OBJ_FROM_PTR(&mp_stream_readinto_obj) };
decompio_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_readline), MP_OBJ_FROM_PTR(&mp_stream_unbuffered_readline_obj) };
MP_OBJ_TYPE_SET_SLOT(&decompio_type, locals_dict, (void*)&decompio_locals_dict, 1);
MP_OBJ_TYPE_SET_SLOT(&decompio_type, locals_dict, (void*)&decompio_locals_dict, 2);

mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_uzlib));
mp_store_global(MP_QSTR_decompress, MP_OBJ_FROM_PTR(&mod_uzlib_decompress_obj));
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_machine_soft_i2c_type,
MP_QSTR_SoftI2C,
MP_TYPE_FLAG_NONE,
mp_machine_soft_i2c_make_new,
make_new, mp_machine_soft_i2c_make_new,
print, mp_machine_soft_i2c_print,
protocol, &mp_machine_soft_i2c_p,
locals_dict, &mp_machine_i2c_locals_dict
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
--n_args; \
++all_args; \
} \
return mp_machine_soft_i2c_type.make_new(&mp_machine_soft_i2c_type, n_args, n_kw, all_args); \
return MP_OBJ_TYPE_GET_SLOT(&mp_machine_soft_i2c_type, make_new)(&mp_machine_soft_i2c_type, n_args, n_kw, all_args); \
} \
} while (0)

Expand Down
1 change: 0 additions & 1 deletion extmod/machine_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ 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
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_pinbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
machine_pinbase_type,
MP_QSTR_PinBase,
MP_TYPE_FLAG_NONE,
pinbase_make_new,
make_new, pinbase_make_new,
protocol, &pinbase_pin_p
);

Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
machine_pwm_type,
MP_QSTR_PWM,
MP_TYPE_FLAG_NONE,
mp_machine_pwm_make_new,
make_new, mp_machine_pwm_make_new,
print, mp_machine_pwm_print,
locals_dict, &machine_pwm_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
machine_signal_type,
MP_QSTR_Signal,
MP_TYPE_FLAG_NONE,
signal_make_new,
make_new, signal_make_new,
call, signal_call,
protocol, &signal_pin_p,
locals_dict, &signal_locals_dict
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_machine_soft_spi_type,
MP_QSTR_SoftSPI,
MP_TYPE_FLAG_NONE,
mp_machine_soft_spi_make_new,
make_new, mp_machine_soft_spi_make_new,
print, mp_machine_soft_spi_print,
protocol, &mp_machine_soft_spi_p,
locals_dict, &mp_machine_spi_locals_dict
Expand Down
2 changes: 1 addition & 1 deletion extmod/machine_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
--n_args; \
++all_args; \
} \
return mp_machine_soft_spi_type.make_new(&mp_machine_soft_spi_type, n_args, n_kw, all_args); \
return MP_OBJ_TYPE_GET_SLOT(&mp_machine_soft_spi_type, make_new)(&mp_machine_soft_spi_type, n_args, n_kw, all_args); \
} \
} while (0)

Expand Down
4 changes: 2 additions & 2 deletions extmod/modbluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_type_bluetooth_uuid,
MP_QSTR_UUID,
MP_TYPE_FLAG_NONE,
bluetooth_uuid_make_new,
make_new, bluetooth_uuid_make_new,
unary_op, bluetooth_uuid_unary_op,
binary_op, bluetooth_uuid_binary_op,
print, bluetooth_uuid_print,
Expand Down Expand Up @@ -980,7 +980,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_bluetooth_ble,
MP_QSTR_BLE,
MP_TYPE_FLAG_NONE,
bluetooth_ble_make_new,
make_new, bluetooth_ble_make_new,
locals_dict, &bluetooth_ble_locals_dict
);

Expand Down
1 change: 0 additions & 1 deletion extmod/modbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
btree_type,
MP_QSTR_btree,
MP_TYPE_FLAG_ITER_IS_CUSTOM,
MP_TYPE_NULL_MAKE_NEW,
// Save on qstr's, reuse same as for module
print, btree_print,
iter, &btree_getiter_iternext,
Expand Down
2 changes: 1 addition & 1 deletion extmod/modframebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_framebuf,
MP_QSTR_FrameBuffer,
MP_TYPE_FLAG_NONE,
framebuf_make_new,
make_new, framebuf_make_new,
buffer, framebuf_get_buffer,
locals_dict, &framebuf_locals_dict
);
Expand Down
4 changes: 2 additions & 2 deletions extmod/modlwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
lwip_slip_type,
MP_QSTR_slip,
MP_TYPE_FLAG_NONE,
lwip_slip_make_new,
make_new, lwip_slip_make_new,
locals_dict, &lwip_slip_locals_dict
);

Expand Down Expand Up @@ -1599,7 +1599,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
lwip_socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
lwip_socket_make_new,
make_new, lwip_socket_make_new,
print, lwip_socket_print,
protocol, &lwip_socket_stream_p,
locals_dict, &lwip_socket_locals_dict
Expand Down
4 changes: 2 additions & 2 deletions extmod/moduasyncio.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
task_queue_type,
MP_QSTR_TaskQueue,
MP_TYPE_FLAG_NONE,
task_queue_make_new,
make_new, task_queue_make_new,
locals_dict, &task_queue_locals_dict
);

Expand Down Expand Up @@ -296,7 +296,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
task_type,
MP_QSTR_Task,
MP_TYPE_FLAG_ITER_IS_CUSTOM,
task_make_new,
make_new, task_make_new,
attr, task_attr,
iter, &task_getiter_iternext
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/moducryptolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
ucryptolib_aes_type,
MP_QSTR_aes,
MP_TYPE_FLAG_NONE,
ucryptolib_aes_make_new,
make_new, ucryptolib_aes_make_new,
locals_dict, &ucryptolib_aes_locals_dict
);

Expand Down
2 changes: 1 addition & 1 deletion extmod/moductypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
uctypes_struct_type,
MP_QSTR_struct,
MP_TYPE_FLAG_NONE,
uctypes_struct_make_new,
make_new, uctypes_struct_make_new,
print, uctypes_struct_print,
attr, uctypes_struct_attr,
subscr, uctypes_struct_subscr,
Expand Down
6 changes: 3 additions & 3 deletions extmod/moduhashlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_sha256_type,
MP_QSTR_sha256,
MP_TYPE_FLAG_NONE,
uhashlib_sha256_make_new,
make_new, uhashlib_sha256_make_new,
locals_dict, &uhashlib_sha256_locals_dict
);
#endif
Expand Down Expand Up @@ -255,7 +255,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_sha1_type,
MP_QSTR_sha1,
MP_TYPE_FLAG_NONE,
uhashlib_sha1_make_new,
make_new, uhashlib_sha1_make_new,
locals_dict, &uhashlib_sha1_locals_dict
);
#endif
Expand Down Expand Up @@ -349,7 +349,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
uhashlib_md5_type,
MP_QSTR_md5,
MP_TYPE_FLAG_NONE,
uhashlib_md5_make_new,
make_new, uhashlib_md5_make_new,
locals_dict, &uhashlib_md5_locals_dict
);
#endif // MICROPY_PY_UHASHLIB_MD5
Expand Down
2 changes: 0 additions & 2 deletions extmod/modure.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ 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, &match_locals_dict
);
Expand Down Expand Up @@ -417,7 +416,6 @@ 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, &re_locals_dict
);
Expand Down
1 change: 0 additions & 1 deletion extmod/moduselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_poll,
MP_QSTR_poll,
MP_TYPE_FLAG_ITER_IS_ITERNEXT,
MP_TYPE_NULL_MAKE_NEW,
iter, poll_iternext,
locals_dict, &poll_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/modusocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
socket_type,
MP_QSTR_socket,
MP_TYPE_FLAG_NONE,
socket_make_new,
make_new, socket_make_new,
protocol, &socket_stream_p,
locals_dict, &socket_locals_dict,
print, socket_print
Expand Down
1 change: 0 additions & 1 deletion extmod/modussl_axtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ 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
print, ussl_socket_print,
protocol, &ussl_socket_stream_p,
Expand Down
1 change: 0 additions & 1 deletion extmod/modussl_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ 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
print, socket_print,
protocol, &ussl_socket_stream_p,
Expand Down
2 changes: 1 addition & 1 deletion extmod/modutimeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
utimeq_type,
MP_QSTR_utimeq,
MP_TYPE_FLAG_NONE,
utimeq_make_new,
make_new, utimeq_make_new,
unary_op, utimeq_unary_op,
locals_dict, &utimeq_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/moduwebsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
websocket_type,
MP_QSTR_websocket,
MP_TYPE_FLAG_NONE,
websocket_make_new,
make_new, websocket_make_new,
protocol, &websocket_stream_p,
locals_dict, &websocket_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/moduzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
decompio_type,
MP_QSTR_DecompIO,
MP_TYPE_FLAG_NONE,
decompio_make_new,
make_new, decompio_make_new,
protocol, &decompio_stream_p,
locals_dict, &decompio_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/modwebrepl.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
webrepl_type,
MP_QSTR__webrepl,
MP_TYPE_FLAG_NONE,
webrepl_make_new,
make_new, webrepl_make_new,
protocol, &webrepl_stream_p,
locals_dict, &webrepl_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion extmod/network_cyw43.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_network_cyw43_type,
MP_QSTR_CYW43,
MP_TYPE_FLAG_NONE,
network_cyw43_make_new,
make_new, network_cyw43_make_new,
print, network_cyw43_print,
locals_dict, &network_cyw43_locals_dict
);
Expand Down
4 changes: 2 additions & 2 deletions extmod/network_ninaw10.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ STATIC mp_obj_t network_ninaw10_active(size_t n_args, const mp_obj_t *args) {
MP_OBJ_NEW_QSTR(MP_QSTR_freq), MP_OBJ_NEW_SMALL_INT(10),
MP_OBJ_NEW_QSTR(MP_QSTR_callback), MP_OBJ_FROM_PTR(&network_ninaw10_timer_callback_obj),
};
MP_STATE_PORT(mp_wifi_timer) = machine_timer_type.make_new((mp_obj_t)&machine_timer_type, 0, 2, timer_args);
MP_STATE_PORT(mp_wifi_timer) = MP_OBJ_TYPE_GET_SLOT(&machine_timer_type, make_new)((mp_obj_t)&machine_timer_type, 0, 2, timer_args);
}
} else {
nina_deinit();
Expand Down Expand Up @@ -778,7 +778,7 @@ STATIC MP_DEFINE_CONST_OBJ_FULL_TYPE(
mod_network_nic_type_nina_base,
MP_QSTR_nina,
MP_TYPE_FLAG_NONE,
network_ninaw10_make_new,
make_new, network_ninaw10_make_new,
locals_dict, &nina_locals_dict
);

Expand Down
6 changes: 3 additions & 3 deletions extmod/network_wiznet5k.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
MP_ROM_QSTR(MP_QSTR_miso), mp_pin_make_new(NULL, 1, 0, &miso_obj),
MP_ROM_QSTR(MP_QSTR_mosi), mp_pin_make_new(NULL, 1, 0, &mosi_obj),
};
spi = MP_OBJ_TO_PTR(machine_spi_type.make_new((mp_obj_t)&machine_spi_type, 2, 3, args));
spi = MP_OBJ_TO_PTR(MP_OBJ_TYPE_GET_SLOT(&machine_spi_type, make_new)((mp_obj_t)&machine_spi_type, 2, 3, args));

cs = mp_hal_get_pin_obj(mp_pin_make_new(NULL, 1, 0, (mp_obj_t[]) {MP_OBJ_NEW_SMALL_INT(MICROPY_HW_WIZNET_PIN_CS)}));
rst = mp_hal_get_pin_obj(mp_pin_make_new(NULL, 1, 0, (mp_obj_t[]) {MP_OBJ_NEW_SMALL_INT(MICROPY_HW_WIZNET_PIN_RST)}));
Expand Down Expand Up @@ -1020,15 +1020,15 @@ MP_DEFINE_CONST_OBJ_TYPE(
mod_network_nic_type_wiznet5k,
MP_QSTR_WIZNET5K,
MP_TYPE_FLAG_NONE,
wiznet5k_make_new,
make_new, wiznet5k_make_new,
locals_dict, &wiznet5k_locals_dict
);
#else // WIZNET5K_PROVIDED_STACK
STATIC MP_DEFINE_CONST_OBJ_FULL_TYPE(
mod_network_nic_type_wiznet5k_base,
MP_QSTR_WIZNET5K,
MP_TYPE_FLAG_NONE,
wiznet5k_make_new,
make_new, wiznet5k_make_new,
locals_dict, &wiznet5k_locals_dict
);

Expand Down
6 changes: 3 additions & 3 deletions extmod/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
#if MICROPY_VFS_LFS1
if (memcmp(&buf[32], "littlefs", 8) == 0) {
// LFS1
mp_obj_t vfs = mp_type_vfs_lfs1.make_new(&mp_type_vfs_lfs1, 1, 0, &bdev_obj);
mp_obj_t vfs = MP_OBJ_TYPE_GET_SLOT(&mp_type_vfs_lfs1, make_new)(&mp_type_vfs_lfs1, 1, 0, &bdev_obj);
nlr_pop();
return vfs;
}
#endif
#if MICROPY_VFS_LFS2
if (memcmp(&buf[0], "littlefs", 8) == 0) {
// LFS2
mp_obj_t vfs = mp_type_vfs_lfs2.make_new(&mp_type_vfs_lfs2, 1, 0, &bdev_obj);
mp_obj_t vfs = MP_OBJ_TYPE_GET_SLOT(&mp_type_vfs_lfs2, make_new)(&mp_type_vfs_lfs2, 1, 0, &bdev_obj);
nlr_pop();
return vfs;
}
Expand All @@ -194,7 +194,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
#endif

#if MICROPY_VFS_FAT
return mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &bdev_obj);
return MP_OBJ_TYPE_GET_SLOT(&mp_fat_vfs_type, make_new)(&mp_fat_vfs_type, 1, 0, &bdev_obj);
#endif

// no filesystem found
Expand Down
Loading

0 comments on commit 94beeab

Please sign in to comment.