diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index ce71d74b88..208cf101f9 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -440,7 +440,7 @@ 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_obj_t)MP_ROM_NONE}, + MP_ROM_NONE}, }; #endif diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index 01fb29f47a..7c405d464d 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -53,12 +53,8 @@ STATIC mp_obj_t samd_clock_get_enabled(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(samd_clock_get_enabled_obj, samd_clock_get_enabled); -const mp_obj_property_t samd_clock_enabled_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&samd_clock_get_enabled_obj, - MP_ROM_NONE, - MP_ROM_NONE,}, -}; +MP_PROPERTY_GETTER(samd_clock_enabled_obj, + (mp_obj_t)&samd_clock_get_enabled_obj); //| parent: Union[Clock, None] //| """Clock parent. (read-only)""" @@ -82,12 +78,8 @@ STATIC mp_obj_t samd_clock_get_parent(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(samd_clock_get_parent_obj, samd_clock_get_parent); -const mp_obj_property_t samd_clock_parent_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&samd_clock_get_parent_obj, - MP_ROM_NONE, - MP_ROM_NONE,}, -}; +MP_PROPERTY_GETTER(samd_clock_parent_obj, + (mp_obj_t)&samd_clock_get_parent_obj); //| frequency: int //| """Clock frequency in Herz. (read-only)""" @@ -99,12 +91,8 @@ STATIC mp_obj_t samd_clock_get_frequency(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(samd_clock_get_frequency_obj, samd_clock_get_frequency); -const mp_obj_property_t samd_clock_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&samd_clock_get_frequency_obj, - MP_ROM_NONE, - MP_ROM_NONE,}, -}; +MP_PROPERTY_GETTER(samd_clock_frequency_obj, + (mp_obj_t)&samd_clock_get_frequency_obj); //| calibration: int //| """Clock calibration. Not all clocks can be calibrated.""" @@ -130,12 +118,9 @@ STATIC mp_obj_t samd_clock_set_calibration(mp_obj_t self_in, mp_obj_t calibratio MP_DEFINE_CONST_FUN_OBJ_2(samd_clock_set_calibration_obj, samd_clock_set_calibration); -const mp_obj_property_t samd_clock_calibration_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&samd_clock_get_calibration_obj, - (mp_obj_t)&samd_clock_set_calibration_obj, - MP_ROM_NONE,}, -}; +MP_PROPERTY_GETSET(samd_clock_calibration_obj, + (mp_obj_t)&samd_clock_get_calibration_obj, + (mp_obj_t)&samd_clock_set_calibration_obj); STATIC const mp_rom_map_elem_t samd_clock_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_enabled), MP_ROM_PTR(&samd_clock_enabled_obj) }, diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld index 05c0de4210..97504d44e5 100644 --- a/ports/atmel-samd/boards/common.template.ld +++ b/ports/atmel-samd/boards/common.template.ld @@ -28,6 +28,13 @@ SECTIONS _sfixed = .; KEEP(*(.vectors)) /* isr vector table */ + __property_getter_start = .; + *(.property_getter) + __property_getter_end = .; + __property_getset_start = .; + *(.property_getset) + __property_getset_end = .; + /* Sort text sections so that they have fewer *fill* bytes needed. */ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.text))) /* .text sections (code) */ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*))) /* .text* sections (code) */ diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 119bc304ac..f031386a73 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -8,6 +8,7 @@ INTERNAL_LIBM = 1 USB_NUM_ENDPOINT_PAIRS = 8 CIRCUITPY_ROTARYIO_SOFTENCODER = 1 +CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 1 ###################################################################### # Put samd21-only choices here. diff --git a/ports/broadcom/bindings/videocore/Framebuffer.c b/ports/broadcom/bindings/videocore/Framebuffer.c index 46a2ac13b0..4be55ee291 100644 --- a/ports/broadcom/bindings/videocore/Framebuffer.c +++ b/ports/broadcom/bindings/videocore/Framebuffer.c @@ -96,12 +96,8 @@ STATIC mp_obj_t videocore_framebuffer_get_width(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_videocore_framebuffer_get_width(self)); } MP_DEFINE_CONST_FUN_OBJ_1(videocore_framebuffer_get_width_obj, videocore_framebuffer_get_width); -const mp_obj_property_t videocore_framebuffer_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&videocore_framebuffer_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(videocore_framebuffer_width_obj, + (mp_obj_t)&videocore_framebuffer_get_width_obj); //| height: int //| """The height of the display, in pixels""" @@ -113,12 +109,8 @@ STATIC mp_obj_t videocore_framebuffer_get_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(videocore_framebuffer_get_height_obj, videocore_framebuffer_get_height); -const mp_obj_property_t videocore_framebuffer_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&videocore_framebuffer_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(videocore_framebuffer_height_obj, + (mp_obj_t)&videocore_framebuffer_get_height_obj); STATIC const mp_rom_map_elem_t videocore_framebuffer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&videocore_framebuffer_deinit_obj) }, diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 28668355b1..ec5a6648d1 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -729,12 +729,9 @@ STATIC mp_obj_t rp2pio_statemachine_obj_set_frequency(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_set_frequency_obj, rp2pio_statemachine_obj_set_frequency); -const mp_obj_property_t rp2pio_statemachine_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_frequency_obj, - (mp_obj_t)&rp2pio_statemachine_set_frequency_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rp2pio_statemachine_frequency_obj, + (mp_obj_t)&rp2pio_statemachine_get_frequency_obj, + (mp_obj_t)&rp2pio_statemachine_set_frequency_obj); //| rxstall: bool //| """True when the state machine has stalled due to a full RX FIFO since the last @@ -748,12 +745,8 @@ STATIC mp_obj_t rp2pio_statemachine_obj_get_rxstall(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_rxstall_obj, rp2pio_statemachine_obj_get_rxstall); -const mp_obj_property_t rp2pio_statemachine_rxstall_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_rxstall_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(rp2pio_statemachine_rxstall_obj, + (mp_obj_t)&rp2pio_statemachine_get_rxstall_obj); //| in_waiting: int //| """The number of words available to readinto""" @@ -766,12 +759,8 @@ STATIC mp_obj_t rp2pio_statemachine_obj_get_in_waiting(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_in_waiting_obj, rp2pio_statemachine_obj_get_in_waiting); -const mp_obj_property_t rp2pio_statemachine_in_waiting_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rp2pio_statemachine_get_in_waiting_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(rp2pio_statemachine_in_waiting_obj, + (mp_obj_t)&rp2pio_statemachine_get_in_waiting_obj); STATIC const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rp2pio_statemachine_deinit_obj) }, diff --git a/ports/raspberrypi/link.ld b/ports/raspberrypi/link.ld index 62b1bd04b6..c9480f84db 100644 --- a/ports/raspberrypi/link.ld +++ b/ports/raspberrypi/link.ld @@ -68,6 +68,14 @@ SECTIONS /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from * FLASH ... we will include any thing excluded here in .data below by default */ *(.init) + + __property_getter_start = .; + *(.property_getter) + __property_getter_end = .; + __property_getset_start = .; + *(.property_getset) + __property_getset_end = .; + *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*) *(.fini) /* Pull all c'tors into .text */ diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 80938c47b0..32666ed9ea 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -1,6 +1,7 @@ # All raspberrypi ports have longints. LONGINT_IMPL = MPZ +CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 1 CIRCUITPY_ALARM ?= 1 CIRCUITPY_RP2PIO ?= 1 diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index ec9274464b..03dca0321c 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -573,4 +573,6 @@ void supervisor_run_background_tasks_if_tick(void); #define MICROPY_WRAP_MP_EXECUTE_BYTECODE PLACE_IN_ITCM #endif +#define MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE (CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE) + #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 661829de26..1899541099 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -32,6 +32,11 @@ CIRCUITPY_FULL_BUILD ?= 1 CFLAGS += -DCIRCUITPY_FULL_BUILD=$(CIRCUITPY_FULL_BUILD) +# Reduce the size of in-flash properties. Requires support in the .ld linker +# file, so not enabled by default. +CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 0 +CFLAGS += -DCIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE=$(CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE) + # async/await language keyword support MICROPY_PY_ASYNC_AWAIT ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT) diff --git a/py/mpconfig.h b/py/mpconfig.h index d66d615996..386a9765eb 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1078,6 +1078,11 @@ typedef double mp_float_t; #define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif +// Whether to optimize property flash storage size (requires linker script support) +#ifndef MICROPY_PY_BUILTINS_PROPERTY +#define MICROPY_PY_BUILTINS_PROPERTY (0) +#endif + // Whether to implement the start/stop/step attributes (readback) on // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS diff --git a/py/obj.h b/py/obj.h index b31320f7e0..5f8f71ba0b 100644 --- a/py/obj.h +++ b/py/obj.h @@ -356,11 +356,7 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; #define MP_DEFINE_CONST_PROP_GET(obj_name, fun_name) \ const mp_obj_fun_builtin_fixed_t fun_name##_obj = {{&mp_type_fun_builtin_1}, .fun._1 = fun_name}; \ - const mp_obj_property_t obj_name = { \ - .base.type = &mp_type_property, \ - .proxy = {(mp_obj_t)&fun_name##_obj, \ - MP_ROM_NONE, \ - MP_ROM_NONE}, } + MP_PROPERTY_GETTER(obj_name, (mp_obj_t)&fun_name##_obj); // These macros are used to define constant or mutable map/dict objects // You can put "static" in front of the definition to make it local @@ -1111,7 +1107,7 @@ typedef struct _mp_rom_obj_static_class_method_t { } mp_rom_obj_static_class_method_t; // property -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy); // sequence helpers diff --git a/py/objproperty.c b/py/objproperty.c index ebb70014a4..e8ae5094fa 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -95,9 +95,24 @@ const mp_obj_type_t mp_type_property = { .locals_dict = (mp_obj_dict_t *)&property_locals_dict, }; -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) { +#if MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE +extern const mp_obj_property_t __property_getter_start, __property_getter_end, __property_getset_start, __property_getset_end; +#endif + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy) { mp_check_self(mp_obj_is_type(self_in, &mp_type_property)); mp_obj_property_t *self = MP_OBJ_TO_PTR(self_in); + #if MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE + if (self >= &__property_getter_start && self < &__property_getter_end) { + *n_proxy = 1; + } else if (self >= &__property_getset_start && self < &__property_getset_end) { + *n_proxy = 2; + } else { + *n_proxy = 3; + } + #else + *n_proxy = 3; + #endif return self->proxy; } diff --git a/py/objproperty.h b/py/objproperty.h index f3ade89d92..c1b5dba460 100644 --- a/py/objproperty.h +++ b/py/objproperty.h @@ -35,6 +35,28 @@ typedef struct _mp_obj_property_t { mp_obj_t proxy[3]; // getter, setter, deleter } mp_obj_property_t; +#if MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE +typedef struct _mp_obj_property_getter_t { + mp_obj_base_t base; + mp_obj_t proxy[1]; // getter +} mp_obj_property_getter_t; + +typedef struct _mp_obj_property_getset_t { + mp_obj_base_t base; + mp_obj_t proxy[2]; // getter, setter +} mp_obj_property_getset_t; + +#define MP_PROPERTY_GETTER(P, G) const mp_obj_property_getter_t P __attribute((section(".property_getter"))) = {.base.type = &mp_type_property, .proxy = {G}} +#define MP_PROPERTY_GETSET(P, G, S) const mp_obj_property_getset_t P __attribute((section(".property_getset"))) = {.base.type = &mp_type_property, .proxy = {G, S}} + +#else +typedef struct _mp_obj_property_t mp_obj_property_getter_t; +typedef struct _mp_obj_property_t mp_obj_property_getset_t; + +#define MP_PROPERTY_GETTER(P, G) const mp_obj_property_t P = {.base.type = &mp_type_property, .proxy = {G, MP_ROM_NONE, MP_ROM_NONE}} +#define MP_PROPERTY_GETSET(P, G, S) const mp_obj_property_t P = {.base.type = &mp_type_property, .proxy = {G, S, MP_ROM_NONE}} +#endif + #endif // MICROPY_PY_BUILTINS_PROPERTY #endif // MICROPY_INCLUDED_PY_OBJPROPERTY_H diff --git a/py/objtype.c b/py/objtype.c index d247987ce2..62ea1ed602 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -660,7 +660,8 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des // be called by the descriptor code down below. But that way // requires overhead for the nested mp_call's and overhead for // the code. - const mp_obj_t *proxy = mp_obj_property_get(member); + size_t n_proxy; + const mp_obj_t *proxy = mp_obj_property_get(member, &n_proxy); if (proxy[0] == mp_const_none) { mp_raise_AttributeError(MP_ERROR_TEXT("unreadable attribute")); } else { @@ -740,11 +741,12 @@ STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t val // would be called by the descriptor code down below. But that way // requires overhead for the nested mp_call's and overhead for // the code. - const mp_obj_t *proxy = mp_obj_property_get(member[0]); + size_t n_proxy; + const mp_obj_t *proxy = mp_obj_property_get(member[0], &n_proxy); mp_obj_t dest[2] = {self_in, value}; if (value == MP_OBJ_NULL) { // delete attribute - if (proxy[2] == mp_const_none) { + if (n_proxy < 3 || proxy[2] == mp_const_none) { // TODO better error message? return false; } else { @@ -753,7 +755,7 @@ STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t val } } else { // store attribute - if (proxy[1] == mp_const_none) { + if (n_proxy < 2 || proxy[1] == mp_const_none) { // TODO better error message? return false; } else { @@ -1374,7 +1376,8 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { // here... #if MICROPY_PY_BUILTINS_PROPERTY if (mp_obj_is_type(member, &mp_type_property)) { - const mp_obj_t *proxy = mp_obj_property_get(member); + size_t n_proxy; + const mp_obj_t *proxy = mp_obj_property_get(member, &n_proxy); if (proxy[0] == mp_const_none) { mp_raise_AttributeError(MP_ERROR_TEXT("unreadable attribute")); } else { diff --git a/py/runtime.c b/py/runtime.c index bf44234434..f2ad8728a5 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1087,7 +1087,8 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t // be called by the descriptor code down below. But that way // requires overhead for the nested mp_call's and overhead for // the code. - const mp_obj_t *proxy = mp_obj_property_get(member); + size_t n_proxy; + const mp_obj_t *proxy = mp_obj_property_get(member, &n_proxy); if (proxy[0] == mp_const_none) { mp_raise_AttributeError(MP_ERROR_TEXT("unreadable attribute")); } else { @@ -1226,15 +1227,16 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { // would be called by the descriptor code down below. But that way // requires overhead for the nested mp_call's and overhead for // the code. - const mp_obj_t *proxy = mp_obj_property_get(elem->value); + size_t n_proxy; + const mp_obj_t *proxy = mp_obj_property_get(elem->value, &n_proxy); mp_obj_t dest[2] = {base, value}; if (value == MP_OBJ_NULL) { // delete attribute - if (proxy[2] != mp_const_none) { + if (n_proxy == 3 && proxy[2] != mp_const_none) { mp_call_function_n_kw(proxy[2], 1, 0, dest); return; } - } else if (proxy[1] != mp_const_none) { + } else if (n_proxy > 1 && proxy[1] != mp_const_none) { mp_call_function_n_kw(proxy[1], 2, 0, dest); return; } diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index baff277b69..ce1080934e 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -128,12 +128,9 @@ static mp_obj_t bleio_adapter_set_enabled(mp_obj_t self, mp_obj_t value) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_adapter_set_enabled_obj, bleio_adapter_set_enabled); -const mp_obj_property_t bleio_adapter_enabled_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_enabled_obj, - (mp_obj_t)&bleio_adapter_set_enabled_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_adapter_enabled_obj, + (mp_obj_t)&bleio_adapter_get_enabled_obj, + (mp_obj_t)&bleio_adapter_set_enabled_obj); //| address: Address //| """MAC address of the BLE adapter.""" @@ -152,12 +149,9 @@ STATIC mp_obj_t bleio_adapter_set_address(mp_obj_t self, mp_obj_t new_address) { } MP_DEFINE_CONST_FUN_OBJ_2(bleio_adapter_set_address_obj, bleio_adapter_set_address); -const mp_obj_property_t bleio_adapter_address_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_address_obj, - (mp_obj_t)&bleio_adapter_set_address_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_adapter_address_obj, + (mp_obj_t)&bleio_adapter_get_address_obj, + (mp_obj_t)&bleio_adapter_set_address_obj); //| name: str //| """name of the BLE adapter used once connected. @@ -176,12 +170,9 @@ STATIC mp_obj_t bleio_adapter_set_name(mp_obj_t self, mp_obj_t new_name) { } MP_DEFINE_CONST_FUN_OBJ_2(bleio_adapter_set_name_obj, bleio_adapter_set_name); -const mp_obj_property_t bleio_adapter_name_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_name_obj, - (mp_obj_t)&bleio_adapter_set_name_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_adapter_name_obj, + (mp_obj_t)&bleio_adapter_get_name_obj, + (mp_obj_t)&bleio_adapter_set_name_obj); //| def start_advertising(self, data: ReadableBuffer, *, //| scan_response: Optional[ReadableBuffer] = None, connectable: bool = True, @@ -380,12 +371,8 @@ STATIC mp_obj_t bleio_adapter_get_advertising(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_advertising_obj, bleio_adapter_get_advertising); -const mp_obj_property_t bleio_adapter_advertising_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_advertising_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_adapter_advertising_obj, + (mp_obj_t)&bleio_adapter_get_advertising_obj); //| connected: bool //| """True when the adapter is connected to another device regardless of who initiated the @@ -397,12 +384,8 @@ STATIC mp_obj_t bleio_adapter_get_connected(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_connected_obj, bleio_adapter_get_connected); -const mp_obj_property_t bleio_adapter_connected_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_connected_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_adapter_connected_obj, + (mp_obj_t)&bleio_adapter_get_connected_obj); //| connections: Tuple[Connection] //| """Tuple of active connections including those initiated through @@ -413,12 +396,8 @@ STATIC mp_obj_t bleio_adapter_get_connections(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_connections_obj, bleio_adapter_get_connections); -const mp_obj_property_t bleio_adapter_connections_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_adapter_get_connections_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_adapter_connections_obj, + (mp_obj_t)&bleio_adapter_get_connections_obj); //| def connect(self, address: Address, *, timeout: float) -> Connection: //| """Attempts a connection to the device with the given address. diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 97322bbb79..9673642a5b 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -101,12 +101,8 @@ STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_address_bytes_obj, bleio_address_get_address_bytes); -const mp_obj_property_t bleio_address_address_bytes_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_address_get_address_bytes_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_address_address_bytes_obj, + (mp_obj_t)&bleio_address_get_address_bytes_obj); //| type: int //| """The address type (read-only). @@ -121,12 +117,8 @@ STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_type_obj, bleio_address_get_type); -const mp_obj_property_t bleio_address_type_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_address_get_type_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_address_type_obj, + (mp_obj_t)&bleio_address_get_type_obj); //| def __eq__(self, other: object) -> bool: //| """Two Address objects are equal if their addresses and address types are equal.""" diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index f4c77405d1..4ff37f0623 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -167,12 +167,8 @@ STATIC mp_obj_t bleio_characteristic_get_properties(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_properties_obj, bleio_characteristic_get_properties); -const mp_obj_property_t bleio_characteristic_properties_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_properties_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_characteristic_properties_obj, + (mp_obj_t)&bleio_characteristic_get_properties_obj); //| uuid: Optional[UUID] //| """The UUID of this characteristic. (read-only) @@ -187,12 +183,8 @@ STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_uuid_obj, bleio_characteristic_get_uuid); -const mp_obj_property_t bleio_characteristic_uuid_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_uuid_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_characteristic_uuid_obj, + (mp_obj_t)&bleio_characteristic_get_uuid_obj); //| value: bytearray //| """The value of this characteristic.""" @@ -218,12 +210,9 @@ STATIC mp_obj_t bleio_characteristic_set_value(mp_obj_t self_in, mp_obj_t value_ } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_value_obj, bleio_characteristic_set_value); -const mp_obj_property_t bleio_characteristic_value_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_value_obj, - (mp_obj_t)&bleio_characteristic_set_value_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_characteristic_value_obj, + (mp_obj_t)&bleio_characteristic_get_value_obj, + (mp_obj_t)&bleio_characteristic_set_value_obj); //| max_length: int //| """The max length of this characteristic.""" @@ -235,12 +224,8 @@ STATIC mp_obj_t bleio_characteristic_get_max_length(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_max_length_obj, bleio_characteristic_get_max_length); -const mp_obj_property_t bleio_characteristic_max_length_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_max_length_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_characteristic_max_length_obj, + (mp_obj_t)&bleio_characteristic_get_max_length_obj); //| descriptors: Descriptor //| """A tuple of :py:class:`Descriptor` objects related to this characteristic. (read-only)""" @@ -253,12 +238,8 @@ STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_descriptors_obj, bleio_characteristic_get_descriptors); -const mp_obj_property_t bleio_characteristic_descriptors_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_descriptors_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_characteristic_descriptors_obj, + (mp_obj_t)&bleio_characteristic_get_descriptors_obj); //| service: Service //| """The Service this Characteristic is a part of.""" @@ -270,12 +251,8 @@ STATIC mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_service_obj, bleio_characteristic_get_service); -const mp_obj_property_t bleio_characteristic_service_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_characteristic_get_service_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_characteristic_service_obj, + (mp_obj_t)&bleio_characteristic_get_service_obj); //| def set_cccd(self, *, notify: bool = False, indicate: bool = False) -> None: //| """Set the remote characteristic's CCCD to enable or disable notification and indication. diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 81562028e7..78ff07fa77 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -173,12 +173,8 @@ STATIC mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) } MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_get_in_waiting_obj, bleio_characteristic_buffer_obj_get_in_waiting); -const mp_obj_property_t bleio_characteristic_buffer_in_waiting_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_characteristic_buffer_get_in_waiting_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_characteristic_buffer_in_waiting_obj, + (mp_obj_t)&bleio_characteristic_buffer_get_in_waiting_obj); //| def reset_input_buffer(self) -> None: //| """Discard any unread characters in the input buffer.""" diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index a7c50a0d07..7a85ccddc2 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -161,12 +161,8 @@ STATIC mp_obj_t bleio_connection_get_connected(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connected_obj, bleio_connection_get_connected); -const mp_obj_property_t bleio_connection_connected_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_connection_get_connected_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_connection_connected_obj, + (mp_obj_t)&bleio_connection_get_connected_obj); //| paired: bool @@ -179,12 +175,8 @@ STATIC mp_obj_t bleio_connection_get_paired(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_paired_obj, bleio_connection_get_paired); -const mp_obj_property_t bleio_connection_paired_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_connection_get_paired_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_connection_paired_obj, + (mp_obj_t)&bleio_connection_get_paired_obj); //| connection_interval: float @@ -235,19 +227,12 @@ STATIC mp_obj_t bleio_connection_set_connection_interval(mp_obj_t self_in, mp_ob } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_connection_set_connection_interval_obj, bleio_connection_set_connection_interval); -const mp_obj_property_t bleio_connection_connection_interval_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_connection_get_connection_interval_obj, - (mp_obj_t)&bleio_connection_set_connection_interval_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_connection_connection_interval_obj, + (mp_obj_t)&bleio_connection_get_connection_interval_obj, + (mp_obj_t)&bleio_connection_set_connection_interval_obj); -const mp_obj_property_t bleio_connection_max_packet_length_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_connection_get_max_packet_length_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_connection_max_packet_length_obj, + (mp_obj_t)&bleio_connection_get_max_packet_length_obj); STATIC const mp_rom_map_elem_t bleio_connection_locals_dict_table[] = { // Methods diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index d4dd9372f3..f2ef6b433d 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -144,12 +144,8 @@ STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid); -const mp_obj_property_t bleio_descriptor_uuid_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_descriptor_get_uuid_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_descriptor_uuid_obj, + (mp_obj_t)&bleio_descriptor_get_uuid_obj); //| characteristic: Characteristic //| """The Characteristic this Descriptor is a part of.""" @@ -161,12 +157,8 @@ STATIC mp_obj_t bleio_descriptor_get_characteristic(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_characteristic_obj, bleio_descriptor_get_characteristic); -const mp_obj_property_t bleio_descriptor_characteristic_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_descriptor_get_characteristic_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_descriptor_characteristic_obj, + (mp_obj_t)&bleio_descriptor_get_characteristic_obj); //| value: bytearray //| """The value of this descriptor.""" @@ -192,12 +184,9 @@ STATIC mp_obj_t bleio_descriptor_set_value(mp_obj_t self_in, mp_obj_t value_in) } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_descriptor_set_value_obj, bleio_descriptor_set_value); -const mp_obj_property_t bleio_descriptor_value_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_descriptor_get_value_obj, - (mp_obj_t)&bleio_descriptor_set_value_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(bleio_descriptor_value_obj, + (mp_obj_t)&bleio_descriptor_get_value_obj, + (mp_obj_t)&bleio_descriptor_set_value_obj); STATIC const mp_rom_map_elem_t bleio_descriptor_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_add_to_characteristic), MP_ROM_PTR(&bleio_descriptor_add_to_characteristic_obj) }, diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index aa6c860a60..9e64661fd3 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -197,12 +197,8 @@ STATIC mp_obj_t bleio_packet_buffer_get_incoming_packet_length(mp_obj_t self_in) } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_get_incoming_packet_length_obj, bleio_packet_buffer_get_incoming_packet_length); -const mp_obj_property_t bleio_packet_buffer_incoming_packet_length_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_packet_buffer_get_incoming_packet_length_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_packet_buffer_incoming_packet_length_obj, + (mp_obj_t)&bleio_packet_buffer_get_incoming_packet_length_obj); //| outgoing_packet_length: int //| """Maximum length in bytes of a packet we are writing.""" @@ -218,12 +214,8 @@ STATIC mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_get_outgoing_packet_length_obj, bleio_packet_buffer_get_outgoing_packet_length); -const mp_obj_property_t bleio_packet_buffer_outgoing_packet_length_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_packet_buffer_get_outgoing_packet_length_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_packet_buffer_outgoing_packet_length_obj, + (mp_obj_t)&bleio_packet_buffer_get_outgoing_packet_length_obj); STATIC const mp_rom_map_elem_t bleio_packet_buffer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bleio_packet_buffer_deinit_obj) }, diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index 5a0f6eb1be..d9434f39cf 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -83,12 +83,8 @@ STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_address_obj, bleio_scanentry_get_address); -const mp_obj_property_t bleio_scanentry_address_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_address_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_scanentry_address_obj, + (mp_obj_t)&bleio_scanentry_get_address_obj); //| advertisement_bytes: bytes //| """All the advertisement data present in the packet, returned as a ``bytes`` object. (read-only)""" @@ -99,12 +95,8 @@ STATIC mp_obj_t scanentry_get_advertisement_bytes(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_advertisement_bytes_obj, scanentry_get_advertisement_bytes); -const mp_obj_property_t bleio_scanentry_advertisement_bytes_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_advertisement_bytes_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_scanentry_advertisement_bytes_obj, + (mp_obj_t)&bleio_scanentry_get_advertisement_bytes_obj); //| rssi: int //| """The signal strength of the device at the time of the scan, in integer dBm. (read-only)""" @@ -115,12 +107,8 @@ STATIC mp_obj_t scanentry_get_rssi(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_rssi_obj, scanentry_get_rssi); -const mp_obj_property_t bleio_scanentry_rssi_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_rssi_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_scanentry_rssi_obj, + (mp_obj_t)&bleio_scanentry_get_rssi_obj); //| connectable: bool //| """True if the device can be connected to. (read-only)""" @@ -131,12 +119,8 @@ STATIC mp_obj_t scanentry_get_connectable(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_connectable_obj, scanentry_get_connectable); -const mp_obj_property_t bleio_scanentry_connectable_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_connectable_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_scanentry_connectable_obj, + (mp_obj_t)&bleio_scanentry_get_connectable_obj); //| scan_response: bool //| """True if the entry was a scan response. (read-only)""" @@ -147,12 +131,8 @@ STATIC mp_obj_t scanentry_get_scan_response(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_scan_response_obj, scanentry_get_scan_response); -const mp_obj_property_t bleio_scanentry_scan_response_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_scan_response_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_scanentry_scan_response_obj, + (mp_obj_t)&bleio_scanentry_get_scan_response_obj); STATIC const mp_rom_map_elem_t bleio_scanentry_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_scanentry_address_obj) }, diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index ff1d8c9e21..ddbdecdf79 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -80,12 +80,8 @@ STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_characteristics_obj, bleio_service_get_characteristics); -const mp_obj_property_t bleio_service_characteristics_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_service_get_characteristics_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_service_characteristics_obj, + (mp_obj_t)&bleio_service_get_characteristics_obj); //| remote: bool //| """True if this is a service provided by a remote device. (read-only)""" @@ -97,12 +93,8 @@ STATIC mp_obj_t bleio_service_get_remote(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_remote_obj, bleio_service_get_remote); -const mp_obj_property_t bleio_service_remote_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_service_get_remote_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_service_remote_obj, + (mp_obj_t)&bleio_service_get_remote_obj); //| secondary: bool //| """True if this is a secondary service. (read-only)""" @@ -114,12 +106,8 @@ STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_secondary_obj, bleio_service_get_secondary); -const mp_obj_property_t bleio_service_secondary_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_service_get_secondary_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_service_secondary_obj, + (mp_obj_t)&bleio_service_get_secondary_obj); //| uuid: Optional[UUID] //| """The UUID of this service. (read-only) @@ -134,12 +122,8 @@ STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_uuid_obj, bleio_service_get_uuid); -const mp_obj_property_t bleio_service_uuid_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_service_get_uuid_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(bleio_service_uuid_obj, + (mp_obj_t)&bleio_service_get_uuid_obj); STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = { diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 4e3154eb03..599a89a581 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -132,12 +132,8 @@ STATIC mp_obj_t bleio_uuid_get_uuid16(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(bleio_uuid_get_uuid16_obj, bleio_uuid_get_uuid16); -const mp_obj_property_t bleio_uuid_uuid16_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_uuid_get_uuid16_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_uuid_uuid16_obj, + (mp_obj_t)&bleio_uuid_get_uuid16_obj); //| uuid128: bytes //| """The 128-bit value of the UUID @@ -158,12 +154,8 @@ STATIC mp_obj_t bleio_uuid_get_uuid128(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(bleio_uuid_get_uuid128_obj, bleio_uuid_get_uuid128); -const mp_obj_property_t bleio_uuid_uuid128_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_uuid_get_uuid128_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_uuid_uuid128_obj, + (mp_obj_t)&bleio_uuid_get_uuid128_obj); //| size: int //| """128 if this UUID represents a 128-bit vendor-specific UUID. 16 if this UUID represents a @@ -178,12 +170,8 @@ STATIC mp_obj_t bleio_uuid_get_size(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(bleio_uuid_get_size_obj, bleio_uuid_get_size); -const mp_obj_property_t bleio_uuid_size_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&bleio_uuid_get_size_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(bleio_uuid_size_obj, + (mp_obj_t)&bleio_uuid_get_size_obj); //| def pack_into(self, buffer: WriteableBuffer, offset: int = 0) -> None: diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index 7be059fa6b..d9436ea45a 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -161,12 +161,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_bpp_obj, pixelbuf_pixelbuf_obj_get_bpp); -const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_bpp_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(pixelbuf_pixelbuf_bpp_obj, + (mp_obj_t)&pixelbuf_pixelbuf_get_bpp_obj); //| brightness: float @@ -193,12 +189,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); -const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_brightness_obj, - (mp_obj_t)&pixelbuf_pixelbuf_set_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(pixelbuf_pixelbuf_brightness_obj, + (mp_obj_t)&pixelbuf_pixelbuf_get_brightness_obj, + (mp_obj_t)&pixelbuf_pixelbuf_set_brightness_obj); //| auto_write: bool //| """Whether to automatically write the pixels after each update.""" @@ -215,12 +208,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_auto_write(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_auto_write_obj, pixelbuf_pixelbuf_obj_set_auto_write); -const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_auto_write_obj, - (mp_obj_t)&pixelbuf_pixelbuf_set_auto_write_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(pixelbuf_pixelbuf_auto_write_obj, + (mp_obj_t)&pixelbuf_pixelbuf_get_auto_write_obj, + (mp_obj_t)&pixelbuf_pixelbuf_set_auto_write_obj); //| byteorder: str //| """byteorder string for the buffer (read-only)""" @@ -230,12 +220,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); -const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_str, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(pixelbuf_pixelbuf_byteorder_str, + (mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_str); STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 4acadc5ab6..bb72b10e7e 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -246,11 +246,9 @@ STATIC mp_obj_t aesio_aes_set_mode(mp_obj_t aesio_obj, mp_obj_t mode_obj) { } MP_DEFINE_CONST_FUN_OBJ_2(aesio_aes_set_mode_obj, aesio_aes_set_mode); -const mp_obj_property_t aesio_aes_mode_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&aesio_aes_get_mode_obj, - (mp_obj_t)&aesio_aes_set_mode_obj, MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(aesio_aes_mode_obj, + (mp_obj_t)&aesio_aes_get_mode_obj, + (mp_obj_t)&aesio_aes_set_mode_obj); STATIC const mp_rom_map_elem_t aesio_locals_dict_table[] = { // Methods diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 50bdfa00de..ff34716786 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -97,12 +97,8 @@ STATIC mp_obj_t alarm_pin_pinalarm_obj_get_pin(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pinalarm_get_pin_obj, alarm_pin_pinalarm_obj_get_pin); -const mp_obj_property_t alarm_pin_pinalarm_pin_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&alarm_pin_pinalarm_get_pin_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(alarm_pin_pinalarm_pin_obj, + (mp_obj_t)&alarm_pin_pinalarm_get_pin_obj); //| value: bool //| """The value on which to trigger.""" @@ -113,12 +109,8 @@ STATIC mp_obj_t alarm_pin_pinalarm_obj_get_value(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pinalarm_get_value_obj, alarm_pin_pinalarm_obj_get_value); -const mp_obj_property_t alarm_pin_pinalarm_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&alarm_pin_pinalarm_get_value_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(alarm_pin_pinalarm_value_obj, + (mp_obj_t)&alarm_pin_pinalarm_get_value_obj); STATIC const mp_rom_map_elem_t alarm_pin_pinalarm_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_pin_pinalarm_pin_obj) }, diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index bd7502e891..ab0274afa9 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -123,12 +123,8 @@ STATIC mp_obj_t alarm_time_timealarm_obj_get_monotonic_time(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_timealarm_get_monotonic_time_obj, alarm_time_timealarm_obj_get_monotonic_time); -const mp_obj_property_t alarm_time_timealarm_monotonic_time_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&alarm_time_timealarm_get_monotonic_time_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(alarm_time_timealarm_monotonic_time_obj, + (mp_obj_t)&alarm_time_timealarm_get_monotonic_time_obj); STATIC const mp_rom_map_elem_t alarm_time_timealarm_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_monotonic_time), MP_ROM_PTR(&alarm_time_timealarm_monotonic_time_obj) }, diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 60b3f97c18..ce5074f7c0 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -71,12 +71,8 @@ STATIC mp_obj_t alarm_touch_touchalarm_obj_get_pin(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(alarm_touch_touchalarm_get_pin_obj, alarm_touch_touchalarm_obj_get_pin); -const mp_obj_property_t alarm_touch_touchalarm_pin_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&alarm_touch_touchalarm_get_pin_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(alarm_touch_touchalarm_pin_obj, + (mp_obj_t)&alarm_touch_touchalarm_get_pin_obj); STATIC const mp_rom_map_elem_t alarm_touch_touchalarm_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_touch_touchalarm_pin_obj) }, diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 636c2500bf..f2c888f727 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -117,12 +117,8 @@ STATIC mp_obj_t analogio_analogin_obj_get_value(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_value_obj, analogio_analogin_obj_get_value); -const mp_obj_property_t analogio_analogin_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&analogio_analogin_get_value_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(analogio_analogin_value_obj, + (mp_obj_t)&analogio_analogin_get_value_obj); //| reference_voltage: float //| """The maximum voltage measurable (also known as the reference voltage) as a @@ -143,12 +139,8 @@ STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_reference_voltage_obj, analogio_analogin_obj_get_reference_voltage); -const mp_obj_property_t analogio_analogin_reference_voltage_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&analogio_analogin_get_reference_voltage_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(analogio_analogin_reference_voltage_obj, + (mp_obj_t)&analogio_analogin_get_reference_voltage_obj); STATIC const mp_rom_map_elem_t analogio_analogin_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogio_analogin_deinit_obj) }, diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index aad298ba07..31173f8890 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -117,12 +117,9 @@ STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t valu } MP_DEFINE_CONST_FUN_OBJ_2(analogio_analogout_set_value_obj, analogio_analogout_obj_set_value); -const mp_obj_property_t analogio_analogout_value_obj = { - .base.type = &mp_type_property, - .proxy = {MP_ROM_NONE, - (mp_obj_t)&analogio_analogout_set_value_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(analogio_analogout_value_obj, + MP_ROM_NONE, + (mp_obj_t)&analogio_analogout_set_value_obj); STATIC const mp_rom_map_elem_t analogio_analogout_locals_dict_table[] = { // instance methods diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 6254f7cde2..93c316d374 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -203,12 +203,8 @@ STATIC mp_obj_t audiobusio_i2sout_obj_get_playing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_get_playing_obj, audiobusio_i2sout_obj_get_playing); -const mp_obj_property_t audiobusio_i2sout_playing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiobusio_i2sout_get_playing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiobusio_i2sout_playing_obj, + (mp_obj_t)&audiobusio_i2sout_get_playing_obj); //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" @@ -252,12 +248,8 @@ STATIC mp_obj_t audiobusio_i2sout_obj_get_paused(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_get_paused_obj, audiobusio_i2sout_obj_get_paused); -const mp_obj_property_t audiobusio_i2sout_paused_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiobusio_i2sout_get_paused_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiobusio_i2sout_paused_obj, + (mp_obj_t)&audiobusio_i2sout_get_paused_obj); #endif // CIRCUITPY_AUDIOBUSIO_I2SOUT STATIC const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = { diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 201b6abcec..aa810f2930 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -226,12 +226,8 @@ STATIC mp_obj_t audiobusio_pdmin_obj_get_sample_rate(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_pdmin_get_sample_rate_obj, audiobusio_pdmin_obj_get_sample_rate); -const mp_obj_property_t audiobusio_pdmin_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiobusio_pdmin_get_sample_rate_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiobusio_pdmin_sample_rate_obj, + (mp_obj_t)&audiobusio_pdmin_get_sample_rate_obj); STATIC const mp_rom_map_elem_t audiobusio_pdmin_locals_dict_table[] = { // Methods diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 05c5b14b5e..82c02450ba 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -153,12 +153,9 @@ STATIC mp_obj_t audioio_rawsample_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(audioio_rawsample_set_sample_rate_obj, audioio_rawsample_obj_set_sample_rate); -const mp_obj_property_t audioio_rawsample_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_rawsample_get_sample_rate_obj, - (mp_obj_t)&audioio_rawsample_set_sample_rate_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(audioio_rawsample_sample_rate_obj, + (mp_obj_t)&audioio_rawsample_get_sample_rate_obj, + (mp_obj_t)&audioio_rawsample_set_sample_rate_obj); STATIC const mp_rom_map_elem_t audioio_rawsample_locals_dict_table[] = { // Methods diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 1a8b5cae11..285bd7cbbe 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -148,12 +148,9 @@ STATIC mp_obj_t audioio_wavefile_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(audioio_wavefile_set_sample_rate_obj, audioio_wavefile_obj_set_sample_rate); -const mp_obj_property_t audioio_wavefile_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_wavefile_get_sample_rate_obj, - (mp_obj_t)&audioio_wavefile_set_sample_rate_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(audioio_wavefile_sample_rate_obj, + (mp_obj_t)&audioio_wavefile_get_sample_rate_obj, + (mp_obj_t)&audioio_wavefile_set_sample_rate_obj); //| bits_per_sample: int //| """Bits per sample. (read only)""" @@ -165,12 +162,8 @@ STATIC mp_obj_t audioio_wavefile_obj_get_bits_per_sample(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_get_bits_per_sample_obj, audioio_wavefile_obj_get_bits_per_sample); -const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_wavefile_get_bits_per_sample_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audioio_wavefile_bits_per_sample_obj, + (mp_obj_t)&audioio_wavefile_get_bits_per_sample_obj); //| channel_count: int //| """Number of audio channels. (read only)""" //| @@ -181,12 +174,8 @@ STATIC mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_get_channel_count_obj, audioio_wavefile_obj_get_channel_count); -const mp_obj_property_t audioio_wavefile_channel_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_wavefile_get_channel_count_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audioio_wavefile_channel_count_obj, + (mp_obj_t)&audioio_wavefile_get_channel_count_obj); STATIC const mp_rom_map_elem_t audioio_wavefile_locals_dict_table[] = { diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 2fd4c0c452..0b4ed7b975 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -197,12 +197,8 @@ STATIC mp_obj_t audioio_audioout_obj_get_playing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_get_playing_obj, audioio_audioout_obj_get_playing); -const mp_obj_property_t audioio_audioout_playing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_audioout_get_playing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audioio_audioout_playing_obj, + (mp_obj_t)&audioio_audioout_get_playing_obj); //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" @@ -246,12 +242,8 @@ STATIC mp_obj_t audioio_audioout_obj_get_paused(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_get_paused_obj, audioio_audioout_obj_get_paused); -const mp_obj_property_t audioio_audioout_paused_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audioio_audioout_get_paused_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audioio_audioout_paused_obj, + (mp_obj_t)&audioio_audioout_get_paused_obj); STATIC const mp_rom_map_elem_t audioio_audioout_locals_dict_table[] = { // Methods diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 3248e649c9..a165435ff0 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -166,12 +166,8 @@ STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomixer_mixer_get_playing_obj, audiomixer_mixer_obj_get_playing); -const mp_obj_property_t audiomixer_mixer_playing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomixer_mixer_get_playing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomixer_mixer_playing_obj, + (mp_obj_t)&audiomixer_mixer_get_playing_obj); //| sample_rate: int //| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" @@ -183,12 +179,8 @@ STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomixer_mixer_get_sample_rate_obj, audiomixer_mixer_obj_get_sample_rate); -const mp_obj_property_t audiomixer_mixer_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomixer_mixer_get_sample_rate_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomixer_mixer_sample_rate_obj, + (mp_obj_t)&audiomixer_mixer_get_sample_rate_obj); //| voice: Tuple[MixerVoice, ...] //| """A tuple of the mixer's `audiomixer.MixerVoice` object(s). @@ -204,12 +196,8 @@ STATIC mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomixer_mixer_get_voice_obj, audiomixer_mixer_obj_get_voice); -const mp_obj_property_t audiomixer_mixer_voice_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomixer_mixer_get_voice_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomixer_mixer_voice_obj, + (mp_obj_t)&audiomixer_mixer_get_voice_obj); //| def play(self, sample: circuitpython_typing.AudioSample, *, voice: int = 0, loop: bool = False) -> None: //| """Plays the sample once when loop=False and continuously when loop=True. diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 82b6972864..f02b9521af 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -130,12 +130,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_set_level(size_t n_args, const mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_set_level_obj, 1, audiomixer_mixervoice_obj_set_level); -const mp_obj_property_t audiomixer_mixervoice_level_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomixer_mixervoice_get_level_obj, - (mp_obj_t)&audiomixer_mixervoice_set_level_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(audiomixer_mixervoice_level_obj, + (mp_obj_t)&audiomixer_mixervoice_get_level_obj, + (mp_obj_t)&audiomixer_mixervoice_set_level_obj); //| playing: bool //| """True when this voice is being output. (read-only)""" @@ -149,12 +146,8 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomixer_mixervoice_get_playing_obj, audiomixer_mixervoice_obj_get_playing); -const mp_obj_property_t audiomixer_mixervoice_playing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomixer_mixervoice_get_playing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomixer_mixervoice_playing_obj, + (mp_obj_t)&audiomixer_mixervoice_get_playing_obj); STATIC const mp_rom_map_elem_t audiomixer_mixervoice_locals_dict_table[] = { // Methods diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 06d9eabbcc..16efa361b8 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -166,12 +166,9 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { } MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file); -const mp_obj_property_t audiomp3_mp3file_file_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_file_obj, - (mp_obj_t)&audiomp3_mp3file_set_file_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(audiomp3_mp3file_file_obj, + (mp_obj_t)&audiomp3_mp3file_get_file_obj, + (mp_obj_t)&audiomp3_mp3file_set_file_obj); @@ -195,12 +192,9 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_sample_rate_obj, audiomp3_mp3file_obj_set_sample_rate); -const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_sample_rate_obj, - (mp_obj_t)&audiomp3_mp3file_set_sample_rate_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(audiomp3_mp3file_sample_rate_obj, + (mp_obj_t)&audiomp3_mp3file_get_sample_rate_obj, + (mp_obj_t)&audiomp3_mp3file_set_sample_rate_obj); //| bits_per_sample: int //| """Bits per sample. (read only)""" @@ -212,12 +206,8 @@ STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_bits_per_sample_obj, audiomp3_mp3file_obj_get_bits_per_sample); -const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_bits_per_sample_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomp3_mp3file_bits_per_sample_obj, + (mp_obj_t)&audiomp3_mp3file_get_bits_per_sample_obj); //| channel_count: int //| """Number of audio channels. (read only)""" @@ -229,12 +219,8 @@ STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_channel_count_obj, audiomp3_mp3file_obj_get_channel_count); -const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_channel_count_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomp3_mp3file_channel_count_obj, + (mp_obj_t)&audiomp3_mp3file_get_channel_count_obj); //| rms_level: float //| """The RMS audio level of a recently played moment of audio. (read only)""" @@ -246,12 +232,8 @@ STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_rms_level_obj, audiomp3_mp3file_obj_get_rms_level); -const mp_obj_property_t audiomp3_mp3file_rms_level_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_rms_level_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomp3_mp3file_rms_level_obj, + (mp_obj_t)&audiomp3_mp3file_get_rms_level_obj); //| samples_decoded: int //| """The number of audio samples decoded from the current file. (read only)""" @@ -263,12 +245,8 @@ STATIC mp_obj_t audiomp3_mp3file_obj_get_samples_decoded(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_samples_decoded_obj, audiomp3_mp3file_obj_get_samples_decoded); -const mp_obj_property_t audiomp3_mp3file_samples_decoded_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiomp3_mp3file_get_samples_decoded_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiomp3_mp3file_samples_decoded_obj, + (mp_obj_t)&audiomp3_mp3file_get_samples_decoded_obj); STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { // Methods diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 85332d0fac..8118eb47f2 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -198,12 +198,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_playing_obj, audiopwmio_pwmaudioout_obj_get_playing); -const mp_obj_property_t audiopwmio_pwmaudioout_playing_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_playing_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiopwmio_pwmaudioout_playing_obj, + (mp_obj_t)&audiopwmio_pwmaudioout_get_playing_obj); //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" @@ -247,12 +243,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_paused_obj, audiopwmio_pwmaudioout_obj_get_paused); -const mp_obj_property_t audiopwmio_pwmaudioout_paused_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_paused_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(audiopwmio_pwmaudioout_paused_obj, + (mp_obj_t)&audiopwmio_pwmaudioout_get_paused_obj); STATIC const mp_rom_map_elem_t audiopwmio_pwmaudioout_locals_dict_table[] = { // Methods diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 92fff7e571..0a6c32f20b 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -425,12 +425,8 @@ STATIC mp_obj_t busio_spi_obj_get_frequency(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_get_frequency_obj, busio_spi_obj_get_frequency); -const mp_obj_property_t busio_spi_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&busio_spi_get_frequency_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(busio_spi_frequency_obj, + (mp_obj_t)&busio_spi_get_frequency_obj); #endif // CIRCUITPY_BUSIO_SPI diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 06a0fb128d..ae14e314af 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -308,12 +308,9 @@ STATIC mp_obj_t busio_uart_obj_set_baudrate(mp_obj_t self_in, mp_obj_t baudrate) MP_DEFINE_CONST_FUN_OBJ_2(busio_uart_set_baudrate_obj, busio_uart_obj_set_baudrate); -const mp_obj_property_t busio_uart_baudrate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&busio_uart_get_baudrate_obj, - (mp_obj_t)&busio_uart_set_baudrate_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(busio_uart_baudrate_obj, + (mp_obj_t)&busio_uart_get_baudrate_obj, + (mp_obj_t)&busio_uart_set_baudrate_obj); //| in_waiting: int //| """The number of bytes in the input buffer, available to be read""" @@ -325,12 +322,8 @@ STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_in_waiting_obj, busio_uart_obj_get_in_waiting); -const mp_obj_property_t busio_uart_in_waiting_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&busio_uart_get_in_waiting_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(busio_uart_in_waiting_obj, + (mp_obj_t)&busio_uart_get_in_waiting_obj); //| timeout: float //| """The current timeout, in seconds (float).""" @@ -353,12 +346,9 @@ STATIC mp_obj_t busio_uart_obj_set_timeout(mp_obj_t self_in, mp_obj_t timeout) { MP_DEFINE_CONST_FUN_OBJ_2(busio_uart_set_timeout_obj, busio_uart_obj_set_timeout); -const mp_obj_property_t busio_uart_timeout_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&busio_uart_get_timeout_obj, - (mp_obj_t)&busio_uart_set_timeout_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(busio_uart_timeout_obj, + (mp_obj_t)&busio_uart_get_timeout_obj, + (mp_obj_t)&busio_uart_set_timeout_obj); //| def reset_input_buffer(self) -> None: //| """Discard any unread characters in the input buffer.""" diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index ec9c2b8a68..e8aec7f0a1 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -112,12 +112,9 @@ STATIC mp_obj_t canio_can_auto_restart_set(mp_obj_t self_in, mp_obj_t flag_in) { } MP_DEFINE_CONST_FUN_OBJ_2(canio_can_auto_restart_set_obj, canio_can_auto_restart_set); -STATIC const mp_obj_property_t canio_can_auto_restart_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_auto_restart_get_obj, - (mp_obj_t)&canio_can_auto_restart_set_obj, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETSET(canio_can_auto_restart_obj, + (mp_obj_t)&canio_can_auto_restart_get_obj, + (mp_obj_t)&canio_can_auto_restart_set_obj); //| baudrate: int @@ -130,12 +127,8 @@ STATIC mp_obj_t canio_can_baudrate_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_can_baudrate_get_obj, canio_can_baudrate_get); -STATIC const mp_obj_property_t canio_can_baudrate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_baudrate_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_baudrate_obj, + (mp_obj_t)&canio_can_baudrate_get_obj); //| transmit_error_count: int //| """The number of transmit errors (read-only). Increased for a detected transmission error, decreased for successful transmission. Limited to the range from 0 to 255 inclusive. Also called TEC.""" @@ -147,12 +140,8 @@ STATIC mp_obj_t canio_can_transmit_error_count_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_can_transmit_error_count_get_obj, canio_can_transmit_error_count_get); -STATIC const mp_obj_property_t canio_can_transmit_error_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_transmit_error_count_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_transmit_error_count_obj, + (mp_obj_t)&canio_can_transmit_error_count_get_obj); //| receive_error_count: int //| """The number of receive errors (read-only). Increased for a detected reception error, decreased for successful reception. Limited to the range from 0 to 255 inclusive. Also called REC.""" @@ -164,12 +153,8 @@ STATIC mp_obj_t canio_can_receive_error_count_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_can_receive_error_count_get_obj, canio_can_receive_error_count_get); -STATIC const mp_obj_property_t canio_can_receive_error_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_receive_error_count_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_receive_error_count_obj, + (mp_obj_t)&canio_can_receive_error_count_get_obj); //| state: BusState //| """The current state of the bus. (read-only)""" @@ -181,12 +166,8 @@ STATIC mp_obj_t canio_can_state_get(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(canio_can_state_get_obj, canio_can_state_get); -STATIC const mp_obj_property_t canio_can_state_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_state_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_state_obj, + (mp_obj_t)&canio_can_state_get_obj); //| def restart(self) -> None: @@ -283,12 +264,8 @@ STATIC mp_obj_t canio_can_loopback_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_can_loopback_get_obj, canio_can_loopback_get); -STATIC const mp_obj_property_t canio_can_loopback_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_loopback_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_loopback_obj, + (mp_obj_t)&canio_can_loopback_get_obj); //| def send(self, message: Union[RemoteTransmissionRequest, Message]) -> None: @@ -322,12 +299,8 @@ STATIC mp_obj_t canio_can_silent_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_can_silent_get_obj, canio_can_silent_get); -STATIC const mp_obj_property_t canio_can_silent_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_can_silent_get_obj, - (mp_obj_t)mp_const_none, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETTER(canio_can_silent_obj, + (mp_obj_t)&canio_can_silent_get_obj); //| def deinit(self) -> None: diff --git a/shared-bindings/canio/Listener.c b/shared-bindings/canio/Listener.c index 6f4e53282f..e59801d4e4 100644 --- a/shared-bindings/canio/Listener.c +++ b/shared-bindings/canio/Listener.c @@ -150,12 +150,9 @@ STATIC mp_obj_t canio_listener_timeout_set(mp_obj_t self_in, mp_obj_t timeout_in } STATIC MP_DEFINE_CONST_FUN_OBJ_2(canio_listener_timeout_set_obj, canio_listener_timeout_set); -STATIC const mp_obj_property_t canio_listener_timeout_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_listener_timeout_get_obj, - (mp_obj_t)&canio_listener_timeout_set_obj, - (mp_obj_t)mp_const_none}, -}; +MP_PROPERTY_GETSET(canio_listener_timeout_obj, + (mp_obj_t)&canio_listener_timeout_get_obj, + (mp_obj_t)&canio_listener_timeout_set_obj); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index e8379d3eda..52262b0a6c 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -82,12 +82,8 @@ STATIC mp_obj_t canio_match_id_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_match_id_get_obj, canio_match_id_get); -const mp_obj_property_t canio_match_id_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_match_id_get_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(canio_match_id_obj, + (mp_obj_t)&canio_match_id_get_obj); //| //| mask: int @@ -100,12 +96,8 @@ STATIC mp_obj_t canio_match_mask_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_match_mask_get_obj, canio_match_mask_get); -const mp_obj_property_t canio_match_mask_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_match_mask_get_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(canio_match_mask_obj, + (mp_obj_t)&canio_match_mask_get_obj); //| extended: bool //| """True to match extended ids, False to match standard ides""" @@ -117,12 +109,8 @@ STATIC mp_obj_t canio_match_extended_get(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(canio_match_extended_get_obj, canio_match_extended_get); -const mp_obj_property_t canio_match_extended_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_match_extended_get_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(canio_match_extended_obj, + (mp_obj_t)&canio_match_extended_get_obj); STATIC const mp_rom_map_elem_t canio_match_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&canio_match_id_obj) }, diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index 8ed1352dcc..64d4094b3f 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -83,12 +83,9 @@ STATIC mp_obj_t canio_message_id_set(const mp_obj_t self_in, const mp_obj_t id) } MP_DEFINE_CONST_FUN_OBJ_2(canio_message_id_set_obj, canio_message_id_set); -STATIC const mp_obj_property_t canio_message_id_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_message_id_get_obj, - (mp_obj_t)&canio_message_id_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_message_id_obj, + (mp_obj_t)&canio_message_id_get_obj, + (mp_obj_t)&canio_message_id_set_obj); //| data: bytes //| """The content of the message""" @@ -112,12 +109,9 @@ STATIC mp_obj_t canio_message_data_set(const mp_obj_t self_in, const mp_obj_t da MP_DEFINE_CONST_FUN_OBJ_2(canio_message_data_set_obj, canio_message_data_set); -STATIC const mp_obj_property_t canio_message_data_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_message_data_get_obj, - (mp_obj_t)&canio_message_data_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_message_data_obj, + (mp_obj_t)&canio_message_data_get_obj, + (mp_obj_t)&canio_message_data_set_obj); //| extended: bool @@ -137,12 +131,9 @@ STATIC mp_obj_t canio_message_extended_set(const mp_obj_t self_in, const mp_obj_ MP_DEFINE_CONST_FUN_OBJ_2(canio_message_extended_set_obj, canio_message_extended_set); -STATIC const mp_obj_property_t canio_message_extended_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_message_extended_get_obj, - (mp_obj_t)&canio_message_extended_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_message_extended_obj, + (mp_obj_t)&canio_message_extended_get_obj, + (mp_obj_t)&canio_message_extended_set_obj); STATIC const mp_rom_map_elem_t canio_message_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&canio_message_id_obj) }, diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 3267cf914d..58ac3aa2de 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -82,12 +82,9 @@ STATIC mp_obj_t canio_remote_transmission_request_id_set(const mp_obj_t self_in, } MP_DEFINE_CONST_FUN_OBJ_2(canio_remote_transmission_request_id_set_obj, canio_remote_transmission_request_id_set); -STATIC const mp_obj_property_t canio_remote_transmission_request_id_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_remote_transmission_request_id_get_obj, - (mp_obj_t)&canio_remote_transmission_request_id_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_remote_transmission_request_id_obj, + (mp_obj_t)&canio_remote_transmission_request_id_get_obj, + (mp_obj_t)&canio_remote_transmission_request_id_set_obj); //| extended: bool //| """True if the message's id is an extended id""" @@ -106,12 +103,9 @@ STATIC mp_obj_t canio_remote_transmission_request_extended_set(const mp_obj_t se MP_DEFINE_CONST_FUN_OBJ_2(canio_remote_transmission_request_extended_set_obj, canio_remote_transmission_request_extended_set); -STATIC const mp_obj_property_t canio_remote_transmission_request_extended_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_remote_transmission_request_extended_get_obj, - (mp_obj_t)&canio_remote_transmission_request_extended_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_remote_transmission_request_extended_obj, + (mp_obj_t)&canio_remote_transmission_request_extended_get_obj, + (mp_obj_t)&canio_remote_transmission_request_extended_set_obj); //| length: int //| """The length of the requested message.""" @@ -134,12 +128,9 @@ STATIC mp_obj_t canio_remote_transmission_request_length_set(const mp_obj_t self MP_DEFINE_CONST_FUN_OBJ_2(canio_remote_transmission_request_length_set_obj, canio_remote_transmission_request_length_set); -STATIC const mp_obj_property_t canio_remote_transmission_request_length_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&canio_remote_transmission_request_length_get_obj, - (mp_obj_t)&canio_remote_transmission_request_length_set_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(canio_remote_transmission_request_length_obj, + (mp_obj_t)&canio_remote_transmission_request_length_get_obj, + (mp_obj_t)&canio_remote_transmission_request_length_set_obj); STATIC const mp_rom_map_elem_t canio_remote_transmission_request_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&canio_remote_transmission_request_id_obj) }, diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index f165eda202..19141245e1 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -114,12 +114,9 @@ STATIC mp_obj_t countio_counter_obj_set_count(mp_obj_t self_in, mp_obj_t new_cou } MP_DEFINE_CONST_FUN_OBJ_2(countio_counter_set_count_obj, countio_counter_obj_set_count); -const mp_obj_property_t countio_counter_count_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&countio_counter_get_count_obj, - (mp_obj_t)&countio_counter_set_count_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(countio_counter_count_obj, + (mp_obj_t)&countio_counter_get_count_obj, + (mp_obj_t)&countio_counter_set_count_obj); //| def reset(self) -> None: //| """Resets the count back to 0.""" diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index af7defd911..37093add8f 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -213,12 +213,9 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_direction(mp_obj_t self_in, mp_ob } MP_DEFINE_CONST_FUN_OBJ_2(digitalio_digitalinout_set_direction_obj, digitalio_digitalinout_obj_set_direction); -const mp_obj_property_t digitalio_digitalio_direction_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&digitalio_digitalinout_get_direction_obj, - (mp_obj_t)&digitalio_digitalinout_set_direction_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(digitalio_digitalio_direction_obj, + (mp_obj_t)&digitalio_digitalinout_get_direction_obj, + (mp_obj_t)&digitalio_digitalinout_set_direction_obj); //| value: bool //| """The digital logic level of the pin.""" @@ -243,12 +240,9 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_value(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(digitalio_digitalinout_set_value_obj, digitalio_digitalinout_obj_set_value); -const mp_obj_property_t digitalio_digitalinout_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&digitalio_digitalinout_get_value_obj, - (mp_obj_t)&digitalio_digitalinout_set_value_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(digitalio_digitalinout_value_obj, + (mp_obj_t)&digitalio_digitalinout_get_value_obj, + (mp_obj_t)&digitalio_digitalinout_set_value_obj); //| drive_mode: DriveMode //| """The pin drive mode. One of: @@ -287,12 +281,9 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_drive_mode(mp_obj_t self_in, mp_o } MP_DEFINE_CONST_FUN_OBJ_2(digitalio_digitalinout_set_drive_mode_obj, digitalio_digitalinout_obj_set_drive_mode); -const mp_obj_property_t digitalio_digitalio_drive_mode_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&digitalio_digitalinout_get_drive_mode_obj, - (mp_obj_t)&digitalio_digitalinout_set_drive_mode_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(digitalio_digitalio_drive_mode_obj, + (mp_obj_t)&digitalio_digitalinout_get_drive_mode_obj, + (mp_obj_t)&digitalio_digitalinout_set_drive_mode_obj); //| pull: Optional[Pull] //| """The pin pull direction. One of: @@ -333,12 +324,9 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t p } MP_DEFINE_CONST_FUN_OBJ_2(digitalio_digitalinout_set_pull_obj, digitalio_digitalinout_obj_set_pull); -const mp_obj_property_t digitalio_digitalio_pull_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&digitalio_digitalinout_get_pull_obj, - (mp_obj_t)&digitalio_digitalinout_set_pull_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(digitalio_digitalio_pull_obj, + (mp_obj_t)&digitalio_digitalinout_get_pull_obj, + (mp_obj_t)&digitalio_digitalinout_set_pull_obj); STATIC const mp_rom_map_elem_t digitalio_digitalinout_locals_dict_table[] = { // instance methods diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index f8f47d34f4..3af152ffdc 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -97,12 +97,8 @@ STATIC mp_obj_t displayio_bitmap_obj_get_width(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_get_width_obj, displayio_bitmap_obj_get_width); -const mp_obj_property_t displayio_bitmap_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_bitmap_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_bitmap_width_obj, + (mp_obj_t)&displayio_bitmap_get_width_obj); //| height: int //| """Height of the bitmap. (read only)""" @@ -115,12 +111,8 @@ STATIC mp_obj_t displayio_bitmap_obj_get_height(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_get_height_obj, displayio_bitmap_obj_get_height); -const mp_obj_property_t displayio_bitmap_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_bitmap_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_bitmap_height_obj, + (mp_obj_t)&displayio_bitmap_get_height_obj); //| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int: //| """Returns the value at the given index. The index can either be an x,y tuple or an int equal diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index f2ca006ced..18b88664c0 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -103,12 +103,9 @@ STATIC mp_obj_t displayio_colorconverter_obj_set_dither(mp_obj_t self_in, mp_obj } MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_set_dither_obj, displayio_colorconverter_obj_set_dither); -const mp_obj_property_t displayio_colorconverter_dither_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_colorconverter_get_dither_obj, - (mp_obj_t)&displayio_colorconverter_set_dither_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_colorconverter_dither_obj, + (mp_obj_t)&displayio_colorconverter_get_dither_obj, + (mp_obj_t)&displayio_colorconverter_set_dither_obj); //| def make_transparent(self, color: int) -> None: //| """Set the transparent color or index for the ColorConverter. This will diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index f7b3305439..253887f1de 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -297,12 +297,9 @@ STATIC mp_obj_t displayio_display_obj_set_auto_refresh(mp_obj_t self_in, mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_auto_refresh_obj, displayio_display_obj_set_auto_refresh); -const mp_obj_property_t displayio_display_auto_refresh_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_auto_refresh_obj, - (mp_obj_t)&displayio_display_set_auto_refresh_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_display_auto_refresh_obj, + (mp_obj_t)&displayio_display_get_auto_refresh_obj, + (mp_obj_t)&displayio_display_set_auto_refresh_obj); //| brightness: float //| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When @@ -334,12 +331,9 @@ STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_brightness_obj, displayio_display_obj_set_brightness); -const mp_obj_property_t displayio_display_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_brightness_obj, - (mp_obj_t)&displayio_display_set_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_display_brightness_obj, + (mp_obj_t)&displayio_display_get_brightness_obj, + (mp_obj_t)&displayio_display_set_brightness_obj); //| auto_brightness: bool //| """True when the display brightness is adjusted automatically, based on an ambient @@ -362,12 +356,9 @@ STATIC mp_obj_t displayio_display_obj_set_auto_brightness(mp_obj_t self_in, mp_o } MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_auto_brightness_obj, displayio_display_obj_set_auto_brightness); -const mp_obj_property_t displayio_display_auto_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_auto_brightness_obj, - (mp_obj_t)&displayio_display_set_auto_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_display_auto_brightness_obj, + (mp_obj_t)&displayio_display_get_auto_brightness_obj, + (mp_obj_t)&displayio_display_set_auto_brightness_obj); @@ -381,12 +372,8 @@ STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_width_obj, displayio_display_obj_get_width); -const mp_obj_property_t displayio_display_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_display_width_obj, + (mp_obj_t)&displayio_display_get_width_obj); //| height: int //| """Gets the height of the board""" @@ -397,12 +384,8 @@ STATIC mp_obj_t displayio_display_obj_get_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_height_obj, displayio_display_obj_get_height); -const mp_obj_property_t displayio_display_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_display_height_obj, + (mp_obj_t)&displayio_display_get_height_obj); //| rotation: int //| """The rotation of the display as an int in degrees.""" @@ -420,12 +403,9 @@ STATIC mp_obj_t displayio_display_obj_set_rotation(mp_obj_t self_in, mp_obj_t va MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_rotation_obj, displayio_display_obj_set_rotation); -const mp_obj_property_t displayio_display_rotation_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_rotation_obj, - (mp_obj_t)&displayio_display_set_rotation_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_display_rotation_obj, + (mp_obj_t)&displayio_display_get_rotation_obj, + (mp_obj_t)&displayio_display_set_rotation_obj); //| bus: _DisplayBus //| """The bus being used by the display""" @@ -437,12 +417,8 @@ STATIC mp_obj_t displayio_display_obj_get_bus(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_bus_obj, displayio_display_obj_get_bus); -const mp_obj_property_t displayio_display_bus_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_bus_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_display_bus_obj, + (mp_obj_t)&displayio_display_get_bus_obj); //| root_group: Group //| """The root group on the display.""" @@ -454,12 +430,8 @@ STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); -const mp_obj_property_t displayio_display_root_group_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_display_get_root_group_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_display_root_group_obj, + (mp_obj_t)&displayio_display_get_root_group_obj); //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index aa14594d97..94d2978cef 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -268,12 +268,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_get_time_to_refresh(mp_obj_t self_in } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_time_to_refresh_obj, displayio_epaperdisplay_obj_get_time_to_refresh); -const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_time_to_refresh_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_epaperdisplay_time_to_refresh_obj, + (mp_obj_t)&displayio_epaperdisplay_get_time_to_refresh_obj); //| busy: bool //| """True when the display is refreshing. This uses the ``busy_pin`` when available or the @@ -285,12 +281,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_get_busy(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_busy_obj, displayio_epaperdisplay_obj_get_busy); -const mp_obj_property_t displayio_epaperdisplay_busy_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_busy_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_epaperdisplay_busy_obj, + (mp_obj_t)&displayio_epaperdisplay_get_busy_obj); //| width: int //| """Gets the width of the display in pixels""" @@ -301,12 +293,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_get_width(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_width_obj, displayio_epaperdisplay_obj_get_width); -const mp_obj_property_t displayio_epaperdisplay_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_epaperdisplay_width_obj, + (mp_obj_t)&displayio_epaperdisplay_get_width_obj); //| height: int //| """Gets the height of the display in pixels""" @@ -317,12 +305,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_get_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_height_obj, displayio_epaperdisplay_obj_get_height); -const mp_obj_property_t displayio_epaperdisplay_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_epaperdisplay_height_obj, + (mp_obj_t)&displayio_epaperdisplay_get_height_obj); //| rotation: int //| """The rotation of the display as an int in degrees.""" @@ -340,12 +324,9 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_set_rotation(mp_obj_t self_in, mp_ob MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_set_rotation_obj, displayio_epaperdisplay_obj_set_rotation); -const mp_obj_property_t displayio_epaperdisplay_rotation_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_rotation_obj, - (mp_obj_t)&displayio_epaperdisplay_set_rotation_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_epaperdisplay_rotation_obj, + (mp_obj_t)&displayio_epaperdisplay_get_rotation_obj, + (mp_obj_t)&displayio_epaperdisplay_set_rotation_obj); //| bus: _DisplayBus //| """The bus being used by the display""" @@ -356,12 +337,8 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_get_bus(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_bus_obj, displayio_epaperdisplay_obj_get_bus); -const mp_obj_property_t displayio_epaperdisplay_bus_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_bus_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_epaperdisplay_bus_obj, + (mp_obj_t)&displayio_epaperdisplay_get_bus_obj); STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = { diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 33329e5ece..188331f99d 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -97,12 +97,9 @@ STATIC mp_obj_t displayio_group_obj_set_hidden(mp_obj_t self_in, mp_obj_t hidden } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_set_hidden_obj, displayio_group_obj_set_hidden); -const mp_obj_property_t displayio_group_hidden_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_group_get_hidden_obj, - (mp_obj_t)&displayio_group_set_hidden_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_group_hidden_obj, + (mp_obj_t)&displayio_group_get_hidden_obj, + (mp_obj_t)&displayio_group_set_hidden_obj); //| scale: int //| """Scales each pixel within the Group in both directions. For example, when scale=2 each pixel @@ -126,12 +123,9 @@ STATIC mp_obj_t displayio_group_obj_set_scale(mp_obj_t self_in, mp_obj_t scale_o } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_set_scale_obj, displayio_group_obj_set_scale); -const mp_obj_property_t displayio_group_scale_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_group_get_scale_obj, - (mp_obj_t)&displayio_group_set_scale_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_group_scale_obj, + (mp_obj_t)&displayio_group_get_scale_obj, + (mp_obj_t)&displayio_group_set_scale_obj); //| x: int //| """X position of the Group in the parent.""" @@ -151,12 +145,9 @@ STATIC mp_obj_t displayio_group_obj_set_x(mp_obj_t self_in, mp_obj_t x_obj) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_set_x_obj, displayio_group_obj_set_x); -const mp_obj_property_t displayio_group_x_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_group_get_x_obj, - (mp_obj_t)&displayio_group_set_x_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_group_x_obj, + (mp_obj_t)&displayio_group_get_x_obj, + (mp_obj_t)&displayio_group_set_x_obj); //| y: int //| """Y position of the Group in the parent.""" @@ -176,12 +167,9 @@ STATIC mp_obj_t displayio_group_obj_set_y(mp_obj_t self_in, mp_obj_t y_obj) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_set_y_obj, displayio_group_obj_set_y); -const mp_obj_property_t displayio_group_y_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_group_get_y_obj, - (mp_obj_t)&displayio_group_set_y_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_group_y_obj, + (mp_obj_t)&displayio_group_get_y_obj, + (mp_obj_t)&displayio_group_set_y_obj); //| def append(self, layer: Union[vectorio.Circle, vectorio.Rectangle, vectorio.Polygon, Group, TileGrid]) -> None: //| """Append a layer to the group. It will be drawn above other layers.""" diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 0564b48fe8..aa749bf7f7 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -109,13 +109,8 @@ STATIC mp_obj_t displayio_ondiskbitmap_obj_get_width(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_width_obj, displayio_ondiskbitmap_obj_get_width); -const mp_obj_property_t displayio_ondiskbitmap_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_ondiskbitmap_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, - -}; +MP_PROPERTY_GETTER(displayio_ondiskbitmap_width_obj, + (mp_obj_t)&displayio_ondiskbitmap_get_width_obj); //| height: int //| """Height of the bitmap. (read only)""" @@ -128,13 +123,8 @@ STATIC mp_obj_t displayio_ondiskbitmap_obj_get_height(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_height_obj, displayio_ondiskbitmap_obj_get_height); -const mp_obj_property_t displayio_ondiskbitmap_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_ondiskbitmap_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, - -}; +MP_PROPERTY_GETTER(displayio_ondiskbitmap_height_obj, + (mp_obj_t)&displayio_ondiskbitmap_get_height_obj); //| pixel_shader: Union[ColorConverter, Palette] //| """The image's pixel_shader. The type depends on the underlying diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 4628939e27..113721bcc6 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -161,12 +161,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_hidden(mp_obj_t self_in, mp_obj_t hid } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_hidden_obj, displayio_tilegrid_obj_set_hidden); -const mp_obj_property_t displayio_tilegrid_hidden_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_hidden_obj, - (mp_obj_t)&displayio_tilegrid_set_hidden_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_hidden_obj, + (mp_obj_t)&displayio_tilegrid_get_hidden_obj, + (mp_obj_t)&displayio_tilegrid_set_hidden_obj); //| x: int //| """X position of the left edge in the parent.""" @@ -186,12 +183,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_x(mp_obj_t self_in, mp_obj_t x_obj) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_x_obj, displayio_tilegrid_obj_set_x); -const mp_obj_property_t displayio_tilegrid_x_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_x_obj, - (mp_obj_t)&displayio_tilegrid_set_x_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_x_obj, + (mp_obj_t)&displayio_tilegrid_get_x_obj, + (mp_obj_t)&displayio_tilegrid_set_x_obj); //| y: int //| """Y position of the top edge in the parent.""" @@ -211,12 +205,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_y(mp_obj_t self_in, mp_obj_t y_obj) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_y_obj, displayio_tilegrid_obj_set_y); -const mp_obj_property_t displayio_tilegrid_y_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_y_obj, - (mp_obj_t)&displayio_tilegrid_set_y_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_y_obj, + (mp_obj_t)&displayio_tilegrid_get_y_obj, + (mp_obj_t)&displayio_tilegrid_set_y_obj); //| width: int //| """Width of the tilegrid in tiles.""" @@ -227,11 +218,8 @@ STATIC mp_obj_t displayio_tilegrid_obj_get_width(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_width_obj, displayio_tilegrid_obj_get_width); -const mp_obj_property_t displayio_tilegrid_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_width_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_tilegrid_width_obj, + (mp_obj_t)&displayio_tilegrid_get_width_obj); //| height: int //| """Height of the tilegrid in tiles.""" @@ -242,11 +230,8 @@ STATIC mp_obj_t displayio_tilegrid_obj_get_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_height_obj, displayio_tilegrid_obj_get_height); -const mp_obj_property_t displayio_tilegrid_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_height_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_tilegrid_height_obj, + (mp_obj_t)&displayio_tilegrid_get_height_obj); //| tile_width: int //| """Width of a single tile in pixels.""" @@ -257,11 +242,8 @@ STATIC mp_obj_t displayio_tilegrid_obj_get_tile_width(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_tile_width_obj, displayio_tilegrid_obj_get_tile_width); -const mp_obj_property_t displayio_tilegrid_tile_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_tile_width_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_tilegrid_tile_width_obj, + (mp_obj_t)&displayio_tilegrid_get_tile_width_obj); //| tile_height: int //| """Height of a single tile in pixels.""" @@ -272,11 +254,8 @@ STATIC mp_obj_t displayio_tilegrid_obj_get_tile_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_tile_height_obj, displayio_tilegrid_obj_get_tile_height); -const mp_obj_property_t displayio_tilegrid_tile_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_tile_height_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(displayio_tilegrid_tile_height_obj, + (mp_obj_t)&displayio_tilegrid_get_tile_height_obj); //| flip_x: bool //| """If true, the left edge rendered will be the right edge of the right-most tile.""" @@ -295,12 +274,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_flip_x(mp_obj_t self_in, mp_obj_t fli } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_flip_x_obj, displayio_tilegrid_obj_set_flip_x); -const mp_obj_property_t displayio_tilegrid_flip_x_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_flip_x_obj, - (mp_obj_t)&displayio_tilegrid_set_flip_x_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_flip_x_obj, + (mp_obj_t)&displayio_tilegrid_get_flip_x_obj, + (mp_obj_t)&displayio_tilegrid_set_flip_x_obj); //| flip_y: bool //| """If true, the top edge rendered will be the bottom edge of the bottom-most tile.""" @@ -319,12 +295,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_flip_y(mp_obj_t self_in, mp_obj_t fli } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_flip_y_obj, displayio_tilegrid_obj_set_flip_y); -const mp_obj_property_t displayio_tilegrid_flip_y_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_flip_y_obj, - (mp_obj_t)&displayio_tilegrid_set_flip_y_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_flip_y_obj, + (mp_obj_t)&displayio_tilegrid_get_flip_y_obj, + (mp_obj_t)&displayio_tilegrid_set_flip_y_obj); //| transpose_xy: bool @@ -345,12 +318,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_transpose_xy(mp_obj_t self_in, mp_obj } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_transpose_xy_obj, displayio_tilegrid_obj_set_transpose_xy); -const mp_obj_property_t displayio_tilegrid_transpose_xy_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_transpose_xy_obj, - (mp_obj_t)&displayio_tilegrid_set_transpose_xy_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_transpose_xy_obj, + (mp_obj_t)&displayio_tilegrid_get_transpose_xy_obj, + (mp_obj_t)&displayio_tilegrid_set_transpose_xy_obj); //| pixel_shader: Union[ColorConverter, Palette] //| """The pixel shader of the tilegrid.""" @@ -373,12 +343,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_pixel_shader_obj, displayio_tilegrid_obj_set_pixel_shader); -const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_pixel_shader_obj, - (mp_obj_t)&displayio_tilegrid_set_pixel_shader_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_pixel_shader_obj, + (mp_obj_t)&displayio_tilegrid_get_pixel_shader_obj, + (mp_obj_t)&displayio_tilegrid_set_pixel_shader_obj); //| bitmap: Union[Bitmap,OnDiskBitmap,Shape] //| """The bitmap of the tilegrid.""" @@ -439,12 +406,9 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_bitmap(mp_obj_t self_in, mp_obj_t bit } MP_DEFINE_CONST_FUN_OBJ_2(displayio_tilegrid_set_bitmap_obj, displayio_tilegrid_obj_set_bitmap); -const mp_obj_property_t displayio_tilegrid_bitmap_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_tilegrid_get_bitmap_obj, - (mp_obj_t)&displayio_tilegrid_set_bitmap_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(displayio_tilegrid_bitmap_obj, + (mp_obj_t)&displayio_tilegrid_get_bitmap_obj, + (mp_obj_t)&displayio_tilegrid_set_bitmap_obj); //| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int: //| """Returns the tile index at the given index. The index can either be an x,y tuple or an int equal diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index fcbde4e80d..9c97d9a9a3 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -76,12 +76,8 @@ STATIC mp_obj_t fontio_builtinfont_obj_get_bitmap(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(fontio_builtinfont_get_bitmap_obj, fontio_builtinfont_obj_get_bitmap); -const mp_obj_property_t fontio_builtinfont_bitmap_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&fontio_builtinfont_get_bitmap_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(fontio_builtinfont_bitmap_obj, + (mp_obj_t)&fontio_builtinfont_get_bitmap_obj); //| def get_bounding_box(self) -> Tuple[int, int]: //| """Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height.""" diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index acc50d7561..daff2174fa 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -168,12 +168,9 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_auto_refresh(mp_obj_t s } MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_auto_refresh_obj, framebufferio_framebufferdisplay_obj_set_auto_refresh); -const mp_obj_property_t framebufferio_framebufferdisplay_auto_refresh_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_auto_refresh_obj, - (mp_obj_t)&framebufferio_framebufferdisplay_set_auto_refresh_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_auto_refresh_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_auto_refresh_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_set_auto_refresh_obj); //| brightness: float //| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When @@ -205,12 +202,9 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_brightness(mp_obj_t sel } MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_brightness_obj, framebufferio_framebufferdisplay_obj_set_brightness); -const mp_obj_property_t framebufferio_framebufferdisplay_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_brightness_obj, - (mp_obj_t)&framebufferio_framebufferdisplay_set_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_brightness_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_brightness_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_set_brightness_obj); //| auto_brightness: bool //| """True when the display brightness is adjusted automatically, based on an ambient @@ -236,12 +230,9 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_auto_brightness(mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_auto_brightness_obj, framebufferio_framebufferdisplay_obj_set_auto_brightness); -const mp_obj_property_t framebufferio_framebufferdisplay_auto_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_auto_brightness_obj, - (mp_obj_t)&framebufferio_framebufferdisplay_set_auto_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_auto_brightness_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_auto_brightness_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_set_auto_brightness_obj); //| width: int //| """Gets the width of the framebuffer""" @@ -252,12 +243,8 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_width(mp_obj_t self_in) } MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_width_obj, framebufferio_framebufferdisplay_obj_get_width); -const mp_obj_property_t framebufferio_framebufferdisplay_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(framebufferio_framebufferdisplay_width_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_width_obj); //| height: int //| """Gets the height of the framebuffer""" @@ -268,12 +255,8 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_height(mp_obj_t self_in } MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_height_obj, framebufferio_framebufferdisplay_obj_get_height); -const mp_obj_property_t framebufferio_framebufferdisplay_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(framebufferio_framebufferdisplay_height_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_height_obj); //| rotation: int //| """The rotation of the display as an int in degrees.""" @@ -291,12 +274,9 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_rotation(mp_obj_t self_ MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_rotation_obj, framebufferio_framebufferdisplay_obj_set_rotation); -const mp_obj_property_t framebufferio_framebufferdisplay_rotation_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_rotation_obj, - (mp_obj_t)&framebufferio_framebufferdisplay_set_rotation_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_rotation_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_rotation_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_set_rotation_obj); //| framebuffer: circuitpython_typing.FrameBuffer //| """The framebuffer being used by the display""" @@ -308,12 +288,8 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_framebuffer(mp_obj_t se } MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_framebuffer_obj, framebufferio_framebufferdisplay_obj_get_framebuffer); -const mp_obj_property_t framebufferio_framebufferframebuffer_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&framebufferio_framebufferdisplay_get_framebuffer_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(framebufferio_framebufferframebuffer_obj, + (mp_obj_t)&framebufferio_framebufferdisplay_get_framebuffer_obj); //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index a59d7a7302..2f6ebd06c2 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -193,12 +193,9 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_set_capture_period(mp_obj_t self_in, } MP_DEFINE_CONST_FUN_OBJ_2(frequencyio_frequency_set_capture_period_obj, frequencyio_frequencyin_obj_set_capture_period); -const mp_obj_property_t frequencyio_frequencyin_capture_period_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&frequencyio_frequency_get_capture_period_obj, - (mp_obj_t)&frequencyio_frequency_set_capture_period_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(frequencyio_frequencyin_capture_period_obj, + (mp_obj_t)&frequencyio_frequency_get_capture_period_obj, + (mp_obj_t)&frequencyio_frequency_set_capture_period_obj); //| def __get__(self, index: int) -> int: //| """Returns the value of the last frequency captured.""" @@ -213,12 +210,8 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_get_value(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_get_value_obj, frequencyio_frequencyin_obj_get_value); -const mp_obj_property_t frequencyio_frequencyin_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&frequencyio_frequencyin_get_value_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(frequencyio_frequencyin_value_obj, + (mp_obj_t)&frequencyio_frequencyin_get_value_obj); STATIC const mp_rom_map_elem_t frequencyio_frequencyin_locals_dict_table[] = { // Methods diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index e304f0a0a2..0bd800bdc6 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -108,12 +108,8 @@ STATIC mp_obj_t gnss_obj_get_latitude(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gnss_get_latitude_obj, gnss_obj_get_latitude); -const mp_obj_property_t gnss_latitude_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&gnss_get_latitude_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(gnss_latitude_obj, + (mp_obj_t)&gnss_get_latitude_obj); //| longitude: float //| """Longitude of current position in degrees (float).""" @@ -125,12 +121,8 @@ STATIC mp_obj_t gnss_obj_get_longitude(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gnss_get_longitude_obj, gnss_obj_get_longitude); -const mp_obj_property_t gnss_longitude_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&gnss_get_longitude_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(gnss_longitude_obj, + (mp_obj_t)&gnss_get_longitude_obj); //| altitude: float //| """Altitude of current position in meters (float).""" @@ -142,12 +134,8 @@ STATIC mp_obj_t gnss_obj_get_altitude(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gnss_get_altitude_obj, gnss_obj_get_altitude); -const mp_obj_property_t gnss_altitude_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&gnss_get_altitude_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(gnss_altitude_obj, + (mp_obj_t)&gnss_get_altitude_obj); //| timestamp: time.struct_time //| """Time when the position data was updated.""" @@ -161,12 +149,8 @@ STATIC mp_obj_t gnss_obj_get_timestamp(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gnss_get_timestamp_obj, gnss_obj_get_timestamp); -const mp_obj_property_t gnss_timestamp_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&gnss_get_timestamp_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(gnss_timestamp_obj, + (mp_obj_t)&gnss_get_timestamp_obj); //| fix: PositionFix //| """Fix mode.""" @@ -178,12 +162,8 @@ STATIC mp_obj_t gnss_obj_get_fix(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(gnss_get_fix_obj, gnss_obj_get_fix); -const mp_obj_property_t gnss_fix_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&gnss_get_fix_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(gnss_fix_obj, + (mp_obj_t)&gnss_get_fix_obj); STATIC const mp_rom_map_elem_t gnss_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gnss_deinit_obj) }, diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index f62e373937..23204329d3 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -96,12 +96,8 @@ STATIC mp_obj_t ipaddress_ipv4address_get_packed(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(ipaddress_ipv4address_get_packed_obj, ipaddress_ipv4address_get_packed); -const mp_obj_property_t ipaddress_ipv4address_packed_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&ipaddress_ipv4address_get_packed_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(ipaddress_ipv4address_packed_obj, + (mp_obj_t)&ipaddress_ipv4address_get_packed_obj); //| version: int //| """4 for IPv4, 6 for IPv6""" @@ -120,12 +116,8 @@ STATIC mp_obj_t ipaddress_ipv4address_get_version(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(ipaddress_ipv4address_get_version_obj, ipaddress_ipv4address_get_version); -const mp_obj_property_t ipaddress_ipv4address_version_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&ipaddress_ipv4address_get_version_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(ipaddress_ipv4address_version_obj, + (mp_obj_t)&ipaddress_ipv4address_get_version_obj); //| def __eq__(self, other: object) -> bool: //| """Two Address objects are equal if their addresses and address types are equal.""" diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c index 597024500d..e1a87e8ee0 100644 --- a/shared-bindings/is31fl3741/FrameBuffer.c +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -166,12 +166,9 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_set_brightness(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_FrameBuffer_set_brightness_obj, is31fl3741_FrameBuffer_set_brightness); -const mp_obj_property_t is31fl3741_FrameBuffer_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_brightness_obj, - (mp_obj_t)&is31fl3741_FrameBuffer_set_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(is31fl3741_FrameBuffer_brightness_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_get_brightness_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_set_brightness_obj); //| def refresh(self) -> None: //| """Transmits the color data in the buffer to the pixels so that @@ -195,12 +192,8 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_get_width(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_width(self)); } MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_width_obj, is31fl3741_FrameBuffer_get_width); -const mp_obj_property_t is31fl3741_FrameBuffer_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(is31fl3741_FrameBuffer_width_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_get_width_obj); //| height: int //| """The height of the display, in pixels""" @@ -211,12 +204,8 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_get_height(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_height(self)); } MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_height_obj, is31fl3741_FrameBuffer_get_height); -const mp_obj_property_t is31fl3741_FrameBuffer_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(is31fl3741_FrameBuffer_height_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_get_height_obj); STATIC const mp_rom_map_elem_t is31fl3741_FrameBuffer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_FrameBuffer_deinit_obj) }, diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 591a330bba..380b6b5b41 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -76,12 +76,8 @@ STATIC mp_obj_t keypad_event_get_key_number(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_event_get_key_number_obj, keypad_event_get_key_number); -const mp_obj_property_t keypad_event_key_number_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_event_get_key_number_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_event_key_number_obj, + (mp_obj_t)&keypad_event_get_key_number_obj); //| pressed: bool //| """``True`` if the event represents a key down (pressed) transition. @@ -94,12 +90,8 @@ STATIC mp_obj_t keypad_event_get_pressed(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_event_get_pressed_obj, keypad_event_get_pressed); -const mp_obj_property_t keypad_event_pressed_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_event_get_pressed_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_event_pressed_obj, + (mp_obj_t)&keypad_event_get_pressed_obj); //| released: bool //| """``True`` if the event represents a key up (released) transition. @@ -112,12 +104,8 @@ STATIC mp_obj_t keypad_event_get_released(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_event_get_released_obj, keypad_event_get_released); -const mp_obj_property_t keypad_event_released_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_event_get_released_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_event_released_obj, + (mp_obj_t)&keypad_event_get_released_obj); //| timestamp: int //| """The timestamp.""" @@ -128,12 +116,8 @@ STATIC mp_obj_t keypad_event_get_timestamp(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_event_get_timestamp_obj, keypad_event_get_timestamp); -const mp_obj_property_t keypad_event_timestamp_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_event_get_timestamp_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_event_timestamp_obj, + (mp_obj_t)&keypad_event_get_timestamp_obj); //| def __eq__(self, other: object) -> bool: diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index 41dc292ba6..8e45f7ad1d 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -129,12 +129,8 @@ STATIC mp_obj_t keypad_eventqueue_get_overflowed(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_get_overflowed_obj, keypad_eventqueue_get_overflowed); -const mp_obj_property_t keypad_eventqueue_overflowed_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&keypad_eventqueue_get_overflowed_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(keypad_eventqueue_overflowed_obj, + (mp_obj_t)&keypad_eventqueue_get_overflowed_obj); STATIC const mp_rom_map_elem_t keypad_eventqueue_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&keypad_eventqueue_clear_obj) }, diff --git a/shared-bindings/mdns/RemoteService.c b/shared-bindings/mdns/RemoteService.c index ecded5561f..846207b69b 100644 --- a/shared-bindings/mdns/RemoteService.c +++ b/shared-bindings/mdns/RemoteService.c @@ -52,12 +52,8 @@ STATIC mp_obj_t mdns_remoteservice_get_hostname(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_hostname_obj, mdns_remoteservice_get_hostname); -const mp_obj_property_t mdns_remoteservice_hostname_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_remoteservice_get_hostname_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(mdns_remoteservice_hostname_obj, + (mp_obj_t)&mdns_remoteservice_get_hostname_obj); //| instance_name: str //| """The human readable instance name for the service. (read-only)""" @@ -69,12 +65,8 @@ STATIC mp_obj_t remoteservice_get_instance_name(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_instance_name_obj, remoteservice_get_instance_name); -const mp_obj_property_t mdns_remoteservice_instance_name_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_remoteservice_get_instance_name_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(mdns_remoteservice_instance_name_obj, + (mp_obj_t)&mdns_remoteservice_get_instance_name_obj); //| service_type: str //| """The service type string such as ``_http``. (read-only)""" @@ -86,12 +78,8 @@ STATIC mp_obj_t remoteservice_get_service_type(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_service_type_obj, remoteservice_get_service_type); -const mp_obj_property_t mdns_remoteservice_service_type_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_remoteservice_get_service_type_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(mdns_remoteservice_service_type_obj, + (mp_obj_t)&mdns_remoteservice_get_service_type_obj); //| protocol: str //| """The protocol string such as ``_tcp``. (read-only)""" @@ -103,12 +91,8 @@ STATIC mp_obj_t remoteservice_get_protocol(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_protocol_obj, remoteservice_get_protocol); -const mp_obj_property_t mdns_remoteservice_protocol_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_remoteservice_get_protocol_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(mdns_remoteservice_protocol_obj, + (mp_obj_t)&mdns_remoteservice_get_protocol_obj); //| port: int //| """Port number used for the service. (read-only)""" @@ -119,12 +103,8 @@ STATIC mp_obj_t remoteservice_get_port(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_port_obj, remoteservice_get_port); -const mp_obj_property_t mdns_remoteservice_port_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_remoteservice_get_port_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(mdns_remoteservice_port_obj, + (mp_obj_t)&mdns_remoteservice_get_port_obj); //| def __del__(self) -> None: //| """Deletes the RemoteService object.""" diff --git a/shared-bindings/mdns/Server.c b/shared-bindings/mdns/Server.c index 132d218aeb..b5e6c11216 100644 --- a/shared-bindings/mdns/Server.c +++ b/shared-bindings/mdns/Server.c @@ -99,12 +99,9 @@ static mp_obj_t mdns_server_set_hostname(mp_obj_t self, mp_obj_t hostname) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mdns_server_set_hostname_obj, mdns_server_set_hostname); -const mp_obj_property_t mdns_server_hostname_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_server_get_hostname_obj, - (mp_obj_t)&mdns_server_set_hostname_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(mdns_server_hostname_obj, + (mp_obj_t)&mdns_server_get_hostname_obj, + (mp_obj_t)&mdns_server_set_hostname_obj); //| instance_name: str //| """Human readable name to describe the device.""" @@ -123,12 +120,9 @@ STATIC mp_obj_t mdns_server_set_instance_name(mp_obj_t self, mp_obj_t new_instan } MP_DEFINE_CONST_FUN_OBJ_2(mdns_server_set_instance_name_obj, mdns_server_set_instance_name); -const mp_obj_property_t mdns_server_instance_name_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&mdns_server_get_instance_name_obj, - (mp_obj_t)&mdns_server_set_instance_name_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(mdns_server_instance_name_obj, + (mp_obj_t)&mdns_server_get_instance_name_obj, + (mp_obj_t)&mdns_server_set_instance_name_obj); //| def find(self, service_type: str, protocol: str, *, timeout: float = 1) -> Tuple[RemoteService]: diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 5679b30c3f..1c39fdcd92 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -105,12 +105,8 @@ STATIC mp_obj_t memorymonitor_allocationsize_obj_get_bytes_per_block(mp_obj_t se } MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_get_bytes_per_block_obj, memorymonitor_allocationsize_obj_get_bytes_per_block); -const mp_obj_property_t memorymonitor_allocationsize_bytes_per_block_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&memorymonitor_allocationsize_get_bytes_per_block_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(memorymonitor_allocationsize_bytes_per_block_obj, + (mp_obj_t)&memorymonitor_allocationsize_get_bytes_per_block_obj); //| def __len__(self) -> int: //| """Returns the number of allocation buckets. diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 423480435e..ff1b52eecd 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -88,13 +88,9 @@ STATIC mp_obj_t mcu_processor_get_frequency(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_frequency_obj, mcu_processor_get_frequency); -const mp_obj_property_t mcu_processor_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_frequency_obj, // getter - (mp_obj_t)&mcu_processor_set_frequency_obj, // setter - MP_ROM_NONE, // no deleter - }, -}; +MP_PROPERTY_GETSET(mcu_processor_frequency_obj, + (mp_obj_t)&mcu_processor_get_frequency_obj, + (mp_obj_t)&mcu_processor_set_frequency_obj); //| reset_reason: microcontroller.ResetReason //| """The reason the microcontroller started up from reset state.""" @@ -105,13 +101,8 @@ STATIC mp_obj_t mcu_processor_get_reset_reason(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_reset_reason_obj, mcu_processor_get_reset_reason); -const mp_obj_property_t mcu_processor_reset_reason_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_reset_reason_obj, // getter - MP_ROM_NONE, // no setter - MP_ROM_NONE, // no deleter - }, -}; +MP_PROPERTY_GETTER(mcu_processor_reset_reason_obj, + (mp_obj_t)&mcu_processor_get_reset_reason_obj); //| temperature: Optional[float] //| """The on-chip temperature, in Celsius, as a float. (read-only) @@ -125,13 +116,8 @@ STATIC mp_obj_t mcu_processor_get_temperature(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_temperature_obj, mcu_processor_get_temperature); -const mp_obj_property_t mcu_processor_temperature_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_temperature_obj, // getter - MP_ROM_NONE, // no setter - MP_ROM_NONE, // no deleter - }, -}; +MP_PROPERTY_GETTER(mcu_processor_temperature_obj, + (mp_obj_t)&mcu_processor_get_temperature_obj); //| uid: bytearray //| """The unique id (aka serial number) of the chip as a `bytearray`. (read-only)""" @@ -144,13 +130,8 @@ STATIC mp_obj_t mcu_processor_get_uid(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_uid_obj, mcu_processor_get_uid); -const mp_obj_property_t mcu_processor_uid_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_uid_obj, // getter - MP_ROM_NONE, // no setter - MP_ROM_NONE, // no deleter - }, -}; +MP_PROPERTY_GETTER(mcu_processor_uid_obj, + (mp_obj_t)&mcu_processor_get_uid_obj); //| voltage: Optional[float] //| """The input voltage to the microcontroller, as a float. (read-only) @@ -164,13 +145,8 @@ STATIC mp_obj_t mcu_processor_get_voltage(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_voltage_obj, mcu_processor_get_voltage); -const mp_obj_property_t mcu_processor_voltage_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_voltage_obj, // getter - MP_ROM_NONE, // no setter - MP_ROM_NONE, // no deleter - }, -}; +MP_PROPERTY_GETTER(mcu_processor_voltage_obj, + (mp_obj_t)&mcu_processor_get_voltage_obj); STATIC const mp_rom_map_elem_t mcu_processor_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&mcu_processor_frequency_obj) }, diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 892dd91696..1719e209b2 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -80,12 +80,9 @@ STATIC mp_obj_t mod_msgpack_exttype_set_code(mp_obj_t self_in, mp_obj_t code_in) } MP_DEFINE_CONST_FUN_OBJ_2(mod_msgpack_exttype_set_code_obj, mod_msgpack_exttype_set_code); -const mp_obj_property_t mod_msgpack_exttype_code_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mod_msgpack_exttype_get_code_obj, - (mp_obj_t)&mod_msgpack_exttype_set_code_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(mod_msgpack_exttype_code_obj, + (mp_obj_t)&mod_msgpack_exttype_get_code_obj, + (mp_obj_t)&mod_msgpack_exttype_set_code_obj); //| data: bytes //| """Data.""" @@ -104,12 +101,9 @@ STATIC mp_obj_t mod_msgpack_exttype_set_data(mp_obj_t self_in, mp_obj_t data_in) } MP_DEFINE_CONST_FUN_OBJ_2(mod_msgpack_exttype_set_data_obj, mod_msgpack_exttype_set_data); -const mp_obj_property_t mod_msgpack_exttype_data_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mod_msgpack_exttype_get_data_obj, - (mp_obj_t)&mod_msgpack_exttype_set_data_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(mod_msgpack_exttype_data_obj, + (mp_obj_t)&mod_msgpack_exttype_get_data_obj, + (mp_obj_t)&mod_msgpack_exttype_set_data_obj); STATIC mp_rom_map_elem_t mod_msgpack_exttype_locals_dict_table[] = { // Properties diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 13721c8106..21dfdae42c 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -208,12 +208,8 @@ STATIC mp_obj_t pulseio_pulsein_obj_get_maxlen(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_get_maxlen_obj, pulseio_pulsein_obj_get_maxlen); -const mp_obj_property_t pulseio_pulsein_maxlen_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pulseio_pulsein_get_maxlen_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(pulseio_pulsein_maxlen_obj, + (mp_obj_t)&pulseio_pulsein_get_maxlen_obj); //| paused: bool //| """True when pulse capture is paused as a result of :py:func:`pause` or an error during capture @@ -227,12 +223,8 @@ STATIC mp_obj_t pulseio_pulsein_obj_get_paused(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_get_paused_obj, pulseio_pulsein_obj_get_paused); -const mp_obj_property_t pulseio_pulsein_paused_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pulseio_pulsein_get_paused_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(pulseio_pulsein_paused_obj, + (mp_obj_t)&pulseio_pulsein_get_paused_obj); //| def __bool__(self) -> bool: ... //| diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 1c0110653b..60a9dfb8b9 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -220,12 +220,9 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_ } MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_duty_cycle_obj, pwmio_pwmout_obj_set_duty_cycle); -const mp_obj_property_t pwmio_pwmout_duty_cycle_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pwmio_pwmout_get_duty_cycle_obj, - (mp_obj_t)&pwmio_pwmout_set_duty_cycle_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(pwmio_pwmout_duty_cycle_obj, + (mp_obj_t)&pwmio_pwmout_get_duty_cycle_obj, + (mp_obj_t)&pwmio_pwmout_set_duty_cycle_obj); //| frequency: int //| """32 bit value that dictates the PWM frequency in Hertz (cycles per @@ -261,12 +258,9 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t freque } MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_frequency_obj, pwmio_pwmout_obj_set_frequency); -const mp_obj_property_t pwmio_pwmout_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pwmio_pwmout_get_frequency_obj, - (mp_obj_t)&pwmio_pwmout_set_frequency_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(pwmio_pwmout_frequency_obj, + (mp_obj_t)&pwmio_pwmout_get_frequency_obj, + (mp_obj_t)&pwmio_pwmout_set_frequency_obj); STATIC const mp_rom_map_elem_t pwmio_pwmout_locals_dict_table[] = { // Methods diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index c8382de42e..d2d4785ed8 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -107,12 +107,9 @@ STATIC mp_obj_t qrio_qrdecoder_set_width(mp_obj_t self_in, mp_obj_t width_in) { } MP_DEFINE_CONST_FUN_OBJ_2(qrio_qrdecoder_set_width_obj, qrio_qrdecoder_set_width); -const mp_obj_property_t qrio_qrdecoder_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&qrio_qrdecoder_get_width_obj, - (mp_obj_t)&qrio_qrdecoder_set_width_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(qrio_qrdecoder_width_obj, + (mp_obj_t)&qrio_qrdecoder_get_width_obj, + (mp_obj_t)&qrio_qrdecoder_set_width_obj); //| height: int //| """The height of image the decoder expects""" @@ -131,12 +128,9 @@ STATIC mp_obj_t qrio_qrdecoder_set_height(mp_obj_t self_in, mp_obj_t height_in) } MP_DEFINE_CONST_FUN_OBJ_2(qrio_qrdecoder_set_height_obj, qrio_qrdecoder_set_height); -const mp_obj_property_t qrio_qrdecoder_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&qrio_qrdecoder_get_height_obj, - (mp_obj_t)&qrio_qrdecoder_set_height_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(qrio_qrdecoder_height_obj, + (mp_obj_t)&qrio_qrdecoder_get_height_obj, + (mp_obj_t)&qrio_qrdecoder_set_height_obj); STATIC const mp_rom_map_elem_t qrio_qrdecoder_locals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_QRDecoder) }, diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 70d6328ab0..4739807bd0 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -310,12 +310,9 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_set_brightness(mp_obj_t self_in, mp_obj_t va } MP_DEFINE_CONST_FUN_OBJ_2(rgbmatrix_rgbmatrix_set_brightness_obj, rgbmatrix_rgbmatrix_set_brightness); -const mp_obj_property_t rgbmatrix_rgbmatrix_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rgbmatrix_rgbmatrix_get_brightness_obj, - (mp_obj_t)&rgbmatrix_rgbmatrix_set_brightness_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rgbmatrix_rgbmatrix_brightness_obj, + (mp_obj_t)&rgbmatrix_rgbmatrix_get_brightness_obj, + (mp_obj_t)&rgbmatrix_rgbmatrix_set_brightness_obj); //| def refresh(self) -> None: //| """Transmits the color data in the buffer to the pixels so that @@ -339,12 +336,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_get_width(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_rgbmatrix_rgbmatrix_get_width(self)); } MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_get_width_obj, rgbmatrix_rgbmatrix_get_width); -const mp_obj_property_t rgbmatrix_rgbmatrix_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rgbmatrix_rgbmatrix_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(rgbmatrix_rgbmatrix_width_obj, + (mp_obj_t)&rgbmatrix_rgbmatrix_get_width_obj); //| height: int //| """The height of the display, in pixels""" @@ -356,12 +349,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_get_height_obj, rgbmatrix_rgbmatrix_get_height); -const mp_obj_property_t rgbmatrix_rgbmatrix_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rgbmatrix_rgbmatrix_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(rgbmatrix_rgbmatrix_height_obj, + (mp_obj_t)&rgbmatrix_rgbmatrix_get_height_obj); STATIC const mp_rom_map_elem_t rgbmatrix_rgbmatrix_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rgbmatrix_rgbmatrix_deinit_obj) }, diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 7793e12837..0fe22be262 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -141,12 +141,9 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj_set_divisor(mp_obj_t self_in, mp } MP_DEFINE_CONST_FUN_OBJ_2(rotaryio_incrementalencoder_set_divisor_obj, rotaryio_incrementalencoder_obj_set_divisor); -const mp_obj_property_t rotaryio_incrementalencoder_divisor_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rotaryio_incrementalencoder_get_divisor_obj, - (mp_obj_t)&rotaryio_incrementalencoder_set_divisor_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rotaryio_incrementalencoder_divisor_obj, + (mp_obj_t)&rotaryio_incrementalencoder_get_divisor_obj, + (mp_obj_t)&rotaryio_incrementalencoder_set_divisor_obj); //| position: int //| """The current position in terms of pulses. The number of pulses per rotation is defined by the @@ -169,12 +166,9 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj_set_position(mp_obj_t self_in, m } MP_DEFINE_CONST_FUN_OBJ_2(rotaryio_incrementalencoder_set_position_obj, rotaryio_incrementalencoder_obj_set_position); -const mp_obj_property_t rotaryio_incrementalencoder_position_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rotaryio_incrementalencoder_get_position_obj, - (mp_obj_t)&rotaryio_incrementalencoder_set_position_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rotaryio_incrementalencoder_position_obj, + (mp_obj_t)&rotaryio_incrementalencoder_get_position_obj, + (mp_obj_t)&rotaryio_incrementalencoder_set_position_obj); STATIC const mp_rom_map_elem_t rotaryio_incrementalencoder_locals_dict_table[] = { // Methods diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index f52871c7da..b07f90bd01 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -87,12 +87,9 @@ STATIC mp_obj_t rtc_rtc_obj_set_datetime(mp_obj_t self_in, mp_obj_t datetime) { } MP_DEFINE_CONST_FUN_OBJ_2(rtc_rtc_set_datetime_obj, rtc_rtc_obj_set_datetime); -const mp_obj_property_t rtc_rtc_datetime_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rtc_rtc_get_datetime_obj, - (mp_obj_t)&rtc_rtc_set_datetime_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rtc_rtc_datetime_obj, + (mp_obj_t)&rtc_rtc_get_datetime_obj, + (mp_obj_t)&rtc_rtc_set_datetime_obj); //| calibration: int //| """The RTC calibration value as an `int`. @@ -118,12 +115,9 @@ STATIC mp_obj_t rtc_rtc_obj_set_calibration(mp_obj_t self_in, mp_obj_t calibrati } MP_DEFINE_CONST_FUN_OBJ_2(rtc_rtc_set_calibration_obj, rtc_rtc_obj_set_calibration); -const mp_obj_property_t rtc_rtc_calibration_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&rtc_rtc_get_calibration_obj, - (mp_obj_t)&rtc_rtc_set_calibration_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(rtc_rtc_calibration_obj, + (mp_obj_t)&rtc_rtc_get_calibration_obj, + (mp_obj_t)&rtc_rtc_set_calibration_obj); STATIC const mp_rom_map_elem_t rtc_rtc_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&rtc_rtc_datetime_obj) }, diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index c4b23ea594..f6407ff2a8 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -218,12 +218,8 @@ STATIC mp_obj_t sdioio_sdcard_obj_get_frequency(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_get_frequency_obj, sdioio_sdcard_obj_get_frequency); -const mp_obj_property_t sdioio_sdcard_frequency_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&sdioio_sdcard_get_frequency_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(sdioio_sdcard_frequency_obj, + (mp_obj_t)&sdioio_sdcard_get_frequency_obj); //| @property //| def width(self) -> int: @@ -237,12 +233,8 @@ STATIC mp_obj_t sdioio_sdcard_obj_get_width(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_get_width_obj, sdioio_sdcard_obj_get_width); -const mp_obj_property_t sdioio_sdcard_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&sdioio_sdcard_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(sdioio_sdcard_width_obj, + (mp_obj_t)&sdioio_sdcard_get_width_obj); //| def deinit(self) -> None: //| """Disable permanently. diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 2b38768f6a..5dfa5e599f 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -105,12 +105,9 @@ STATIC mp_obj_t ssl_sslcontext_set_check_hostname(mp_obj_t self_in, mp_obj_t val } STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslcontext_set_check_hostname_obj, ssl_sslcontext_set_check_hostname); -const mp_obj_property_t ssl_sslcontext_check_hostname_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&ssl_sslcontext_get_check_hostname_obj, - (mp_obj_t)&ssl_sslcontext_set_check_hostname_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(ssl_sslcontext_check_hostname_obj, + (mp_obj_t)&ssl_sslcontext_get_check_hostname_obj, + (mp_obj_t)&ssl_sslcontext_set_check_hostname_obj); //| def wrap_socket(self, sock: socketpool.Socket, *, server_side: bool = False, server_hostname: Optional[str] = None) -> ssl.SSLSocket: //| """Wraps the socket into a socket-compatible class that handles SSL negotiation. diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 08d68ec93f..55217ec97a 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -69,12 +69,8 @@ STATIC mp_obj_t supervisor_runtime_get_usb_connected(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_usb_connected_obj, supervisor_runtime_get_usb_connected); -const mp_obj_property_t supervisor_runtime_usb_connected_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&supervisor_runtime_get_usb_connected_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(supervisor_runtime_usb_connected_obj, + (mp_obj_t)&supervisor_runtime_get_usb_connected_obj); //| serial_connected: bool //| """Returns the USB serial communication status (read-only).""" @@ -84,12 +80,8 @@ STATIC mp_obj_t supervisor_runtime_get_serial_connected(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_serial_connected_obj, supervisor_runtime_get_serial_connected); -const mp_obj_property_t supervisor_runtime_serial_connected_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&supervisor_runtime_get_serial_connected_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(supervisor_runtime_serial_connected_obj, + (mp_obj_t)&supervisor_runtime_get_serial_connected_obj); //| serial_bytes_available: int //| """Returns the whether any bytes are available to read @@ -101,12 +93,8 @@ STATIC mp_obj_t supervisor_runtime_get_serial_bytes_available(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_serial_bytes_available_obj, supervisor_runtime_get_serial_bytes_available); -const mp_obj_property_t supervisor_runtime_serial_bytes_available_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&supervisor_runtime_get_serial_bytes_available_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(supervisor_runtime_serial_bytes_available_obj, + (mp_obj_t)&supervisor_runtime_get_serial_bytes_available_obj); supervisor_run_reason_t supervisor_get_run_reason(void) { return _run_reason; @@ -124,12 +112,8 @@ STATIC mp_obj_t supervisor_runtime_get_run_reason(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_run_reason_obj, supervisor_runtime_get_run_reason); -const mp_obj_property_t supervisor_runtime_run_reason_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&supervisor_runtime_get_run_reason_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(supervisor_runtime_run_reason_obj, + (mp_obj_t)&supervisor_runtime_get_run_reason_obj); STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_usb_connected), MP_ROM_PTR(&supervisor_runtime_usb_connected_obj) }, diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 1fb3fdbec1..7805c1a6a0 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -132,12 +132,8 @@ STATIC mp_obj_t synthio_miditrack_obj_get_sample_rate(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(synthio_miditrack_get_sample_rate_obj, synthio_miditrack_obj_get_sample_rate); -const mp_obj_property_t synthio_miditrack_sample_rate_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&synthio_miditrack_get_sample_rate_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(synthio_miditrack_sample_rate_obj, + (mp_obj_t)&synthio_miditrack_get_sample_rate_obj); STATIC const mp_rom_map_elem_t synthio_miditrack_locals_dict_table[] = { // Methods diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 537ae29776..23b35253cb 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -120,12 +120,8 @@ STATIC mp_obj_t touchio_touchin_obj_get_value(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(touchio_touchin_get_value_obj, touchio_touchin_obj_get_value); -const mp_obj_property_t touchio_touchin_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&touchio_touchin_get_value_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(touchio_touchin_value_obj, + (mp_obj_t)&touchio_touchin_get_value_obj); //| raw_value: int @@ -139,12 +135,8 @@ STATIC mp_obj_t touchio_touchin_obj_get_raw_value(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(touchio_touchin_get_raw_value_obj, touchio_touchin_obj_get_raw_value); -const mp_obj_property_t touchio_touchin_raw_value_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&touchio_touchin_get_raw_value_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(touchio_touchin_raw_value_obj, + (mp_obj_t)&touchio_touchin_get_raw_value_obj); //| threshold: Optional[int] @@ -183,12 +175,9 @@ STATIC mp_obj_t touchio_touchin_obj_set_threshold(mp_obj_t self_in, mp_obj_t thr MP_DEFINE_CONST_FUN_OBJ_2(touchio_touchin_set_threshold_obj, touchio_touchin_obj_set_threshold); -const mp_obj_property_t touchio_touchin_threshold_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&touchio_touchin_get_threshold_obj, - (mp_obj_t)&touchio_touchin_set_threshold_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(touchio_touchin_threshold_obj, + (mp_obj_t)&touchio_touchin_get_threshold_obj, + (mp_obj_t)&touchio_touchin_set_threshold_obj); STATIC const mp_rom_map_elem_t touchio_touchin_locals_dict_table[] = { diff --git a/shared-bindings/usb/core/Device.c b/shared-bindings/usb/core/Device.c index 6828a6b6f7..3a9e9bb421 100644 --- a/shared-bindings/usb/core/Device.c +++ b/shared-bindings/usb/core/Device.c @@ -79,12 +79,8 @@ STATIC mp_obj_t usb_core_device_obj_get_idVendor(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_idVendor_obj, usb_core_device_obj_get_idVendor); -const mp_obj_property_t usb_core_device_idVendor_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_core_device_get_idVendor_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_core_device_idVendor_obj, + (mp_obj_t)&usb_core_device_get_idVendor_obj); //| idProduct: int //| """The USB product ID of the device""" @@ -95,12 +91,8 @@ STATIC mp_obj_t usb_core_device_obj_get_idProduct(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_idProduct_obj, usb_core_device_obj_get_idProduct); -const mp_obj_property_t usb_core_device_idProduct_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_core_device_get_idProduct_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_core_device_idProduct_obj, + (mp_obj_t)&usb_core_device_get_idProduct_obj); //| serial_number: str //| """The USB device's serial number string.""" @@ -111,12 +103,8 @@ STATIC mp_obj_t usb_core_device_obj_get_serial_number(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_serial_number_obj, usb_core_device_obj_get_serial_number); -const mp_obj_property_t usb_core_device_serial_number_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_core_device_get_serial_number_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_core_device_serial_number_obj, + (mp_obj_t)&usb_core_device_get_serial_number_obj); //| product: str //| """The USB device's product string.""" @@ -127,12 +115,8 @@ STATIC mp_obj_t usb_core_device_obj_get_product(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_product_obj, usb_core_device_obj_get_product); -const mp_obj_property_t usb_core_device_product_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_core_device_get_product_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_core_device_product_obj, + (mp_obj_t)&usb_core_device_get_product_obj); //| manufacturer: str //| """The USB device's manufacturer string.""" @@ -143,12 +127,8 @@ STATIC mp_obj_t usb_core_device_obj_get_manufacturer(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_manufacturer_obj, usb_core_device_obj_get_manufacturer); -const mp_obj_property_t usb_core_device_manufacturer_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_core_device_get_manufacturer_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_core_device_manufacturer_obj, + (mp_obj_t)&usb_core_device_get_manufacturer_obj); //| def write(self, endpoint: int, data: ReadableBuffer, timeout = None) -> int: //| """Write data to a specific endpoint on the device. diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 95ecb98ccd..760efb6278 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -157,12 +157,8 @@ STATIC mp_obj_t usb_cdc_serial_get_connected(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_cdc_serial_get_connected_obj, usb_cdc_serial_get_connected); -const mp_obj_property_t usb_cdc_serial_connected_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_cdc_serial_get_connected_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_cdc_serial_connected_obj, + (mp_obj_t)&usb_cdc_serial_get_connected_obj); //| in_waiting: int //| """Returns the number of bytes waiting to be read on the USB serial input. (read-only)""" @@ -173,12 +169,8 @@ STATIC mp_obj_t usb_cdc_serial_get_in_waiting(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_cdc_serial_get_in_waiting_obj, usb_cdc_serial_get_in_waiting); -const mp_obj_property_t usb_cdc_serial_in_waiting_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_cdc_serial_get_in_waiting_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_cdc_serial_in_waiting_obj, + (mp_obj_t)&usb_cdc_serial_get_in_waiting_obj); //| out_waiting: int //| """Returns the number of bytes waiting to be written on the USB serial output. (read-only)""" @@ -189,12 +181,8 @@ STATIC mp_obj_t usb_cdc_serial_get_out_waiting(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_cdc_serial_get_out_waiting_obj, usb_cdc_serial_get_out_waiting); -const mp_obj_property_t usb_cdc_serial_out_waiting_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_cdc_serial_get_out_waiting_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_cdc_serial_out_waiting_obj, + (mp_obj_t)&usb_cdc_serial_get_out_waiting_obj); //| def reset_input_buffer(self) -> None: //| """Clears any unread bytes.""" @@ -237,12 +225,9 @@ STATIC mp_obj_t usb_cdc_serial_set_timeout(mp_obj_t self_in, mp_obj_t timeout_in } MP_DEFINE_CONST_FUN_OBJ_2(usb_cdc_serial_set_timeout_obj, usb_cdc_serial_set_timeout); -const mp_obj_property_t usb_cdc_serial_timeout_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_cdc_serial_get_timeout_obj, - (mp_obj_t)&usb_cdc_serial_set_timeout_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(usb_cdc_serial_timeout_obj, + (mp_obj_t)&usb_cdc_serial_get_timeout_obj, + (mp_obj_t)&usb_cdc_serial_set_timeout_obj); //| write_timeout: Optional[float] //| """The initial value of `write_timeout` is ``None``. If ``None``, wait indefinitely to finish @@ -264,12 +249,9 @@ STATIC mp_obj_t usb_cdc_serial_set_write_timeout(mp_obj_t self_in, mp_obj_t writ } MP_DEFINE_CONST_FUN_OBJ_2(usb_cdc_serial_set_write_timeout_obj, usb_cdc_serial_set_write_timeout); -const mp_obj_property_t usb_cdc_serial_write_timeout_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_cdc_serial_get_write_timeout_obj, - (mp_obj_t)&usb_cdc_serial_set_write_timeout_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(usb_cdc_serial_write_timeout_obj, + (mp_obj_t)&usb_cdc_serial_get_write_timeout_obj, + (mp_obj_t)&usb_cdc_serial_set_write_timeout_obj); STATIC const mp_rom_map_elem_t usb_cdc_serial_locals_dict_table[] = { diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 50f67e90cb..4ca6a18304 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -236,12 +236,8 @@ STATIC mp_obj_t usb_hid_device_obj_get_last_received_report_property(mp_obj_t se } MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_device_get_last_received_report_property_obj, usb_hid_device_obj_get_last_received_report_property); -const mp_obj_property_t usb_hid_device_last_received_report_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_hid_device_get_last_received_report_property_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_hid_device_last_received_report_obj, + (mp_obj_t)&usb_hid_device_get_last_received_report_property_obj); //| usage_page: int //| """The device usage page identifier, which designates a category of device. (read-only)""" @@ -252,12 +248,8 @@ STATIC mp_obj_t usb_hid_device_obj_get_usage_page(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_device_get_usage_page_obj, usb_hid_device_obj_get_usage_page); -const mp_obj_property_t usb_hid_device_usage_page_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_hid_device_get_usage_page_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_hid_device_usage_page_obj, + (mp_obj_t)&usb_hid_device_get_usage_page_obj); //| usage: int //| """The device usage identifier, which designates a specific kind of device. (read-only) @@ -272,12 +264,8 @@ STATIC mp_obj_t usb_hid_device_obj_get_usage(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_device_get_usage_obj, usb_hid_device_obj_get_usage); -const mp_obj_property_t usb_hid_device_usage_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&usb_hid_device_get_usage_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETTER(usb_hid_device_usage_obj, + (mp_obj_t)&usb_hid_device_get_usage_obj); STATIC const mp_rom_map_elem_t usb_hid_device_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_send_report), MP_ROM_PTR(&usb_hid_device_send_report_obj) }, diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 289bab031c..ded1861896 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -76,12 +76,9 @@ STATIC mp_obj_t vectorio_circle_obj_set_radius(mp_obj_t self_in, mp_obj_t radius } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_circle_set_radius_obj, vectorio_circle_obj_set_radius); -const mp_obj_property_t vectorio_circle_radius_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_circle_get_radius_obj, - (mp_obj_t)&vectorio_circle_set_radius_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_circle_radius_obj, + (mp_obj_t)&vectorio_circle_get_radius_obj, + (mp_obj_t)&vectorio_circle_set_radius_obj); //| color_index : int //| """The color_index of the circle as 0 based index of the palette.""" @@ -99,12 +96,9 @@ STATIC mp_obj_t vectorio_circle_obj_set_color_index(mp_obj_t self_in, mp_obj_t c } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_circle_set_color_index_obj, vectorio_circle_obj_set_color_index); -const mp_obj_property_t vectorio_circle_color_index_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_circle_get_color_index_obj, - (mp_obj_t)&vectorio_circle_set_color_index_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_circle_color_index_obj, + (mp_obj_t)&vectorio_circle_get_color_index_obj, + (mp_obj_t)&vectorio_circle_set_color_index_obj); // Documentation for properties inherited from VectorShape. diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index ea33baad55..ae9d7a01ca 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -82,12 +82,9 @@ STATIC mp_obj_t vectorio_polygon_obj_set_points(mp_obj_t self_in, mp_obj_t point } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_polygon_set_points_obj, vectorio_polygon_obj_set_points); -const mp_obj_property_t vectorio_polygon_points_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_polygon_get_points_obj, - (mp_obj_t)&vectorio_polygon_set_points_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_polygon_points_obj, + (mp_obj_t)&vectorio_polygon_get_points_obj, + (mp_obj_t)&vectorio_polygon_set_points_obj); //| color_index : int //| """The color_index of the polygon as 0 based index of the palette.""" @@ -105,12 +102,9 @@ STATIC mp_obj_t vectorio_polygon_obj_set_color_index(mp_obj_t self_in, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_polygon_set_color_index_obj, vectorio_polygon_obj_set_color_index); -const mp_obj_property_t vectorio_polygon_color_index_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_polygon_get_color_index_obj, - (mp_obj_t)&vectorio_polygon_set_color_index_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_polygon_color_index_obj, + (mp_obj_t)&vectorio_polygon_get_color_index_obj, + (mp_obj_t)&vectorio_polygon_set_color_index_obj); // Documentation for properties inherited from VectorShape. diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 3293466cc4..fe6be555cd 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -120,12 +120,9 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_x(mp_obj_t wrapper_shape, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_x_obj, vectorio_vector_shape_obj_set_x); -const mp_obj_property_t vectorio_vector_shape_x_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_vector_shape_get_x_obj, - (mp_obj_t)&vectorio_vector_shape_set_x_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_vector_shape_x_obj, + (mp_obj_t)&vectorio_vector_shape_get_x_obj, + (mp_obj_t)&vectorio_vector_shape_set_x_obj); // y: int @@ -151,12 +148,9 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_y(mp_obj_t wrapper_shape, mp_obj_t } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_y_obj, vectorio_vector_shape_obj_set_y); -const mp_obj_property_t vectorio_vector_shape_y_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_vector_shape_get_y_obj, - (mp_obj_t)&vectorio_vector_shape_set_y_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_vector_shape_y_obj, + (mp_obj_t)&vectorio_vector_shape_get_y_obj, + (mp_obj_t)&vectorio_vector_shape_set_y_obj); // location: Tuple[int, int] @@ -181,12 +175,9 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_location(mp_obj_t wrapper_shape, m } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_location_obj, vectorio_vector_shape_obj_set_location); -const mp_obj_property_t vectorio_vector_shape_location_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_vector_shape_get_location_obj, - (mp_obj_t)&vectorio_vector_shape_set_location_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_vector_shape_location_obj, + (mp_obj_t)&vectorio_vector_shape_get_location_obj, + (mp_obj_t)&vectorio_vector_shape_set_location_obj); // pixel_shader: Union[ColorConverter, Palette] @@ -216,12 +207,9 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t wrapper_shap } MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_pixel_shader_obj, vectorio_vector_shape_obj_set_pixel_shader); -const mp_obj_property_t vectorio_vector_shape_pixel_shader_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&vectorio_vector_shape_get_pixel_shader_obj, - (mp_obj_t)&vectorio_vector_shape_set_pixel_shader_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(vectorio_vector_shape_pixel_shader_obj, + (mp_obj_t)&vectorio_vector_shape_get_pixel_shader_obj, + (mp_obj_t)&vectorio_vector_shape_set_pixel_shader_obj); STATIC const mp_rom_map_elem_t vectorio_vector_shape_locals_dict_table[] = { diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h index 959a38dff0..13f62922f3 100644 --- a/shared-bindings/vectorio/VectorShape.h +++ b/shared-bindings/vectorio/VectorShape.h @@ -38,10 +38,10 @@ void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displ // Composable property definition for shapes that use VectorShape extern vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl; -extern const mp_obj_property_t vectorio_vector_shape_x_obj; -extern const mp_obj_property_t vectorio_vector_shape_y_obj; -extern const mp_obj_property_t vectorio_vector_shape_location_obj; -extern const mp_obj_property_t vectorio_vector_shape_pixel_shader_obj; +extern const mp_obj_property_getset_t vectorio_vector_shape_x_obj; +extern const mp_obj_property_getset_t vectorio_vector_shape_y_obj; +extern const mp_obj_property_getset_t vectorio_vector_shape_location_obj; +extern const mp_obj_property_getset_t vectorio_vector_shape_pixel_shader_obj; extern const mp_obj_fun_builtin_fixed_t vectorio_vector_shape_contains_obj; #endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 13ab99f50e..e00b288080 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -107,12 +107,9 @@ STATIC mp_obj_t watchdog_watchdogtimer_obj_set_timeout(mp_obj_t self_in, mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(watchdog_watchdogtimer_set_timeout_obj, watchdog_watchdogtimer_obj_set_timeout); -const mp_obj_property_t watchdog_watchdogtimer_timeout_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&watchdog_watchdogtimer_get_timeout_obj, - (mp_obj_t)&watchdog_watchdogtimer_set_timeout_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(watchdog_watchdogtimer_timeout_obj, + (mp_obj_t)&watchdog_watchdogtimer_get_timeout_obj, + (mp_obj_t)&watchdog_watchdogtimer_set_timeout_obj); //| mode: WatchDogMode //| """The current operating mode of the WatchDogTimer `watchdog.WatchDogMode`. @@ -158,12 +155,9 @@ STATIC mp_obj_t watchdog_watchdogtimer_obj_set_mode(mp_obj_t self_in, mp_obj_t m } MP_DEFINE_CONST_FUN_OBJ_2(watchdog_watchdogtimer_set_mode_obj, watchdog_watchdogtimer_obj_set_mode); -const mp_obj_property_t watchdog_watchdogtimer_mode_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&watchdog_watchdogtimer_get_mode_obj, - (mp_obj_t)&watchdog_watchdogtimer_set_mode_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(watchdog_watchdogtimer_mode_obj, + (mp_obj_t)&watchdog_watchdogtimer_get_mode_obj, + (mp_obj_t)&watchdog_watchdogtimer_set_mode_obj); STATIC const mp_rom_map_elem_t watchdog_watchdogtimer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_feed), MP_ROM_PTR(&watchdog_watchdogtimer_feed_obj) }, diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index 4e5235ea88..a63c0a8023 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -92,12 +92,9 @@ STATIC mp_obj_t wifi_monitor_obj_set_channel(mp_obj_t self_in, mp_obj_t channel) } MP_DEFINE_CONST_FUN_OBJ_2(wifi_monitor_set_channel_obj, wifi_monitor_obj_set_channel); -const mp_obj_property_t wifi_monitor_channel_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_monitor_get_channel_obj, - (mp_obj_t)&wifi_monitor_set_channel_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(wifi_monitor_channel_obj, + (mp_obj_t)&wifi_monitor_get_channel_obj, + (mp_obj_t)&wifi_monitor_set_channel_obj); //| queue: int //| """The queue size for buffering the packet.""" @@ -107,12 +104,8 @@ STATIC mp_obj_t wifi_monitor_obj_get_queue(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_get_queue_obj, wifi_monitor_obj_get_queue); -const mp_obj_property_t wifi_monitor_queue_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_monitor_get_queue_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_monitor_queue_obj, + (mp_obj_t)&wifi_monitor_get_queue_obj); //| def deinit(self) -> None: //| """De-initialize `wifi.Monitor` singleton.""" diff --git a/shared-bindings/wifi/Network.c b/shared-bindings/wifi/Network.c index 11053e629e..9a457b9499 100644 --- a/shared-bindings/wifi/Network.c +++ b/shared-bindings/wifi/Network.c @@ -50,12 +50,8 @@ STATIC mp_obj_t wifi_network_get_ssid(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_ssid_obj, wifi_network_get_ssid); -const mp_obj_property_t wifi_network_ssid_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_ssid_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_ssid_obj, + (mp_obj_t)&wifi_network_get_ssid_obj); //| bssid: bytes @@ -67,12 +63,8 @@ STATIC mp_obj_t wifi_network_get_bssid(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_bssid_obj, wifi_network_get_bssid); -const mp_obj_property_t wifi_network_bssid_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_bssid_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_bssid_obj, + (mp_obj_t)&wifi_network_get_bssid_obj); //| rssi: int @@ -84,12 +76,8 @@ STATIC mp_obj_t wifi_network_get_rssi(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_rssi_obj, wifi_network_get_rssi); -const mp_obj_property_t wifi_network_rssi_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_rssi_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_rssi_obj, + (mp_obj_t)&wifi_network_get_rssi_obj); //| channel: int @@ -101,12 +89,8 @@ STATIC mp_obj_t wifi_network_get_channel(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_channel_obj, wifi_network_get_channel); -const mp_obj_property_t wifi_network_channel_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_channel_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_channel_obj, + (mp_obj_t)&wifi_network_get_channel_obj); //| country: str //| """String id of the country code""" @@ -117,12 +101,8 @@ STATIC mp_obj_t wifi_network_get_country(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_country_obj, wifi_network_get_country); -const mp_obj_property_t wifi_network_country_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_country_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_country_obj, + (mp_obj_t)&wifi_network_get_country_obj); //| authmode: str //| """String id of the authmode""" @@ -133,12 +113,8 @@ STATIC mp_obj_t wifi_network_get_authmode(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_authmode_obj, wifi_network_get_authmode); -const mp_obj_property_t wifi_network_authmode_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_network_get_authmode_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_network_authmode_obj, + (mp_obj_t)&wifi_network_get_authmode_obj); STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_ssid), MP_ROM_PTR(&wifi_network_ssid_obj) }, diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 119ab66c97..cf1e9dfc4e 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -69,12 +69,9 @@ static mp_obj_t wifi_radio_set_enabled(mp_obj_t self, mp_obj_t value) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_enabled_obj, wifi_radio_set_enabled); -const mp_obj_property_t wifi_radio_enabled_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_enabled_obj, - (mp_obj_t)&wifi_radio_set_enabled_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(wifi_radio_enabled_obj, + (mp_obj_t)&wifi_radio_get_enabled_obj, + (mp_obj_t)&wifi_radio_set_enabled_obj); //| hostname: Union[str | ReadableBuffer] //| """Hostname for wifi interface. When the hostname is altered after interface started/connected @@ -110,12 +107,9 @@ STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) } MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_hostname_obj, wifi_radio_set_hostname); -const mp_obj_property_t wifi_radio_hostname_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&wifi_radio_get_hostname_obj, - (mp_obj_t)&wifi_radio_set_hostname_obj, - MP_ROM_NONE}, -}; +MP_PROPERTY_GETSET(wifi_radio_hostname_obj, + (mp_obj_t)&wifi_radio_get_hostname_obj, + (mp_obj_t)&wifi_radio_set_hostname_obj); //| mac_address: ReadableBuffer //| """MAC address for the station. When the address is altered after interface is connected @@ -142,12 +136,9 @@ STATIC mp_obj_t wifi_radio_set_mac_address(mp_obj_t self_in, mp_obj_t mac_addres } MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_mac_address_obj, wifi_radio_set_mac_address); -const mp_obj_property_t wifi_radio_mac_address_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_mac_address_obj, - (mp_obj_t)&wifi_radio_set_mac_address_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(wifi_radio_mac_address_obj, + (mp_obj_t)&wifi_radio_get_mac_address_obj, + (mp_obj_t)&wifi_radio_set_mac_address_obj); //| mac_address_ap: ReadableBuffer //| """MAC address for the AP. When the address is altered after interface is started @@ -174,12 +165,9 @@ STATIC mp_obj_t wifi_radio_set_mac_address_ap(mp_obj_t self_in, mp_obj_t mac_add } MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_mac_address_ap_obj, wifi_radio_set_mac_address_ap); -const mp_obj_property_t wifi_radio_mac_address_ap_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_mac_address_ap_obj, - (mp_obj_t)&wifi_radio_set_mac_address_ap_obj, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETSET(wifi_radio_mac_address_ap_obj, + (mp_obj_t)&wifi_radio_get_mac_address_ap_obj, + (mp_obj_t)&wifi_radio_set_mac_address_ap_obj); //| def start_scanning_networks(self, *, start_channel: int = 1, stop_channel: int = 11) -> Iterable[Network]: //| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country.""" @@ -393,12 +381,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_gateway(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_gateway_obj, wifi_radio_get_ipv4_gateway); -const mp_obj_property_t wifi_radio_ipv4_gateway_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_gateway_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_gateway_obj, + (mp_obj_t)&wifi_radio_get_ipv4_gateway_obj); //| ipv4_gateway_ap: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the access point gateway, when enabled. None otherwise.""" @@ -409,12 +393,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_gateway_ap(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_gateway_ap_obj, wifi_radio_get_ipv4_gateway_ap); -const mp_obj_property_t wifi_radio_ipv4_gateway_ap_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_gateway_ap_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_gateway_ap_obj, + (mp_obj_t)&wifi_radio_get_ipv4_gateway_ap_obj); //| ipv4_subnet: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the station subnet when connected to an access point. None otherwise.""" @@ -425,12 +405,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_subnet(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_obj, wifi_radio_get_ipv4_subnet); -const mp_obj_property_t wifi_radio_ipv4_subnet_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_subnet_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_obj, + (mp_obj_t)&wifi_radio_get_ipv4_subnet_obj); //| ipv4_subnet_ap: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the access point subnet, when enabled. None otherwise.""" @@ -441,12 +417,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_subnet_ap(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_ap_obj, wifi_radio_get_ipv4_subnet_ap); -const mp_obj_property_t wifi_radio_ipv4_subnet_ap_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_subnet_ap_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_ap_obj, + (mp_obj_t)&wifi_radio_get_ipv4_subnet_ap_obj); //| ipv4_address: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the station when connected to an access point. None otherwise.""" @@ -457,12 +429,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_address(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_address_obj, wifi_radio_get_ipv4_address); -const mp_obj_property_t wifi_radio_ipv4_address_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_address_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_address_obj, + (mp_obj_t)&wifi_radio_get_ipv4_address_obj); //| ipv4_address_ap: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the access point, when enabled. None otherwise.""" @@ -473,12 +441,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_address_ap(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_address_ap_obj, wifi_radio_get_ipv4_address_ap); -const mp_obj_property_t wifi_radio_ipv4_address_ap_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_address_ap_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_address_ap_obj, + (mp_obj_t)&wifi_radio_get_ipv4_address_ap_obj); //| ipv4_dns: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the DNS server in use when connected to an access point. None otherwise.""" @@ -489,12 +453,8 @@ STATIC mp_obj_t wifi_radio_get_ipv4_dns(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_dns_obj, wifi_radio_get_ipv4_dns); -const mp_obj_property_t wifi_radio_ipv4_dns_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ipv4_dns_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ipv4_dns_obj, + (mp_obj_t)&wifi_radio_get_ipv4_dns_obj); //| ap_info: Optional[Network] //| """Network object containing BSSID, SSID, authmode, channel, country and RSSI when connected to an access point. None otherwise.""" @@ -505,12 +465,8 @@ STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_info_obj, wifi_radio_get_ap_info); -const mp_obj_property_t wifi_radio_ap_info_obj = { - .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&wifi_radio_get_ap_info_obj, - MP_ROM_NONE, - MP_ROM_NONE }, -}; +MP_PROPERTY_GETTER(wifi_radio_ap_info_obj, + (mp_obj_t)&wifi_radio_get_ap_info_obj); //| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> Optional[float]: //| """Ping an IP to test connectivity. Returns echo time in seconds.