From 7e72009ca6da9ba97e78a71380fe1140cefd5948 Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Fri, 4 Oct 2024 11:01:14 +0800 Subject: [PATCH 1/5] remove 'mp_obj_property_t' usage remains --- extmod/vfs_fat.c | 19 +++++-------- .../bindings/rp2pio/StateMachine.c | 26 +++++------------- shared-bindings/displayio/OnDiskBitmap.c | 9 ++----- shared-bindings/keypad/__init__.c | 17 +++--------- shared-bindings/vectorio/Rectangle.c | 27 +++++++------------ 5 files changed, 28 insertions(+), 70 deletions(-) diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 85541d3cf01d..9b579afaa97f 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -484,12 +484,9 @@ static mp_obj_t vfs_fat_getreadonly(mp_obj_t self_in) { return mp_obj_new_bool(!filesystem_is_writable_by_python(self)); } static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getreadonly_obj, vfs_fat_getreadonly); -static const mp_obj_property_t fat_vfs_readonly_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&fat_vfs_getreadonly_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; + +MP_PROPERTY_GETTER(fat_vfs_readonly_obj, + (mp_obj_t)&fat_vfs_getreadonly_obj); #if MICROPY_FATFS_USE_LABEL static mp_obj_t vfs_fat_getlabel(mp_obj_t self_in) { @@ -517,12 +514,10 @@ static mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) { return mp_const_none; } static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_setlabel_obj, vfs_fat_setlabel); -static const mp_obj_property_t fat_vfs_label_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&fat_vfs_getlabel_obj, - (mp_obj_t)&fat_vfs_setlabel_obj, - MP_ROM_NONE}, -}; + +MP_PROPERTY_GETSET(fat_vfs_label_obj, + (mp_obj_t)&fat_vfs_getlabel_obj, + (mp_obj_t)&fat_vfs_setlabel_obj); #endif static const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 806674ee4c3d..fd94ae5fe146 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -610,13 +610,8 @@ static mp_obj_t rp2pio_statemachine_obj_get_writing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_writing_obj, rp2pio_statemachine_obj_get_writing); -const mp_obj_property_t rp2pio_statemachine_writing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_writing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; - +MP_PROPERTY_GETTER(rp2pio_statemachine_writing_obj, + (mp_obj_t)&rp2pio_statemachine_get_writing_obj); //| pending: int //| """Returns the number of pending buffers for background writing. @@ -628,12 +623,8 @@ static mp_obj_t rp2pio_statemachine_obj_get_pending(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_pending_obj, rp2pio_statemachine_obj_get_pending); -const mp_obj_property_t rp2pio_statemachine_pending_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_pending_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(rp2pio_statemachine_pending_obj, + (mp_obj_t)&rp2pio_statemachine_get_pending_obj); //| def readinto( //| self, @@ -847,13 +838,8 @@ static mp_obj_t rp2pio_statemachine_obj_get_txstall(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_txstall_obj, rp2pio_statemachine_obj_get_txstall); -const mp_obj_property_t rp2pio_statemachine_txstall_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_txstall_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; - +MP_PROPERTY_GETTER(rp2pio_statemachine_txstall_obj, + (mp_obj_t)&rp2pio_statemachine_get_txstall_obj); //| rxstall: bool //| """True when the state machine has stalled due to a full RX FIFO since the last diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index fea3763657e8..cb2e20c2d0fe 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -113,13 +113,8 @@ static mp_obj_t displayio_ondiskbitmap_obj_get_pixel_shader(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_pixel_shader_obj, displayio_ondiskbitmap_obj_get_pixel_shader); -const mp_obj_property_t displayio_ondiskbitmap_pixel_shader_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_ondiskbitmap_get_pixel_shader_obj, - (mp_obj_t)MP_ROM_NONE, - (mp_obj_t)MP_ROM_NONE}, -}; - +MP_PROPERTY_GETTER(displayio_ondiskbitmap_pixel_shader_obj, + (mp_obj_t)&displayio_ondiskbitmap_get_pixel_shader_obj); static const mp_rom_map_elem_t displayio_ondiskbitmap_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_ondiskbitmap_height_obj) }, diff --git a/shared-bindings/keypad/__init__.c b/shared-bindings/keypad/__init__.c index 1a7151c61ea5..48d19d59d376 100644 --- a/shared-bindings/keypad/__init__.c +++ b/shared-bindings/keypad/__init__.c @@ -37,12 +37,8 @@ static mp_obj_t keypad_generic_get_key_count(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_generic_get_key_count_obj, keypad_generic_get_key_count); -const mp_obj_property_t keypad_generic_key_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_generic_get_key_count_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_generic_key_count_obj, + (mp_obj_t)&keypad_generic_get_key_count_obj); static mp_obj_t keypad_generic_get_events(mp_obj_t self_in) { keypad_keymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -52,13 +48,8 @@ static mp_obj_t keypad_generic_get_events(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_generic_get_events_obj, keypad_generic_get_events); -const mp_obj_property_t keypad_generic_events_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_generic_get_events_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; - +MP_PROPERTY_GETTER(keypad_generic_events_obj, + (mp_obj_t)&keypad_generic_get_events_obj); //| """Support for scanning keys and key matrices //| diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index d1f2e6193ce3..8949df7dd1e6 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -85,12 +85,9 @@ static mp_obj_t vectorio_rectangle_obj_set_width(mp_obj_t self_in, mp_obj_t widt } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_width_obj, vectorio_rectangle_obj_set_width); -const mp_obj_property_t vectorio_rectangle_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_rectangle_get_width_obj, - (mp_obj_t)&vectorio_rectangle_set_width_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_rectangle_width_obj, + (mp_obj_t)&vectorio_rectangle_get_width_obj, + (mp_obj_t)&vectorio_rectangle_set_width_obj); //| height: int //| """The height of the rectangle in pixels.""" @@ -107,12 +104,9 @@ static mp_obj_t vectorio_rectangle_obj_set_height(mp_obj_t self_in, mp_obj_t hei } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_height_obj, vectorio_rectangle_obj_set_height); -const mp_obj_property_t vectorio_rectangle_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_rectangle_get_height_obj, - (mp_obj_t)&vectorio_rectangle_set_height_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_rectangle_height_obj, + (mp_obj_t)&vectorio_rectangle_get_height_obj, + (mp_obj_t)&vectorio_rectangle_set_height_obj); //| color_index: int //| """The color_index of the rectangle in 1 based index of the palette.""" @@ -129,12 +123,9 @@ static mp_obj_t vectorio_rectangle_obj_set_color_index(mp_obj_t self_in, mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_color_index_obj, vectorio_rectangle_obj_set_color_index); -const mp_obj_property_t vectorio_rectangle_color_index_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_rectangle_get_color_index_obj, - (mp_obj_t)&vectorio_rectangle_set_color_index_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_rectangle_color_index_obj, + (mp_obj_t)&vectorio_rectangle_get_color_index_obj, + (mp_obj_t)&vectorio_rectangle_set_color_index_obj); // Documentation for properties inherited from VectorShape. From d976f832f107090e7fa4c2a4d3d63fa4b6a842b5 Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Fri, 4 Oct 2024 11:14:46 +0800 Subject: [PATCH 2/5] fix formatting --- extmod/vfs_fat.c | 2 +- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 4 ++-- shared-bindings/displayio/OnDiskBitmap.c | 2 +- shared-bindings/keypad/__init__.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 9b579afaa97f..930d5a2a6c96 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -485,7 +485,7 @@ static mp_obj_t vfs_fat_getreadonly(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getreadonly_obj, vfs_fat_getreadonly); -MP_PROPERTY_GETTER(fat_vfs_readonly_obj, +MP_PROPERTY_GETTER(fat_vfs_readonly_obj, (mp_obj_t)&fat_vfs_getreadonly_obj); #if MICROPY_FATFS_USE_LABEL diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index fd94ae5fe146..aa0f33789564 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -623,7 +623,7 @@ static mp_obj_t rp2pio_statemachine_obj_get_pending(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_pending_obj, rp2pio_statemachine_obj_get_pending); -MP_PROPERTY_GETTER(rp2pio_statemachine_pending_obj, +MP_PROPERTY_GETTER(rp2pio_statemachine_pending_obj, (mp_obj_t)&rp2pio_statemachine_get_pending_obj); //| def readinto( @@ -838,7 +838,7 @@ static mp_obj_t rp2pio_statemachine_obj_get_txstall(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_txstall_obj, rp2pio_statemachine_obj_get_txstall); -MP_PROPERTY_GETTER(rp2pio_statemachine_txstall_obj, +MP_PROPERTY_GETTER(rp2pio_statemachine_txstall_obj, (mp_obj_t)&rp2pio_statemachine_get_txstall_obj); //| rxstall: bool diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index cb2e20c2d0fe..e15ecd45a954 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -113,7 +113,7 @@ static mp_obj_t displayio_ondiskbitmap_obj_get_pixel_shader(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_pixel_shader_obj, displayio_ondiskbitmap_obj_get_pixel_shader); -MP_PROPERTY_GETTER(displayio_ondiskbitmap_pixel_shader_obj, +MP_PROPERTY_GETTER(displayio_ondiskbitmap_pixel_shader_obj, (mp_obj_t)&displayio_ondiskbitmap_get_pixel_shader_obj); static const mp_rom_map_elem_t displayio_ondiskbitmap_locals_dict_table[] = { diff --git a/shared-bindings/keypad/__init__.c b/shared-bindings/keypad/__init__.c index 48d19d59d376..b29de197262f 100644 --- a/shared-bindings/keypad/__init__.c +++ b/shared-bindings/keypad/__init__.c @@ -37,7 +37,7 @@ static mp_obj_t keypad_generic_get_key_count(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_generic_get_key_count_obj, keypad_generic_get_key_count); -MP_PROPERTY_GETTER(keypad_generic_key_count_obj, +MP_PROPERTY_GETTER(keypad_generic_key_count_obj, (mp_obj_t)&keypad_generic_get_key_count_obj); static mp_obj_t keypad_generic_get_events(mp_obj_t self_in) { From d5d40267bf2b87017f087275c8acf7b34a97b563 Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Fri, 4 Oct 2024 14:56:36 +0800 Subject: [PATCH 3/5] use 'mp_obj_property_getter_t' type --- shared-bindings/keypad/__init__.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/keypad/__init__.h b/shared-bindings/keypad/__init__.h index 7f8079ecdc92..fd193cee217c 100644 --- a/shared-bindings/keypad/__init__.h +++ b/shared-bindings/keypad/__init__.h @@ -17,5 +17,5 @@ mp_obj_t common_hal_keypad_generic_get_events(void *self); MP_DECLARE_CONST_FUN_OBJ_1(keypad_generic_reset_obj); -extern const mp_obj_property_t keypad_generic_events_obj; -extern const mp_obj_property_t keypad_generic_key_count_obj; +extern const mp_obj_property_getter_t keypad_generic_events_obj; +extern const mp_obj_property_getter_t keypad_generic_key_count_obj; From a19ddf57dfe5582f8f1ecd4810e4a1f1f5773a2f Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Fri, 4 Oct 2024 15:38:13 +0800 Subject: [PATCH 4/5] add static 'MP_PROPERTY_GETTER(fat_vfs_readonly_obj, (mp_obj_t)&fat_vfs_getreadonly_obj);' --- extmod/vfs_fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 930d5a2a6c96..d91e04ceea5d 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -485,7 +485,7 @@ static mp_obj_t vfs_fat_getreadonly(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getreadonly_obj, vfs_fat_getreadonly); -MP_PROPERTY_GETTER(fat_vfs_readonly_obj, +static MP_PROPERTY_GETTER(fat_vfs_readonly_obj, (mp_obj_t)&fat_vfs_getreadonly_obj); #if MICROPY_FATFS_USE_LABEL From 2a8589471f11986383e35723b34f80797115a907 Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Fri, 4 Oct 2024 16:55:35 +0800 Subject: [PATCH 5/5] add static to 'extmod/vfs_fat.c: fat_vfs_label_obj' --- extmod/vfs_fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index d91e04ceea5d..929bd5fd98e0 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -515,7 +515,7 @@ static mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) { } static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_setlabel_obj, vfs_fat_setlabel); -MP_PROPERTY_GETSET(fat_vfs_label_obj, +static MP_PROPERTY_GETSET(fat_vfs_label_obj, (mp_obj_t)&fat_vfs_getlabel_obj, (mp_obj_t)&fat_vfs_setlabel_obj); #endif