From 4d175ab41a8ff5dfe84e660a3aa69119ec6de5ee Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 19 Sep 2023 21:09:29 -0400 Subject: [PATCH] convert to MP_DEFINED_CONST_OBJ_TYPE() --- ports/atmel-samd/bindings/samd/Clock.c | 13 ++++---- .../broadcom/bindings/videocore/Framebuffer.c | 20 +++++------ ports/espressif/bindings/espcamera/Camera.c | 13 ++++---- ports/espressif/bindings/espidf/__init__.c | 32 +++++++++--------- ports/espressif/bindings/espnow/ESPNow.c | 20 +++++------ ports/espressif/bindings/espnow/Peer.c | 13 ++++---- ports/espressif/bindings/espnow/Peers.c | 22 ++++++------- ports/espressif/bindings/espulp/ULP.c | 13 ++++---- ports/espressif/bindings/espulp/ULPAlarm.c | 11 ++++--- ports/raspberrypi/bindings/cyw43/__init__.c | 17 +++++----- .../bindings/picodvi/Framebuffer.c | 20 +++++------ .../bindings/rp2pio/StateMachine.c | 13 ++++---- ports/stm/boards/swan_r5/pins.c | 11 ++++--- py/obj.h | 1 - py/objtraceback.c | 11 ++++--- shared-bindings/_bleio/Adapter.c | 13 ++++---- shared-bindings/_bleio/Address.c | 22 ++++++------- shared-bindings/_bleio/Attribute.c | 11 ++++--- shared-bindings/_bleio/Characteristic.c | 13 ++++---- shared-bindings/_bleio/CharacteristicBuffer.c | 21 +++++------- shared-bindings/_bleio/Connection.c | 16 ++++----- shared-bindings/_bleio/Descriptor.c | 13 ++++---- shared-bindings/_bleio/PacketBuffer.c | 13 ++++---- shared-bindings/_bleio/ScanEntry.c | 11 ++++--- shared-bindings/_bleio/ScanResults.c | 16 ++++----- shared-bindings/_bleio/ScanResults.h | 20 ----------- shared-bindings/_bleio/Service.c | 15 +++++---- shared-bindings/_bleio/UUID.c | 22 ++++++------- shared-bindings/_eve/__init__.c | 13 ++++---- shared-bindings/_pew/PewPew.c | 14 ++++---- shared-bindings/_pixelmap/PixelMap.c | 20 +++++------ shared-bindings/_stage/Layer.c | 13 ++++---- shared-bindings/_stage/Text.c | 13 ++++---- .../i2c_device/I2CDevice.c | 13 ++++---- .../spi_device/SPIDevice.c | 13 ++++---- shared-bindings/adafruit_pixelbuf/PixelBuf.c | 22 ++++++------- shared-bindings/aesio/aes.c | 13 ++++---- shared-bindings/alarm/SleepMemory.c | 18 +++++----- shared-bindings/alarm/pin/PinAlarm.c | 13 ++++---- shared-bindings/alarm/time/TimeAlarm.c | 13 ++++---- shared-bindings/alarm/touch/TouchAlarm.c | 13 ++++---- shared-bindings/analogbufio/BufferedIn.c | 13 ++++---- shared-bindings/analogio/AnalogIn.c | 13 ++++---- shared-bindings/analogio/AnalogOut.c | 13 ++++---- shared-bindings/audiobusio/I2SOut.c | 13 ++++---- shared-bindings/audiobusio/PDMIn.c | 13 ++++---- shared-bindings/audiocore/RawSample.c | 18 +++++----- shared-bindings/audiocore/WaveFile.c | 18 +++++----- shared-bindings/audioio/AudioOut.c | 13 ++++---- shared-bindings/audiomixer/Mixer.c | 18 +++++----- shared-bindings/audiomixer/MixerVoice.c | 13 ++++---- shared-bindings/audiomp3/MP3Decoder.c | 18 +++++----- shared-bindings/audiopwmio/PWMAudioOut.c | 13 ++++---- shared-bindings/bitbangio/I2C.c | 13 ++++---- shared-bindings/bitbangio/SPI.c | 13 ++++---- shared-bindings/busio/I2C.c | 13 ++++---- shared-bindings/busio/SPI.c | 13 ++++---- shared-bindings/busio/UART.c | 33 +++++++++---------- shared-bindings/camera/Camera.c | 13 ++++---- shared-bindings/camera/ImageFormat.c | 13 ++++---- shared-bindings/canio/CAN.c | 13 ++++---- shared-bindings/canio/Listener.c | 15 ++++----- shared-bindings/canio/Match.c | 13 ++++---- shared-bindings/canio/Message.c | 13 ++++---- .../canio/RemoteTransmissionRequest.c | 13 ++++---- shared-bindings/countio/Counter.c | 13 ++++---- shared-bindings/digitalio/DigitalInOut.c | 13 ++++---- shared-bindings/digitalio/Direction.c | 13 ++++---- shared-bindings/digitalio/DriveMode.c | 13 ++++---- shared-bindings/digitalio/Pull.c | 13 ++++---- shared-bindings/displayio/Bitmap.c | 20 +++++------ shared-bindings/displayio/ColorConverter.c | 13 ++++---- shared-bindings/displayio/Display.c | 13 ++++---- shared-bindings/displayio/EPaperDisplay.c | 13 ++++---- shared-bindings/displayio/FourWire.c | 13 ++++---- shared-bindings/displayio/Group.c | 22 ++++++------- shared-bindings/displayio/I2CDisplay.c | 13 ++++---- shared-bindings/displayio/OnDiskBitmap.c | 13 ++++---- shared-bindings/displayio/Palette.c | 23 +++++++------ shared-bindings/displayio/Shape.c | 13 ++++---- shared-bindings/displayio/TileGrid.c | 19 +++++------ shared-bindings/fontio/BuiltinFont.c | 11 ++++--- .../framebufferio/FramebufferDisplay.c | 13 ++++---- shared-bindings/frequencyio/FrequencyIn.c | 13 ++++---- shared-bindings/gifio/GifWriter.c | 13 ++++---- shared-bindings/gifio/OnDiskGif.c | 13 ++++---- shared-bindings/gnss/GNSS.c | 13 ++++---- shared-bindings/gnss/PositionFix.c | 13 ++++---- shared-bindings/gnss/SatelliteSystem.c | 13 ++++---- shared-bindings/hashlib/Hash.c | 11 ++++--- shared-bindings/i2ctarget/I2CTarget.c | 13 ++++---- .../imagecapture/ParallelImageCapture.c | 13 ++++---- shared-bindings/ipaddress/IPv4Address.c | 22 ++++++------- shared-bindings/is31fl3741/FrameBuffer.c | 20 +++++------ shared-bindings/is31fl3741/IS31FL3741.c | 13 ++++---- shared-bindings/keypad/Event.c | 22 ++++++------- shared-bindings/keypad/EventQueue.c | 22 ++++++------- shared-bindings/keypad/KeyMatrix.c | 13 ++++---- shared-bindings/keypad/Keys.c | 13 ++++---- shared-bindings/keypad/ShiftRegisterKeys.c | 13 ++++---- shared-bindings/mdns/RemoteService.c | 11 ++++--- shared-bindings/mdns/Server.c | 13 ++++---- shared-bindings/memorymap/AddressRange.c | 20 +++++------ .../memorymonitor/AllocationAlarm.c | 13 ++++---- .../memorymonitor/AllocationSize.c | 21 ++++++------ shared-bindings/microcontroller/Pin.c | 16 ++++----- shared-bindings/microcontroller/Processor.c | 11 ++++--- shared-bindings/microcontroller/RunMode.c | 13 ++++---- shared-bindings/msgpack/ExtType.c | 13 ++++---- shared-bindings/nvm/ByteArray.c | 18 +++++----- shared-bindings/onewireio/OneWire.c | 13 ++++---- shared-bindings/paralleldisplay/ParallelBus.c | 13 ++++---- shared-bindings/ps2io/Ps2.c | 18 +++++----- shared-bindings/pulseio/PulseIn.c | 20 +++++------ shared-bindings/pulseio/PulseOut.c | 12 +++---- shared-bindings/pwmio/PWMOut.c | 13 ++++---- shared-bindings/qrio/QRDecoder.c | 13 ++++---- shared-bindings/rgbmatrix/RGBMatrix.c | 20 +++++------ shared-bindings/rotaryio/IncrementalEncoder.c | 13 ++++---- shared-bindings/rtc/RTC.c | 13 ++++---- shared-bindings/sdcardio/SDCard.c | 13 ++++---- shared-bindings/sdioio/SDCard.c | 13 ++++---- .../sharpdisplay/SharpMemoryFramebuffer.c | 20 +++++------ shared-bindings/socketpool/Socket.c | 18 +++++----- shared-bindings/socketpool/SocketPool.c | 13 ++++---- shared-bindings/ssl/SSLContext.c | 13 ++++---- shared-bindings/ssl/SSLSocket.c | 17 +++++----- shared-bindings/supervisor/Runtime.c | 11 ++++--- shared-bindings/supervisor/StatusBar.c | 11 ++++--- shared-bindings/synthio/LFO.c | 20 +++++------ shared-bindings/synthio/Math.c | 20 +++++------ shared-bindings/synthio/MidiTrack.c | 19 +++++------ shared-bindings/synthio/Note.c | 15 +++++---- shared-bindings/synthio/Synthesizer.c | 18 +++++----- shared-bindings/terminalio/Terminal.c | 22 ++++++------- shared-bindings/touchio/TouchIn.c | 13 ++++---- shared-bindings/usb/core/Device.c | 11 ++++--- shared-bindings/usb/core/__init__.c | 16 ++++----- shared-bindings/usb_cdc/Serial.c | 18 +++++----- shared-bindings/usb_hid/Device.c | 13 ++++---- shared-bindings/usb_host/Port.c | 12 +++---- shared-bindings/usb_midi/PortIn.c | 19 +++++------ shared-bindings/usb_midi/PortOut.c | 20 +++++------ shared-bindings/vectorio/Circle.c | 18 +++++----- shared-bindings/vectorio/Polygon.c | 18 +++++----- shared-bindings/vectorio/Rectangle.c | 18 +++++----- shared-bindings/vectorio/VectorShape.c | 11 ++++--- shared-bindings/watchdog/WatchDogMode.c | 13 ++++---- shared-bindings/watchdog/WatchDogTimer.c | 12 +++---- shared-bindings/watchdog/__init__.c | 15 +++++---- shared-bindings/wifi/Monitor.c | 15 +++++---- shared-bindings/wifi/Network.c | 11 ++++--- shared-bindings/wifi/Packet.c | 18 +++++----- shared-bindings/wifi/Radio.c | 11 ++++--- shared-bindings/wifi/ScannedNetworks.c | 15 ++++----- supervisor/shared/flash.c | 13 ++++---- 156 files changed, 1165 insertions(+), 1183 deletions(-) diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index 00c1959ccf..fb8dd366d6 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -128,12 +128,13 @@ STATIC const mp_rom_map_elem_t samd_clock_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(samd_clock_locals_dict, samd_clock_locals_dict_table); -const mp_obj_type_t samd_clock_type = { - { &mp_type_type }, - .name = MP_QSTR_Clock, - .print = samd_clock_print, - .locals_dict = (mp_obj_t)&samd_clock_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + samd_clock_type, + MP_QSTR_Clock, + MP_TYPE_FLAG_NONE, + print, samd_clock_print, + locals_dict, &samd_clock_locals_dict + ); #ifdef SAMD21 diff --git a/ports/broadcom/bindings/videocore/Framebuffer.c b/ports/broadcom/bindings/videocore/Framebuffer.c index 39c5e71467..7239456d3e 100644 --- a/ports/broadcom/bindings/videocore/Framebuffer.c +++ b/ports/broadcom/bindings/videocore/Framebuffer.c @@ -169,14 +169,12 @@ STATIC const framebuffer_p_t videocore_framebuffer_proto = { .deinit = videocore_framebuffer_deinit_proto, }; -const mp_obj_type_t videocore_framebuffer_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Framebuffer, - .locals_dict = (mp_obj_dict_t *)&videocore_framebuffer_locals_dict, - .make_new = videocore_framebuffer_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = common_hal_videocore_framebuffer_get_buffer, }, - .protocol = &videocore_framebuffer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + videocore_framebuffer_type, + MP_QSTR_Framebuffer, + MP_TYPE_FLAG_NONE, + locals_dict, (mp_obj_dict_t *)&videocore_framebuffer_locals_dict, + make_new, videocore_framebuffer_make_new, + buffer, common_hal_videocore_framebuffer_get_buffer, + protocol, &videocore_framebuffer_proto + ); diff --git a/ports/espressif/bindings/espcamera/Camera.c b/ports/espressif/bindings/espcamera/Camera.c index 109ed5cffe..aea4cc775b 100644 --- a/ports/espressif/bindings/espcamera/Camera.c +++ b/ports/espressif/bindings/espcamera/Camera.c @@ -992,9 +992,10 @@ STATIC const mp_rom_map_elem_t espcamera_camera_locals_table[] = { STATIC MP_DEFINE_CONST_DICT(espcamera_camera_locals_dict, espcamera_camera_locals_table); -const mp_obj_type_t espcamera_camera_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Camera, - .make_new = espcamera_camera_make_new, - .locals_dict = (mp_obj_t)&espcamera_camera_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + espcamera_camera_type, + MP_QSTR_Camera, + MP_TYPE_FLAG_NONE, + make_new, espcamera_camera_make_new, + locals_dict, &espcamera_camera_locals_dict + ); diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index 65b7f12a18..092d29c0fd 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -104,14 +104,15 @@ STATIC void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr //| //| ... //| -const mp_obj_type_t mp_type_espidf_IDFError = { - { &mp_type_type }, - .name = MP_QSTR_IDFError, - .print = espidf_exception_print, - .make_new = mp_obj_exception_make_new, - .attr = mp_obj_exception_attr, - .parent = &mp_type_OSError, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_espidf_IDFError, + MP_QSTR_IDFError, + MP_TYPE_FLAG_NONE, + print, espidf_exception_print, + make_new, mp_obj_exception_make_new, + attr, mp_obj_exception_attr, + parent, &mp_type_OSError + ); //| class MemoryError(builtins.MemoryError): //| """Raised when an ``ESP-IDF`` memory allocation fails.""" @@ -122,13 +123,14 @@ NORETURN void mp_raise_espidf_MemoryError(void) { nlr_raise(mp_obj_new_exception(&mp_type_espidf_MemoryError)); } -const mp_obj_type_t mp_type_espidf_MemoryError = { - { &mp_type_type }, - .name = MP_QSTR_MemoryError, - .print = espidf_exception_print, - .make_new = mp_obj_exception_make_new, - .attr = mp_obj_exception_attr, - .parent = &mp_type_MemoryError, +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_espidf_MemoryError, + MP_QSTR_MemoryError, + MP_TYPE_FLAG_NONE, + print, espidf_exception_print, + make_new, mp_obj_exception_make_new, + attr, mp_obj_exception_attr, + parent, &mp_type_MemoryError }; //| def get_total_psram() -> int: diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 6255e19f86..211cb080d4 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -359,14 +359,12 @@ STATIC mp_obj_t espnow_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -const mp_obj_type_t espnow_type = { - { &mp_type_type }, - .name = MP_QSTR_ESPNow, - .make_new = espnow_make_new, - .locals_dict = (mp_obj_t)&espnow_locals_dict, - .flags = MP_TYPE_FLAG_EXTENDED, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &espnow_stream_p, - .unary_op = &espnow_unary_op - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + espnow_type, + MP_QSTR_ESPNow, + MP_TYPE_FLAG_NONE, + make_new, espnow_make_new, + locals_dict, &espnow_locals_dict, + protocol, &espnow_stream_p, + unary_op, &espnow_unary_op + ); diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 4cceec1498..6279734d4f 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -220,9 +220,10 @@ STATIC const mp_rom_map_elem_t espnow_peer_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(espnow_peer_locals_dict, espnow_peer_locals_dict_table); -const mp_obj_type_t espnow_peer_type = { - { &mp_type_type }, - .name = MP_QSTR_Peer, - .make_new = espnow_peer_make_new, - .locals_dict = (mp_obj_t)&espnow_peer_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + espnow_peer_type, + MP_QSTR_Peer, + MP_TYPE_FLAG_NONE, + make_new, espnow_peer_make_new, + locals_dict, &espnow_peer_locals_dict + ); diff --git a/ports/espressif/bindings/espnow/Peers.c b/ports/espressif/bindings/espnow/Peers.c index 096a5266a0..a2bfcd255f 100644 --- a/ports/espressif/bindings/espnow/Peers.c +++ b/ports/espressif/bindings/espnow/Peers.c @@ -123,15 +123,13 @@ espnow_peers_obj_t *espnow_peers_new(void) { return self; } -const mp_obj_type_t espnow_peers_type = { - { &mp_type_type }, - .name = MP_QSTR_Peers, - .print = espnow_peers_print, - .locals_dict = (mp_obj_t)&espnow_peers_locals_dict, - .flags = MP_TYPE_FLAG_EXTENDED, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = espnow_peers_unary_op, - .subscr = espnow_peers_subscr, - .getiter = espnow_peers_getiter, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + espnow_peers_type, + MP_QSTR_Peers, + MP_TYPE_FLAG_NONE, + print, espnow_peers_print, + locals_dict, &espnow_peers_locals_dict, + unary_op, espnow_peers_unary_op, + subscr, espnow_peers_subscr, + getiter, espnow_peers_getiter + ); diff --git a/ports/espressif/bindings/espulp/ULP.c b/ports/espressif/bindings/espulp/ULP.c index 09453c9a09..4e9c331758 100644 --- a/ports/espressif/bindings/espulp/ULP.c +++ b/ports/espressif/bindings/espulp/ULP.c @@ -172,9 +172,10 @@ STATIC const mp_rom_map_elem_t espulp_ulp_locals_table[] = { }; STATIC MP_DEFINE_CONST_DICT(espulp_ulp_locals_dict, espulp_ulp_locals_table); -const mp_obj_type_t espulp_ulp_type = { - { &mp_type_type }, - .name = MP_QSTR_ULP, - .make_new = espulp_ulp_make_new, - .locals_dict = (mp_obj_t)&espulp_ulp_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + espulp_ulp_type, + MP_QSTR_ULP, + MP_TYPE_FLAG_NONE, + make_new, espulp_ulp_make_new, + locals_dict, &espulp_ulp_locals_dict + ); diff --git a/ports/espressif/bindings/espulp/ULPAlarm.c b/ports/espressif/bindings/espulp/ULPAlarm.c index b8b0a7c122..7c13e8cbca 100644 --- a/ports/espressif/bindings/espulp/ULPAlarm.c +++ b/ports/espressif/bindings/espulp/ULPAlarm.c @@ -59,8 +59,9 @@ STATIC mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_arg return MP_OBJ_FROM_PTR(self); } -const mp_obj_type_t espulp_ulpalarm_type = { - { &mp_type_type }, - .name = MP_QSTR_ULPAlarm, - .make_new = espulp_ulpalarm_make_new, -}; +MP_DEFINE_CONST_OBJ_TYPE( + espulp_ulpalarm_type, + MP_QSTR_ULPAlarm, + MP_TYPE_FLAG_NONE, + make_new, espulp_ulpalarm_make_new + ); diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index d00612518e..0df67f5bda 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -52,15 +52,14 @@ void bindings_cyw43_wifi_enforce_pm() { //| in :py:mod:`board`. A `CywPin` can be used as a DigitalInOut, but not with other //| peripherals such as `PWMOut`.""" //| -const mp_obj_type_t cyw43_pin_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_CywPin, - .print = shared_bindings_microcontroller_pin_print, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + cyw43_pin_type, + MP_TYPE_FLAG_EXTENDED, + MP_TYPE_FLAG_NONE, + name, MP_QSTR_CywPin, + print, shared_bindings_microcontroller_pin_print, + unary_op, mp_generic_unary_op, + ); //| PM_STANDARD: int //| """The standard power management mode""" diff --git a/ports/raspberrypi/bindings/picodvi/Framebuffer.c b/ports/raspberrypi/bindings/picodvi/Framebuffer.c index f6fa7f986a..31fbea7efd 100644 --- a/ports/raspberrypi/bindings/picodvi/Framebuffer.c +++ b/ports/raspberrypi/bindings/picodvi/Framebuffer.c @@ -248,14 +248,12 @@ STATIC const framebuffer_p_t picodvi_framebuffer_proto = { .deinit = picodvi_framebuffer_deinit_proto, }; -const mp_obj_type_t picodvi_framebuffer_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Framebuffer, - .locals_dict = (mp_obj_dict_t *)&picodvi_framebuffer_locals_dict, - .make_new = picodvi_framebuffer_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = common_hal_picodvi_framebuffer_get_buffer, }, - .protocol = &picodvi_framebuffer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + picodvi_framebuffer_type, + MP_QSTR_Framebuffer, + MP_TYPE_FLAG_NONE, + locals_dict, &picodvi_framebuffer_locals_dict, + make_new, picodvi_framebuffer_make_new, + buffer, common_hal_picodvi_framebuffer_get_buffer, + protocol, &picodvi_framebuffer_proto, + ); diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 8e2df24c6c..120145f5ea 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -859,9 +859,10 @@ STATIC const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(rp2pio_statemachine_locals_dict, rp2pio_statemachine_locals_dict_table); -const mp_obj_type_t rp2pio_statemachine_type = { - { &mp_type_type }, - .name = MP_QSTR_StateMachine, - .make_new = rp2pio_statemachine_make_new, - .locals_dict = (mp_obj_dict_t *)&rp2pio_statemachine_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + rp2pio_statemachine_type, + MP_QSTR_StateMachine, + MP_TYPE_FLAG_NONE, + make_new, rp2pio_statemachine_make_new, + locals_dict, &rp2pio_statemachine_locals_dict + ); diff --git a/ports/stm/boards/swan_r5/pins.c b/ports/stm/boards/swan_r5/pins.c index dc273cb6d4..28fda5e653 100644 --- a/ports/stm/boards/swan_r5/pins.c +++ b/ports/stm/boards/swan_r5/pins.c @@ -74,11 +74,12 @@ STATIC const mp_rom_map_elem_t board_module_carrier_table[] = { MP_DEFINE_CONST_DICT(board_module_carrier, board_module_carrier_table); -const mp_obj_type_t carrier_type = { - { &mp_type_type }, - .name = MP_QSTR_Ext, - .locals_dict = (mp_obj_dict_t *)&board_module_carrier, -}; +MP_DEFINE_CONST_OBJ_TYPE( + carrier_type, + MP_QSTR_Ext, + MP_TYPE_FLAG_NONE, + locals_dict, &board_module_carrier + ); // Core Feather Pins diff --git a/py/obj.h b/py/obj.h index 538343c4b1..e436ec8ea5 100644 --- a/py/obj.h +++ b/py/obj.h @@ -1226,7 +1226,6 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun); mp_obj_t mp_identity(mp_obj_t self); MP_DECLARE_CONST_FUN_OBJ_1(mp_identity_obj); -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); // Generic iterator that uses unary op and subscr to iterate over a native type. It will be slower // than a custom iterator but applies broadly. diff --git a/py/objtraceback.c b/py/objtraceback.c index 989521a0a6..7fcec9383d 100644 --- a/py/objtraceback.c +++ b/py/objtraceback.c @@ -35,8 +35,9 @@ STATIC void mp_obj_traceback_print(const mp_print_t *print, mp_obj_t o_in, mp_pr mp_printf(print, "<%q object at %p>", MP_QSTR_traceback, o); } -const mp_obj_type_t mp_type_traceback = { - { &mp_type_type }, - .name = MP_QSTR_traceback, - .print = mp_obj_traceback_print, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_traceback, + MP_QSTR_traceback, + MP_TYPE_FLAG_NONE, + print, mp_obj_traceback_print + ); diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index a45f17ca2c..6b90258111 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -468,9 +468,10 @@ STATIC const mp_rom_map_elem_t bleio_adapter_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bleio_adapter_locals_dict, bleio_adapter_locals_dict_table); -const mp_obj_type_t bleio_adapter_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Adapter, - .make_new = bleio_adapter_make_new, - .locals_dict = (mp_obj_t)&bleio_adapter_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_adapter_type, + MP_QSTR_Adapter, + MP_TYPE_FLAG_NONE, + make_new, bleio_adapter_make_new, + locals_dict, &bleio_adapter_locals_dict + ); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index cae1b9a235..623bc7aaed 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -199,15 +199,13 @@ STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bleio_address_locals_dict, bleio_address_locals_dict_table); -const mp_obj_type_t bleio_address_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Address, - .make_new = bleio_address_make_new, - .print = bleio_address_print, - .locals_dict = (mp_obj_dict_t *)&bleio_address_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = bleio_address_unary_op, - .binary_op = bleio_address_binary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_address_type, + MP_QSTR_Address, + MP_TYPE_FLAG_NONE, + make_new, bleio_address_make_new, + print, bleio_address_print, + locals_dict, &bleio_address_locals_dict, + unary_op, bleio_address_unary_op, + binary_op, bleio_address_binary_op + ); diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c index 176198d450..b060757951 100644 --- a/shared-bindings/_bleio/Attribute.c +++ b/shared-bindings/_bleio/Attribute.c @@ -74,8 +74,9 @@ STATIC const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(bleio_attribute_locals_dict, bleio_attribute_locals_dict_table); -const mp_obj_type_t bleio_attribute_type = { - { &mp_type_type }, - .name = MP_QSTR_Attribute, - .locals_dict = (mp_obj_dict_t *)&bleio_attribute_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_attribute_type, + MP_QSTR_Attribute, + MP_TYPE_FLAG_NONE, + locals_dict, &bleio_attribute_locals_dict + ); diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 1f752577c1..8b14acd7df 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -325,9 +325,10 @@ STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in } } -const mp_obj_type_t bleio_characteristic_type = { - { &mp_type_type }, - .name = MP_QSTR_Characteristic, - .print = bleio_characteristic_print, - .locals_dict = (mp_obj_dict_t *)&bleio_characteristic_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_characteristic_type, + MP_QSTR_Characteristic, + MP_TYPE_FLAG_NONE, + print, bleio_characteristic_print, + locals_dict, &bleio_characteristic_locals_dict + ); diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 842ea4cc58..d95972d263 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -222,15 +222,12 @@ STATIC const mp_stream_p_t characteristic_buffer_stream_p = { }; -const mp_obj_type_t bleio_characteristic_buffer_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_CharacteristicBuffer, - .make_new = bleio_characteristic_buffer_make_new, - .locals_dict = (mp_obj_dict_t *)&bleio_characteristic_buffer_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &characteristic_buffer_stream_p, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_characteristic_buffer_type, + MP_QSTR_CharacteristicBuffer, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + make_new, bleio_characteristic_buffer_make_new, + locals_dict, &bleio_characteristic_buffer_locals_dict, + iternext, mp_stream_unbuffered_iter, + protocol, &characteristic_buffer_stream_p + ); diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index f76ecc8167..cec1c4a851 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -244,12 +244,10 @@ STATIC const mp_rom_map_elem_t bleio_connection_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bleio_connection_locals_dict, bleio_connection_locals_dict_table); -const mp_obj_type_t bleio_connection_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Connection, - .locals_dict = (mp_obj_dict_t *)&bleio_connection_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_connection_type, + MP_QSTR_Connection, + MP_TYPE_FLAG_NONE, + locals_dict, &bleio_connection_locals_dict, + unary_op, mp_generic_unary_op + ); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 813ef8f9fe..093b51100e 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -211,9 +211,10 @@ STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp } } -const mp_obj_type_t bleio_descriptor_type = { - { &mp_type_type }, - .name = MP_QSTR_Descriptor, - .print = bleio_descriptor_print, - .locals_dict = (mp_obj_dict_t *)&bleio_descriptor_locals_dict -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_descriptor_type, + MP_QSTR_Descriptor, + MP_TYPE_FLAG_NONE, + print, bleio_descriptor_print, + locals_dict, &bleio_descriptor_locals_dict + ); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 2c03a6855e..c97e97b410 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -229,9 +229,10 @@ STATIC const mp_rom_map_elem_t bleio_packet_buffer_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bleio_packet_buffer_locals_dict, bleio_packet_buffer_locals_dict_table); -const mp_obj_type_t bleio_packet_buffer_type = { - { &mp_type_type }, - .name = MP_QSTR_PacketBuffer, - .make_new = bleio_packet_buffer_make_new, - .locals_dict = (mp_obj_dict_t *)&bleio_packet_buffer_locals_dict -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_packet_buffer_type, + MP_QSTR_PacketBuffer, + MP_TYPE_FLAG_NONE, + make_new, bleio_packet_buffer_make_new, + locals_dict, &bleio_packet_buffer_locals_dict + ); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index 83966d1719..f859f22be1 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -136,8 +136,9 @@ STATIC const mp_rom_map_elem_t bleio_scanentry_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_dict_table); -const mp_obj_type_t bleio_scanentry_type = { - { &mp_type_type }, - .name = MP_QSTR_ScanEntry, - .locals_dict = (mp_obj_dict_t *)&bleio_scanentry_locals_dict -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_scanentry_type, + MP_QSTR_ScanEntry, + MP_TYPE_FLAG_NONE, + locals_dict, &bleio_scanentry_locals_dict + ); diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c index ec4e0c72e8..1fba594ec6 100644 --- a/shared-bindings/_bleio/ScanResults.c +++ b/shared-bindings/_bleio/ScanResults.c @@ -59,12 +59,10 @@ STATIC mp_obj_t scanresults_iternext(mp_obj_t self_in) { //| ... //| -const mp_obj_type_t bleio_scanresults_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_ScanResults, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = scanresults_iternext, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_scanresults_type, + MP_QSTR_ScanResults, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + getiter, mp_identity_getiter, + iternext, scanresults_iternext + ); diff --git a/shared-bindings/_bleio/ScanResults.h b/shared-bindings/_bleio/ScanResults.h index f3102eb2ce..a8c88c215d 100644 --- a/shared-bindings/_bleio/ScanResults.h +++ b/shared-bindings/_bleio/ScanResults.h @@ -3,13 +3,9 @@ * * The MIT License (MIT) * -<<<<<<<< HEAD:shared-bindings/_bleio/ScanResults.h * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * Copyright (c) 2017 Glenn Ruben Bakke -======== - * Copyright (c) 2022 Blake W. Felt & Angus Gratton ->>>>>>>> v1.20.0:shared/tinyusb/mp_usbd.h * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +26,6 @@ * THE SOFTWARE. */ -<<<<<<<< HEAD:shared-bindings/_bleio/ScanResults.h #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANRESULTS_H #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANRESULTS_H @@ -42,18 +37,3 @@ extern const mp_obj_type_t bleio_scanresults_type; mp_obj_t common_hal_bleio_scanresults_next(bleio_scanresults_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANRESULTS_H -======== -#ifndef MICROPY_INCLUDED_SHARED_TINYUSB_MP_USBD_H -#define MICROPY_INCLUDED_SHARED_TINYUSB_MP_USBD_H - -#include "py/obj.h" - -// Call instead of tud_task() -void mp_usbd_task(void); - -// Function to be implemented in port code. -// Can write a string up to MICROPY_HW_USB_DESC_STR_MAX characters long, plus terminating byte. -extern void mp_usbd_port_get_serial_number(char *buf); - -#endif // MICROPY_INCLUDED_SHARED_TINYUSB_USBD_H ->>>>>>>> v1.20.0:shared/tinyusb/mp_usbd.h diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index f107b068e0..f5ffa982f6 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -140,10 +140,11 @@ STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_pr } } -const mp_obj_type_t bleio_service_type = { - { &mp_type_type }, - .name = MP_QSTR_Service, - .make_new = bleio_service_make_new, - .print = bleio_service_print, - .locals_dict = (mp_obj_dict_t *)&bleio_service_locals_dict -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_service_type, + MP_QSTR_Service, + MP_TYPE_FLAG_NONE, + make_new, bleio_service_make_new, + print, bleio_service_print, + locals_dict, &bleio_service_locals_dict + ); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index b7fc05fbc6..3469982458 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -280,15 +280,13 @@ void bleio_uuid_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t } } -const mp_obj_type_t bleio_uuid_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_UUID, - .print = bleio_uuid_print, - .make_new = bleio_uuid_make_new, - .locals_dict = (mp_obj_dict_t *)&bleio_uuid_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = bleio_uuid_unary_op, - .binary_op = bleio_uuid_binary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + bleio_uuid_type, + MP_QSTR_UUID, + MP_TYPE_FLAG_NONE, + print, bleio_uuid_print, + make_new, bleio_uuid_make_new, + locals_dict, &bleio_uuid_locals_dict, + unary_op, bleio_uuid_unary_op, + binary_op, bleio_uuid_binary_op, + ); diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 203a9cbfd2..ed1ddd961a 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -1064,12 +1064,13 @@ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, size_t n return MP_OBJ_FROM_PTR(o); } -STATIC const mp_obj_type_t _EVE_type = { - { &mp_type_type }, - .name = MP_QSTR__EVE, - .make_new = _EVE_make_new, - .locals_dict = (void *)&_EVE_locals_dict, -}; +STATIC MP_DEFINE_CONST_OBJ_TYPE( + _EVE_type, + MP_QSTR__EVE, + MP_TYPE_FLAG_NONE, + make_new, _EVE_make_new, + locals_dict, &_EVE_locals_dict + ); STATIC const mp_rom_map_elem_t mp_module__eve_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__eve) }, diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 794d4b207c..5309baa0e2 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -129,9 +129,11 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, size_t STATIC const mp_rom_map_elem_t pewpew_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(pewpew_locals_dict, pewpew_locals_dict_table); -const mp_obj_type_t pewpew_type = { - { &mp_type_type }, - .name = MP_QSTR_PewPew, - .make_new = pewpew_make_new, - .locals_dict = (mp_obj_dict_t *)&pewpew_locals_dict, -}; + +MP_DEFINE_CONST_OBJ_TYPE( + pewpew_type, + MP_QSTR_PewPew, + MP_TYPE_FLAG_NONE, + make_new, pewpew_make_new, + locals_dict, &pewpew_locals_dict + ); diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 5de918bbbe..618135f995 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -255,14 +255,12 @@ STATIC const mp_rom_map_elem_t pixelmap_pixelmap_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(pixelmap_pixelmap_locals_dict, pixelmap_pixelmap_locals_dict_table); -const mp_obj_type_t pixelmap_pixelmap_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelMap, - .flags = MP_TYPE_FLAG_EXTENDED, - .locals_dict = (mp_obj_t)&pixelmap_pixelmap_locals_dict, - .make_new = pixelmap_pixelmap_make_new, - MP_TYPE_EXTENDED_FIELDS( - .subscr = pixelmap_pixelmap_subscr, - .unary_op = pixelmap_pixelmap_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + pixelmap_pixelmap_type, + MP_QSTR_PixelMap, + MP_TYPE_FLAG_NONE, + .locals_dict, &pixelmap_pixelmap_locals_dict, + .make_new, pixelmap_pixelmap_make_new, + .subscr, pixelmap_pixelmap_subscr, + .unary_op, pixelmap_pixelmap_unary_op + ); diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index e92e950fb1..d2780ac352 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -124,9 +124,10 @@ STATIC const mp_rom_map_elem_t layer_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(layer_locals_dict, layer_locals_dict_table); -const mp_obj_type_t mp_type_layer = { - { &mp_type_type }, - .name = MP_QSTR_Layer, - .make_new = layer_make_new, - .locals_dict = (mp_obj_dict_t *)&layer_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_layer, + MP_QSTR_Layer, + MP_TYPE_FLAG_NONE, + make_new, layer_make_new, + locals_dict, &layer_locals_dict + ); diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index b53dccfc65..c406c0ec4a 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -104,9 +104,10 @@ STATIC const mp_rom_map_elem_t text_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(text_locals_dict, text_locals_dict_table); -const mp_obj_type_t mp_type_text = { - { &mp_type_type }, - .name = MP_QSTR_Text, - .make_new = text_make_new, - .locals_dict = (mp_obj_dict_t *)&text_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_text, + MP_QSTR_Text, + MP_TYPE_FLAG_NONE, + make_new, text_make_new, + locals_dict,&text_locals_dict + ); diff --git a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index dfc77fde16..c0380871fa 100644 --- a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -284,9 +284,10 @@ STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_i2cdevice_locals_dict, adafruit_bus_device_i2cdevice_locals_dict_table); -const mp_obj_type_t adafruit_bus_device_i2cdevice_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CDevice, - .make_new = adafruit_bus_device_i2cdevice_make_new, - .locals_dict = (mp_obj_dict_t *)&adafruit_bus_device_i2cdevice_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + adafruit_bus_device_i2cdevice_type, + MP_QSTR_I2CDevice, + MP_TYPE_FLAG_NONE, + make_new, adafruit_bus_device_i2cdevice_make_new, + locals_dict = &adafruit_bus_device_i2cdevice_locals_dict + ); diff --git a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index cb148143e4..34b2c0e25b 100644 --- a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -142,9 +142,10 @@ STATIC const mp_rom_map_elem_t adafruit_bus_device_spidevice_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spidevice_locals_dict, adafruit_bus_device_spidevice_locals_dict_table); -const mp_obj_type_t adafruit_bus_device_spidevice_type = { - { &mp_type_type }, - .name = MP_QSTR_SPIDevice, - .make_new = adafruit_bus_device_spidevice_make_new, - .locals_dict = (mp_obj_dict_t *)&adafruit_bus_device_spidevice_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + adafruit_bus_device_spidevice_type, + MP_QSTR_SPIDevice, + MP_TYPE_FLAG_NONE, + make_new, adafruit_bus_device_spidevice_make_new, + locals_dict, &adafruit_bus_device_spidevice_locals_dict + ); diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index d259b57dbb..e7bde6f429 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -368,15 +368,13 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); -const mp_obj_type_t pixelbuf_pixelbuf_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelBuf, - .flags = MP_TYPE_FLAG_EXTENDED, - .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, - .make_new = pixelbuf_pixelbuf_make_new, - MP_TYPE_EXTENDED_FIELDS( - .subscr = pixelbuf_pixelbuf_subscr, - .unary_op = pixelbuf_pixelbuf_unary_op, - .getiter = mp_obj_new_generic_iterator, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + pixelbuf_pixelbuf_type, + MP_QSTR_PixelBuf, + MP_TYPE_FLAG_ITER_IS_GETITER, + locals_dict, &pixelbuf_pixelbuf_locals_dict, + make_new, pixelbuf_pixelbuf_make_new, + subscr, pixelbuf_pixelbuf_subscr, + unary_op, pixelbuf_pixelbuf_unary_op, + iter, mp_obj_new_generic_iterator + ); diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 7a6a2f47ed..8344c43c9b 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -249,9 +249,10 @@ STATIC const mp_rom_map_elem_t aesio_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(aesio_locals_dict, aesio_locals_dict_table); -const mp_obj_type_t aesio_aes_type = { - {&mp_type_type}, - .name = MP_QSTR_AES, - .make_new = aesio_aes_make_new, - .locals_dict = (mp_obj_dict_t *)&aesio_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + aesio_aes_type, + MP_QSTR_AES, + MP_TYPE_FLAG_NONE, + make_new, aesio_aes_make_new, + locals_dict, &aesio_locals_dict + ); diff --git a/shared-bindings/alarm/SleepMemory.c b/shared-bindings/alarm/SleepMemory.c index c51c15ad46..ab4659629a 100644 --- a/shared-bindings/alarm/SleepMemory.c +++ b/shared-bindings/alarm/SleepMemory.c @@ -169,13 +169,11 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m } } -const mp_obj_type_t alarm_sleep_memory_type = { - { &mp_type_type }, - .name = MP_QSTR_SleepMemory, - .flags = MP_TYPE_FLAG_EXTENDED, - .locals_dict = (mp_obj_t)&alarm_sleep_memory_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = alarm_sleep_memory_subscr, - .unary_op = alarm_sleep_memory_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + alarm_sleep_memory_type, + MP_QSTR_SleepMemory, + MP_TYPE_FLAG_NONE, + locals_dict, &alarm_sleep_memory_locals_dict, + subscr, alarm_sleep_memory_subscr, + unary_op, alarm_sleep_memory_unary_op + ); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 3eeb83c835..2e9441c725 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -117,9 +117,10 @@ STATIC const mp_rom_map_elem_t alarm_pin_pinalarm_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(alarm_pin_pinalarm_locals_dict, alarm_pin_pinalarm_locals_dict_table); -const mp_obj_type_t alarm_pin_pinalarm_type = { - { &mp_type_type }, - .name = MP_QSTR_PinAlarm, - .make_new = alarm_pin_pinalarm_make_new, - .locals_dict = (mp_obj_t)&alarm_pin_pinalarm_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + alarm_pin_pinalarm_type, + MP_QSTR_PinAlarm, + MP_TYPE_FLAG_NONE, + make_new, alarm_pin_pinalarm_make_new, + locals_dict, &alarm_pin_pinalarm_locals_dict + ); diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 0a886e6680..9a6440d451 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -131,9 +131,10 @@ STATIC const mp_rom_map_elem_t alarm_time_timealarm_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(alarm_time_timealarm_locals_dict, alarm_time_timealarm_locals_dict_table); -const mp_obj_type_t alarm_time_timealarm_type = { - { &mp_type_type }, - .name = MP_QSTR_TimeAlarm, - .make_new = alarm_time_timealarm_make_new, - .locals_dict = (mp_obj_t)&alarm_time_timealarm_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + alarm_time_timealarm_type, + MP_QSTR_TimeAlarm, + MP_TYPE_FLAG_NONE, + make_new, alarm_time_timealarm_make_new, + locals_dict, &alarm_time_timealarm_locals_dict + ); diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 71fcb67a4f..6433e1d845 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -79,9 +79,10 @@ STATIC const mp_rom_map_elem_t alarm_touch_touchalarm_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(alarm_touch_touchalarm_locals_dict, alarm_touch_touchalarm_locals_dict_table); -const mp_obj_type_t alarm_touch_touchalarm_type = { - { &mp_type_type }, - .name = MP_QSTR_TouchAlarm, - .make_new = alarm_touch_touchalarm_make_new, - .locals_dict = (mp_obj_t)&alarm_touch_touchalarm_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + alarm_touch_touchalarm_type, + MP_QSTR_TouchAlarm, + MP_TYPE_FLAG_NONE, + make_new, alarm_touch_touchalarm_make_new, + locals_dict, &alarm_touch_touchalarm_locals_dict + ); diff --git a/shared-bindings/analogbufio/BufferedIn.c b/shared-bindings/analogbufio/BufferedIn.c index 4641df6891..1e64dc6d7b 100644 --- a/shared-bindings/analogbufio/BufferedIn.c +++ b/shared-bindings/analogbufio/BufferedIn.c @@ -164,9 +164,10 @@ STATIC const mp_rom_map_elem_t analogbufio_bufferedin_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(analogbufio_bufferedin_locals_dict, analogbufio_bufferedin_locals_dict_table); -const mp_obj_type_t analogbufio_bufferedin_type = { - { &mp_type_type }, - .name = MP_QSTR_BufferedIn, - .make_new = analogbufio_bufferedin_make_new, - .locals_dict = (mp_obj_t)&analogbufio_bufferedin_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + analogbufio_bufferedin_type, + MP_QSTR_BufferedIn, + MP_TYPE_FLAG_NONE, + make_new, analogbufio_bufferedin_make_new, + locals_dict, &analogbufio_bufferedin_locals_dict + ); diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index faf085905e..c99d48fd56 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -149,9 +149,10 @@ STATIC const mp_rom_map_elem_t analogio_analogin_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(analogio_analogin_locals_dict, analogio_analogin_locals_dict_table); -const mp_obj_type_t analogio_analogin_type = { - { &mp_type_type }, - .name = MP_QSTR_AnalogIn, - .make_new = analogio_analogin_make_new, - .locals_dict = (mp_obj_t)&analogio_analogin_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + analogio_analogin_type, + MP_QSTR_AnalogIn, + MP_TYPE_FLAG_NONE, + make_new, analogio_analogin_make_new, + locals_dict, &analogio_analogin_locals_dict + ); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 7261bc61f6..facf45cf98 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -130,9 +130,10 @@ STATIC const mp_rom_map_elem_t analogio_analogout_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(analogio_analogout_locals_dict, analogio_analogout_locals_dict_table); -const mp_obj_type_t analogio_analogout_type = { - { &mp_type_type }, - .name = MP_QSTR_AnalogOut, - .make_new = analogio_analogout_make_new, - .locals_dict = (mp_obj_t)&analogio_analogout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + analogio_analogout_type, + MP_QSTR_AnalogOut, + MP_TYPE_FLAG_NONE, + make_new, analogio_analogout_make_new, + locals_dict, &analogio_analogout_locals_dict + ); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index eeabde281e..343d614045 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -268,9 +268,10 @@ STATIC const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audiobusio_i2sout_locals_dict, audiobusio_i2sout_locals_dict_table); -const mp_obj_type_t audiobusio_i2sout_type = { - { &mp_type_type }, - .name = MP_QSTR_I2SOut, - .make_new = audiobusio_i2sout_make_new, - .locals_dict = (mp_obj_dict_t *)&audiobusio_i2sout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + audiobusio_i2sout_type, + MP_QSTR_I2SOut, + MP_TYPE_FLAG_NONE, + make_new, audiobusio_i2sout_make_new, + locals_dict, &audiobusio_i2sout_locals_dict + ); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index f3062bd223..c36b717197 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -241,11 +241,12 @@ STATIC const mp_rom_map_elem_t audiobusio_pdmin_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(audiobusio_pdmin_locals_dict, audiobusio_pdmin_locals_dict_table); #endif -const mp_obj_type_t audiobusio_pdmin_type = { - { &mp_type_type }, - .name = MP_QSTR_PDMIn, - .make_new = audiobusio_pdmin_make_new, +MP_DEFINE_CONST_OBJ_TYPE( + audiobusio_pdmin_type, + MP_QSTR_PDMIn, + MP_TYPE_FLAG_NONE, + make_new, audiobusio_pdmin_make_new, #if CIRCUITPY_AUDIOBUSIO_PDMIN - .locals_dict = (mp_obj_dict_t *)&audiobusio_pdmin_locals_dict, + locals_dict, &audiobusio_pdmin_locals_dict #endif -}; + ); diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index cf593de603..04ddf282b6 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -174,13 +174,11 @@ STATIC const audiosample_p_t audioio_rawsample_proto = { .get_buffer_structure = (audiosample_get_buffer_structure_fun)audioio_rawsample_get_buffer_structure, }; -const mp_obj_type_t audioio_rawsample_type = { - { &mp_type_type }, - .name = MP_QSTR_RawSample, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = audioio_rawsample_make_new, - .locals_dict = (mp_obj_dict_t *)&audioio_rawsample_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &audioio_rawsample_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + audioio_rawsample_type, + MP_QSTR_RawSample, + MP_TYPE_FLAG_NONE, + make_new, audioio_rawsample_make_new, + locals_dict, &audioio_rawsample_locals_dict, + protocol, &audioio_rawsample_proto + ); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 4831a104f8..40de1ce023 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -200,13 +200,11 @@ STATIC const audiosample_p_t audioio_wavefile_proto = { }; -const mp_obj_type_t audioio_wavefile_type = { - { &mp_type_type }, - .name = MP_QSTR_WaveFile, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = audioio_wavefile_make_new, - .locals_dict = (mp_obj_dict_t *)&audioio_wavefile_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &audioio_wavefile_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + audioio_wavefile_type, + MP_QSTR_WaveFile, + MP_TYPE_FLAG_NONE, + make_new, audioio_wavefile_make_new, + locals_dict, &audioio_wavefile_locals_dict, + protocol, &audioio_wavefile_proto + ); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 39ceb8cefb..3df62dbe02 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -258,9 +258,10 @@ STATIC const mp_rom_map_elem_t audioio_audioout_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audioio_audioout_locals_dict, audioio_audioout_locals_dict_table); -const mp_obj_type_t audioio_audioout_type = { - { &mp_type_type }, - .name = MP_QSTR_AudioOut, - .make_new = audioio_audioout_make_new, - .locals_dict = (mp_obj_dict_t *)&audioio_audioout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + audioio_audioout_type, + MP_QSTR_AudioOut, + MP_TYPE_FLAG_NONE, + make_new, audioio_audioout_make_new, + locals_dict, &audioio_audioout_locals_dict + ); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 35b21f9341..04d80caf78 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -272,13 +272,11 @@ STATIC const audiosample_p_t audiomixer_mixer_proto = { .get_buffer_structure = (audiosample_get_buffer_structure_fun)audiomixer_mixer_get_buffer_structure, }; -const mp_obj_type_t audiomixer_mixer_type = { - { &mp_type_type }, - .name = MP_QSTR_Mixer, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = audiomixer_mixer_make_new, - .locals_dict = (mp_obj_dict_t *)&audiomixer_mixer_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &audiomixer_mixer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + audiomixer_mixer_type, + MP_QSTR_Mixer, + MP_TYPE_FLAG_NONE, + make_new, audiomixer_mixer_make_new, + locals_dict, &audiomixer_mixer_locals_dict, + protocol, &audiomixer_mixer_proto + ); diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 637e91f053..f2003abd75 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -153,9 +153,10 @@ STATIC const mp_rom_map_elem_t audiomixer_mixervoice_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audiomixer_mixervoice_locals_dict, audiomixer_mixervoice_locals_dict_table); -const mp_obj_type_t audiomixer_mixervoice_type = { - { &mp_type_type }, - .name = MP_QSTR_MixerVoice, - .make_new = audiomixer_mixervoice_make_new, - .locals_dict = (mp_obj_dict_t *)&audiomixer_mixervoice_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + audiomixer_mixervoice_type, + MP_QSTR_MixerVoice, + MP_TYPE_FLAG_NONE, + make_new, audiomixer_mixervoice_make_new, + locals_dict, &audiomixer_mixervoice_locals_dict + ); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 01496d1d90..160b415ad1 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -283,13 +283,11 @@ STATIC const audiosample_p_t audiomp3_mp3file_proto = { .get_buffer_structure = (audiosample_get_buffer_structure_fun)audiomp3_mp3file_get_buffer_structure, }; -const mp_obj_type_t audiomp3_mp3file_type = { - { &mp_type_type }, - .name = MP_QSTR_MP3Decoder, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = audiomp3_mp3file_make_new, - .locals_dict = (mp_obj_dict_t *)&audiomp3_mp3file_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &audiomp3_mp3file_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + audiomp3_mp3file_type, + MP_QSTR_MP3Decoder, + MP_TYPE_FLAG_NONE, + make_new, audiomp3_mp3file_make_new, + locals_dict, &audiomp3_mp3file_locals_dict, + .protocol, &audiomp3_mp3file_proto + ); diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 24aa01e678..f0837b5620 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -268,9 +268,10 @@ STATIC const mp_rom_map_elem_t audiopwmio_pwmaudioout_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audiopwmio_pwmaudioout_locals_dict, audiopwmio_pwmaudioout_locals_dict_table); -const mp_obj_type_t audiopwmio_pwmaudioout_type = { - { &mp_type_type }, - .name = MP_QSTR_PWMAudioOut, - .make_new = audiopwmio_pwmaudioout_make_new, - .locals_dict = (mp_obj_dict_t *)&audiopwmio_pwmaudioout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + audiopwmio_pwmaudioout_type, + MP_QSTR_PWMAudioOut, + MP_TYPE_FLAG_NONE, + make_new, audiopwmio_pwmaudioout_make_new, + locals_dict, &audiopwmio_pwmaudioout_locals_dict + ); diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 26f85fa54f..e9821efd10 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -362,9 +362,10 @@ STATIC const mp_rom_map_elem_t bitbangio_i2c_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bitbangio_i2c_locals_dict, bitbangio_i2c_locals_dict_table); -const mp_obj_type_t bitbangio_i2c_type = { - { &mp_type_type }, - .name = MP_QSTR_I2C, - .make_new = bitbangio_i2c_make_new, - .locals_dict = (mp_obj_dict_t *)&bitbangio_i2c_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + bitbangio_i2c_type, + MP_QSTR_I2C, + MP_TYPE_FLAG_NONE, + make_new,bitbangio_i2c_make_new, + locals_dict, &bitbangio_i2c_locals_dict + ); diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 14af508032..e78b96bc09 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -410,9 +410,10 @@ STATIC const mp_rom_map_elem_t bitbangio_spi_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(bitbangio_spi_locals_dict, bitbangio_spi_locals_dict_table); -const mp_obj_type_t bitbangio_spi_type = { - { &mp_type_type }, - .name = MP_QSTR_SPI, - .make_new = bitbangio_spi_make_new, - .locals_dict = (mp_obj_dict_t *)&bitbangio_spi_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + bitbangio_spi_type, + MP_QSTR_SPI, + MP_TYPE_FLAG_NONE, + make_new, bitbangio_spi_make_new, + locals_dict, &bitbangio_spi_locals_dict + ); diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 4ebbe03184..1bf92d1329 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -388,9 +388,10 @@ STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(busio_i2c_locals_dict, busio_i2c_locals_dict_table); -const mp_obj_type_t busio_i2c_type = { - { &mp_type_type }, - .name = MP_QSTR_I2C, - .make_new = busio_i2c_make_new, - .locals_dict = (mp_obj_dict_t *)&busio_i2c_locals_dict, -}; +const MP_DEFINE_CONST_OBJ_TYPE( + busio_i2c_type, + MP_QSTR_I2C, + MP_TYPE_FLAG_NONE, + make_new, busio_i2c_make_new, + locals_dict, &busio_i2c_locals_dict + ); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index f9061450ae..42dae0180a 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -474,12 +474,13 @@ STATIC const mp_rom_map_elem_t busio_spi_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(busio_spi_locals_dict, busio_spi_locals_dict_table); -const mp_obj_type_t busio_spi_type = { - { &mp_type_type }, - .name = MP_QSTR_SPI, - .make_new = busio_spi_make_new, - .locals_dict = (mp_obj_dict_t *)&busio_spi_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + busio_spi_type, + MP_QSTR_SPI, + MP_TYPE_FLAG_NONE, + make_new, busio_spi_make_new, + locals_dict, &busio_spi_locals_dict + ); busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj, qstr arg_name) { return mp_arg_validate_type(obj, &busio_spi_type, arg_name); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 6cedfad64a..66f15b1bb8 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -446,23 +446,20 @@ STATIC const mp_stream_p_t uart_stream_p = { .pyserial_readinto_compatibility = true, }; -const mp_obj_type_t busio_uart_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_UART, - .make_new = busio_uart_make_new, - .locals_dict = (mp_obj_dict_t *)&busio_uart_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &uart_stream_p, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + busio_uart_type, + MP_QSTR_UART, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + make_new, busio_uart_make_new, + locals_dict, &busio_uart_locals_dict, + iter, mp_stream_unbuffered_iter + ); #else -const mp_obj_type_t busio_uart_type = { - { &mp_type_type }, - .name = MP_QSTR_UART, - .make_new = busio_uart_make_new, - .locals_dict = (mp_obj_dict_t *)&busio_uart_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + busio_uart_type, + MP_QSTR_UART, + MP_TYPE_FLAG_NONE, + make_new, busio_uart_make_new, + locals_dict, &busio_uart_locals_dict + ); #endif // CIRCUITPY_BUSIO_UART diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index eea22a0d81..3934c80208 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -121,9 +121,10 @@ STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(camera_locals_dict, camera_locals_dict_table); -const mp_obj_type_t camera_type = { - { &mp_type_type }, - .name = MP_QSTR_Camera, - .make_new = camera_make_new, - .locals_dict = (mp_obj_dict_t *)&camera_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + camera_type, + MP_QSTR_Camera, + MP_TYPE_FLAG_NONE, + make_new, camera_make_new, + locals_dict, &camera_locals_dict + ); diff --git a/shared-bindings/camera/ImageFormat.c b/shared-bindings/camera/ImageFormat.c index 1a0c3c88d6..0bf29bb184 100644 --- a/shared-bindings/camera/ImageFormat.c +++ b/shared-bindings/camera/ImageFormat.c @@ -83,9 +83,10 @@ STATIC void camera_imageformat_print(const mp_print_t *print, mp_obj_t self_in, mp_printf(print, "%q.%q.%q", MP_QSTR_camera, MP_QSTR_ImageSize, format); } -const mp_obj_type_t camera_imageformat_type = { - { &mp_type_type }, - .name = MP_QSTR_ImageFormat, - .print = camera_imageformat_print, - .locals_dict = (mp_obj_t)&camera_imageformat_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + camera_imageformat_type, + MP_QSTR_ImageFormat, + MP_TYPE_FLAG_NONE, + print, camera_imageformat_print, + locals_dict, &camera_imageformat_locals_dict + ); diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 912255adf4..f82b06216f 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -343,9 +343,10 @@ STATIC const mp_rom_map_elem_t canio_can_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(canio_can_locals_dict, canio_can_locals_dict_table); -const mp_obj_type_t canio_can_type = { - { &mp_type_type }, - .name = MP_QSTR_CAN, - .make_new = canio_can_make_new, - .locals_dict = (mp_obj_t)&canio_can_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + canio_can_type, + MP_QSTR_CAN, + MP_TYPE_FLAG_NONE, + make_new, canio_can_make_new, + locals_dict, &canio_can_locals_dict + ); diff --git a/shared-bindings/canio/Listener.c b/shared-bindings/canio/Listener.c index e10f7fde6f..96d119349b 100644 --- a/shared-bindings/canio/Listener.c +++ b/shared-bindings/canio/Listener.c @@ -166,13 +166,10 @@ STATIC const mp_rom_map_elem_t canio_listener_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(canio_listener_locals_dict, canio_listener_locals_dict_table); -const mp_obj_type_t canio_listener_type = { - { &mp_type_type }, - .name = MP_QSTR_Listener, - .flags = MP_TYPE_FLAG_EXTENDED, +MP_DEFINE_CONST_OBJ_TYPE( + canio_listener_type, + MP_QSTR_Listener, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, .locals_dict = (mp_obj_dict_t *)&canio_listener_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = canio_iternext, - ), -}; + .iternext = canio_iternext + ); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 1a9cd34916..4ead5d75c2 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -113,9 +113,10 @@ STATIC const mp_rom_map_elem_t canio_match_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(canio_match_locals_dict, canio_match_locals_dict_table); -const mp_obj_type_t canio_match_type = { - { &mp_type_type }, - .name = MP_QSTR_Match, - .make_new = canio_match_make_new, - .locals_dict = (mp_obj_dict_t *)&canio_match_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + canio_match_type, + MP_QSTR_Match, + MP_TYPE_FLAG_NONE, + make_new, canio_match_make_new, + locals_dict, &canio_match_locals_dict + ); diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index 432b10b4e8..b53181e0dd 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -136,9 +136,10 @@ STATIC const mp_rom_map_elem_t canio_message_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(canio_message_locals_dict, canio_message_locals_dict_table); -const mp_obj_type_t canio_message_type = { - { &mp_type_type }, - .name = MP_QSTR_Message, - .make_new = canio_message_make_new, - .locals_dict = (mp_obj_t)&canio_message_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + canio_message_type, + MP_QSTR_Message, + MP_TYPE_FLAG_NONE, + make_new, canio_message_make_new, + locals_dict, &canio_message_locals_dict + ); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 4b55bf2e75..3920942bfe 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -136,9 +136,10 @@ STATIC const mp_rom_map_elem_t canio_remote_transmission_request_locals_dict_tab }; STATIC MP_DEFINE_CONST_DICT(canio_remote_transmission_request_locals_dict, canio_remote_transmission_request_locals_dict_table); -const mp_obj_type_t canio_remote_transmission_request_type = { - { &mp_type_type }, - .name = MP_QSTR_RemoteTransmissionRequest, - .make_new = canio_remote_transmission_request_make_new, - .locals_dict = (mp_obj_t)&canio_remote_transmission_request_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + canio_remote_transmission_request_type, + MP_QSTR_RemoteTransmissionRequest, + MP_TYPE_FLAG_NONE, + make_new, canio_remote_transmission_request_make_new, + locals_dict, &canio_remote_transmission_request_locals_dict + ); diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 2b646a83a7..fc7a9ca11d 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -145,9 +145,10 @@ STATIC const mp_rom_map_elem_t countio_counter_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(countio_counter_locals_dict, countio_counter_locals_dict_table); -const mp_obj_type_t countio_counter_type = { - { &mp_type_type }, - .name = MP_QSTR_Counter, - .make_new = countio_counter_make_new, - .locals_dict = (mp_obj_dict_t *)&countio_counter_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + countio_counter_type, + MP_QSTR_Counter, + MP_TYPE_FLAG_NONE, + make_new, countio_counter_make_new, + locals_dict, &countio_counter_locals_dict + ); diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 500c9b7253..07f6bc40a4 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -359,12 +359,13 @@ STATIC const mp_rom_map_elem_t digitalio_digitalinout_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(digitalio_digitalinout_locals_dict, digitalio_digitalinout_locals_dict_table); -const mp_obj_type_t digitalio_digitalinout_type = { - { &mp_type_type }, - .name = MP_QSTR_DigitalInOut, - .make_new = digitalio_digitalinout_make_new, - .locals_dict = (mp_obj_dict_t *)&digitalio_digitalinout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + digitalio_digitalinout_type, + MP_QSTR_DigitalInOut, + MP_TYPE_FLAG_NONE, + make_new, digitalio_digitalinout_make_new, + locals_dict, &digitalio_digitalinout_locals_dict + ); // Helper for validating digitalio.DigitalInOut arguments digitalio_digitalinout_obj_t *assert_digitalinout(mp_obj_t obj) { diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c index 78552e025c..a9cca3441f 100644 --- a/shared-bindings/digitalio/Direction.c +++ b/shared-bindings/digitalio/Direction.c @@ -75,9 +75,10 @@ STATIC void digitalio_direction_print(const mp_print_t *print, mp_obj_t self_in, mp_printf(print, "%q.%q.%q", MP_QSTR_digitalio, MP_QSTR_Direction, direction); } -const mp_obj_type_t digitalio_direction_type = { - { &mp_type_type }, - .name = MP_QSTR_Direction, - .print = digitalio_direction_print, - .locals_dict = (mp_obj_dict_t *)&digitalio_direction_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + digitalio_direction_type, + MP_QSTR_Direction, + MP_TYPE_FLAG_NONE, + print, digitalio_direction_print, + locals_dict, &digitalio_direction_locals_dict + ); diff --git a/shared-bindings/digitalio/DriveMode.c b/shared-bindings/digitalio/DriveMode.c index 1ebf51daea..4a582d8a81 100644 --- a/shared-bindings/digitalio/DriveMode.c +++ b/shared-bindings/digitalio/DriveMode.c @@ -64,9 +64,10 @@ STATIC void digitalio_drive_mode_print(const mp_print_t *print, mp_obj_t self_in mp_printf(print, "%q.%q.%q", MP_QSTR_digitalio, MP_QSTR_DriveMode, drive_mode); } -const mp_obj_type_t digitalio_drive_mode_type = { - { &mp_type_type }, - .name = MP_QSTR_DriveMode, - .print = digitalio_drive_mode_print, - .locals_dict = (mp_obj_dict_t *)&digitalio_drive_mode_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + digitalio_drive_mode_type, + name, MP_QSTR_DriveMode, + MP_TYPE_FLAG_NONE, + print, digitalio_drive_mode_print, + locals_dict, &digitalio_drive_mode_locals_dict + ); diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 5f89c9dc26..58ae4fb529 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -66,12 +66,13 @@ STATIC void digitalio_pull_print(const mp_print_t *print, mp_obj_t self_in, mp_p mp_printf(print, "%q.%q.%q", MP_QSTR_digitalio, MP_QSTR_Pull, pull); } -const mp_obj_type_t digitalio_pull_type = { - { &mp_type_type }, - .name = MP_QSTR_Pull, - .print = digitalio_pull_print, - .locals_dict = (mp_obj_dict_t *)&digitalio_pull_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + digitalio_pull_type, + MP_TYPE_FLAG_NONE, + name, MP_QSTR_Pull, + print, digitalio_pull_print, + locals_dict, &digitalio_pull_locals_dict + ); digitalio_pull_t validate_pull(mp_rom_obj_t obj, qstr arg_name) { if (obj == MP_ROM_PTR(&digitalio_pull_up_obj)) { diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 6b758a4c75..0b8b445a4f 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -286,14 +286,12 @@ STATIC mp_int_t bitmap_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, m return common_hal_displayio_bitmap_get_buffer(self, bufinfo, flags); } -const mp_obj_type_t displayio_bitmap_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Bitmap, - .make_new = displayio_bitmap_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_bitmap_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = bitmap_subscr, - .buffer_p = { .get_buffer = bitmap_get_buffer }, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_bitmap_type, + MP_QSTR_Bitmap, + MP_TYPE_FLAG_NONE, + make_new, displayio_bitmap_make_new, + locals_dict, &displayio_bitmap_locals_dict, + subscr, bitmap_subscr, + buffer, bitmap_get_buffer + ); diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index fe891b38a0..8962a58fa8 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -135,9 +135,10 @@ STATIC const mp_rom_map_elem_t displayio_colorconverter_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_colorconverter_locals_dict, displayio_colorconverter_locals_dict_table); -const mp_obj_type_t displayio_colorconverter_type = { - { &mp_type_type }, - .name = MP_QSTR_ColorConverter, - .make_new = displayio_colorconverter_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_colorconverter_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_colorconverter_type, + MP_QSTR_ColorConverter, + MP_TYPE_FLAG_NONE, + make_new, displayio_colorconverter_make_new, + locals_dict, &displayio_colorconverter_locals_dict + ); diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 9d33081815..8c889e3ba5 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -527,9 +527,10 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); -const mp_obj_type_t displayio_display_type = { - { &mp_type_type }, - .name = MP_QSTR_Display, - .make_new = displayio_display_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_display_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_display_type, + MP_QSTR_Display, + MP_TYPE_FLAG_NONE, + make_new, displayio_display_make_new, + locals_dict, &displayio_display_locals_dict + ); diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 59d394b7fb..4a97592e70 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -428,9 +428,10 @@ STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_epaperdisplay_locals_dict, displayio_epaperdisplay_locals_dict_table); -const mp_obj_type_t displayio_epaperdisplay_type = { - { &mp_type_type }, - .name = MP_QSTR_EPaperDisplay, - .make_new = displayio_epaperdisplay_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_epaperdisplay_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_epaperdisplay_type, + MP_QSTR_EPaperDisplay, + MP_TYPE_FLAG_NONE, + make_new, displayio_epaperdisplay_make_new, + locals_dict, &displayio_epaperdisplay_locals_dict + ); diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index cca473d392..42f7dc352c 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -165,9 +165,10 @@ STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_fourwire_locals_dict, displayio_fourwire_locals_dict_table); -const mp_obj_type_t displayio_fourwire_type = { - { &mp_type_type }, - .name = MP_QSTR_FourWire, - .make_new = displayio_fourwire_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_fourwire_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_fourwire_type, + MP_QSTR_FourWire, + MP_TYPE_FLAG_NONE, + make_new, displayio_fourwire_make_new, + locals_dict, &displayio_fourwire_locals_dict + ); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 1fd3d1f154..de07916bba 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -348,15 +348,13 @@ STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_group_locals_dict, displayio_group_locals_dict_table); -const mp_obj_type_t displayio_group_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Group, - .make_new = displayio_group_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_group_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = group_subscr, - .unary_op = group_unary_op, - .getiter = mp_obj_new_generic_iterator, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_group_type, + MP_QSTR_Group, + MP_TYPE_FLAG_ITER_IS_GETITER, + .make_new, displayio_group_make_new, + locals_dict, &displayio_group_locals_dict, + subscr, group_subscr, + unary_op, group_unary_op, + iter, mp_obj_new_generic_iterator + ); diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index 28c80071e8..3356333688 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -129,9 +129,10 @@ STATIC const mp_rom_map_elem_t displayio_i2cdisplay_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_i2cdisplay_locals_dict, displayio_i2cdisplay_locals_dict_table); -const mp_obj_type_t displayio_i2cdisplay_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CDisplay, - .make_new = displayio_i2cdisplay_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_i2cdisplay_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_i2cdisplay_type, + MP_QSTR_I2CDisplay, + MP_TYPE_FLAG_NONE, + make_new, displayio_i2cdisplay_make_new, + locals_dict, &displayio_i2cdisplay_locals_dict + ); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index f922020650..aace45c44e 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -148,9 +148,10 @@ STATIC const mp_rom_map_elem_t displayio_ondiskbitmap_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_ondiskbitmap_locals_dict, displayio_ondiskbitmap_locals_dict_table); -const mp_obj_type_t displayio_ondiskbitmap_type = { - { &mp_type_type }, - .name = MP_QSTR_OnDiskBitmap, - .make_new = displayio_ondiskbitmap_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_ondiskbitmap_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_ondiskbitmap_type, + MP_QSTR_OnDiskBitmap, + MP_TYPE_FLAG_NONE, + make_new, displayio_ondiskbitmap_make_new, + locals_dict, &displayio_ondiskbitmap_locals_dict + ); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 039af2a730..7c36a2d46b 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -215,15 +215,14 @@ STATIC const mp_rom_map_elem_t displayio_palette_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_palette_locals_dict, displayio_palette_locals_dict_table); -const mp_obj_type_t displayio_palette_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Palette, - .make_new = displayio_palette_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_palette_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = palette_subscr, - .unary_op = group_unary_op, - .getiter = mp_obj_new_generic_iterator, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_palette_type, + MP_QSTR_Palette, + MP_TYPE_FLAG_ITER_IS_GETITER, + make_new, displayio_palette_make_new, + locals_dict, &displayio_palette_locals_dict, + subscr, palette_subscr, + unary_op, group_unary_op, + iter, mp_obj_new_generic_iterator + + ); diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index db35e8e277..767185f6c9 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -93,9 +93,10 @@ STATIC const mp_rom_map_elem_t displayio_shape_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_shape_locals_dict, displayio_shape_locals_dict_table); -const mp_obj_type_t displayio_shape_type = { - { &mp_type_type }, - .name = MP_QSTR_Shape, - .make_new = displayio_shape_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_shape_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_shape_type, + MP_QSTR_Shape, + MP_TYPE_FLAG_NONE, + make_new, displayio_shape_make_new, + locals_dict, &displayio_shape_locals_dict + ); diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index dbade39e51..cbcb04c6db 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -503,13 +503,12 @@ STATIC const mp_rom_map_elem_t displayio_tilegrid_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(displayio_tilegrid_locals_dict, displayio_tilegrid_locals_dict_table); -const mp_obj_type_t displayio_tilegrid_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_TileGrid, - .make_new = displayio_tilegrid_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_tilegrid_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = tilegrid_subscr, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + displayio_tilegrid_type, + MP_TYPE_FLAG_EXTENDED, + MP_TYPE_FLAG_NONE, + name, MP_QSTR_TileGrid, + make_new, displayio_tilegrid_make_new, + locals_dict, &displayio_tilegrid_locals_dict, + .subscr, tilegrid_subscr + ); diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 8e47640730..53d92df995 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -106,8 +106,9 @@ STATIC const mp_rom_map_elem_t fontio_builtinfont_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(fontio_builtinfont_locals_dict, fontio_builtinfont_locals_dict_table); -const mp_obj_type_t fontio_builtinfont_type = { - { &mp_type_type }, - .name = MP_QSTR_BuiltinFont, - .locals_dict = (mp_obj_dict_t *)&fontio_builtinfont_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + fontio_builtinfont_type, + MP_QSTR_BuiltinFont, + MP_TYPE_FLAG_NONE, + locals_dict, &fontio_builtinfont_locals_dict + ); diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 3c0bf4407d..d77e8b55dd 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -369,9 +369,10 @@ STATIC const mp_rom_map_elem_t framebufferio_framebufferdisplay_locals_dict_tabl }; STATIC MP_DEFINE_CONST_DICT(framebufferio_framebufferdisplay_locals_dict, framebufferio_framebufferdisplay_locals_dict_table); -const mp_obj_type_t framebufferio_framebufferdisplay_type = { - { &mp_type_type }, - .name = MP_QSTR_FramebufferDisplay, - .make_new = framebufferio_framebufferdisplay_make_new, - .locals_dict = (mp_obj_dict_t *)&framebufferio_framebufferdisplay_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + framebufferio_framebufferdisplay_type, + MP_QSTR_FramebufferDisplay, + MP_TYPE_FLAG_NONE, + make_new, framebufferio_framebufferdisplay_make_new, + locals_dict, &framebufferio_framebufferdisplay_locals_dict + ); diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 832948d6ae..569361a566 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -217,9 +217,10 @@ STATIC const mp_rom_map_elem_t frequencyio_frequencyin_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(frequencyio_frequencyin_locals_dict, frequencyio_frequencyin_locals_dict_table); -const mp_obj_type_t frequencyio_frequencyin_type = { - { &mp_type_type }, - .name = MP_QSTR_frequencyin, - .make_new = frequencyio_frequencyin_make_new, - .locals_dict = (mp_obj_dict_t *)&frequencyio_frequencyin_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + frequencyio_frequencyin_type, + MP_QSTR_frequencyin, + MP_TYPE_FLAG_NONE, + make_new, frequencyio_frequencyin_make_new, + locals_dict, &frequencyio_frequencyin_locals_dict + ); diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index e28d48bb99..a230478bb7 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -158,9 +158,10 @@ STATIC const mp_rom_map_elem_t gifio_gifwriter_locals_table[] = { STATIC MP_DEFINE_CONST_DICT(gifio_gifwriter_locals, gifio_gifwriter_locals_table); -const mp_obj_type_t gifio_gifwriter_type = { - { &mp_type_type }, - .name = MP_QSTR_GifWriter, - .make_new = gifio_gifwriter_make_new, - .locals_dict = (mp_obj_dict_t *)&gifio_gifwriter_locals, -}; +MP_DEFINE_CONST_OBJ_TYPE( + gifio_gifwriter_type, + MP_QSTR_GifWriter, + MP_TYPE_FLAG_NONE, + make_new, gifio_gifwriter_make_new, + locals_dict, &gifio_gifwriter_locals + ); diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index c36b725202..a7a7b62dae 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -320,9 +320,10 @@ STATIC const mp_rom_map_elem_t gifio_ondiskgif_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(gifio_ondiskgif_locals_dict, gifio_ondiskgif_locals_dict_table); -const mp_obj_type_t gifio_ondiskgif_type = { - { &mp_type_type }, - .name = MP_QSTR_OnDiskGif, - .make_new = gifio_ondiskgif_make_new, - .locals_dict = (mp_obj_dict_t *)&gifio_ondiskgif_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + gifio_ondiskgif_type, + MP_QSTR_OnDiskGif, + MP_TYPE_FLAG_NONE, + make_new, gifio_ondiskgif_make_new, + locals_dict, &gifio_ondiskgif_locals_dict + ); diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index 54b3f0b46c..a3b2f464d9 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -169,9 +169,10 @@ STATIC const mp_rom_map_elem_t gnss_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(gnss_locals_dict, gnss_locals_dict_table); -const mp_obj_type_t gnss_type = { - { &mp_type_type }, - .name = MP_QSTR_GNSS, - .make_new = gnss_make_new, - .locals_dict = (mp_obj_dict_t *)&gnss_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + gnss_type, + MP_QSTR_GNSS, + MP_TYPE_FLAG_NONE, + make_new, gnss_make_new, + locals_dict, &gnss_locals_dict + ); diff --git a/shared-bindings/gnss/PositionFix.c b/shared-bindings/gnss/PositionFix.c index 35d4971b66..d63623eb6a 100644 --- a/shared-bindings/gnss/PositionFix.c +++ b/shared-bindings/gnss/PositionFix.c @@ -71,9 +71,10 @@ STATIC void gnss_positionfix_print(const mp_print_t *print, mp_obj_t self_in, mp mp_printf(print, "%q.%q.%q", MP_QSTR_gnss, MP_QSTR_PositionFix, posfix); } -const mp_obj_type_t gnss_positionfix_type = { - { &mp_type_type }, - .name = MP_QSTR_PositionFix, - .print = gnss_positionfix_print, - .locals_dict = (mp_obj_t)&gnss_positionfix_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + gnss_positionfix_type, + MP_QSTR_PositionFix, + MP_TYPE_FLAG_NONE, + print, gnss_positionfix_print, + locals_dict, &gnss_positionfix_locals_dict + ); diff --git a/shared-bindings/gnss/SatelliteSystem.c b/shared-bindings/gnss/SatelliteSystem.c index 4bf0d6cf4b..c9e71f2c8f 100644 --- a/shared-bindings/gnss/SatelliteSystem.c +++ b/shared-bindings/gnss/SatelliteSystem.c @@ -104,9 +104,10 @@ STATIC void gnss_satellitesystem_print(const mp_print_t *print, mp_obj_t self_in mp_printf(print, "%q.%q.%q", MP_QSTR_gnss, MP_QSTR_SatelliteSystem, system); } -const mp_obj_type_t gnss_satellitesystem_type = { - { &mp_type_type }, - .name = MP_QSTR_SatelliteSystem, - .print = gnss_satellitesystem_print, - .locals_dict = (mp_obj_t)&gnss_satellitesystem_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + gnss_satellitesystem_type, + MP_QSTR_SatelliteSystem, + MP_TYPE_FLAG_NONE, + print, gnss_satellitesystem_print, + locals_dict, &gnss_satellitesystem_locals_dict + ); diff --git a/shared-bindings/hashlib/Hash.c b/shared-bindings/hashlib/Hash.c index e3cbbc39d3..6ab23e1613 100644 --- a/shared-bindings/hashlib/Hash.c +++ b/shared-bindings/hashlib/Hash.c @@ -89,8 +89,9 @@ STATIC const mp_rom_map_elem_t hashlib_hash_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(hashlib_hash_locals_dict, hashlib_hash_locals_dict_table); -const mp_obj_type_t hashlib_hash_type = { - { &mp_type_type }, - .name = MP_QSTR_Hash, - .locals_dict = (mp_obj_dict_t *)&hashlib_hash_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + hashlib_hash_type, + MP_QSTR_Hash, + MP_TYPE_FLAG_NONE, + locals_dict, &hashlib_hash_locals_dict + ); diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index 1bc672032d..c7866813ea 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -416,9 +416,10 @@ STATIC const mp_rom_map_elem_t i2ctarget_i2c_target_request_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(i2ctarget_i2c_target_request_locals_dict, i2ctarget_i2c_target_request_locals_dict_table); -const mp_obj_type_t i2ctarget_i2c_target_request_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CTargetRequest, - .make_new = i2ctarget_i2c_target_request_make_new, - .locals_dict = (mp_obj_dict_t *)&i2ctarget_i2c_target_request_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + i2ctarget_i2c_target_request_type, + MP_QSTR_I2CTargetRequest, + MP_TYPE_FLAG_NONE, + make_new, i2ctarget_i2c_target_request_make_new, + locals_dict, &i2ctarget_i2c_target_request_locals_dict + ); diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index 56d7bfbc48..e79d989712 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -189,9 +189,10 @@ STATIC const mp_rom_map_elem_t imagecapture_parallelimagecapture_locals_dict_tab STATIC MP_DEFINE_CONST_DICT(imagecapture_parallelimagecapture_locals_dict, imagecapture_parallelimagecapture_locals_dict_table); -const mp_obj_type_t imagecapture_parallelimagecapture_type = { - { &mp_type_type }, - .name = MP_QSTR_ParallelImageCapture, - .make_new = imagecapture_parallelimagecapture_make_new, - .locals_dict = (mp_obj_dict_t *)&imagecapture_parallelimagecapture_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + imagecapture_parallelimagecapture_type, + MP_QSTR_ParallelImageCapture, + MP_TYPE_FLAG_NONE, + make_new, imagecapture_parallelimagecapture_make_new, + locals_dict, &imagecapture_parallelimagecapture_locals_dict + ); diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index 4f7cfc3853..13cc165c4d 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -175,15 +175,13 @@ STATIC const mp_rom_map_elem_t ipaddress_ipv4address_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(ipaddress_ipv4address_locals_dict, ipaddress_ipv4address_locals_dict_table); -const mp_obj_type_t ipaddress_ipv4address_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Address, - .make_new = ipaddress_ipv4address_make_new, - .locals_dict = (mp_obj_dict_t *)&ipaddress_ipv4address_locals_dict, - .print = ipaddress_ipv4address_print, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = ipaddress_ipv4address_unary_op, - .binary_op = ipaddress_ipv4address_binary_op, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + ipaddress_ipv4address_type, + MP_QSTR_Address, + MP_TYPE_FLAG_NONE, + make_new, ipaddress_ipv4address_make_new, + locals_dict, &ipaddress_ipv4address_locals_dict, + print, ipaddress_ipv4address_print, + unary_op, ipaddress_ipv4address_unary_op, + binary_op, ipaddress_ipv4address_binary_op + ); diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c index 02a783fd15..a7725ff65e 100644 --- a/shared-bindings/is31fl3741/FrameBuffer.c +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -292,14 +292,12 @@ STATIC mp_int_t is31fl3741_FrameBuffer_get_buffer(mp_obj_t self_in, mp_buffer_in return 0; } -const mp_obj_type_t is31fl3741_FrameBuffer_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_is31fl3741, - .locals_dict = (mp_obj_dict_t *)&is31fl3741_FrameBuffer_locals_dict, - .make_new = is31fl3741_FrameBuffer_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = is31fl3741_FrameBuffer_get_buffer, }, - .protocol = &is31fl3741_FrameBuffer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + is31fl3741_FrameBuffer_type, + MP_QSTR_is31fl3741, + MP_TYPE_FLAG_NONE, + locals_dict, &is31fl3741_FrameBuffer_locals_dict, + make_new, is31fl3741_FrameBuffer_make_new, + buffer, is31fl3741_FrameBuffer_get_buffer, + protocol, &is31fl3741_FrameBuffer_proto + ); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 79982b4c90..6debc82dc5 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -172,9 +172,10 @@ STATIC const mp_rom_map_elem_t is31fl3741_IS31FL3741_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(is31fl3741_IS31FL3741_locals_dict, is31fl3741_IS31FL3741_locals_dict_table); -const mp_obj_type_t is31fl3741_IS31FL3741_type = { - { &mp_type_type }, - .name = MP_QSTR_is31fl3741, - .locals_dict = (mp_obj_dict_t *)&is31fl3741_IS31FL3741_locals_dict, - .make_new = is31fl3741_IS31FL3741_make_new, -}; +MP_DEFINE_CONST_OBJ_TYPE( + is31fl3741_IS31FL3741_type, + MP_QSTR_is31fl3741, + MP_TYPE_FLAG_NONE, + locals_dict, &is31fl3741_IS31FL3741_locals_dict, + make_new, is31fl3741_IS31FL3741_make_new + ); diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 1a3db1c61f..ea6dd0018b 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -180,15 +180,13 @@ STATIC const mp_rom_map_elem_t keypad_event_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(keypad_event_locals_dict, keypad_event_locals_dict_table); -const mp_obj_type_t keypad_event_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Event, - .make_new = keypad_event_make_new, - .print = keypad_event_print, - .locals_dict = (mp_obj_dict_t *)&keypad_event_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = keypad_event_unary_op, - .binary_op = keypad_event_binary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + keypad_event_type, + MP_QSTR_Event, + MP_TYPE_FLAG_NONE, + make_new, keypad_event_make_new, + print, keypad_event_print, + locals_dict, &keypad_event_locals_dict, + unary_op, keypad_event_unary_op, + binary_op, keypad_event_binary_op + ); diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index d09d5db129..596c141b41 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -165,15 +165,13 @@ STATIC const mp_stream_p_t eventqueue_p = { #endif -const mp_obj_type_t keypad_eventqueue_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_EventQueue, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = keypad_eventqueue_unary_op, - #if MICROPY_PY_USELECT - .protocol = &eventqueue_p, - #endif - ), - .locals_dict = (mp_obj_t)&keypad_eventqueue_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + keypad_eventqueue_type, + P_QSTR_EventQueue, + MP_TYPE_FLAG_NONE, + unary_op, keypad_eventqueue_unary_op, + #if MICROPY_PY_USELECT + protocol, &eventqueue_p, + #endif + locals_dict, &keypad_eventqueue_locals_dict + ); diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index 32787f8e9d..b9486e9417 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -235,11 +235,12 @@ STATIC MP_DEFINE_CONST_DICT(keypad_keymatrix_locals_dict, keypad_keymatrix_local #endif -const mp_obj_type_t keypad_keymatrix_type = { - { &mp_type_type }, - .name = MP_QSTR_KeyMatrix, - .make_new = keypad_keymatrix_make_new, +MP_DEFINE_CONST_OBJ_TYPE( + keypad_keymatrix_type, + MP_QSTR_KeyMatrix, + MP_TYPE_FLAG_NONE, + make_new, keypad_keymatrix_make_new #if CIRCUITPY_KEYPAD_KEYMATRIX - .locals_dict = (mp_obj_t)&keypad_keymatrix_locals_dict, + , locals_dict, &keypad_keymatrix_locals_dict #endif -}; + ); diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 63a27425f5..6b9f394a08 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -169,11 +169,12 @@ STATIC const mp_rom_map_elem_t keypad_keys_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(keypad_keys_locals_dict, keypad_keys_locals_dict_table); #endif -const mp_obj_type_t keypad_keys_type = { - { &mp_type_type }, - .name = MP_QSTR_Keys, - .make_new = keypad_keys_make_new, +MP_DEFINE_CONST_OBJ_TYPE( + keypad_keys_type, + MP_QSTR_Keys, + MP_TYPE_FLAG_NONE, + .make_new = keypad_keys_make_new #if CIRCUITPY_KEYPAD_KEYS - .locals_dict = (mp_obj_t)&keypad_keys_locals_dict, + , locals_dict, &keypad_keys_locals_dict #endif -}; + ); diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 83c610236f..7d2861d6b0 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -221,11 +221,12 @@ STATIC const mp_rom_map_elem_t keypad_shiftregisterkeys_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(keypad_shiftregisterkeys_locals_dict, keypad_shiftregisterkeys_locals_dict_table); #endif -const mp_obj_type_t keypad_shiftregisterkeys_type = { - { &mp_type_type }, - .name = MP_QSTR_ShiftRegisterKeys, - .make_new = keypad_shiftregisterkeys_make_new, +MP_DEFINE_CONST_OBJ_TYPE( + keypad_shiftregisterkeys_type, + MP_QSTR_ShiftRegisterKeys, + MP_TYPE_FLAG_NONE, + make_new, keypad_shiftregisterkeys_make_new #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS - .locals_dict = (mp_obj_t)&keypad_shiftregisterkeys_locals_dict, + , locals_dict, &keypad_shiftregisterkeys_locals_dict #endif -}; + ); diff --git a/shared-bindings/mdns/RemoteService.c b/shared-bindings/mdns/RemoteService.c index c1d7b25783..defd055722 100644 --- a/shared-bindings/mdns/RemoteService.c +++ b/shared-bindings/mdns/RemoteService.c @@ -135,8 +135,9 @@ STATIC const mp_rom_map_elem_t mdns_remoteservice_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(mdns_remoteservice_locals_dict, mdns_remoteservice_locals_dict_table); -const mp_obj_type_t mdns_remoteservice_type = { - { &mp_type_type }, - .name = MP_QSTR_RemoteService, - .locals_dict = (mp_obj_dict_t *)&mdns_remoteservice_locals_dict -}; +MP_DEFINE_CONST_OBJ_TYPE( + mdns_remoteservice_type, + MP_QSTR_RemoteService, + MP_TYPE_FLAG_NONE, + locals_dict, &mdns_remoteservice_locals_dict + ); diff --git a/shared-bindings/mdns/Server.c b/shared-bindings/mdns/Server.c index 2afc64e02b..d9afe891e6 100644 --- a/shared-bindings/mdns/Server.c +++ b/shared-bindings/mdns/Server.c @@ -213,9 +213,10 @@ STATIC const mp_rom_map_elem_t mdns_server_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(mdns_server_locals_dict, mdns_server_locals_dict_table); -const mp_obj_type_t mdns_server_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Server, - .make_new = mdns_server_make_new, - .locals_dict = (mp_obj_t)&mdns_server_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mdns_server_type, + MP_QSTR_Server, + MP_TYPE_FLAG_NONE, + make_new, mdns_server_make_new, + locals_dict, &mdns_server_locals_dict + ); diff --git a/shared-bindings/memorymap/AddressRange.c b/shared-bindings/memorymap/AddressRange.c index ea814214b8..85a60f267b 100644 --- a/shared-bindings/memorymap/AddressRange.c +++ b/shared-bindings/memorymap/AddressRange.c @@ -192,14 +192,12 @@ STATIC mp_obj_t memorymap_addressrange_subscr(mp_obj_t self_in, mp_obj_t index_i } } -const mp_obj_type_t memorymap_addressrange_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_AddressRange, - .make_new = memorymap_addressrange_make_new, - .locals_dict = (mp_obj_t)&memorymap_addressrange_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = memorymap_addressrange_subscr, - .unary_op = memorymap_addressrange_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + memorymap_addressrange_type, + MP_QSTR_AddressRange, + MP_TYPE_FLAG_NONE, + make_new, memorymap_addressrange_make_new, + locals_dict, (mp_obj_t)&memorymap_addressrange_locals_dict, + subscr, memorymap_addressrange_subscr, + unary_op, memorymap_addressrange_unary_op + ); diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index 8cf810d3b8..1ba59a0354 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -123,9 +123,10 @@ STATIC const mp_rom_map_elem_t memorymonitor_allocationalarm_locals_dict_table[] }; STATIC MP_DEFINE_CONST_DICT(memorymonitor_allocationalarm_locals_dict, memorymonitor_allocationalarm_locals_dict_table); -const mp_obj_type_t memorymonitor_allocationalarm_type = { - { &mp_type_type }, - .name = MP_QSTR_AllocationAlarm, - .make_new = memorymonitor_allocationalarm_make_new, - .locals_dict = (mp_obj_dict_t *)&memorymonitor_allocationalarm_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + memorymonitor_allocationalarm_type, + MP_QSTR_AllocationAlarm, + MP_TYPE_FLAG_NONE, + make_new, memorymonitor_allocationalarm_make_new, + locals_dict, &memorymonitor_allocationalarm_locals_dict + ); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 9ac0e9617e..53ca66227d 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -1,4 +1,4 @@ -/* +>/* * This file is part of the Micro Python project, http://micropython.org/ * * The MIT License (MIT) @@ -164,12 +164,13 @@ STATIC const mp_rom_map_elem_t memorymonitor_allocationsize_locals_dict_table[] }; STATIC MP_DEFINE_CONST_DICT(memorymonitor_allocationsize_locals_dict, memorymonitor_allocationsize_locals_dict_table); -const mp_obj_type_t memorymonitor_allocationsize_type = { - { &mp_type_type }, - .name = MP_QSTR_AllocationSize, - .make_new = memorymonitor_allocationsize_make_new, - .subscr = memorymonitor_allocationsize_subscr, - .unary_op = memorymonitor_allocationsize_unary_op, - .getiter = mp_obj_new_generic_iterator, - .locals_dict = (mp_obj_dict_t *)&memorymonitor_allocationsize_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + memorymonitor_allocationsize_type, + MP_QSTR_AllocationSize, + MP_TYPE_FLAG_ITER_IS_GETITER, + make_new, memorymonitor_allocationsize_make_new, + subscr, memorymonitor_allocationsize_subscr, + unary_op, memorymonitor_allocationsize_unary_op, + getiter, mp_obj_new_generic_iterator, + locals_dict, &memorymonitor_allocationsize_locals_dict + ); diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index 06aacea8f1..5d33b6a590 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -82,15 +82,13 @@ void shared_bindings_microcontroller_pin_print(const mp_print_t *print, mp_obj_t } } -const mp_obj_type_t mcu_pin_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Pin, - .print = shared_bindings_microcontroller_pin_print, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + mcu_pin_type, + MP_QSTR_Pin, + MP_TYPE_FLAG_NONE, + print, shared_bindings_microcontroller_pin_print, + unary_op, mp_generic_unary_op + ); const mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj, qstr arg_name) { return MP_OBJ_TO_PTR(mp_arg_validate_type(obj, &mcu_pin_type, arg_name)); diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index d57fbc2dd0..80064f75a0 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -170,8 +170,9 @@ STATIC const mp_rom_map_elem_t mcu_processor_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(mcu_processor_locals_dict, mcu_processor_locals_dict_table); -const mp_obj_type_t mcu_processor_type = { - { &mp_type_type }, - .name = MP_QSTR_Processor, - .locals_dict = (mp_obj_dict_t *)&mcu_processor_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mcu_processor_type, + MP_QSTR_Processor, + MP_TYPE_FLAG_NONE, + locals_dict, &mcu_processor_locals_dict + ); diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index b29670576b..e4e8282234 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -92,9 +92,10 @@ STATIC void mcu_runmode_print(const mp_print_t *print, mp_obj_t self_in, mp_prin runmode); } -const mp_obj_type_t mcu_runmode_type = { - { &mp_type_type }, - .name = MP_QSTR_RunMode, - .print = mcu_runmode_print, - .locals_dict = (mp_obj_dict_t *)&mcu_runmode_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mcu_runmode_type, + MP_QSTR_RunMode, + MP_TYPE_FLAG_NONE, + print, mcu_runmode_print, + locals_dict, &mcu_runmode_locals_dict + ); diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 15e30c1575..36b342a594 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -108,9 +108,10 @@ STATIC mp_rom_map_elem_t mod_msgpack_exttype_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(mod_msgpack_exttype_locals_dict, mod_msgpack_exttype_locals_dict_table); -const mp_obj_type_t mod_msgpack_exttype_type = { - { &mp_type_type }, - .name = MP_QSTR_ExtType, - .make_new = mod_msgpack_exttype_make_new, - .locals_dict = (mp_obj_dict_t *)&mod_msgpack_exttype_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mod_msgpack_exttype_type, + MP_QSTR_ExtType, + MP_TYPE_FLAG_NONE, + make_new, mod_msgpack_exttype_make_new, + locals_dict, &mod_msgpack_exttype_locals_dict + ); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 4b74a2a48f..f5b3f83e08 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -158,13 +158,11 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj } } -const mp_obj_type_t nvm_bytearray_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_ByteArray, - .locals_dict = (mp_obj_t)&nvm_bytearray_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = nvm_bytearray_subscr, - .unary_op = nvm_bytearray_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + nvm_bytearray_type, + MP_QSTR_ByteArray, + MP_TYPE_FLAG_NONE, + locals_dict, &nvm_bytearray_locals_dict, + subscr, nvm_bytearray_subscr, + unary_op, nvm_bytearray_unary_op + ); diff --git a/shared-bindings/onewireio/OneWire.c b/shared-bindings/onewireio/OneWire.c index f52ebb4c6a..88b9111bf2 100644 --- a/shared-bindings/onewireio/OneWire.c +++ b/shared-bindings/onewireio/OneWire.c @@ -152,9 +152,10 @@ STATIC const mp_rom_map_elem_t onewireio_onewire_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(onewireio_onewire_locals_dict, onewireio_onewire_locals_dict_table); -const mp_obj_type_t onewireio_onewire_type = { - { &mp_type_type }, - .name = MP_QSTR_OneWire, - .make_new = onewireio_onewire_make_new, - .locals_dict = (mp_obj_dict_t *)&onewireio_onewire_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + onewireio_onewire_type, + MP_QSTR_OneWire, + MP_TYPE_FLAG_NONE, + make_new, onewireio_onewire_make_new, + locals_dict, &onewireio_onewire_locals_dict + ); diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index be75e57018..890c06c60a 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -157,9 +157,10 @@ STATIC const mp_rom_map_elem_t paralleldisplay_parallelbus_locals_dict_table[] = }; STATIC MP_DEFINE_CONST_DICT(paralleldisplay_parallelbus_locals_dict, paralleldisplay_parallelbus_locals_dict_table); -const mp_obj_type_t paralleldisplay_parallelbus_type = { - { &mp_type_type }, - .name = MP_QSTR_ParallelBus, - .make_new = paralleldisplay_parallelbus_make_new, - .locals_dict = (mp_obj_dict_t *)¶lleldisplay_parallelbus_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + paralleldisplay_parallelbus_type, + MP_QSTR_ParallelBus, + MP_TYPE_FLAG_NONE, + make_new, paralleldisplay_parallelbus_make_new, + locals_dict, ¶lleldisplay_parallelbus_locals_dict + ); diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 3f5c1d6f00..076cb4ca73 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -225,13 +225,11 @@ STATIC const mp_rom_map_elem_t ps2io_ps2_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(ps2io_ps2_locals_dict, ps2io_ps2_locals_dict_table); -const mp_obj_type_t ps2io_ps2_type = { - { &mp_type_type }, - .name = MP_QSTR_Ps2, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = ps2io_ps2_make_new, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = ps2_unary_op, - ), - .locals_dict = (mp_obj_dict_t *)&ps2io_ps2_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + ps2io_ps2_type, + MP_QSTR_Ps2, + MP_TYPE_FLAG_NONE, + make_new, ps2io_ps2_make_new, + unary_op, ps2_unary_op, + locals_dict, &ps2io_ps2_locals_dict + ); diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 444b2a770f..f26edfea2c 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -289,14 +289,12 @@ STATIC const mp_rom_map_elem_t pulseio_pulsein_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(pulseio_pulsein_locals_dict, pulseio_pulsein_locals_dict_table); -const mp_obj_type_t pulseio_pulsein_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_PulseIn, - .make_new = pulseio_pulsein_make_new, - .locals_dict = (mp_obj_dict_t *)&pulseio_pulsein_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .subscr = pulsein_subscr, - .unary_op = pulsein_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + pulseio_pulsein_type, + MP_QSTR_PulseIn, + MP_TYPE_FLAG_NONE, + make_new, pulseio_pulsein_make_new, + locals_dict, &pulseio_pulsein_locals_dict, + subscr, pulsein_subscr, + unary_op, pulsein_unary_op + ); diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index e9084bf4ba..13188c0d14 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -147,9 +147,9 @@ STATIC const mp_rom_map_elem_t pulseio_pulseout_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(pulseio_pulseout_locals_dict, pulseio_pulseout_locals_dict_table); -const mp_obj_type_t pulseio_pulseout_type = { - { &mp_type_type }, - .name = MP_QSTR_PulseOut, - .make_new = pulseio_pulseout_make_new, - .locals_dict = (mp_obj_dict_t *)&pulseio_pulseout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + MP_QSTR_PulseOut, + MP_TYPE_FLAG_NONE, + make_new, pulseio_pulseout_make_new, + locals_dict, &pulseio_pulseout_locals_dict + ); diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 83a0f4ad1c..94bf34b8ee 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -298,9 +298,10 @@ STATIC const mp_rom_map_elem_t pwmio_pwmout_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(pwmio_pwmout_locals_dict, pwmio_pwmout_locals_dict_table); -const mp_obj_type_t pwmio_pwmout_type = { - { &mp_type_type }, - .name = MP_QSTR_PWMOut, - .make_new = pwmio_pwmout_make_new, - .locals_dict = (mp_obj_dict_t *)&pwmio_pwmout_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + pwmio_pwmout_type, + MP_QSTR_PWMOut, + MP_TYPE_FLAG_NONE, + .make_new, pwmio_pwmout_make_new, + locals_dict, &pwmio_pwmout_locals_dict + ); diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index e8cabade33..a2c8ea7ee8 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -139,9 +139,10 @@ STATIC const mp_rom_map_elem_t qrio_qrdecoder_locals_table[] = { STATIC MP_DEFINE_CONST_DICT(qrio_qrdecoder_locals, qrio_qrdecoder_locals_table); -const mp_obj_type_t qrio_qrdecoder_type_obj = { - { &mp_type_type }, - .name = MP_QSTR_QRDecoder, - .make_new = qrio_qrdecoder_make_new, - .locals_dict = (mp_obj_dict_t *)&qrio_qrdecoder_locals, -}; +MP_DEFINE_CONST_OBJ_TYPE( + qrio_qrdecoder_type_obj, + MP_QSTR_QRDecoder, + MP_TYPE_FLAG_NONE, + make_new, qrio_qrdecoder_make_new, + locals_dict, &qrio_qrdecoder_locals + ); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 0f5cc91fc7..6ea601f1e0 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -421,14 +421,12 @@ STATIC mp_int_t rgbmatrix_rgbmatrix_get_buffer(mp_obj_t self_in, mp_buffer_info_ return 0; } -const mp_obj_type_t rgbmatrix_RGBMatrix_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_RGBMatrix, - .locals_dict = (mp_obj_dict_t *)&rgbmatrix_rgbmatrix_locals_dict, - .make_new = rgbmatrix_rgbmatrix_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = rgbmatrix_rgbmatrix_get_buffer, }, - .protocol = &rgbmatrix_rgbmatrix_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + rgbmatrix_RGBMatrix_type, + MP_QSTR_RGBMatrix, + MP_TYPE_FLAG_NONE, + locals_dict, &rgbmatrix_rgbmatrix_locals_dict, + make_new, rgbmatrix_rgbmatrix_make_new, + buffer, rgbmatrix_rgbmatrix_get_buffer, + protocol = &rgbmatrix_rgbmatrix_proto + ); diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 24df2b2d15..3abfa8db1a 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -178,9 +178,10 @@ STATIC const mp_rom_map_elem_t rotaryio_incrementalencoder_locals_dict_table[] = }; STATIC MP_DEFINE_CONST_DICT(rotaryio_incrementalencoder_locals_dict, rotaryio_incrementalencoder_locals_dict_table); -const mp_obj_type_t rotaryio_incrementalencoder_type = { - { &mp_type_type }, - .name = MP_QSTR_IncrementalEncoder, - .make_new = rotaryio_incrementalencoder_make_new, - .locals_dict = (mp_obj_dict_t *)&rotaryio_incrementalencoder_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + rotaryio_incrementalencoder_type, + MP_QSTR_IncrementalEncoder, + MP_TYPE_FLAG_NONE, + make_new, rotaryio_incrementalencoder_make_new, + locals_dict, &rotaryio_incrementalencoder_locals_dict + ); diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index ea323306f7..114055833d 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -125,9 +125,10 @@ STATIC const mp_rom_map_elem_t rtc_rtc_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(rtc_rtc_locals_dict, rtc_rtc_locals_dict_table); -const mp_obj_type_t rtc_rtc_type = { - { &mp_type_type }, - .name = MP_QSTR_RTC, - .make_new = rtc_rtc_make_new, - .locals_dict = (mp_obj_dict_t *)&rtc_rtc_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + rtc_rtc_type, + MP_QSTR_RTC, + MP_TYPE_FLAG_NONE, + make_new, rtc_rtc_make_new, + locals_dict, &rtc_rtc_locals_dict + ); diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index 4bceefba45..94ea3ab321 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -194,9 +194,10 @@ STATIC const mp_rom_map_elem_t sdcardio_sdcard_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(sdcardio_sdcard_locals_dict, sdcardio_sdcard_locals_dict_table); -const mp_obj_type_t sdcardio_SDCard_type = { - { &mp_type_type }, - .name = MP_QSTR_SDCard, - .make_new = sdcardio_sdcard_make_new, - .locals_dict = (mp_obj_dict_t *)&sdcardio_sdcard_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + sdcardio_SDCard_type, + MP_QSTR_SDCard, + MP_TYPE_FLAG_NONE, + make_new, sdcardio_sdcard_make_new, + locals_dict, &sdcardio_sdcard_locals_dict + ); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index 80a82a3ed3..7c0d391957 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -267,9 +267,10 @@ STATIC const mp_rom_map_elem_t sdioio_sdcard_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(sdioio_sdcard_locals_dict, sdioio_sdcard_locals_dict_table); -const mp_obj_type_t sdioio_SDCard_type = { - { &mp_type_type }, - .name = MP_QSTR_SDCard, - .make_new = sdioio_sdcard_make_new, - .locals_dict = (mp_obj_dict_t *)&sdioio_sdcard_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + sdioio_SDCard_type, + MP_QSTR_SDCard, + MP_TYPE_FLAG_NONE, + make_new, sdioio_sdcard_make_new, + locals_dict, &sdioio_sdcard_locals_dict + ); diff --git a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c index d9643495ba..58a4113693 100644 --- a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c @@ -116,14 +116,12 @@ STATIC const mp_rom_map_elem_t sharpdisplay_framebuffer_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(sharpdisplay_framebuffer_locals_dict, sharpdisplay_framebuffer_locals_dict_table); -const mp_obj_type_t sharpdisplay_framebuffer_type = { - { &mp_type_type }, - .name = MP_QSTR_SharpMemoryFramebuffer, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = sharpdisplay_framebuffer_make_new, - .locals_dict = (mp_obj_dict_t *)&sharpdisplay_framebuffer_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = sharpdisplay_framebuffer_get_buffer, }, - .protocol = &sharpdisplay_framebuffer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + sharpdisplay_framebuffer_type, + MP_QSTR_SharpMemoryFramebuffer, + MP_TYPE_FLAG_NONE, + make_new, sharpdisplay_framebuffer_make_new, + locals_dict, &sharpdisplay_framebuffer_locals_dict, + buffer, sharpdisplay_framebuffer_get_buffer, + protocol, &sharpdisplay_framebuffer_proto + ); diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 9d439b5bd4..f4a811913a 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -447,13 +447,11 @@ STATIC const mp_stream_p_t socket_stream_p = { .is_text = false, }; -const mp_obj_type_t socketpool_socket_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Socket, - .locals_dict = (mp_obj_dict_t *)&socketpool_socket_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - .protocol = &socket_stream_p, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + socketpool_socket_type, + MP_QSTR_Socket, + MP_TYPE_FLAG_NONE, + locals_dict, &socketpool_socket_locals_dict, + unary_op, mp_generic_unary_op, + protocol, &socket_stream_p + ); diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 3023721378..884a241d39 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -188,12 +188,13 @@ STATIC const mp_rom_map_elem_t socketpool_socketpool_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(socketpool_socketpool_locals_dict, socketpool_socketpool_locals_dict_table); -const mp_obj_type_t socketpool_socketpool_type = { - { &mp_type_type }, - .name = MP_QSTR_SocketPool, - .make_new = socketpool_socketpool_make_new, - .locals_dict = (mp_obj_dict_t *)&socketpool_socketpool_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + socketpool_socketpool_type, + MP_QSTR_SocketPool, + MP_TYPE_FLAG_NONE, + make_new, socketpool_socketpool_make_new, + locals_dict, &socketpool_socketpool_locals_dict + ); MP_WEAK mp_obj_t common_hal_socketpool_socketpool_gethostbyname_raise(socketpool_socketpool_obj_t *self, const char *host) { diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 5fc4238f75..317c806ea5 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -198,9 +198,10 @@ STATIC const mp_rom_map_elem_t ssl_sslcontext_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(ssl_sslcontext_locals_dict, ssl_sslcontext_locals_dict_table); -const mp_obj_type_t ssl_sslcontext_type = { - { &mp_type_type }, - .name = MP_QSTR_SSLContext, - .make_new = ssl_sslcontext_make_new, - .locals_dict = (mp_obj_dict_t *)&ssl_sslcontext_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + ssl_sslcontext_type, + MP_QSTR_SSLContext, + MP_TYPE_FLAG_NONE, + make_new, ssl_sslcontext_make_new, + locals_dict, &ssl_sslcontext_locals_dict + ); diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index e0e7911715..f2a8d8ade6 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -297,12 +297,11 @@ STATIC const mp_rom_map_elem_t ssl_sslsocket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(ssl_sslsocket_locals_dict, ssl_sslsocket_locals_dict_table); -const mp_obj_type_t ssl_sslsocket_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_SSLSocket, - .locals_dict = (mp_obj_dict_t *)&ssl_sslsocket_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + ssl_sslsocket_type, + MP_QSTR_SSLSocket, + MP_TYPE_FLAG_NONE, + locals_dict, &ssl_sslsocket_locals_dict, + unary_op, mp_generic_unary_op + + ); diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 792f18637a..672b59f076 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -251,8 +251,9 @@ STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(supervisor_runtime_locals_dict, supervisor_runtime_locals_dict_table); -const mp_obj_type_t supervisor_runtime_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Runtime, - .locals_dict = (mp_obj_dict_t *)&supervisor_runtime_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + supervisor_runtime_type, + MP_QSTR_Runtime, + MP_TYPE_FLAG_NONE, + locals_dict, &supervisor_runtime_locals_dict + ); diff --git a/shared-bindings/supervisor/StatusBar.c b/shared-bindings/supervisor/StatusBar.c index 8db1906f5e..4438c5fa4d 100644 --- a/shared-bindings/supervisor/StatusBar.c +++ b/shared-bindings/supervisor/StatusBar.c @@ -118,8 +118,9 @@ STATIC const mp_rom_map_elem_t supervisor_status_bar_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(supervisor_status_bar_locals_dict, supervisor_status_bar_locals_dict_table); -const mp_obj_type_t supervisor_status_bar_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Status_Bar, - .locals_dict = (mp_obj_dict_t *)&supervisor_status_bar_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + supervisor_status_bar_type, + MP_QSTR_Status_Bar, + MP_TYPE_FLAG_NONE, + locals_dict, &supervisor_status_bar_locals_dict + ); diff --git a/shared-bindings/synthio/LFO.c b/shared-bindings/synthio/LFO.c index 86e32999cf..6d56da910a 100644 --- a/shared-bindings/synthio/LFO.c +++ b/shared-bindings/synthio/LFO.c @@ -291,14 +291,12 @@ STATIC const synthio_block_proto_t lfo_proto = { .tick = common_hal_synthio_lfo_tick, }; -const mp_obj_type_t synthio_lfo_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_LFO, - .make_new = synthio_lfo_make_new, - .locals_dict = (mp_obj_dict_t *)&synthio_lfo_locals_dict, - .print = lfo_print, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &lfo_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + synthio_lfo_type, + MP_QSTR_LFO, + MP_TYPE_FLAG_NONE, + make_new, synthio_lfo_make_new, + locals_dict, &synthio_lfo_locals_dict, + print, lfo_print, + protocol, &lfo_proto + ); diff --git a/shared-bindings/synthio/Math.c b/shared-bindings/synthio/Math.c index ea75b7c4bf..8ae92cbb94 100644 --- a/shared-bindings/synthio/Math.c +++ b/shared-bindings/synthio/Math.c @@ -293,14 +293,12 @@ STATIC const synthio_block_proto_t math_proto = { .tick = common_hal_synthio_math_tick, }; -const mp_obj_type_t synthio_math_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Math, - .make_new = synthio_math_make_new, - .locals_dict = (mp_obj_dict_t *)&synthio_math_locals_dict, - .print = math_print, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &math_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + synthio_math_type, + MP_QSTR_Math, + MP_TYPE_FLAG_NONE, + make_new, synthio_math_make_new, + locals_dict, &synthio_math_locals_dict, + print, math_print, + protocol, &math_proto + ); diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index c7863e1cb2..1c385c0229 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -185,13 +185,12 @@ STATIC const audiosample_p_t synthio_miditrack_proto = { .get_buffer_structure = (audiosample_get_buffer_structure_fun)synthio_miditrack_get_buffer_structure, }; -const mp_obj_type_t synthio_miditrack_type = { - { &mp_type_type }, - .name = MP_QSTR_MidiTrack, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = synthio_miditrack_make_new, - .locals_dict = (mp_obj_dict_t *)&synthio_miditrack_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &synthio_miditrack_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + synthio_miditrack_type, + MP_QSTR_MidiTrack, + MP_TYPE_FLAG_NONE, + flags, MP_TYPE_FLAG_EXTENDED, + make_new, synthio_miditrack_make_new, + locals_dict, &synthio_miditrack_locals_dict, + protocol, &synthio_miditrack_proto + ); diff --git a/shared-bindings/synthio/Note.c b/shared-bindings/synthio/Note.c index a1d0effbed..a1aee54c54 100644 --- a/shared-bindings/synthio/Note.c +++ b/shared-bindings/synthio/Note.c @@ -317,10 +317,11 @@ STATIC const mp_rom_map_elem_t synthio_note_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(synthio_note_locals_dict, synthio_note_locals_dict_table); -const mp_obj_type_t synthio_note_type = { - { &mp_type_type }, - .name = MP_QSTR_Note, - .make_new = synthio_note_make_new, - .locals_dict = (mp_obj_dict_t *)&synthio_note_locals_dict, - .print = note_print, -}; +MP_DEFINE_CONST_OBJ_TYPE( + synthio_note_type, + MP_QSTR_Note, + MP_TYPE_FLAG_NONE, + make_new, synthio_note_make_new, + locals_dict, &synthio_note_locals_dict, + print, note_print + ); diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c index db1d6312f7..ef7eb1f1bc 100644 --- a/shared-bindings/synthio/Synthesizer.c +++ b/shared-bindings/synthio/Synthesizer.c @@ -450,13 +450,11 @@ STATIC const audiosample_p_t synthio_synthesizer_proto = { .get_buffer_structure = (audiosample_get_buffer_structure_fun)synthio_synthesizer_get_buffer_structure, }; -const mp_obj_type_t synthio_synthesizer_type = { - { &mp_type_type }, - .name = MP_QSTR_Synthesizer, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = synthio_synthesizer_make_new, - .locals_dict = (mp_obj_dict_t *)&synthio_synthesizer_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &synthio_synthesizer_proto, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + synthio_synthesizer_type, + MP_QSTR_Synthesizer, + MP_TYPE_FLAG_NONE, + make_new, synthio_synthesizer_make_new, + locals_dict, &synthio_synthesizer_locals_dict, + protocol, &synthio_synthesizer_proto + ); diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index fb2a8283c7..50f4264b24 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -139,15 +139,13 @@ STATIC const mp_stream_p_t terminalio_terminal_stream_p = { .is_text = true, }; -const mp_obj_type_t terminalio_terminal_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_Terminal, - .make_new = terminalio_terminal_make_new, - .locals_dict = (mp_obj_dict_t *)&terminalio_terminal_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &terminalio_terminal_stream_p, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + terminalio_terminal_type, + MP_QSTR_Terminal, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + make_new, terminalio_terminal_make_new, + locals_dict, (mp_obj_dict_t *)&terminalio_terminal_locals_dict, + getiter, mp_identity_getiter, + iternext, mp_stream_unbuffered_iter, + protocol, &terminalio_terminal_stream_p + ); diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 100b22c03d..a5a2593630 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -181,9 +181,10 @@ STATIC const mp_rom_map_elem_t touchio_touchin_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(touchio_touchin_locals_dict, touchio_touchin_locals_dict_table); -const mp_obj_type_t touchio_touchin_type = { - { &mp_type_type }, - .name = MP_QSTR_TouchIn, - .make_new = touchio_touchin_make_new, - .locals_dict = (mp_obj_t)&touchio_touchin_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + touchio_touchin_type, + MP_QSTR_TouchIn, + MP_TYPE_FLAG_NONE, + make_new, touchio_touchin_make_new, + locals_dict, &touchio_touchin_locals_dict + ); diff --git a/shared-bindings/usb/core/Device.c b/shared-bindings/usb/core/Device.c index d700ccef86..120bbefd45 100644 --- a/shared-bindings/usb/core/Device.c +++ b/shared-bindings/usb/core/Device.c @@ -331,8 +331,9 @@ STATIC const mp_rom_map_elem_t usb_core_device_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usb_core_device_locals_dict, usb_core_device_locals_dict_table); -const mp_obj_type_t usb_core_device_type = { - { &mp_type_type }, - .name = MP_QSTR_Device, - .locals_dict = (mp_obj_t)&usb_core_device_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_core_device_type, + MP_QSTR_Device, + MP_TYPE_FLAG_NONE, + locals_dict, &usb_core_device_locals_dict + ); diff --git a/shared-bindings/usb/core/__init__.c b/shared-bindings/usb/core/__init__.c index ab7e0a2020..03609a5a3c 100644 --- a/shared-bindings/usb/core/__init__.c +++ b/shared-bindings/usb/core/__init__.c @@ -126,15 +126,13 @@ STATIC mp_obj_t usb_core_devices_iternext(mp_obj_t self_in) { return MP_OBJ_STOP_ITERATION; } -const mp_obj_type_t usb_core_devices_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_USBDevices, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = usb_core_devices_iternext, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_core_devices_type, + MP_QSTR_USBDevices, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + getiter, mp_identity_getiter, + iternext, usb_core_devices_iternext + ); STATIC mp_obj_t usb_core_find(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_find_all, ARG_idVendor, ARG_idProduct }; diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index f7da2a8881..7d9fd251ce 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -277,14 +277,12 @@ STATIC const mp_stream_p_t usb_cdc_serial_stream_p = { .pyserial_dont_return_none_compatibility = true, }; -const mp_obj_type_t usb_cdc_serial_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, +MP_DEFINE_CONST_OBJ_TYPE( + usb_cdc_serial_type, .name = MP_QSTR_Serial, - .locals_dict = (mp_obj_dict_t *)&usb_cdc_serial_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &usb_cdc_serial_stream_p, - ), -}; + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + locals_dict, &usb_cdc_serial_locals_dict, + getiter, mp_identity_getiter, + iter, mp_stream_unbuffered_iter, + protocol, &usb_cdc_serial_stream_p + ); diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index d998788fd4..efd0d15a6e 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -263,9 +263,10 @@ STATIC const mp_rom_map_elem_t usb_hid_device_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usb_hid_device_locals_dict, usb_hid_device_locals_dict_table); -const mp_obj_type_t usb_hid_device_type = { - { &mp_type_type }, - .name = MP_QSTR_Device, - .make_new = usb_hid_device_make_new, - .locals_dict = (mp_obj_t)&usb_hid_device_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_hid_device_type, + MP_QSTR_Device, + MP_TYPE_FLAG_NONE, + make_new, usb_hid_device_make_new, + locals_dict, &usb_hid_device_locals_dict + ); diff --git a/shared-bindings/usb_host/Port.c b/shared-bindings/usb_host/Port.c index 9be6da9df3..afe1d6daa8 100644 --- a/shared-bindings/usb_host/Port.c +++ b/shared-bindings/usb_host/Port.c @@ -69,9 +69,9 @@ STATIC const mp_rom_map_elem_t usb_host_port_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usb_host_port_locals_dict, usb_host_port_locals_dict_table); -const mp_obj_type_t usb_host_port_type = { - { &mp_type_type }, - .name = MP_QSTR_Port, - .make_new = usb_host_port_make_new, - .locals_dict = (mp_obj_t)&usb_host_port_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_host_port_type, + MP_QSTR_Port, + make_new, usb_host_port_make_new, + locals_dict, &usb_host_port_locals_dict + ); diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index 6510063e2f..8bc238a43e 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -108,14 +108,11 @@ STATIC const mp_stream_p_t usb_midi_portin_stream_p = { .is_text = false, }; -const mp_obj_type_t usb_midi_portin_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_PortIn, - .locals_dict = (mp_obj_dict_t *)&usb_midi_portin_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &usb_midi_portin_stream_p, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_midi_portin_type, + MP_QSTR_PortIn, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + locals_dict, &usb_midi_portin_locals_dict, + iter, mp_stream_unbuffered_iter, + protocol, &usb_midi_portin_stream_p + ); diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index 1ba1466e0f..2d2c2fa281 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -90,14 +90,12 @@ STATIC const mp_stream_p_t usb_midi_portout_stream_p = { .is_text = false, }; -const mp_obj_type_t usb_midi_portout_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_PortOut, - .locals_dict = (mp_obj_dict_t *)&usb_midi_portout_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &usb_midi_portout_stream_p, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + usb_midi_portout_type, + MP_QSTR_PortOut, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + locals_dict, &usb_midi_portout_locals_dict, + getiter, mp_identity_getiter, + iternext, mp_stream_unbuffered_iter, + protocol, &usb_midi_portout_stream_p + ); diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 1334492317..4dc3058e74 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -132,13 +132,11 @@ STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(vectorio_circle_locals_dict, vectorio_circle_locals_dict_table); -const mp_obj_type_t vectorio_circle_type = { - { &mp_type_type }, - .name = MP_QSTR_Circle, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = vectorio_circle_make_new, - .locals_dict = (mp_obj_dict_t *)&vectorio_circle_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &circle_draw_protocol, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + vectorio_circle_type, + MP_QSTR_Circle, + MP_TYPE_FLAG_NONE, + make_new, vectorio_circle_make_new, + locals_dict, &vectorio_circle_locals_dict, + protocol, &circle_draw_protocol + ); diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index e4b0f43afe..251e113d9f 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -141,13 +141,11 @@ STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(vectorio_polygon_locals_dict, vectorio_polygon_locals_dict_table); -const mp_obj_type_t vectorio_polygon_type = { - { &mp_type_type }, - .name = MP_QSTR_Polygon, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = vectorio_polygon_make_new, - .locals_dict = (mp_obj_dict_t *)&vectorio_polygon_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &polygon_draw_protocol, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + vectorio_polygon_type, + MP_QSTR_Polygon, + MP_TYPE_FLAG_NONE, + make_new, vectorio_polygon_make_new, + locals_dict, &vectorio_polygon_locals_dict, + protocol, &polygon_draw_protocol + ); diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 89e9be7d53..35e207559f 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -163,13 +163,11 @@ STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(vectorio_rectangle_locals_dict, vectorio_rectangle_locals_dict_table); -const mp_obj_type_t vectorio_rectangle_type = { - { &mp_type_type }, - .name = MP_QSTR_Rectangle, - .flags = MP_TYPE_FLAG_EXTENDED, - .make_new = vectorio_rectangle_make_new, - .locals_dict = (mp_obj_dict_t *)&vectorio_rectangle_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .protocol = &rectangle_draw_protocol, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + vectorio_rectangle_type, + MP_QSTR_Rectangle, + MP_TYPE_FLAG_NONE, + make_new, vectorio_rectangle_make_new, + locals_dict, &vectorio_rectangle_locals_dict, + protocol, &rectangle_draw_protocol + ); diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 0adc386a07..fb91f487b3 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -241,8 +241,9 @@ STATIC const mp_rom_map_elem_t vectorio_vector_shape_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(vectorio_vector_shape_locals_dict, vectorio_vector_shape_locals_dict_table); -const mp_obj_type_t vectorio_vector_shape_type = { - { &mp_type_type }, - .name = MP_QSTR_VectorShape, - .locals_dict = (mp_obj_dict_t *)&vectorio_vector_shape_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + vectorio_vector_shape_type, + MP_QSTR_VectorShape, + MP_TYPE_FLAG_NONE, + locals_dict = &vectorio_vector_shape_locals_dict + ); diff --git a/shared-bindings/watchdog/WatchDogMode.c b/shared-bindings/watchdog/WatchDogMode.c index c707054d27..b1ff617a09 100644 --- a/shared-bindings/watchdog/WatchDogMode.c +++ b/shared-bindings/watchdog/WatchDogMode.c @@ -91,9 +91,10 @@ STATIC void watchdog_watchdogmode_print(const mp_print_t *print, mp_obj_t self_i runmode); } -const mp_obj_type_t watchdog_watchdogmode_type = { - { &mp_type_type }, - .name = MP_QSTR_WatchDogMode, - .print = watchdog_watchdogmode_print, - .locals_dict = (mp_obj_t)&watchdog_watchdogmode_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + watchdog_watchdogmode_type, + MP_QSTR_WatchDogMode, + MP_TYPE_FLAG_NONE, + print, watchdog_watchdogmode_print, + locals_dict, &watchdog_watchdogmode_locals_dict + ); diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index acfd353c34..3526f818c0 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -159,9 +159,9 @@ STATIC const mp_rom_map_elem_t watchdog_watchdogtimer_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(watchdog_watchdogtimer_locals_dict, watchdog_watchdogtimer_locals_dict_table); -const mp_obj_type_t watchdog_watchdogtimer_type = { - { &mp_type_type }, - .name = MP_QSTR_WatchDogTimer, - // .make_new = watchdog_watchdogtimer_make_new, - .locals_dict = (mp_obj_dict_t *)&watchdog_watchdogtimer_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + watchdog_watchdogtimer_type, + MP_QSTR_WatchDogTimer, + MP_TYPE_FLAG_NONE, + locals_dict, &watchdog_watchdogtimer_locals_dict + ); diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c index 70aaddc8a5..da7fb23868 100644 --- a/shared-bindings/watchdog/__init__.c +++ b/shared-bindings/watchdog/__init__.c @@ -79,13 +79,14 @@ //| """ //| -const mp_obj_type_t mp_type_WatchDogTimeout = { - { &mp_type_type }, - .name = MP_QSTR_WatchDogTimeout, - .make_new = mp_obj_exception_make_new, - .attr = mp_obj_exception_attr, - .parent = &mp_type_Exception, -}; +MP_DEFINE_CONST_OBJ_TYPE( + mp_type_WatchDogTimeout, + MP_QSTR_WatchDogTimeout, + MP_TYPE_FLAG_NONE, + make_new, mp_obj_exception_make_new, + attr, mp_obj_exception_attr, + parent, &mp_type_Exception + ); mp_obj_exception_t mp_watchdog_timeout_exception = { .base.type = &mp_type_WatchDogTimeout, diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index acbc63ec89..02a3ae5e0e 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -1,4 +1,4 @@ -/* +1/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) @@ -151,9 +151,10 @@ STATIC const mp_rom_map_elem_t wifi_monitor_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(wifi_monitor_locals_dict, wifi_monitor_locals_dict_table); -const mp_obj_type_t wifi_monitor_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Monitor, - .make_new = wifi_monitor_make_new, - .locals_dict = (mp_obj_t)&wifi_monitor_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + wifi_monitor_type, + MP_QSTR_Monitor, + MP_TYPE_FLAG_NONE, + make_new, wifi_monitor_make_new, + locals_dict, &wifi_monitor_locals_dict + ); diff --git a/shared-bindings/wifi/Network.c b/shared-bindings/wifi/Network.c index 387b1f587d..d262b392eb 100644 --- a/shared-bindings/wifi/Network.c +++ b/shared-bindings/wifi/Network.c @@ -119,8 +119,9 @@ STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_table); -const mp_obj_type_t wifi_network_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Network, - .locals_dict = (mp_obj_t)&wifi_network_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + wifi_network_type, + MP_QSTR_Network, + MP_TYPE_FLAG_NONE, + locals_dict, &wifi_network_locals_dict + ); diff --git a/shared-bindings/wifi/Packet.c b/shared-bindings/wifi/Packet.c index d21c8b0639..1a5056aaf6 100644 --- a/shared-bindings/wifi/Packet.c +++ b/shared-bindings/wifi/Packet.c @@ -58,13 +58,11 @@ STATIC MP_DEFINE_CONST_DICT(wifi_packet_locals_dict, wifi_packet_locals_table); MAKE_PRINTER(wifi, wifi_packet); -const mp_obj_type_t wifi_packet_type = { - { &mp_type_type }, - .name = MP_QSTR_Packet, - .print = wifi_packet_print, - .locals_dict = (mp_obj_t)&wifi_packet_locals_dict, - .flags = MP_TYPE_FLAG_EXTENDED, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = mp_generic_unary_op, - ), -}; +MP_DEFINE_CONST_OBJ_TYPE( + wifi_packet_type, + MP_QSTR_Packet, + MP_TYPE_FLAG_NONE, + print, wifi_packet_print, + locals_dict, &wifi_packet_locals_dict, + unary_op, mp_generic_unary_op + ); diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 495e7fd13b..0b27c7cba9 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -776,8 +776,9 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(wifi_radio_locals_dict, wifi_radio_locals_dict_table); -const mp_obj_type_t wifi_radio_type = { - .base = { &mp_type_type }, - .name = MP_QSTR_Radio, - .locals_dict = (mp_obj_t)&wifi_radio_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + wifi_radio_type, + MP_QSTR_Radio, + MP_TYPE_FLAG_NONE, + locals_dict, &wifi_radio_locals_dict + ); diff --git a/shared-bindings/wifi/ScannedNetworks.c b/shared-bindings/wifi/ScannedNetworks.c index a893213719..82e8a53b22 100644 --- a/shared-bindings/wifi/ScannedNetworks.c +++ b/shared-bindings/wifi/ScannedNetworks.c @@ -59,12 +59,9 @@ STATIC mp_obj_t scannednetworks_iternext(mp_obj_t self_in) { //| ... //| -const mp_obj_type_t wifi_scannednetworks_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_ScannedNetworks, - MP_TYPE_EXTENDED_FIELDS( - .getiter = mp_identity_getiter, - .iternext = scannednetworks_iternext, - ) -}; +MP_DEFINE_CONST_OBJ_TYPE( + wifi_scannednetworks_type, + MP_QSTR_ScannedNetworks, + MP_TYPE_FLAG_ITER_IS_ITERNEXT, + iter, scannednetworks_iternext + ); diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index 53815c9836..3baca1d0e6 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -203,12 +203,13 @@ STATIC const mp_rom_map_elem_t supervisor_flash_obj_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(supervisor_flash_obj_locals_dict, supervisor_flash_obj_locals_dict_table); -const mp_obj_type_t supervisor_flash_type = { - { &mp_type_type }, - .name = MP_QSTR_Flash, - .make_new = supervisor_flash_obj_make_new, - .locals_dict = (struct _mp_obj_dict_t *)&supervisor_flash_obj_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + supervisor_flash_type, + MP_QSTR_Flash, + MP_TYPE_FLAG_NONE, + make_new, supervisor_flash_obj_make_new, + locals_dict, &supervisor_flash_obj_locals_dict + ); void supervisor_flash_init_vfs(fs_user_mount_t *vfs) { vfs->base.type = &mp_fat_vfs_type;