diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c index 843c143424..bd936f3687 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.c +++ b/devices/ble_hci/common-hal/_bleio/Adapter.c @@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) { // Generic Access Service setup. - bleio_uuid_obj_t *generic_access_service_uuid = m_new_obj(bleio_uuid_obj_t); - generic_access_service_uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *generic_access_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); common_hal_bleio_uuid_construct(generic_access_service_uuid, 0x1800, NULL); - bleio_uuid_obj_t *device_name_characteristic_uuid = m_new_obj(bleio_uuid_obj_t); - device_name_characteristic_uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *device_name_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); common_hal_bleio_uuid_construct(device_name_characteristic_uuid, 0x2A00, NULL); - bleio_uuid_obj_t *appearance_characteristic_uuid = m_new_obj(bleio_uuid_obj_t); - appearance_characteristic_uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *appearance_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); common_hal_bleio_uuid_construct(appearance_characteristic_uuid, 0x2A01, NULL); // Not implemented: // Peripheral Preferred Connection Parameters // Central Address Resolution - bleio_service_obj_t *generic_access_service = m_new_obj(bleio_service_obj_t); - generic_access_service->base.type = &bleio_service_type; + bleio_service_obj_t *generic_access_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); common_hal_bleio_service_construct(generic_access_service, generic_access_service_uuid, false); - adapter->device_name_characteristic = m_new_obj(bleio_characteristic_obj_t); - adapter->device_name_characteristic->base.type = &bleio_characteristic_type; + adapter->device_name_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); char generic_name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 'n', 'n', 'n', 'n' }; mp_buffer_info_t generic_name_bufinfo = { @@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) { .len = sizeof(zero_16), }; - adapter->appearance_characteristic = m_new_obj(bleio_characteristic_obj_t); - adapter->appearance_characteristic->base.type = &bleio_characteristic_type; + adapter->appearance_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); common_hal_bleio_characteristic_construct( adapter->appearance_characteristic, @@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) { // Generic Attribute Service setup. - bleio_uuid_obj_t *generic_attribute_service_uuid = m_new_obj(bleio_uuid_obj_t); - generic_attribute_service_uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *generic_attribute_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); common_hal_bleio_uuid_construct(generic_attribute_service_uuid, 0x1801, NULL); - bleio_uuid_obj_t *service_changed_characteristic_uuid = m_new_obj(bleio_uuid_obj_t); - service_changed_characteristic_uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *service_changed_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); common_hal_bleio_uuid_construct(service_changed_characteristic_uuid, 0x2A05, NULL); - bleio_service_obj_t *generic_attribute_service = m_new_obj(bleio_service_obj_t); - generic_attribute_service->base.type = &bleio_service_type; + bleio_service_obj_t *generic_attribute_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); common_hal_bleio_service_construct(generic_attribute_service, generic_attribute_service_uuid, false); - adapter->service_changed_characteristic = m_new_obj(bleio_characteristic_obj_t); - adapter->service_changed_characteristic->base.type = &bleio_characteristic_type; + adapter->service_changed_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); uint32_t zero_32 = 0; mp_buffer_info_t zero_32_value = { @@ -416,8 +406,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s bt_addr_t addr; hci_check_error(hci_read_bd_addr(&addr)); - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; + bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); common_hal_bleio_address_construct(address, addr.val, BT_ADDR_LE_PUBLIC); return address; diff --git a/devices/ble_hci/common-hal/_bleio/Connection.c b/devices/ble_hci/common-hal/_bleio/Connection.c index e9e1254b43..b1e2ac6f39 100644 --- a/devices/ble_hci/common-hal/_bleio/Connection.c +++ b/devices/ble_hci/common-hal/_bleio/Connection.c @@ -453,8 +453,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // for (size_t i = 0; i < response->count; ++i) { // ble_gattc_service_t *gattc_service = &response->services[i]; -// bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); -// service->base.type = &bleio_service_type; +// bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); // // Initialize several fields at once. // bleio_service_from_connection(service, bleio_connection_new_from_internal(connection)); @@ -466,8 +465,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // // Known service UUID. -// bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); -// uuid->base.type = &bleio_uuid_type; +// bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); // bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); // service->uuid = uuid; // } else { @@ -491,15 +489,14 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // for (size_t i = 0; i < response->count; ++i) { // ble_gattc_char_t *gattc_char = &response->chars[i]; -// bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); -// characteristic->base.type = &bleio_characteristic_type; +// bleio_characteristic_obj_t *characteristic = +// mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); // bleio_uuid_obj_t *uuid = NULL; // if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // // Known characteristic UUID. -// uuid = m_new_obj(bleio_uuid_obj_t); -// uuid->base.type = &bleio_uuid_type; +// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); // bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); // } else { // // The discovery response contained a 128-bit UUID that has not yet been registered with the @@ -557,15 +554,13 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // break; // } -// bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); -// descriptor->base.type = &bleio_descriptor_type; +// bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); // bleio_uuid_obj_t *uuid = NULL; // if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // // Known descriptor UUID. -// uuid = m_new_obj(bleio_uuid_obj_t); -// uuid->base.type = &bleio_uuid_type; +// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); // bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid); // } else { // // The discovery response contained a 128-bit UUID that has not yet been registered with the @@ -750,8 +745,7 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna if (internal->connection_obj != mp_const_none) { return internal->connection_obj; } - bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); - connection->base.type = &bleio_connection_type; + bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type); connection->connection = internal; internal->connection_obj = connection; diff --git a/devices/ble_hci/common-hal/_bleio/Service.c b/devices/ble_hci/common-hal/_bleio/Service.c index 11b7efd523..6aff981f8e 100644 --- a/devices/ble_hci/common-hal/_bleio/Service.c +++ b/devices/ble_hci/common-hal/_bleio/Service.c @@ -101,8 +101,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, if (characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE)) { // We need a CCCD if this characteristic is doing notify or indicate. - bleio_descriptor_obj_t *cccd = m_new_obj(bleio_descriptor_obj_t); - cccd->base.type = &bleio_descriptor_type; + bleio_descriptor_obj_t *cccd = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); uint16_t zero = 0; mp_buffer_info_t zero_cccd_value = { diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index c35af3d02b..11f8d1e03d 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -382,6 +382,6 @@ const mp_obj_module_t mp_module_uhashlib = { .globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib, MICROPY_PY_UHASHLIB); +MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib); #endif // MICROPY_PY_UHASHLIB diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/ports/atmel-samd/bindings/samd/__init__.c index 29d12357d1..8f36452926 100644 --- a/ports/atmel-samd/bindings/samd/__init__.c +++ b/ports/atmel-samd/bindings/samd/__init__.c @@ -57,4 +57,4 @@ const mp_obj_module_t samd_module = { .globals = (mp_obj_dict_t *)&samd_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_samd, samd_module, CIRCUITPY_SAMD); +MP_REGISTER_MODULE(MP_QSTR_samd, samd_module); diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c index 1a340ae226..8feca31817 100644 --- a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c @@ -127,4 +127,4 @@ const mp_obj_module_t _bhb_user_cmodule = { .globals = (mp_obj_dict_t *)&_bhb_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule, MODULE_BHB_ENABLED); +MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule); diff --git a/ports/atmel-samd/common-hal/canio/Listener.c b/ports/atmel-samd/common-hal/canio/Listener.c index 5cdfafe9c0..28e82d7818 100644 --- a/ports/atmel-samd/common-hal/canio/Listener.c +++ b/ports/atmel-samd/common-hal/canio/Listener.c @@ -368,8 +368,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) { int index = self->hw->RXFS.bit.F0GI; canio_can_rx_fifo_t *hw_message = &self->fifo[index]; bool rtr = hw_message->rxf0.bit.RTR; - canio_message_obj_t *message = m_new_obj(canio_message_obj_t); - message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type; + canio_message_obj_t *message = + mp_obj_malloc(canio_message_obj_t, rtr ? &canio_remote_transmission_request_type : &canio_message_type); message->extended = hw_message->rxf0.bit.XTD; if (message->extended) { message->id = hw_message->rxf0.bit.ID; diff --git a/ports/broadcom/bindings/videocore/__init__.c b/ports/broadcom/bindings/videocore/__init__.c index 9ec345dae7..ffb90680ef 100644 --- a/ports/broadcom/bindings/videocore/__init__.c +++ b/ports/broadcom/bindings/videocore/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t videocore_module = { .globals = (mp_obj_dict_t *)&videocore_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module, CIRCUITPY_VIDEOCORE); +MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module); diff --git a/ports/espressif/bindings/espcamera/Camera.c b/ports/espressif/bindings/espcamera/Camera.c index 5fb9576e58..109ed5cffe 100644 --- a/ports/espressif/bindings/espcamera/Camera.c +++ b/ports/espressif/bindings/espcamera/Camera.c @@ -143,8 +143,7 @@ STATIC mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_ar mp_int_t jpeg_quality = mp_arg_validate_int_range(args[ARG_jpeg_quality].u_int, 2, 55, MP_QSTR_jpeg_quality); mp_int_t framebuffer_count = mp_arg_validate_int_range(args[ARG_framebuffer_count].u_int, 1, 2, MP_QSTR_framebuffer_count); - espcamera_camera_obj_t *self = m_new_obj(espcamera_camera_obj_t); - self->base.type = &espcamera_camera_type; + espcamera_camera_obj_t *self = mp_obj_malloc(espcamera_camera_obj_t, &espcamera_camera_type); common_hal_espcamera_camera_construct( self, data_pins, diff --git a/ports/espressif/bindings/espcamera/__init__.c b/ports/espressif/bindings/espcamera/__init__.c index 633f547fe9..3963f46bfe 100644 --- a/ports/espressif/bindings/espcamera/__init__.c +++ b/ports/espressif/bindings/espcamera/__init__.c @@ -285,4 +285,4 @@ const mp_obj_module_t espcamera_module = { .globals = (mp_obj_dict_t *)&espcamera_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module, CIRCUITPY_ESPCAMERA); +MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module); diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 78d80924fd..2caabd13c3 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -78,8 +78,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t } // Allocate a new object - self = m_new_obj(espnow_obj_t); - self->base.type = &espnow_type; + self = mp_obj_malloc(espnow_obj_t, &espnow_type); // Construct the object common_hal_espnow_construct(self, args[ARG_buffer_size].u_int, args[ARG_phy_rate].u_int); diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index f69bec01e6..98b65c5bdc 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -65,8 +65,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - espnow_peer_obj_t *self = m_new_obj(espnow_peer_obj_t); - self->base.type = &espnow_peer_type; + espnow_peer_obj_t *self = mp_obj_malloc(espnow_peer_obj_t, &espnow_peer_type); self->peer_info = (esp_now_peer_info_t) { .channel = 0, .ifidx = WIFI_IF_STA, diff --git a/ports/espressif/bindings/espnow/Peers.c b/ports/espressif/bindings/espnow/Peers.c index 6fda9aed7a..096a5266a0 100644 --- a/ports/espressif/bindings/espnow/Peers.c +++ b/ports/espressif/bindings/espnow/Peers.c @@ -118,8 +118,7 @@ STATIC mp_obj_t espnow_peers_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_b } espnow_peers_obj_t *espnow_peers_new(void) { - espnow_peers_obj_t *self = m_new_obj(espnow_peers_obj_t); - self->base.type = &espnow_peers_type; + espnow_peers_obj_t *self = mp_obj_malloc(espnow_peers_obj_t, &espnow_peers_type); self->list = mp_obj_new_list(0, NULL); return self; } diff --git a/ports/espressif/bindings/espnow/__init__.c b/ports/espressif/bindings/espnow/__init__.c index 3135858601..e0493a2897 100644 --- a/ports/espressif/bindings/espnow/__init__.c +++ b/ports/espressif/bindings/espnow/__init__.c @@ -91,4 +91,4 @@ const mp_obj_module_t espnow_module = { .globals = (mp_obj_dict_t *)&espnow_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_espnow, espnow_module, CIRCUITPY_ESPNOW); +MP_REGISTER_MODULE(MP_QSTR_espnow, espnow_module); diff --git a/ports/espressif/bindings/espulp/ULP.c b/ports/espressif/bindings/espulp/ULP.c index c9666fb143..09453c9a09 100644 --- a/ports/espressif/bindings/espulp/ULP.c +++ b/ports/espressif/bindings/espulp/ULP.c @@ -52,8 +52,7 @@ STATIC mp_obj_t espulp_ulp_make_new(const mp_obj_type_t *type, size_t n_args, si const espulp_architecture_t arch = cp_enum_value(&espulp_architecture_type, args[ARG_arch].u_obj, MP_QSTR_arch); - espulp_ulp_obj_t *self = m_new_obj(espulp_ulp_obj_t); - self->base.type = &espulp_ulp_type; + espulp_ulp_obj_t *self = mp_obj_malloc(espulp_ulp_obj_t, &espulp_ulp_type); common_hal_espulp_ulp_construct(self, arch); diff --git a/ports/espressif/bindings/espulp/ULPAlarm.c b/ports/espressif/bindings/espulp/ULPAlarm.c index 6efd1c98ef..b8b0a7c122 100644 --- a/ports/espressif/bindings/espulp/ULPAlarm.c +++ b/ports/espressif/bindings/espulp/ULPAlarm.c @@ -50,8 +50,7 @@ STATIC mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - espulp_ulpalarm_obj_t *self = m_new_obj(espulp_ulpalarm_obj_t); - self->base.type = &espulp_ulpalarm_type; + espulp_ulpalarm_obj_t *self = mp_obj_malloc(espulp_ulpalarm_obj_t, &espulp_ulpalarm_type); espulp_ulp_obj_t *ulp = mp_arg_validate_type(args[ARG_ulp].u_obj, &espulp_ulp_type, MP_QSTR_ulp); diff --git a/ports/espressif/bindings/espulp/__init__.c b/ports/espressif/bindings/espulp/__init__.c index f2b688dda4..36f50e8949 100644 --- a/ports/espressif/bindings/espulp/__init__.c +++ b/ports/espressif/bindings/espulp/__init__.c @@ -91,4 +91,4 @@ const mp_obj_module_t espulp_module = { .globals = (mp_obj_dict_t *)&espulp_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_espulp, espulp_module, CIRCUITPY_ESPULP); +MP_REGISTER_MODULE(MP_QSTR_espulp, espulp_module); diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c index 01adae3adb..24452993cb 100644 --- a/ports/espressif/common-hal/_bleio/Adapter.c +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -142,8 +142,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s return NULL; } - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; + bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); common_hal_bleio_address_construct(address, address_bytes, BLEIO_ADDRESS_TYPE_RANDOM_STATIC); return address; } diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c index 5e3e02d8e5..8861137210 100644 --- a/ports/espressif/common-hal/_bleio/Connection.c +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -176,12 +176,7 @@ STATIC int _discovered_service_cb(uint16_t conn_handle, if (_last_discovery_status != BLE_ERR_SUCCESS) { return 0; } - bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); - if (service == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - service->base.type = &bleio_service_type; + bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); // Initialize several fields at once. bleio_service_from_connection(service, bleio_connection_new_from_internal(self)); @@ -191,12 +186,8 @@ STATIC int _discovered_service_cb(uint16_t conn_handle, service->end_handle = svc->end_handle; service->handle = svc->start_handle; - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - if (uuid == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); + uuid->nimble_ble_uuid = svc->uuid; service->uuid = uuid; @@ -224,20 +215,12 @@ STATIC int _discovered_characteristic_cb(uint16_t conn_handle, return 0; } - bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); - if (characteristic == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - characteristic->base.type = &bleio_characteristic_type; + bleio_characteristic_obj_t *characteristic = + mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); // Known characteristic UUID. - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - if (uuid == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); + uuid->nimble_ble_uuid = chr->uuid; bleio_characteristic_properties_t props = @@ -301,19 +284,9 @@ STATIC int _discovered_descriptor_cb(uint16_t conn_handle, break; } - bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); - if (descriptor == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - descriptor->base.type = &bleio_descriptor_type; + bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - if (uuid == NULL) { - _last_discovery_status = BLE_ERR_MEM_CAPACITY; - return 0; - } - uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); uuid->nimble_ble_uuid = dsc->uuid; common_hal_bleio_descriptor_construct( @@ -438,8 +411,8 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna if (internal->connection_obj != mp_const_none) { return internal->connection_obj; } - bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); - connection->base.type = &bleio_connection_type; + bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type); + connection->connection = internal; internal->connection_obj = connection; diff --git a/ports/espressif/common-hal/canio/Listener.c b/ports/espressif/common-hal/canio/Listener.c index eccddf6243..94bf03317c 100644 --- a/ports/espressif/common-hal/canio/Listener.c +++ b/ports/espressif/common-hal/canio/Listener.c @@ -162,8 +162,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) { bool rtr = self->message_in.rtr; int dlc = self->message_in.data_length_code; - canio_message_obj_t *message = m_new_obj(canio_message_obj_t); - message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type; + canio_message_obj_t *message = + mp_obj_malloc(canio_message_obj_t,rtr ? &canio_remote_transmission_request_type : &canio_message_type); message->extended = self->message_in.extd; message->id = self->message_in.identifier; message->size = dlc; diff --git a/ports/espressif/common-hal/espidf/__init__.c b/ports/espressif/common-hal/espidf/__init__.c index d2d00ebc56..379d7c5ab4 100644 --- a/ports/espressif/common-hal/espidf/__init__.c +++ b/ports/espressif/common-hal/espidf/__init__.c @@ -198,4 +198,4 @@ void raise_esp_error(esp_err_t err) { mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err); } -MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module, CIRCUITPY_ESPIDF); +MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module); diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index d0592b718f..381606059c 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -175,8 +175,7 @@ mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, u } set_mode_station(self, true); - wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t); - scan->base.type = &wifi_scannednetworks_type; + wifi_scannednetworks_obj_t *scan = mp_obj_malloc(wifi_scannednetworks_obj_t, &wifi_scannednetworks_type); self->current_scan = scan; scan->current_channel_index = 0; scan->start_channel = start_channel; @@ -366,8 +365,7 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { return mp_const_none; } - wifi_network_obj_t *ap_info = m_new_obj(wifi_network_obj_t); - ap_info->base.type = &wifi_network_type; + wifi_network_obj_t *ap_info = mp_obj_malloc(wifi_network_obj_t, &wifi_network_type); // From esp_wifi.h, the possible return values (typos theirs): // ESP_OK: succeed // ESP_ERR_WIFI_CONN: The station interface don't initialized diff --git a/ports/espressif/common-hal/wifi/ScannedNetworks.c b/ports/espressif/common-hal/wifi/ScannedNetworks.c index 50df9f8c95..e37bdc2f44 100644 --- a/ports/espressif/common-hal/wifi/ScannedNetworks.c +++ b/ports/espressif/common-hal/wifi/ScannedNetworks.c @@ -115,8 +115,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) self->channel_scan_in_progress = false; } - wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t); - entry->base.type = &wifi_network_type; + wifi_network_obj_t *entry = mp_obj_malloc(wifi_network_obj_t, &wifi_network_type); memcpy(&entry->record, &self->results[self->current_result], sizeof(wifi_ap_record_t)); self->current_result++; diff --git a/ports/nrf/boards/bluemicro833/mpconfigboard.h b/ports/nrf/boards/bluemicro833/mpconfigboard.h index 2340cdc988..8bfeb7cb98 100644 --- a/ports/nrf/boards/bluemicro833/mpconfigboard.h +++ b/ports/nrf/boards/bluemicro833/mpconfigboard.h @@ -42,9 +42,6 @@ #define BOARD_HAS_CRYSTAL 1 -// Take 1k RAM to save 1k flash. -#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (0) - // Reduce nRF SoftRadio memory usage #define BLEIO_VS_UUID_COUNT 10 #define BLEIO_HVN_TX_QUEUE_SIZE 2 diff --git a/ports/nrf/boards/pca10100/mpconfigboard.h b/ports/nrf/boards/pca10100/mpconfigboard.h index 8b1ff19a89..dca629b422 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.h +++ b/ports/nrf/boards/pca10100/mpconfigboard.h @@ -37,9 +37,6 @@ #define CIRCUITPY_BLE_CONFIG_SIZE (12 * 1024) -// Take 1k RAM to save 1k flash. -#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (0) - // Reduce nRF SoftRadio memory usage #define BLEIO_VS_UUID_COUNT 10 #define BLEIO_HVN_TX_QUEUE_SIZE 2 diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 828ff8806d..c442cf6936 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -429,8 +429,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s ble_gap_addr_t local_address; get_address(self, &local_address); - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; + bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); common_hal_bleio_address_construct(address, local_address.addr, local_address.addr_type); return address; diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 69e6945d21..5f185de999 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -466,8 +466,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res for (size_t i = 0; i < response->count; ++i) { ble_gattc_service_t *gattc_service = &response->services[i]; - bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); - service->base.type = &bleio_service_type; + bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); // Initialize several fields at once. bleio_service_from_connection(service, bleio_connection_new_from_internal(connection)); @@ -479,8 +478,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // Known service UUID. - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - uuid->base.type = &bleio_uuid_type; + bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); service->uuid = uuid; } else { @@ -504,15 +502,14 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio for (size_t i = 0; i < response->count; ++i) { ble_gattc_char_t *gattc_char = &response->chars[i]; - bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); - characteristic->base.type = &bleio_characteristic_type; + bleio_characteristic_obj_t *characteristic = + mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); bleio_uuid_obj_t *uuid = NULL; if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // Known characteristic UUID. - uuid = m_new_obj(bleio_uuid_obj_t); - uuid->base.type = &bleio_uuid_type; + uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); } else { // The discovery response contained a 128-bit UUID that has not yet been registered with the @@ -571,15 +568,13 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio break; } - bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); - descriptor->base.type = &bleio_descriptor_type; + bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); bleio_uuid_obj_t *uuid = NULL; if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // Known descriptor UUID. - uuid = m_new_obj(bleio_uuid_obj_t); - uuid->base.type = &bleio_uuid_type; + uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid); } else { // The discovery response contained a 128-bit UUID that has not yet been registered with the @@ -763,8 +758,7 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna if (internal->connection_obj != mp_const_none) { return internal->connection_obj; } - bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); - connection->base.type = &bleio_connection_type; + bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type); connection->connection = internal; internal->connection_obj = connection; diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index 520d10263c..d00612518e 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -155,4 +155,4 @@ const mp_obj_module_t cyw43_module = { .globals = (mp_obj_dict_t *)&cyw43_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_cyw43, cyw43_module, CIRCUITPY_CYW43); +MP_REGISTER_MODULE(MP_QSTR_cyw43, cyw43_module); diff --git a/ports/raspberrypi/bindings/picodvi/__init__.c b/ports/raspberrypi/bindings/picodvi/__init__.c index edfe7759c8..878da11d0c 100644 --- a/ports/raspberrypi/bindings/picodvi/__init__.c +++ b/ports/raspberrypi/bindings/picodvi/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t picodvi_module = { .globals = (mp_obj_dict_t *)&picodvi_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_picodvi, picodvi_module, CIRCUITPY_PICODVI); +MP_REGISTER_MODULE(MP_QSTR_picodvi, picodvi_module); diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index bbf076ba68..b7dd548c76 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -150,8 +150,7 @@ //| ... STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - rp2pio_statemachine_obj_t *self = m_new_obj(rp2pio_statemachine_obj_t); - self->base.type = &rp2pio_statemachine_type; + rp2pio_statemachine_obj_t *self = mp_obj_malloc(rp2pio_statemachine_obj_t, &rp2pio_statemachine_type); enum { ARG_program, ARG_frequency, ARG_init, ARG_first_out_pin, ARG_out_pin_count, ARG_initial_out_pin_state, ARG_initial_out_pin_direction, ARG_first_in_pin, ARG_in_pin_count, diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.c b/ports/raspberrypi/bindings/rp2pio/__init__.c index 193a3a2025..ed2eced8ea 100644 --- a/ports/raspberrypi/bindings/rp2pio/__init__.c +++ b/ports/raspberrypi/bindings/rp2pio/__init__.c @@ -72,4 +72,4 @@ const mp_obj_module_t rp2pio_module = { .globals = (mp_obj_dict_t *)&rp2pio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_rp2pio, rp2pio_module, CIRCUITPY_RP2PIO); +MP_REGISTER_MODULE(MP_QSTR_rp2pio, rp2pio_module); diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index c6ee5492ad..35dc9f3369 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -137,8 +137,7 @@ mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, u if (!common_hal_wifi_radio_get_enabled(self)) { mp_raise_RuntimeError(translate("Wifi is not enabled")); } - wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t); - scan->base.type = &wifi_scannednetworks_type; + wifi_scannednetworks_obj_t *scan = mp_obj_malloc(wifi_scannednetworks_obj_t, &wifi_scannednetworks_type); mp_obj_t args[] = { mp_const_empty_tuple, MP_OBJ_NEW_SMALL_INT(16) }; scan->results = mp_type_deque.make_new(&mp_type_deque, 2, 0, args); self->current_scan = scan; diff --git a/ports/raspberrypi/common-hal/wifi/ScannedNetworks.c b/ports/raspberrypi/common-hal/wifi/ScannedNetworks.c index 97299e2f74..e2de56a6d6 100644 --- a/ports/raspberrypi/common-hal/wifi/ScannedNetworks.c +++ b/ports/raspberrypi/common-hal/wifi/ScannedNetworks.c @@ -97,8 +97,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) } - wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t); - entry->base.type = &wifi_network_type; + wifi_network_obj_t *entry = mp_obj_malloc(wifi_network_obj_t, &wifi_network_type); scan_result_get(&entry->record); return MP_OBJ_FROM_PTR(entry); diff --git a/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c b/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c index cdffa9f1e5..55011e556a 100644 --- a/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c +++ b/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c @@ -211,4 +211,4 @@ const mp_obj_module_t sensor_module = { .globals = (mp_obj_dict_t *)&sensor_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_sensor, sensor_module,1); +MP_REGISTER_MODULE(MP_QSTR_sensor, sensor_module); diff --git a/ports/silabs/common-hal/_bleio/Adapter.c b/ports/silabs/common-hal/_bleio/Adapter.c index ec2e6632ec..4d592f4422 100644 --- a/ports/silabs/common-hal/_bleio/Adapter.c +++ b/ports/silabs/common-hal/_bleio/Adapter.c @@ -127,8 +127,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s return NULL; } - address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; + address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); common_hal_bleio_address_construct(address, get_address.addr, BLEIO_ADDRESS_TYPE_RANDOM_STATIC); return address; diff --git a/ports/silabs/common-hal/_bleio/Connection.c b/ports/silabs/common-hal/_bleio/Connection.c index ad3f6db198..f6cd664a57 100644 --- a/ports/silabs/common-hal/_bleio/Connection.c +++ b/ports/silabs/common-hal/_bleio/Connection.c @@ -251,8 +251,7 @@ mp_obj_t bleio_connection_new_from_internal( if (internal->connection_obj != mp_const_none) { return internal->connection_obj; } - connection = m_new_obj(bleio_connection_obj_t); - connection->base.type = &bleio_connection_type; + connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type); connection->connection = internal; internal->connection_obj = connection; diff --git a/ports/silabs/common-hal/_bleio/__init__.c b/ports/silabs/common-hal/_bleio/__init__.c index 79a0b764e9..8b85f9ed6b 100644 --- a/ports/silabs/common-hal/_bleio/__init__.c +++ b/ports/silabs/common-hal/_bleio/__init__.c @@ -183,17 +183,12 @@ void sl_bt_on_event(sl_bt_msg_t *evt) { osMutexAcquire(bluetooth_connection_mutex_id, osWaitForever); connection = bleio_conn_handle_to_connection( evt->data.evt_gatt_service.connection); - service = m_new_obj(bleio_service_obj_t); - if (NULL == service) { - mp_raise_bleio_BluetoothError( - translate("Create new service obj fail")); - } - service->base.type = &bleio_service_type; + service = m_new_obj(bleio_service_obj_t, &bleio_service_type); bleio_service_from_connection(service, bleio_connection_new_from_internal(connection)); service->is_remote = true; service->handle = evt->data.evt_gatt_service.service; - uuid = m_new_obj(bleio_uuid_obj_t); + uuid = m_new_obj_maybe(bleio_uuid_obj_t); if (NULL == uuid) { osMutexRelease(bluetooth_connection_mutex_id); mp_raise_bleio_BluetoothError( @@ -231,21 +226,8 @@ void sl_bt_on_event(sl_bt_msg_t *evt) { service = MP_OBJ_TO_PTR(connection->remote_service_list->items[serv_idx - 1]); - characteristic = m_new_obj(bleio_characteristic_obj_t); - if (characteristic == NULL) { - mp_raise_bleio_BluetoothError( - translate("Create new characteristic obj fail.")); - } - - characteristic->base.type = &bleio_characteristic_type; - uuid = m_new_obj(bleio_uuid_obj_t); - if (uuid == NULL) { - mp_raise_bleio_BluetoothError( - translate("Create new characteristic uuid obj fail.")); - break; - } - - uuid->base.type = &bleio_uuid_type; + characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type); + uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); if (UUID16_LEN == evt->data.evt_gatt_characteristic.uuid.len) { uuid->efr_ble_uuid.uuid16.value &= 0x0000; uuid->efr_ble_uuid.uuid16.value diff --git a/ports/stm/common-hal/canio/Listener.c b/ports/stm/common-hal/canio/Listener.c index 0def8192f9..36c138ddd2 100644 --- a/ports/stm/common-hal/canio/Listener.c +++ b/ports/stm/common-hal/canio/Listener.c @@ -285,8 +285,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) { uint32_t rdtr = self->mailbox->RDTR; bool rtr = rir & CAN_RI0R_RTR; - canio_message_obj_t *message = m_new_obj(canio_message_obj_t); - message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type; + canio_message_obj_t *message = + mp_obj_malloc(canio_message_obj_t, rtr ? &canio_remote_transmission_request_type : &canio_message_type); message->extended = rir & CAN_RI0R_IDE; if (message->extended) { message->id = rir >> 3; diff --git a/ports/unix/displayio_min.c b/ports/unix/displayio_min.c index debca1e088..45cfc1b73c 100644 --- a/ports/unix/displayio_min.c +++ b/ports/unix/displayio_min.c @@ -89,4 +89,4 @@ const mp_obj_module_t displayio_module = { .globals = (mp_obj_dict_t *)&displayio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO_UNIX); +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module); diff --git a/py/builtin.h b/py/builtin.h index db45f9841d..ab228278a7 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2013, 2014 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/py/builtinimport.c b/py/builtinimport.c index 5ba4da0b43..a47211165b 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -236,6 +236,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) { } #endif } + #endif // MICROPY_MODULE_FROZEN // If we support loading .mpy files then check if the file extension is of @@ -463,6 +464,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, // because the file will not exist. } + //CIRCUITPY // Loading a module thrashes the heap significantly so we explicitly clean up // afterwards. gc_collect(); diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 78fa340f5d..02e796b4d1 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -214,7 +214,6 @@ typedef long mp_off_t; #define mp_type_fileio mp_type_vfs_fat_fileio #define mp_type_textio mp_type_vfs_fat_textio -#define mp_import_stat mp_vfs_import_stat #define mp_builtin_open_obj mp_vfs_open_obj @@ -492,13 +491,6 @@ void background_callback_run_all(void); #define CIRCUITPY_VERBOSE_BLE 0 -// This trades ~1k flash space (1) for that much in RAM plus the cost to compute -// the values once on init (0). Only turn it off, when you really need the flash -// space and are willing to trade the RAM. -#ifndef CIRCUITPY_PRECOMPUTE_QSTR_ATTR -#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (1) -#endif - // Display the Blinka logo in the REPL on displayio displays. #ifndef CIRCUITPY_REPL_LOGO #define CIRCUITPY_REPL_LOGO (1) diff --git a/py/gc_long_lived.c b/py/gc_long_lived.c index 647c4f75b7..6ceff0c1d4 100644 --- a/py/gc_long_lived.c +++ b/py/gc_long_lived.c @@ -37,38 +37,38 @@ mp_obj_fun_bc_t *make_fun_bc_long_lived(mp_obj_fun_bc_t *fun_bc, uint8_t max_dep return fun_bc; } fun_bc->bytecode = gc_make_long_lived((byte *)fun_bc->bytecode); - fun_bc->globals = make_dict_long_lived(fun_bc->globals, max_depth - 1); - for (uint32_t i = 0; i < gc_nbytes(fun_bc->const_table) / sizeof(mp_obj_t); i++) { - // Skip things that aren't allocated on the heap (and hence have zero bytes.) - if (gc_nbytes(MP_OBJ_TO_PTR(fun_bc->const_table[i])) == 0) { - continue; - } - // Try to detect raw code. - mp_raw_code_t *raw_code = MP_OBJ_TO_PTR(fun_bc->const_table[i]); - if (raw_code->kind == MP_CODE_BYTECODE) { - raw_code->fun_data = gc_make_long_lived((byte *)raw_code->fun_data); - raw_code->const_table = gc_make_long_lived((byte *)raw_code->const_table); - } - ((mp_uint_t *)fun_bc->const_table)[i] = (mp_uint_t)make_obj_long_lived( - (mp_obj_t)fun_bc->const_table[i], max_depth - 1); + fun_bc->context->module.globals = make_dict_long_lived(fun_bc->context->module.globals, max_depth - 1); + // for (uint32_t i = 0; i < gc_nbytes(fun_bc->const_table) / sizeof(mp_obj_t); i++) { + // // Skip things that aren't allocated on the heap (and hence have zero bytes.) + // if (gc_nbytes(MP_OBJ_TO_PTR(fun_bc->const_table[i])) == 0) { + // continue; + // } + // // Try to detect raw code. + // mp_raw_code_t *raw_code = MP_OBJ_TO_PTR(fun_bc->const_table[i]); + // if (raw_code->kind == MP_CODE_BYTECODE) { + // raw_code->fun_data = gc_make_long_lived((byte *)raw_code->fun_data); + // raw_code->const_table = gc_make_long_lived((byte *)raw_code->const_table); + // } + // ((mp_uint_t *)fun_bc->const_table)[i] = (mp_uint_t)make_obj_long_lived( + // (mp_obj_t)fun_bc->const_table[i], max_depth - 1); - } - fun_bc->const_table = gc_make_long_lived((mp_uint_t *)fun_bc->const_table); - // extra_args stores keyword only argument default values. - size_t words = gc_nbytes(fun_bc) / sizeof(mp_uint_t *); - // Functions (mp_obj_fun_bc_t) have four pointers (base, globals, bytecode and const_table) - // before the variable length extra_args so remove them from the length. - for (size_t i = 0; i < words - 4; i++) { - if (MP_OBJ_TO_PTR(fun_bc->extra_args[i]) == NULL) { - continue; - } - if (mp_obj_is_type(fun_bc->extra_args[i], &mp_type_dict)) { - fun_bc->extra_args[i] = MP_OBJ_FROM_PTR(make_dict_long_lived(MP_OBJ_TO_PTR(fun_bc->extra_args[i]), max_depth - 1)); - } else { - fun_bc->extra_args[i] = make_obj_long_lived(fun_bc->extra_args[i], max_depth - 1); - } + // } + // fun_bc->const_table = gc_make_long_lived((mp_uint_t *)fun_bc->const_table); + // // extra_args stores keyword only argument default values. + // size_t words = gc_nbytes(fun_bc) / sizeof(mp_uint_t *); + // // Functions (mp_obj_fun_bc_t) have four pointers (base, globals, bytecode and const_table) + // // before the variable length extra_args so remove them from the length. + // for (size_t i = 0; i < words - 4; i++) { + // if (MP_OBJ_TO_PTR(fun_bc->extra_args[i]) == NULL) { + // continue; + // } + // if (mp_obj_is_type(fun_bc->extra_args[i], &mp_type_dict)) { + // fun_bc->extra_args[i] = MP_OBJ_FROM_PTR(make_dict_long_lived(MP_OBJ_TO_PTR(fun_bc->extra_args[i]), max_depth - 1)); + // } else { + // fun_bc->extra_args[i] = make_obj_long_lived(fun_bc->extra_args[i], max_depth - 1); + // } - } + // } return gc_make_long_lived(fun_bc); } diff --git a/py/obj.c b/py/obj.c index 01efd8ad28..9e08e314a3 100644 --- a/py/obj.c +++ b/py/obj.c @@ -45,7 +45,7 @@ // Allocates an object and also sets type, for mp_obj_malloc{,_var} macros. void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type) { - mp_obj_base_t *base = (mp_obj_base_t *)m_malloc(num_bytes); + mp_obj_base_t *base = (mp_obj_base_t *)m_malloc(num_bytes, false); base->type = type; return base; } @@ -346,7 +346,7 @@ mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2) { } // Try calling __eq__. - mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2); + mp_obj_t r = binary_op(MP_BINARY_OP_EQUAL, o1, o2); if (r != MP_OBJ_NULL) { if (op == MP_BINARY_OP_EQUAL) { return r; diff --git a/py/obj.h b/py/obj.h index 9f5314e30d..1e08d2f3b4 100644 --- a/py/obj.h +++ b/py/obj.h @@ -460,7 +460,7 @@ typedef struct _mp_rom_map_elem_t { typedef struct _mp_map_t { size_t all_keys_are_qstrs : 1; size_t is_fixed : 1; // if set, table is fixed/read-only and can't be modified - size_t is_ordered : 1; / if set, table is an ordered array, not a hash map + size_t is_ordered : 1; // if set, table is an ordered array, not a hash map size_t scanning : 1; // true if we're in the middle of scanning linked dictionaries, // e.g., make_dict_long_lived() size_t used : (8 * sizeof(size_t) - 4); @@ -611,6 +611,39 @@ struct _mp_obj_type_ext { // One of disjoint protocols (interfaces), like mp_stream_p_t, etc. const void *protocol; +}; + +struct _mp_obj_type_t { + // A type is an object so must start with this entry, which points to mp_type_type. + mp_obj_base_t base; + + // Flags associated with this type. + uint16_t flags; + // The name of this type, a qstr. + uint16_t name; + + // A dict mapping qstrs to objects local methods/constants/etc. + struct _mp_obj_dict_t *locals_dict; + + // Corresponds to __new__ and __init__ special methods, to make an instance of the type. + mp_make_new_fun_t make_new; + + // Corresponds to __repr__ and __str__ special methods. + mp_print_fun_t print; + + // Implements load, store and delete attribute. + // + // dest[0] = MP_OBJ_NULL means load + // return: for fail, do nothing + // for fail but continue lookup in locals_dict, dest[1] = MP_OBJ_SENTINEL + // for attr, dest[0] = value + // for method, dest[0] = method, dest[1] = self + // + // dest[0,1] = {MP_OBJ_SENTINEL, MP_OBJ_NULL} means delete + // dest[0,1] = {MP_OBJ_SENTINEL, object} means store + // return: for fail, do nothing + // for success set dest[0] = MP_OBJ_NULL + mp_attr_fun_t attr; // A pointer to the parents of this type: // - 0 parents: pointer is NULL (object is implicitly the single parent) @@ -851,10 +884,6 @@ mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const com #endif // Only use this string version from native MPY files with static error strings. mp_obj_t mp_obj_new_exception_msg_str(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table); -mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table); -mp_obj_t mp_obj_new_fun_viper(size_t n_args, const void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig); mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun, bool is_coroutine); mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed, const mp_obj_t *closed); mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items); @@ -928,6 +957,7 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type); void mp_obj_exception_clear_traceback(mp_obj_t self_in); void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block); void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values); +mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in); mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); @@ -1003,6 +1033,7 @@ void mp_obj_tuple_del(mp_obj_t self_in); mp_int_t mp_obj_tuple_hash(mp_obj_t self_in); // list +mp_obj_t mp_obj_list_clear(mp_obj_t self_in); mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg); mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value); void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items); @@ -1022,7 +1053,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index); mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value); mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key); mp_obj_t mp_obj_dict_copy(mp_obj_t self_in); -static inline mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) { +static MP_INLINE mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) { return &((mp_obj_dict_t *)MP_OBJ_TO_PTR(dict))->map; } @@ -1082,9 +1113,8 @@ typedef struct _mp_obj_module_t { mp_obj_base_t base; mp_obj_dict_t *globals; } mp_obj_module_t; -static inline mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t module) { - return ((mp_obj_module_t *)MP_OBJ_TO_PTR(module))->globals; -} +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); +void mp_obj_module_set_globals(mp_obj_t self_in, mp_obj_dict_t *globals); // check if given module object is a package bool mp_obj_is_package(mp_obj_t module); diff --git a/py/objfun.h b/py/objfun.h index 9de15b8841..6baea818f4 100644 --- a/py/objfun.h +++ b/py/objfun.h @@ -31,7 +31,8 @@ typedef struct _mp_obj_fun_bc_t { mp_obj_base_t base; - const mp_module_context_t *context; // context within which this function was defined + // CIRCUITPY - Long-lived conversions need to write into context, so un-const the field. + /*const*/ mp_module_context_t *context; // context within which this function was defined struct _mp_raw_code_t *const *child_table; // table of children const byte *bytecode; // bytecode for the function #if MICROPY_PY_SYS_SETTRACE diff --git a/py/qstr.c b/py/qstr.c index 19ade1b6a4..ca8d8597c5 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -76,27 +76,23 @@ mp_uint_t qstr_compute_hash(const byte *data, size_t len) { } return hash; } -#ifndef CIRCUITPY_PRECOMPUTE_QSTR_ATTR -#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (1) -#endif -#if CIRCUITPY_PRECOMPUTE_QSTR_ATTR == 1 -const qstr_attr_t mp_qstr_const_attr[MP_QSTRnumber_of] = { const qstr_hash_t mp_qstr_const_hashes[] = { #ifndef NO_QSTR #define QDEF(id, hash, len, str) hash, +#define TRANSLATION(id, length, compressed ...) #include "genhdr/qstrdefs.generated.h" +#undef TRANSLATION #undef QDEF #endif }; -#else -qstr_attr_t mp_qstr_const_attr[MP_QSTRnumber_of]; -#endif const qstr_len_t mp_qstr_const_lengths[] = { #ifndef NO_QSTR #define QDEF(id, hash, len, str) len, +#define TRANSLATION(id, length, compressed ...) #include "genhdr/qstrdefs.generated.h" +#undef TRANSLATION #undef QDEF #endif }; @@ -130,16 +126,6 @@ void qstr_init(void) { MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left MP_STATE_VM(qstr_last_chunk) = NULL; - #if CIRCUITPY_PRECOMPUTE_QSTR_ATTR == 0 - if (mp_qstr_const_attr[MP_QSTR_circuitpython].len == 0) { - for (size_t i = 0; i < mp_qstr_const_pool.len; i++) { - size_t len = strlen(mp_qstr_const_pool.qstrs[i]); - mp_qstr_const_attr[i].hash = qstr_compute_hash((const byte *)mp_qstr_const_pool.qstrs[i], len); - mp_qstr_const_attr[i].len = len; - } - } - #endif - #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex)); #endif @@ -170,7 +156,7 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) { #endif mp_uint_t pool_size = sizeof(qstr_pool_t) + (sizeof(const char *) + sizeof(qstr_hash_t) + sizeof(qstr_len_t)) * new_alloc; - qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size); + qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size, true); if (pool == NULL) { // Keep qstr_last_chunk consistent with qstr_pool_t: qstr_last_chunk is not scanned // at garbage collection since it's reachable from a qstr_pool_t. And the caller of diff --git a/py/qstr.h b/py/qstr.h index fa634f90b0..c6c9768d05 100644 --- a/py/qstr.h +++ b/py/qstr.h @@ -39,8 +39,10 @@ enum { #ifndef NO_QSTR #define QDEF(id, hash, len, str) id, +#define TRANSLATION(english_id, number) #include "genhdr/qstrdefs.generated.h" #undef QDEF +#undef TRANSLATION #endif MP_QSTRnumber_of, // no underscore so it can't clash with any of the above }; diff --git a/shared-bindings/__future__/__init__.c b/shared-bindings/__future__/__init__.c index ad1bb3b283..dfef2204ca 100644 --- a/shared-bindings/__future__/__init__.c +++ b/shared-bindings/__future__/__init__.c @@ -57,4 +57,4 @@ const mp_obj_module_t future_module = { .globals = (mp_obj_dict_t *)&future_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR___future__, future_module, CIRCUITPY_FUTURE); +MP_REGISTER_MODULE(MP_QSTR___future__, future_module); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 236ca9e39e..cae1b9a235 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -56,8 +56,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - bleio_address_obj_t *self = m_new_obj(bleio_address_obj_t); - self->base.type = &bleio_address_type; + bleio_address_obj_t *self = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); const mp_obj_t address = args[ARG_address].u_obj; mp_buffer_info_t buf_info; diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 823250c365..faad911c80 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -141,8 +141,8 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ user_description = mp_obj_str_get_str(args[ARG_user_description].u_obj); } - bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); - characteristic->base.type = &bleio_characteristic_type; + bleio_characteristic_obj_t *characteristic = + m_new_obj(bleio_characteristic_obj_t, &bleio_characteristic_type); // Range checking on max_length arg is done by the common_hal layer, because // it may vary depending on underlying BLE implementation. diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 1efb992c72..842ea4cc58 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -74,8 +74,8 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, const mp_int_t buffer_size = mp_arg_validate_int_min(args[ARG_buffer_size].u_int, 1, MP_QSTR_buffer_size); - bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t); - self->base.type = &bleio_characteristic_buffer_type; + bleio_characteristic_buffer_obj_t *self = + mp_obj_malloc(bleio_characteristic_buffer_obj_t, &bleio_characteristic_buffer_type); common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 9ebe95432e..813ef8f9fe 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -122,8 +122,7 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o mp_raise_ValueError(translate("initial_value length is wrong")); } - bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); - descriptor->base.type = &bleio_descriptor_type; + bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); // Range checking on max_length arg is done by the common_hal layer, because // it may vary depending on underlying BLE implementation. diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 0ce74beff4..2c03a6855e 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -85,8 +85,7 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n max_packet_size = mp_obj_get_int(args[ARG_max_packet_size].u_obj); } - bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t); - self->base.type = &bleio_packet_buffer_type; + bleio_packet_buffer_obj_t *self = mp_obj_malloc(bleio_packet_buffer_obj_t, &bleio_packet_buffer_type); common_hal_bleio_packet_buffer_construct(self, characteristic, buffer_size, max_packet_size); diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 7b357882f0..f107b068e0 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -61,8 +61,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, const bool is_secondary = args[ARG_secondary].u_bool; - bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); - service->base.type = &bleio_service_type; + bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type); common_hal_bleio_service_construct(service, uuid, is_secondary); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 922b1ac5fb..b7fc05fbc6 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -53,8 +53,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); - bleio_uuid_obj_t *self = m_new_obj(bleio_uuid_obj_t); - self->base.type = type; + bleio_uuid_obj_t *self = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type); const mp_obj_t value = all_args[0]; uint8_t uuid128[16]; diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index f34d3af5c5..1131b52eb9 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -203,4 +203,4 @@ const mp_obj_module_t bleio_module = { .globals = (mp_obj_dict_t *)&bleio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__bleio, bleio_module, CIRCUITPY_BLEIO); +MP_REGISTER_MODULE(MP_QSTR__bleio, bleio_module); diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 5975ee1ca1..203a9cbfd2 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -1058,8 +1058,7 @@ STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); - mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); - o->base.type = &_EVE_type; + mp_obj__EVE_t *o = mp_obj_malloc(mp_obj__EVE_t, &_EVE_type); o->_eve.n = 0; o->_eve.vscale = 16; return MP_OBJ_FROM_PTR(o); @@ -1084,4 +1083,4 @@ const mp_obj_module_t _eve_module = { .globals = (mp_obj_dict_t *)&mp_module__eve_globals, }; -MP_REGISTER_MODULE(MP_QSTR__eve, _eve_module, CIRCUITPY__EVE); +MP_REGISTER_MODULE(MP_QSTR__eve, _eve_module); diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 1a4356c719..d9cc325a0a 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -110,8 +110,7 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, size_t pew_obj_t *pew = MP_STATE_VM(pew_singleton); if (!pew) { - pew = m_new_obj(pew_obj_t); - pew->base.type = &pewpew_type; + pew = mp_obj_malloc(pew_obj_t, &pewpew_type); pew = gc_make_long_lived(pew); MP_STATE_VM(pew_singleton) = pew; } diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 94fa4d5c96..5de918bbbe 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -87,8 +87,7 @@ STATIC mp_obj_t pixelmap_pixelmap_make_new(const mp_obj_type_t *type, size_t n_a } } - pixelmap_pixelmap_obj_t *self = m_new_obj(pixelmap_pixelmap_obj_t); - self->base.type = &pixelmap_pixelmap_type; + pixelmap_pixelmap_obj_t *self = mp_obj_malloc(pixelmap_pixelmap_obj_t, &pixelmap_pixelmap_type); shared_module_pixelmap_pixelmap_construct(self, pixelbuf, indices); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/_pixelmap/__init__.c b/shared-bindings/_pixelmap/__init__.c index 13a09d69d2..9c71c5498a 100644 --- a/shared-bindings/_pixelmap/__init__.c +++ b/shared-bindings/_pixelmap/__init__.c @@ -59,4 +59,4 @@ const mp_obj_module_t pixelmap_module = { .globals = (mp_obj_dict_t *)&pixelmap_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__pixelmap, pixelmap_module, CIRCUITPY_PIXELMAP); +MP_REGISTER_MODULE(MP_QSTR__pixelmap, pixelmap_module); diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 81d76321f0..a5dd130dac 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -58,8 +58,7 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 4, 5, false); - layer_obj_t *self = m_new_obj(layer_obj_t); - self->base.type = type; + layer_obj_t *self = mp_obj_malloc(layer_obj_t, type); self->width = mp_obj_get_int(args[0]); self->height = mp_obj_get_int(args[1]); diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index c735669861..0c54f123d7 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -58,8 +58,7 @@ STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 5, 5, false); - text_obj_t *self = m_new_obj(text_obj_t); - self->base.type = type; + text_obj_t *self = mp_obj_malloc(text_obj_t, type); self->width = mp_obj_get_int(args[0]); self->height = mp_obj_get_int(args[1]); diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index b2542f9df4..46ae93f4ba 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -118,4 +118,4 @@ const mp_obj_module_t stage_module = { .globals = (mp_obj_dict_t *)&stage_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__stage, stage_module, CIRCUITPY_STAGE); +MP_REGISTER_MODULE(MP_QSTR__stage, stage_module); diff --git a/shared-bindings/adafruit_bus_device/__init__.c b/shared-bindings/adafruit_bus_device/__init__.c index 410c6fb2f2..13993b18ff 100644 --- a/shared-bindings/adafruit_bus_device/__init__.c +++ b/shared-bindings/adafruit_bus_device/__init__.c @@ -76,6 +76,6 @@ const mp_obj_module_t adafruit_bus_device_module = { .globals = (mp_obj_dict_t *)&adafruit_bus_device_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device, adafruit_bus_device_module, CIRCUITPY_BUSDEVICE); -MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_i2c_device, adafruit_bus_device_i2c_device_module, CIRCUITPY_BUSDEVICE); -MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_spi_device, adafruit_bus_device_spi_device_module, CIRCUITPY_BUSDEVICE); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device, adafruit_bus_device_module); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_i2c_device, adafruit_bus_device_i2c_device_module); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_spi_device, adafruit_bus_device_spi_device_module); diff --git a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index a77179c886..7dd5e09868 100644 --- a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -66,8 +66,8 @@ //| """ //| ... STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - adafruit_bus_device_i2cdevice_obj_t *self = m_new_obj(adafruit_bus_device_i2cdevice_obj_t); - self->base.type = &adafruit_bus_device_i2cdevice_type; + adafruit_bus_device_i2cdevice_obj_t *self = + mp_obj_malloc(adafruit_bus_device_i2cdevice_obj_t, &adafruit_bus_device_i2cdevice_type); enum { ARG_i2c, ARG_device_address, ARG_probe }; static const mp_arg_t allowed_args[] = { { MP_QSTR_i2c, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index 13b57477e4..47f93f3230 100644 --- a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -79,8 +79,8 @@ //| spi.write(bytes_read)""" //| ... STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - adafruit_bus_device_spidevice_obj_t *self = m_new_obj(adafruit_bus_device_spidevice_obj_t); - self->base.type = &adafruit_bus_device_spidevice_type; + adafruit_bus_device_spidevice_obj_t *self = + mp_obj_malloc(adafruit_bus_device_spidevice_obj_t, &adafruit_bus_device_spidevice_type); enum { ARG_spi, ARG_chip_select, ARG_cs_active_value, ARG_baudrate, ARG_polarity, ARG_phase, ARG_extra_clocks }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index 2848a02c62..d259b57dbb 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -120,8 +120,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a } // Validation complete, allocate and populate object. - pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); - self->base.type = &pixelbuf_pixelbuf_type; + pixelbuf_pixelbuf_obj_t *self = mp_obj_malloc(pixelbuf_pixelbuf_obj_t, &pixelbuf_pixelbuf_type); common_hal_adafruit_pixelbuf_pixelbuf_construct(self, args[ARG_size].u_int, &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); diff --git a/shared-bindings/adafruit_pixelbuf/__init__.c b/shared-bindings/adafruit_pixelbuf/__init__.c index fd2915ee0a..bb741e3da6 100644 --- a/shared-bindings/adafruit_pixelbuf/__init__.c +++ b/shared-bindings/adafruit_pixelbuf/__init__.c @@ -62,4 +62,4 @@ const mp_obj_module_t pixelbuf_module = { .globals = (mp_obj_dict_t *)&pixelbuf_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_adafruit_pixelbuf, pixelbuf_module, CIRCUITPY_PIXELBUF); +MP_REGISTER_MODULE(MP_QSTR_adafruit_pixelbuf, pixelbuf_module); diff --git a/shared-bindings/aesio/__init__.c b/shared-bindings/aesio/__init__.c index f3e1d7dd17..314ac847b6 100644 --- a/shared-bindings/aesio/__init__.c +++ b/shared-bindings/aesio/__init__.c @@ -68,4 +68,4 @@ const mp_obj_module_t aesio_module = { .globals = (mp_obj_dict_t *)&aesio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_aesio, aesio_module, CIRCUITPY_AESIO); +MP_REGISTER_MODULE(MP_QSTR_aesio, aesio_module); diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index c5c50515ea..78999b87f1 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -47,8 +47,7 @@ STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - aesio_aes_obj_t *self = m_new_obj(aesio_aes_obj_t); - self->base.type = &aesio_aes_type; + aesio_aes_obj_t *self = mp_obj_malloc(aesio_aes_obj_t, &aesio_aes_type); enum { ARG_key, ARG_mode, ARG_IV, ARG_counter, ARG_segment_size }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 94879e14d4..7f927df016 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -312,4 +312,4 @@ MP_WEAK void common_hal_alarm_pretending_deep_sleep(void) { port_idle_until_interrupt(); } -MP_REGISTER_MODULE(MP_QSTR_alarm, alarm_module, CIRCUITPY_ALARM); +MP_REGISTER_MODULE(MP_QSTR_alarm, alarm_module); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index c75061b77a..b0e21771c5 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -62,8 +62,7 @@ //| """ //| ... STATIC mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *all_args) { - alarm_pin_pinalarm_obj_t *self = m_new_obj(alarm_pin_pinalarm_obj_t); - self->base.type = &alarm_pin_pinalarm_type; + alarm_pin_pinalarm_obj_t *self = mp_obj_malloc(alarm_pin_pinalarm_obj_t, &alarm_pin_pinalarm_type); enum { ARG_pin, ARG_value, ARG_edge, ARG_pull }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 86c96de1d4..aed14613ea 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -61,8 +61,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| ... STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - alarm_time_timealarm_obj_t *self = m_new_obj(alarm_time_timealarm_obj_t); - self->base.type = &alarm_time_timealarm_type; + alarm_time_timealarm_obj_t *self = mp_obj_malloc(alarm_time_timealarm_obj_t, &alarm_time_timealarm_type); enum { ARG_monotonic_time, ARG_epoch_time }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 20612cb106..71fcb67a4f 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -45,8 +45,7 @@ //| ... STATIC mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - alarm_touch_touchalarm_obj_t *self = m_new_obj(alarm_touch_touchalarm_obj_t); - self->base.type = &alarm_touch_touchalarm_type; + alarm_touch_touchalarm_obj_t *self = mp_obj_malloc(alarm_touch_touchalarm_obj_t, &alarm_touch_touchalarm_type); enum { ARG_pin }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/analogbufio/__init__.c b/shared-bindings/analogbufio/__init__.c index 749f1aec09..552fc56b25 100644 --- a/shared-bindings/analogbufio/__init__.c +++ b/shared-bindings/analogbufio/__init__.c @@ -59,4 +59,4 @@ const mp_obj_module_t analogbufio_module = { .globals = (mp_obj_dict_t *)&analogbufio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_analogbufio, analogbufio_module, CIRCUITPY_ANALOGBUFIO); +MP_REGISTER_MODULE(MP_QSTR_analogbufio, analogbufio_module); diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 3b71f688c8..faf085905e 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -65,8 +65,7 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, // 1st argument is the pin const mcu_pin_obj_t *pin = common_hal_analogio_analogin_validate_pin(args[0]); - analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t); - self->base.type = &analogio_analogin_type; + analogio_analogin_obj_t *self = mp_obj_malloc(analogio_analogin_obj_t, &analogio_analogin_type); common_hal_analogio_analogin_construct(self, pin); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 6b10d37571..36a6532b7c 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -63,8 +63,7 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0], MP_QSTR_pin); - analogio_analogout_obj_t *self = m_new_obj(analogio_analogout_obj_t); - self->base.type = &analogio_analogout_type; + analogio_analogout_obj_t *self = mp_obj_malloc(analogio_analogout_obj_t, &analogio_analogout_type); common_hal_analogio_analogout_construct(self, pin); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/analogio/__init__.c b/shared-bindings/analogio/__init__.c index 2e7ccf7115..e6bd2f1f4d 100644 --- a/shared-bindings/analogio/__init__.c +++ b/shared-bindings/analogio/__init__.c @@ -79,4 +79,4 @@ const mp_obj_module_t analogio_module = { .globals = (mp_obj_dict_t *)&analogio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_analogio, analogio_module, CIRCUITPY_ANALOGIO); +MP_REGISTER_MODULE(MP_QSTR_analogio, analogio_module); diff --git a/shared-bindings/atexit/__init__.c b/shared-bindings/atexit/__init__.c index 9a91e0bc80..b3fe1b6c01 100644 --- a/shared-bindings/atexit/__init__.c +++ b/shared-bindings/atexit/__init__.c @@ -93,4 +93,4 @@ const mp_obj_module_t atexit_module = { .globals = (mp_obj_dict_t *)&atexit_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_atexit, atexit_module, CIRCUITPY_ATEXIT); +MP_REGISTER_MODULE(MP_QSTR_atexit, atexit_module); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 1f0e500292..4529920c6d 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -116,8 +116,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar const mcu_pin_obj_t *data_pin = validate_obj_is_free_pin(args[ARG_data_pin].u_obj, MP_QSTR_data_pin); // create PDMIn object from the given pin - audiobusio_pdmin_obj_t *self = m_new_obj(audiobusio_pdmin_obj_t); - self->base.type = &audiobusio_pdmin_type; + audiobusio_pdmin_obj_t *self = mp_obj_malloc(audiobusio_pdmin_obj_t, &audiobusio_pdmin_type); uint32_t sample_rate = args[ARG_sample_rate].u_int; uint8_t bit_depth = args[ARG_bit_depth].u_int; diff --git a/shared-bindings/audiobusio/__init__.c b/shared-bindings/audiobusio/__init__.c index 937028ee1f..a7ae705170 100644 --- a/shared-bindings/audiobusio/__init__.c +++ b/shared-bindings/audiobusio/__init__.c @@ -58,4 +58,4 @@ const mp_obj_module_t audiobusio_module = { .globals = (mp_obj_dict_t *)&audiobusio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audiobusio, audiobusio_module, CIRCUITPY_AUDIOBUSIO); +MP_REGISTER_MODULE(MP_QSTR_audiobusio, audiobusio_module); diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 39992f87c1..58ec83fe35 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -80,8 +80,7 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - audioio_rawsample_obj_t *self = m_new_obj(audioio_rawsample_obj_t); - self->base.type = &audioio_rawsample_type; + audioio_rawsample_obj_t *self = mp_obj_malloc(audioio_rawsample_obj_t, &audioio_rawsample_type); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); uint8_t bytes_per_sample = 1; diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 3a13db72a0..aa50321040 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -79,8 +79,7 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar arg = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), arg, MP_ROM_QSTR(MP_QSTR_rb)); } - audioio_wavefile_obj_t *self = m_new_obj(audioio_wavefile_obj_t); - self->base.type = &audioio_wavefile_type; + audioio_wavefile_obj_t *self = mp_obj_malloc(audioio_wavefile_obj_t, &audioio_wavefile_type); if (!mp_obj_is_type(arg, &mp_type_fileio)) { mp_raise_TypeError(translate("file must be a file opened in byte mode")); } diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c index 3ecd7391b6..1e90f370d3 100644 --- a/shared-bindings/audiocore/__init__.c +++ b/shared-bindings/audiocore/__init__.c @@ -112,4 +112,4 @@ const mp_obj_module_t audiocore_module = { .globals = (mp_obj_dict_t *)&audiocore_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audiocore, audiocore_module, CIRCUITPY_AUDIOCORE); +MP_REGISTER_MODULE(MP_QSTR_audiocore, audiocore_module); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 7909176114..c66f109f9a 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -111,8 +111,7 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj, MP_QSTR_right_channel); // create AudioOut object from the given pin - audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t); - self->base.type = &audioio_audioout_type; + audioio_audioout_obj_t *self = mp_obj_malloc(audioio_audioout_obj_t, &audioio_audioout_type); common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c index b76b534a7d..89778d8f82 100644 --- a/shared-bindings/audioio/__init__.c +++ b/shared-bindings/audioio/__init__.c @@ -65,4 +65,4 @@ const mp_obj_module_t audioio_module = { .globals = (mp_obj_dict_t *)&audioio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audioio, audioio_module, CIRCUITPY_AUDIOIO); +MP_REGISTER_MODULE(MP_QSTR_audioio, audioio_module); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 83fcc06712..adfc447589 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -103,8 +103,8 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar if (bits_per_sample != 8 && bits_per_sample != 16) { mp_raise_ValueError(translate("bits_per_sample must be 8 or 16")); } - audiomixer_mixer_obj_t *self = m_new_obj_var(audiomixer_mixer_obj_t, mp_obj_t, voice_count); - self->base.type = &audiomixer_mixer_type; + audiomixer_mixer_obj_t *self = + mp_obj_malloc_var(audiomixer_mixer_obj_t, mp_obj_t, voice_count, &audiomixer_mixer_type; common_hal_audiomixer_mixer_construct(self, voice_count, args[ARG_buffer_size].u_int, bits_per_sample, args[ARG_samples_signed].u_bool, channel_count, sample_rate); for (int v = 0; v < voice_count; v++) { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 1d6cd7f39a..74b9c6745d 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -46,8 +46,7 @@ // TODO: support mono or stereo voices STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 0, 0, false); - audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); - self->base.type = &audiomixer_mixervoice_type; + audiomixer_mixervoice_obj_t *self = mp_obj_malloc(audiomixer_mixervoice_obj_t, &audiomixer_mixervoice_type); common_hal_audiomixer_mixervoice_construct(self); diff --git a/shared-bindings/audiomixer/__init__.c b/shared-bindings/audiomixer/__init__.c index 4c8068172b..552cc55e0c 100644 --- a/shared-bindings/audiomixer/__init__.c +++ b/shared-bindings/audiomixer/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t audiomixer_module = { .globals = (mp_obj_dict_t *)&audiomixer_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audiomixer, audiomixer_module, CIRCUITPY_AUDIOMIXER); +MP_REGISTER_MODULE(MP_QSTR_audiomixer, audiomixer_module); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 68e78cb0d5..ef5445a1de 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -95,8 +95,7 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar arg = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), arg, MP_ROM_QSTR(MP_QSTR_rb)); } - audiomp3_mp3file_obj_t *self = m_new_obj(audiomp3_mp3file_obj_t); - self->base.type = &audiomp3_mp3file_type; + audiomp3_mp3file_obj_t *self = mp_obj_malloc(audiomp3_mp3file_obj_t, &audiomp3_mp3file_type); if (!mp_obj_is_type(arg, &mp_type_fileio)) { mp_raise_TypeError(translate("file must be a file opened in byte mode")); } diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index 9fe525dfe2..09a3d4f886 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -50,4 +50,4 @@ const mp_obj_module_t audiomp3_module = { .globals = (mp_obj_dict_t *)&audiomp3_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audiomp3, audiomp3_module, CIRCUITPY_AUDIOMP3); +MP_REGISTER_MODULE(MP_QSTR_audiomp3, audiomp3_module); diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index 441bca2132..f8d7c0e5cb 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -57,4 +57,4 @@ const mp_obj_module_t audiopwmio_module = { .globals = (mp_obj_dict_t *)&audiopwmio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_audiopwmio, audiopwmio_module, CIRCUITPY_AUDIOPWMIO); +MP_REGISTER_MODULE(MP_QSTR_audiopwmio, audiopwmio_module); diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 9684b87df2..390e1c0c98 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -80,8 +80,7 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mcu_pin_obj_t *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj, MP_QSTR_scl); const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj, MP_QSTR_sda); - bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t); - self->base.type = &bitbangio_i2c_type; + bitbangio_i2c_obj_t *self = mp_obj_malloc(bitbangio_i2c_obj_t, &bitbangio_i2c_type); shared_module_bitbangio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int); return (mp_obj_t)self; } diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index cf4f34f0e4..dd452fc843 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -89,8 +89,7 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mcu_pin_obj_t *mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj, MP_QSTR_mosi); const mcu_pin_obj_t *miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj, MP_QSTR_miso); - bitbangio_spi_obj_t *self = m_new_obj(bitbangio_spi_obj_t); - self->base.type = &bitbangio_spi_type; + bitbangio_spi_obj_t *self = mp_obj_malloc(bitbangio_spi_obj_t, &bitbangio_spi_type); shared_module_bitbangio_spi_construct(self, clock, mosi, miso); return (mp_obj_t)self; } diff --git a/shared-bindings/bitbangio/__init__.c b/shared-bindings/bitbangio/__init__.c index 1b13003e89..99bf6d26a7 100644 --- a/shared-bindings/bitbangio/__init__.c +++ b/shared-bindings/bitbangio/__init__.c @@ -80,4 +80,4 @@ const mp_obj_module_t bitbangio_module = { .globals = (mp_obj_dict_t *)&bitbangio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_bitbangio, bitbangio_module, CIRCUITPY_BITBANGIO); +MP_REGISTER_MODULE(MP_QSTR_bitbangio, bitbangio_module); diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index d0aea33ef9..5a70533ebe 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -970,4 +970,4 @@ const mp_obj_module_t bitmaptools_module = { .globals = (mp_obj_dict_t *)&bitmaptools_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_bitmaptools, bitmaptools_module, CIRCUITPY_BITMAPTOOLS); +MP_REGISTER_MODULE(MP_QSTR_bitmaptools, bitmaptools_module); diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index 3107b310db..48cf1df0d6 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -99,4 +99,4 @@ const mp_obj_module_t bitops_module = { .globals = (mp_obj_dict_t *)&bitops_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_bitops, bitops_module, CIRCUITPY_BITOPS); +MP_REGISTER_MODULE(MP_QSTR_bitops, bitops_module); diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 99b99b37ea..273ef7ff90 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -119,4 +119,4 @@ const mp_obj_module_t board_module = { .globals = (mp_obj_dict_t *)&board_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_board, board_module, CIRCUITPY_BOARD); +MP_REGISTER_MODULE(MP_QSTR_board, board_module); diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 5cf52eaa1a..14ec7093a5 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -68,8 +68,7 @@ //| """ //| ... STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); - self->base.type = &busio_i2c_type; + busio_i2c_obj_t *self = mp_obj_malloc(busio_i2c_obj_t, &busio_i2c_type); enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; static const mp_arg_t allowed_args[] = { { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index ccdceb5760..42c9d5b63b 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -91,8 +91,7 @@ // TODO(tannewt): Support LSB SPI. STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BUSIO_SPI - busio_spi_obj_t *self = m_new_obj(busio_spi_obj_t); - self->base.type = &busio_spi_type; + busio_spi_obj_t *self = mp_obj_malloc(busio_spi_obj_t, &busio_spi_type); enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_half_duplex }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 4d62c8333e..5d6b60ac3f 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -93,4 +93,4 @@ const mp_obj_module_t busio_module = { .globals = (mp_obj_dict_t *)&busio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_busio, busio_module, CIRCUITPY_BUSIO); +MP_REGISTER_MODULE(MP_QSTR_busio, busio_module); diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index 4f6023c9fd..eea22a0d81 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -61,8 +61,7 @@ //| """Initialize camera.""" //| ... STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - camera_obj_t *self = m_new_obj(camera_obj_t); - self->base.type = &camera_type; + camera_obj_t *self = mp_obj_malloc(camera_obj_t, &camera_type); // No arguments mp_arg_check_num(n_args, n_kw, 0, 0, false); diff --git a/shared-bindings/camera/__init__.c b/shared-bindings/camera/__init__.c index e4ee263f58..a2b15933c4 100644 --- a/shared-bindings/camera/__init__.c +++ b/shared-bindings/camera/__init__.c @@ -48,4 +48,4 @@ const mp_obj_module_t camera_module = { .globals = (mp_obj_dict_t *)&camera_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_camera, camera_module, CIRCUITPY_CAMERA); +MP_REGISTER_MODULE(MP_QSTR_camera, camera_module); diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index bce581f501..912255adf4 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -83,8 +83,7 @@ STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, siz mp_raise_ValueError(translate("tx and rx cannot both be None")); } - canio_can_obj_t *self = m_new_obj(canio_can_obj_t); - self->base.type = &canio_can_type; + canio_can_obj_t *self = mp_obj_malloc(canio_can_obj_t, &canio_can_type); common_hal_canio_can_construct(self, tx_pin, rx_pin, args[ARG_baudrate].u_int, args[ARG_loopback].u_bool, args[ARG_silent].u_bool); common_hal_canio_can_auto_restart_set(self, args[ARG_auto_restart].u_bool); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 06729f9c54..1a9cd34916 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -64,8 +64,7 @@ STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, s mp_raise_ValueError_varg(translate("%q out of range"), MP_QSTR_mask); } - canio_match_obj_t *self = m_new_obj(canio_match_obj_t); - self->base.type = &canio_match_type; + canio_match_obj_t *self = mp_obj_malloc(canio_match_obj_t, &canio_match_type); common_hal_canio_match_construct(self, id, mask, args[ARG_extended].u_bool); return self; } diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index c3857256bd..432b10b4e8 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -58,8 +58,7 @@ STATIC mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_validate_length_range(data.len, 0, 8, MP_QSTR_data); - canio_message_obj_t *self = m_new_obj(canio_message_obj_t); - self->base.type = &canio_message_type; + canio_message_obj_t *self = mp_obj_malloc(canio_message_obj_t, &canio_message_type); common_hal_canio_message_construct(self, args[ARG_id].u_int, data.buf, data.len, args[ARG_extended].u_bool); return self; } diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 1efc401909..4b55bf2e75 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -58,8 +58,8 @@ STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t * mp_raise_ValueError(translate("RemoteTransmissionRequests limited to 8 bytes")); } - canio_remote_transmission_request_obj_t *self = m_new_obj(canio_remote_transmission_request_obj_t); - self->base.type = &canio_remote_transmission_request_type; + canio_remote_transmission_request_obj_t *self = + mp_obj_malloc(canio_remote_transmission_request_obj_t, &canio_remote_transmission_request_type); common_hal_canio_remote_transmission_request_construct(self, args[ARG_id].u_int, length, args[ARG_extended].u_bool); return self; } diff --git a/shared-bindings/canio/__init__.c b/shared-bindings/canio/__init__.c index ecef7ebde6..f5de9af547 100644 --- a/shared-bindings/canio/__init__.c +++ b/shared-bindings/canio/__init__.c @@ -128,4 +128,4 @@ const mp_obj_module_t canio_module = { .globals = (mp_obj_dict_t *)&canio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_canio, canio_module, CIRCUITPY_CANIO); +MP_REGISTER_MODULE(MP_QSTR_canio, canio_module); diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c index 0d412cc17f..9646e0879e 100644 --- a/shared-bindings/countio/__init__.c +++ b/shared-bindings/countio/__init__.c @@ -35,4 +35,5 @@ const mp_obj_module_t countio_module = { .globals = (mp_obj_dict_t *)&countio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_countio, countio_module, CIRCUITPY_COUNTIO); +MP_REGISTER_MODULE(MP_QSTR_countio, countio_module); +p diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index c0195115fa..832f16558a 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -90,8 +90,7 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); - digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t); - self->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *self = mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); const mcu_pin_obj_t *pin = common_hal_digitalio_validate_pin(args[0]); common_hal_digitalio_digitalinout_construct(self, pin); diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index 9a9db69816..938b7df754 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -97,4 +97,4 @@ const mp_obj_module_t digitalio_module = { .globals = (mp_obj_dict_t *)&digitalio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_digitalio, digitalio_module, CIRCUITPY_DIGITALIO); +MP_REGISTER_MODULE(MP_QSTR_digitalio, digitalio_module); diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 5b939c5892..86486210b0 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -75,8 +75,7 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar } } - displayio_bitmap_t *self = m_new_obj(displayio_bitmap_t); - self->base.type = &displayio_bitmap_type; + displayio_bitmap_t *self = mp_obj_malloc(displayio_bitmap_t, &displayio_bitmap_type); common_hal_displayio_bitmap_construct(self, width, height, bits); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 06de5a4b09..0ec78779ee 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -58,8 +58,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_colorconverter_t *self = m_new_obj(displayio_colorconverter_t); - self->base.type = &displayio_colorconverter_type; + displayio_colorconverter_t *self = mp_obj_malloc(displayio_colorconverter_t, &displayio_colorconverter_type); common_hal_displayio_colorconverter_construct(self, args[ARG_dither].u_bool, (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_input_colorspace].u_obj, MP_QSTR_input_colorspace)); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 279e1f161b..b24acfd675 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -58,8 +58,7 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg mp_int_t scale = mp_arg_validate_int_range(args[ARG_scale].u_int, 1, 32767,MP_QSTR_scale); - displayio_group_t *self = m_new_obj(displayio_group_t); - self->base.type = &displayio_group_type; + displayio_group_t *self = mp_obj_malloc(displayio_group_t, &displayio_group_type); common_hal_displayio_group_construct(self, scale, args[ARG_x].u_int, args[ARG_y].u_int); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index a53196ef05..d0dcba2339 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -89,8 +89,7 @@ STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_ mp_raise_TypeError(translate("file must be a file opened in byte mode")); } - displayio_ondiskbitmap_t *self = m_new_obj(displayio_ondiskbitmap_t); - self->base.type = &displayio_ondiskbitmap_type; + displayio_ondiskbitmap_t *self = mp_obj_malloc(displayio_ondiskbitmap_t, &displayio_ondiskbitmap_type); common_hal_displayio_ondiskbitmap_construct(self, MP_OBJ_TO_PTR(arg)); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 0c44ed0f60..abe5e369dd 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -59,8 +59,7 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_palette_t *self = m_new_obj(displayio_palette_t); - self->base.type = &displayio_palette_type; + displayio_palette_t *self = mp_obj_malloc(displayio_palette_t, &displayio_palette_type); common_hal_displayio_palette_construct(self, mp_arg_validate_int_range(args[ARG_color_count].u_int, 1, 32767, MP_QSTR_color_count), args[ARG_dither].u_bool); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index c8b3959837..11b73c4463 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -62,8 +62,7 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg mp_int_t width = mp_arg_validate_int_min(args[ARG_width].u_int, 1, MP_QSTR_width); mp_int_t height = mp_arg_validate_int_min(args[ARG_height].u_int, 1, MP_QSTR_height); - displayio_shape_t *self = m_new_obj(displayio_shape_t); - self->base.type = &displayio_shape_type; + displayio_shape_t *self = mp_obj_malloc(displayio_shape_t, &displayio_shape_type); common_hal_displayio_shape_construct(self, width, height, diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index f2e16985c3..5d27580fdf 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -139,8 +139,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ int16_t x = args[ARG_x].u_int; int16_t y = args[ARG_y].u_int; - displayio_tilegrid_t *self = m_new_obj(displayio_tilegrid_t); - self->base.type = &displayio_tilegrid_type; + displayio_tilegrid_t *self = mp_obj_malloc(displayio_tilegrid_t, &displayio_tilegrid_type); common_hal_displayio_tilegrid_construct(self, native, bitmap_width / tile_width, bitmap_height / tile_height, pixel_shader, args[ARG_width].u_int, args[ARG_height].u_int, diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 6b4dc6d895..e377a49dea 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -109,4 +109,4 @@ const mp_obj_module_t displayio_module = { .globals = (mp_obj_dict_t *)&displayio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO); +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module); diff --git a/shared-bindings/dualbank/__init__.c b/shared-bindings/dualbank/__init__.c index b77fb6d76b..0bb095ddac 100644 --- a/shared-bindings/dualbank/__init__.c +++ b/shared-bindings/dualbank/__init__.c @@ -141,4 +141,4 @@ const mp_obj_module_t dualbank_module = { .globals = (mp_obj_dict_t *)&dualbank_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_dualbank, dualbank_module, CIRCUITPY_DUALBANK); +MP_REGISTER_MODULE(MP_QSTR_dualbank, dualbank_module); diff --git a/shared-bindings/floppyio/__init__.c b/shared-bindings/floppyio/__init__.c index b114ab46dc..86c5813bdc 100644 --- a/shared-bindings/floppyio/__init__.c +++ b/shared-bindings/floppyio/__init__.c @@ -127,4 +127,4 @@ const mp_obj_module_t floppyio_module = { .globals = (mp_obj_dict_t *)&floppyio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_floppyio, floppyio_module, CIRCUITPY_FLOPPYIO); +MP_REGISTER_MODULE(MP_QSTR_floppyio, floppyio_module); diff --git a/shared-bindings/fontio/__init__.c b/shared-bindings/fontio/__init__.c index 24e1eb1e3b..d988ceda7f 100644 --- a/shared-bindings/fontio/__init__.c +++ b/shared-bindings/fontio/__init__.c @@ -56,4 +56,4 @@ const mp_obj_module_t fontio_module = { .globals = (mp_obj_dict_t *)&fontio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_fontio, fontio_module, CIRCUITPY_FONTIO); +MP_REGISTER_MODULE(MP_QSTR_fontio, fontio_module); diff --git a/shared-bindings/framebufferio/__init__.c b/shared-bindings/framebufferio/__init__.c index 324442268e..739c26f171 100644 --- a/shared-bindings/framebufferio/__init__.c +++ b/shared-bindings/framebufferio/__init__.c @@ -49,5 +49,5 @@ const mp_obj_module_t framebufferio_module = { .globals = (mp_obj_dict_t *)&framebufferio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_framebufferio, framebufferio_module, CIRCUITPY_FRAMEBUFFERIO); +MP_REGISTER_MODULE(MP_QSTR_framebufferio, framebufferio_module); #endif diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index bf09196e3d..c3ce5e94a7 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -73,8 +73,8 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 1, 1, true); - frequencyio_frequencyin_obj_t *self = m_new_obj(frequencyio_frequencyin_obj_t); - self->base.type = &frequencyio_frequencyin_type; + frequencyio_frequencyin_obj_t *self = + mp_obj_malloc(frequencyio_frequencyin_obj_t, &frequencyio_frequencyin_type); enum { ARG_pin, ARG_capture_period }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 18022c7f6e..80b60651de 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -71,4 +71,4 @@ const mp_obj_module_t frequencyio_module = { .globals = (mp_obj_dict_t *)&frequencyio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_frequencyio, frequencyio_module, CIRCUITPY_FREQUENCYIO); +MP_REGISTER_MODULE(MP_QSTR_frequencyio, frequencyio_module); diff --git a/shared-bindings/getpass/__init__.c b/shared-bindings/getpass/__init__.c index 811d78e03d..d6b65ec945 100644 --- a/shared-bindings/getpass/__init__.c +++ b/shared-bindings/getpass/__init__.c @@ -84,4 +84,4 @@ const mp_obj_module_t getpass_module = { .globals = (mp_obj_dict_t *)&getpass_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_getpass, getpass_module, CIRCUITPY_GETPASS); +MP_REGISTER_MODULE(MP_QSTR_getpass, getpass_module); diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index a0de52e2cc..e28d48bb99 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -73,8 +73,7 @@ static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_arg own_file = true; } - gifio_gifwriter_t *self = m_new_obj(gifio_gifwriter_t); - self->base.type = &gifio_gifwriter_type; + gifio_gifwriter_t *self = mp_obj_malloc(gifio_gifwriter_t, &gifio_gifwriter_type); shared_module_gifio_gifwriter_construct( self, file, diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index e4335f9e44..ec120f5838 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -135,8 +135,7 @@ STATIC mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_arg mp_raise_TypeError(translate("file must be a file opened in byte mode")); } - gifio_ondiskgif_t *self = m_new_obj(gifio_ondiskgif_t); - self->base.type = &gifio_ondiskgif_type; + gifio_ondiskgif_t *self = mp_obj_malloc(gifio_ondiskgif_t, &gifio_ondiskgif_type); common_hal_gifio_ondiskgif_construct(self, MP_OBJ_TO_PTR(filename), args[ARG_use_palette].u_bool); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/gifio/__init__.c b/shared-bindings/gifio/__init__.c index bfc87f0d99..7691a6cedb 100644 --- a/shared-bindings/gifio/__init__.c +++ b/shared-bindings/gifio/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t gifio_module = { .globals = (mp_obj_dict_t *)&gifio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_gifio, gifio_module, CIRCUITPY_GIFIO); +MP_REGISTER_MODULE(MP_QSTR_gifio, gifio_module); diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index d3c9547787..54b3f0b46c 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -37,8 +37,7 @@ //| :param system: satellite system to use""" //| ... STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - gnss_obj_t *self = m_new_obj(gnss_obj_t); - self->base.type = &gnss_type; + gnss_obj_t *self = mp_obj_malloc(gnss_obj_t, &gnss_type); enum { ARG_system }; static const mp_arg_t allowed_args[] = { { MP_QSTR_system, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/gnss/__init__.c b/shared-bindings/gnss/__init__.c index 6029e1a54e..7fe1b06e16 100644 --- a/shared-bindings/gnss/__init__.c +++ b/shared-bindings/gnss/__init__.c @@ -29,4 +29,4 @@ const mp_obj_module_t gnss_module = { .globals = (mp_obj_dict_t *)&gnss_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_gnss, gnss_module, CIRCUITPY_GNSS); +MP_REGISTER_MODULE(MP_QSTR_gnss, gnss_modulex); diff --git a/shared-bindings/hashlib/__init__.c b/shared-bindings/hashlib/__init__.c index 424159f84c..87f6df495a 100644 --- a/shared-bindings/hashlib/__init__.c +++ b/shared-bindings/hashlib/__init__.c @@ -57,8 +57,7 @@ STATIC mp_obj_t hashlib_new(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k const char *algorithm = mp_obj_str_get_str(args[ARG_name].u_obj); - hashlib_hash_obj_t *self = m_new_obj(hashlib_hash_obj_t); - self->base.type = &hashlib_hash_type; + hashlib_hash_obj_t *self = mp_obj_malloc(hashlib_hash_obj_t, &hashlib_hash_type); if (!common_hal_hashlib_new(self, algorithm)) { mp_raise_ValueError(translate("Unsupported hash algorithm")); @@ -87,4 +86,4 @@ const mp_obj_module_t hashlib_module = { .globals = (mp_obj_dict_t *)&hashlib_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_hashlib, hashlib_module, CIRCUITPY_HASHLIB); +MP_REGISTER_MODULE(MP_QSTR_hashlib, hashlib_module); diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index a07d038c6f..4346362632 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -40,8 +40,8 @@ #include "py/runtime.h" STATIC mp_obj_t mp_obj_new_i2ctarget_i2c_target_request(i2ctarget_i2c_target_obj_t *target, uint8_t address, bool is_read, bool is_restart) { - i2ctarget_i2c_target_request_obj_t *self = m_new_obj(i2ctarget_i2c_target_request_obj_t); - self->base.type = &i2ctarget_i2c_target_request_type; + i2ctarget_i2c_target_request_obj_t *self = + mp_obj_malloc(i2ctarget_i2c_target_request_obj_t, &i2ctarget_i2c_target_request_type) self->target = target; self->address = address; self->is_read = is_read; @@ -69,8 +69,7 @@ STATIC mp_obj_t mp_obj_new_i2ctarget_i2c_target_request(i2ctarget_i2c_target_obj //| :param bool smbus: Use SMBUS timings if the hardware supports it""" //| ... STATIC mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - i2ctarget_i2c_target_obj_t *self = m_new_obj(i2ctarget_i2c_target_obj_t); - self->base.type = &i2ctarget_i2c_target_type; + i2ctarget_i2c_target_obj_t *self = mp_obj_malloc(i2ctarget_i2c_target_obj_t, &i2ctarget_i2c_target_type); enum { ARG_scl, ARG_sda, ARG_addresses, ARG_smbus }; static const mp_arg_t allowed_args[] = { { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/i2ctarget/__init__.c b/shared-bindings/i2ctarget/__init__.c index 0fa7e50dd6..f9a358eef4 100644 --- a/shared-bindings/i2ctarget/__init__.c +++ b/shared-bindings/i2ctarget/__init__.c @@ -106,7 +106,4 @@ const mp_obj_module_t i2ctarget_module = { .globals = (mp_obj_dict_t *)&i2ctarget_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_i2ctarget, i2ctarget_module, CIRCUITPY_I2CTARGET); - -// TODO: Remove for CircuitPython 9.0.0 -MP_REGISTER_MODULE(MP_QSTR_i2cperipheral, i2ctarget_module, CIRCUITPY_I2CTARGET); +MP_REGISTER_MODULE(MP_QSTR_i2ctarget, i2ctarget_module); diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index d568da158f..56d7bfbc48 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -76,8 +76,8 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t * const mcu_pin_obj_t *vsync = validate_obj_is_free_pin_or_none(args[ARG_vsync].u_obj, MP_QSTR_vsync); const mcu_pin_obj_t *href = validate_obj_is_free_pin_or_none(args[ARG_href].u_obj, MP_QSTR_href); - imagecapture_parallelimagecapture_obj_t *self = m_new_obj(imagecapture_parallelimagecapture_obj_t); - self->base.type = &imagecapture_parallelimagecapture_type; + imagecapture_parallelimagecapture_obj_t *self = + mp_obj_malloc(imagecapture_parallelimagecapture_obj_t, &imagecapture_parallelimagecapture_type); common_hal_imagecapture_parallelimagecapture_construct(self, pins, pin_count, clock, vsync, href); diff --git a/shared-bindings/imagecapture/__init__.c b/shared-bindings/imagecapture/__init__.c index 71d0b9125b..de30ec24ba 100644 --- a/shared-bindings/imagecapture/__init__.c +++ b/shared-bindings/imagecapture/__init__.c @@ -50,4 +50,4 @@ const mp_obj_module_t imagecapture_module = { .globals = (mp_obj_dict_t *)&imagecapture_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_imagecapture, imagecapture_module, CIRCUITPY_IMAGECAPTURE); +MP_REGISTER_MODULE(MP_QSTR_imagecapture, imagecapture_module); diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index b9a2363e09..4f7cfc3853 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -77,8 +77,7 @@ STATIC mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t } - ipaddress_ipv4address_obj_t *self = m_new_obj(ipaddress_ipv4address_obj_t); - self->base.type = &ipaddress_ipv4address_type; + ipaddress_ipv4address_obj_t *self = mp_obj_malloc(ipaddress_ipv4address_obj_t, &ipaddress_ipv4address_type); common_hal_ipaddress_ipv4address_construct(self, buf, 4); diff --git a/shared-bindings/ipaddress/__init__.c b/shared-bindings/ipaddress/__init__.c index 6da5a52299..eb2b8f8ff6 100644 --- a/shared-bindings/ipaddress/__init__.c +++ b/shared-bindings/ipaddress/__init__.c @@ -112,4 +112,4 @@ const mp_obj_module_t ipaddress_module = { .globals = (mp_obj_dict_t *)&ipaddress_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ipaddress, ipaddress_module, CIRCUITPY_IPADDRESS); +MP_REGISTER_MODULE(MP_QSTR_ipaddress, ipaddress_module); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 17b12da67a..79982b4c90 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -57,8 +57,7 @@ STATIC mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus); - is31fl3741_IS31FL3741_obj_t *self = m_new_obj(is31fl3741_IS31FL3741_obj_t); - self->base.type = &is31fl3741_IS31FL3741_type; + is31fl3741_IS31FL3741_obj_t *self = mp_obj_malloc(is31fl3741_IS31FL3741_obj_t, &is31fl3741_IS31FL3741_type); common_hal_is31fl3741_IS31FL3741_construct(self, MP_OBJ_TO_PTR(i2c), diff --git a/shared-bindings/is31fl3741/__init__.c b/shared-bindings/is31fl3741/__init__.c index 605889700c..d7fbc5f6e6 100644 --- a/shared-bindings/is31fl3741/__init__.c +++ b/shared-bindings/is31fl3741/__init__.c @@ -47,4 +47,4 @@ const mp_obj_module_t is31fl3741_module = { .globals = (mp_obj_dict_t *)&is31fl3741_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_is31fl3741, is31fl3741_module, CIRCUITPY_IS31FL3741); +MP_REGISTER_MODULE(MP_QSTR_is31fl3741, is31fl3741_module); diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 52c574e692..1a3db1c61f 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -45,8 +45,7 @@ //| """ //| ... STATIC mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - keypad_event_obj_t *self = m_new_obj(keypad_event_obj_t); - self->base.type = &keypad_event_type; + keypad_event_obj_t *self = mp_obj_malloc(keypad_event_obj_t, &keypad_event_type); enum { ARG_key_number, ARG_pressed, ARG_timestamp }; static const mp_arg_t allowed_args[] = { { MP_QSTR_key_number, MP_ARG_INT, {.u_int = 0} }, diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index 2209f3f68f..32787f8e9d 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -72,8 +72,7 @@ STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_KEYMATRIX - keypad_keymatrix_obj_t *self = m_new_obj(keypad_keymatrix_obj_t); - self->base.type = &keypad_keymatrix_type; + keypad_keymatrix_obj_t *self = mp_obj_malloc(keypad_keymatrix_obj_t, &keypad_keymatrix_type); enum { ARG_row_pins, ARG_column_pins, ARG_columns_to_anodes, ARG_interval, ARG_max_events }; static const mp_arg_t allowed_args[] = { { MP_QSTR_row_pins, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 2481fedc6b..63a27425f5 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -74,8 +74,7 @@ STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_KEYS - keypad_keys_obj_t *self = m_new_obj(keypad_keys_obj_t); - self->base.type = &keypad_keys_type; + keypad_keys_obj_t *self = mp_obj_malloc(keypad_keys_obj_t, &keypad_keys_type); enum { ARG_pins, ARG_value_when_pressed, ARG_pull, ARG_interval, ARG_max_events }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pins, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 1fcf517ac3..fc8ec64914 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -83,8 +83,8 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS - keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t); - self->base.type = &keypad_shiftregisterkeys_type; + keypad_shiftregisterkeys_obj_t *self = + mp_obj_malloc(keypad_shiftregisterkeys_obj_t, &keypad_shiftregisterkeys_type); enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/keypad/__init__.c b/shared-bindings/keypad/__init__.c index 7dd76c1947..263e324b9b 100644 --- a/shared-bindings/keypad/__init__.c +++ b/shared-bindings/keypad/__init__.c @@ -107,4 +107,4 @@ const mp_obj_module_t keypad_module = { .globals = (mp_obj_dict_t *)&keypad_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_keypad, keypad_module, CIRCUITPY_KEYPAD); +MP_REGISTER_MODULE(MP_QSTR_keypad, keypad_module); diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 8aee44ffb8..2c17532197 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -473,6 +473,6 @@ const mp_obj_module_t math_module = { .globals = (mp_obj_dict_t *)&mp_module_math_globals, }; -MP_REGISTER_MODULE(MP_QSTR_math, math_module, CIRCUITPY_MATH); +MP_REGISTER_MODULE(MP_QSTR_math, math_module); #endif // MICROPY_PY_BUILTINS_FLOAT diff --git a/shared-bindings/mdns/__init__.c b/shared-bindings/mdns/__init__.c index 73bd71c65c..2a8cd85e39 100644 --- a/shared-bindings/mdns/__init__.c +++ b/shared-bindings/mdns/__init__.c @@ -52,4 +52,4 @@ const mp_obj_module_t mdns_module = { .globals = (mp_obj_dict_t *)&mdns_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_mdns, mdns_module, CIRCUITPY_MDNS); +MP_REGISTER_MODULE(MP_QSTR_mdns, mdns_module); diff --git a/shared-bindings/memorymap/AddressRange.c b/shared-bindings/memorymap/AddressRange.c index fb55c07efe..7fd1062534 100644 --- a/shared-bindings/memorymap/AddressRange.c +++ b/shared-bindings/memorymap/AddressRange.c @@ -69,8 +69,7 @@ STATIC mp_obj_t memorymap_addressrange_make_new(const mp_obj_type_t *type, size_ mp_arg_validate_int_min(args[ARG_length].u_int, 1, MP_QSTR_length); - memorymap_addressrange_obj_t *self = m_new_obj(memorymap_addressrange_obj_t); - self->base.type = &memorymap_addressrange_type; + memorymap_addressrange_obj_t *self = mp_obj_malloc(memorymap_addressrange_obj_t, &memorymap_addressrange_type); common_hal_memorymap_addressrange_construct(self, (uint8_t *)start, length); diff --git a/shared-bindings/memorymap/__init__.c b/shared-bindings/memorymap/__init__.c index 576c7f1e1d..a276e371ba 100644 --- a/shared-bindings/memorymap/__init__.c +++ b/shared-bindings/memorymap/__init__.c @@ -49,4 +49,4 @@ const mp_obj_module_t memorymap_module = { .globals = (mp_obj_dict_t *)&memorymap_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_memorymap, memorymap_module, CIRCUITPY_MEMORYMAP); +MP_REGISTER_MODULE(MP_QSTR_memorymap, memorymap_module); diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index e279fa6854..a21a14b2f0 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -66,8 +66,8 @@ STATIC mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type mp_arg_validate_int_min(args[ARG_minimum_block_count].u_int, 1, MP_QSTR_minimum_block_count); - memorymonitor_allocationalarm_obj_t *self = m_new_obj(memorymonitor_allocationalarm_obj_t); - self->base.type = &memorymonitor_allocationalarm_type; + memorymonitor_allocationalarm_obj_t *self = + mp_obj_malloc(memorymonitor_allocationalarm_obj_t, &memorymonitor_allocationalarm_type); common_hal_memorymonitor_allocationalarm_construct(self, minimum_block_count); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index dd3a1e03cf..3340f51615 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -62,8 +62,8 @@ //| """ //| ... STATIC mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { - memorymonitor_allocationsize_obj_t *self = m_new_obj(memorymonitor_allocationsize_obj_t); - self->base.type = &memorymonitor_allocationsize_type; + memorymonitor_allocationsize_obj_t *self = + m_new_obj(memorymonitor_allocationsize_obj_t, &memorymonitor_allocationsize_type); common_hal_memorymonitor_allocationsize_construct(self); diff --git a/shared-bindings/memorymonitor/__init__.c b/shared-bindings/memorymonitor/__init__.c index 7b05acd095..9ee0d46bf0 100644 --- a/shared-bindings/memorymonitor/__init__.c +++ b/shared-bindings/memorymonitor/__init__.c @@ -77,4 +77,4 @@ const mp_obj_module_t memorymonitor_module = { .globals = (mp_obj_dict_t *)&memorymonitor_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_memorymonitor, memorymonitor_module, CIRCUITPY_MEMORYMONITOR); +MP_REGISTER_MODULE(MP_QSTR_memorymonitor, memorymonitor_module); diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 2c1fdd5b58..3858cad776 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -192,4 +192,4 @@ const mp_obj_module_t microcontroller_module = { .globals = (mp_obj_dict_t *)&mcu_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_microcontroller, microcontroller_module, CIRCUITPY_MICROCONTROLLER); +MP_REGISTER_MODULE(MP_QSTR_microcontroller, microcontroller_module); diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 7bfe3bd8bd..15e30c1575 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -37,8 +37,7 @@ //| :param int code: type code in range 0~127. //| :param bytes data: representation.""" STATIC mp_obj_t mod_msgpack_exttype_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - mod_msgpack_extype_obj_t *self = m_new_obj(mod_msgpack_extype_obj_t); - self->base.type = &mod_msgpack_exttype_type; + mod_msgpack_extype_obj_t *self = mp_obj_malloc(mod_msgpack_extype_obj_t, &mod_msgpack_exttype_type); enum { ARG_code, ARG_data }; static const mp_arg_t allowed_args[] = { { MP_QSTR_code, MP_ARG_INT | MP_ARG_REQUIRED }, diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index 7773d6d190..fb4fe63304 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -174,4 +174,4 @@ const mp_obj_module_t msgpack_module = { .globals = (mp_obj_dict_t *)&msgpack_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_msgpack, msgpack_module, CIRCUITPY_MSGPACK); +MP_REGISTER_MODULE(MP_QSTR_msgpack, msgpack_module); diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index cc0e2a041a..8a471f26ff 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -140,4 +140,4 @@ const mp_obj_module_t neopixel_write_module = { .globals = (mp_obj_dict_t *)&neopixel_write_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_neopixel_write, neopixel_write_module, CIRCUITPY_NEOPIXEL_WRITE); +MP_REGISTER_MODULE(MP_QSTR_neopixel_write, neopixel_write_module); diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index 0ecadd9880..ff553741a9 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -51,4 +51,4 @@ const mp_obj_module_t nvm_module = { .globals = (mp_obj_dict_t *)&nvm_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_nvm, nvm_module, CIRCUITPY_NVM); +MP_REGISTER_MODULE(MP_QSTR_nvm, nvm_module); diff --git a/shared-bindings/onewireio/OneWire.c b/shared-bindings/onewireio/OneWire.c index 3f0dc87722..f52ebb4c6a 100644 --- a/shared-bindings/onewireio/OneWire.c +++ b/shared-bindings/onewireio/OneWire.c @@ -62,8 +62,7 @@ STATIC mp_obj_t onewireio_onewire_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin); - onewireio_onewire_obj_t *self = m_new_obj(onewireio_onewire_obj_t); - self->base.type = &onewireio_onewire_type; + onewireio_onewire_obj_t *self = mp_obj_malloc(onewireio_onewire_obj_t, &onewireio_onewire_type); common_hal_onewireio_onewire_construct(self, pin); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/onewireio/__init__.c b/shared-bindings/onewireio/__init__.c index 282192179b..869300deba 100644 --- a/shared-bindings/onewireio/__init__.c +++ b/shared-bindings/onewireio/__init__.c @@ -51,4 +51,4 @@ const mp_obj_module_t onewireio_module = { .globals = (mp_obj_dict_t *)&onewireio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_onewireio, onewireio_module, CIRCUITPY_ONEWIREIO); +MP_REGISTER_MODULE(MP_QSTR_onewireio, onewireio_module); diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index e9e5f0885f..881c95d696 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -300,4 +300,4 @@ const mp_obj_module_t os_module = { .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, os_module, CIRCUITPY_OS); +MP_REGISTER_MODULE(MP_QSTR_os, os_module); diff --git a/shared-bindings/paralleldisplay/__init__.c b/shared-bindings/paralleldisplay/__init__.c index e87479a9f9..de4492f550 100644 --- a/shared-bindings/paralleldisplay/__init__.c +++ b/shared-bindings/paralleldisplay/__init__.c @@ -48,4 +48,4 @@ const mp_obj_module_t paralleldisplay_module = { .globals = (mp_obj_dict_t *)¶lleldisplay_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_paralleldisplay, paralleldisplay_module, CIRCUITPY_PARALLELDISPLAY); +MP_REGISTER_MODULE(MP_QSTR_paralleldisplay, paralleldisplay_module); diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 67cffc9f7b..789e1173c8 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -78,8 +78,7 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, siz const mcu_pin_obj_t *clock_pin = validate_obj_is_free_pin(args[ARG_clock_pin].u_obj, MP_QSTR_clock_pin); const mcu_pin_obj_t *data_pin = validate_obj_is_free_pin(args[ARG_data_pin].u_obj, MP_QSTR_data_pin); - ps2io_ps2_obj_t *self = m_new_obj(ps2io_ps2_obj_t); - self->base.type = &ps2io_ps2_type; + ps2io_ps2_obj_t *self = mp_obj_malloc(ps2io_ps2_obj_t, &ps2io_ps2_type); common_hal_ps2io_ps2_construct(self, data_pin, clock_pin); diff --git a/shared-bindings/ps2io/__init__.c b/shared-bindings/ps2io/__init__.c index 6857744036..e6aed10955 100644 --- a/shared-bindings/ps2io/__init__.c +++ b/shared-bindings/ps2io/__init__.c @@ -57,4 +57,4 @@ const mp_obj_module_t ps2io_module = { .globals = (mp_obj_dict_t *)&ps2io_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ps2io, ps2io_module, CIRCUITPY_PS2IO); +MP_REGISTER_MODULE(MP_QSTR_ps2io, ps2io_module); diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 2af07a46d8..16777d9843 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -81,8 +81,7 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar mp_int_t frequency = args[ARG_frequency].u_int; mp_int_t duty_cycle = args[ARG_duty_cycle].u_int; - pulseio_pulseout_obj_t *self = m_new_obj(pulseio_pulseout_obj_t); - self->base.type = &pulseio_pulseout_type; + pulseio_pulseout_obj_t *self = mp_obj_malloc(pulseio_pulseout_obj_t, &pulseio_pulseout_type); common_hal_pulseio_pulseout_construct(self, pin, frequency, duty_cycle); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/pulseio/__init__.c b/shared-bindings/pulseio/__init__.c index c062cedd11..b8a190ef5d 100644 --- a/shared-bindings/pulseio/__init__.c +++ b/shared-bindings/pulseio/__init__.c @@ -58,4 +58,4 @@ const mp_obj_module_t pulseio_module = { .globals = (mp_obj_dict_t *)&pulseio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_pulseio, pulseio_module, CIRCUITPY_PULSEIO); +MP_REGISTER_MODULE(MP_QSTR_pulseio, pulseio_module); diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 784f87a025..0c99e26a7d 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -176,8 +176,7 @@ STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, bool variable_frequency = parsed_args[ARG_variable_frequency].u_bool; // create PWM object from the given pin - pwmio_pwmout_obj_t *self = m_new_obj(pwmio_pwmout_obj_t); - self->base.type = &pwmio_pwmout_type; + pwmio_pwmout_obj_t *self = mp_obj_malloc(pwmio_pwmout_obj_t, &pwmio_pwmout_type); pwmout_result_t result = common_hal_pwmio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency); common_hal_pwmio_pwmout_raise_error(result); diff --git a/shared-bindings/pwmio/__init__.c b/shared-bindings/pwmio/__init__.c index 6aeaf9c3c8..38388fec84 100644 --- a/shared-bindings/pwmio/__init__.c +++ b/shared-bindings/pwmio/__init__.c @@ -74,4 +74,4 @@ const mp_obj_module_t pwmio_module = { .globals = (mp_obj_dict_t *)&pwmio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_pwmio, pwmio_module, CIRCUITPY_PWMIO); +MP_REGISTER_MODULE(MP_QSTR_pwmio, pwmio_module); diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index b37a14fd8f..e8cabade33 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -50,8 +50,7 @@ STATIC mp_obj_t qrio_qrdecoder_make_new(const mp_obj_type_t *type, size_t n_args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, args_in, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - qrio_qrdecoder_obj_t *self = m_new_obj(qrio_qrdecoder_obj_t); - self->base.type = &qrio_qrdecoder_type_obj; + qrio_qrdecoder_obj_t *self = mp_obj_malloc(qrio_qrdecoder_obj_t, &qrio_qrdecoder_type_obj); shared_module_qrio_qrdecoder_construct(self, args[ARG_width].u_int, args[ARG_height].u_int); return self; diff --git a/shared-bindings/qrio/__init__.c b/shared-bindings/qrio/__init__.c index 18c74b9a88..3daee820ed 100644 --- a/shared-bindings/qrio/__init__.c +++ b/shared-bindings/qrio/__init__.c @@ -55,4 +55,4 @@ const mp_obj_module_t qrio_module = { .globals = (mp_obj_dict_t *)&qrio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_qrio, qrio_module, CIRCUITPY_QRIO); +MP_REGISTER_MODULE(MP_QSTR_qrio, qrio_module); diff --git a/shared-bindings/rainbowio/__init__.c b/shared-bindings/rainbowio/__init__.c index 324f43198e..b4a5536588 100644 --- a/shared-bindings/rainbowio/__init__.c +++ b/shared-bindings/rainbowio/__init__.c @@ -55,4 +55,4 @@ const mp_obj_module_t rainbowio_module = { .globals = (mp_obj_dict_t *)&rainbowio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_rainbowio, rainbowio_module, CIRCUITPY_RAINBOWIO); +MP_REGISTER_MODULE(MP_QSTR_rainbowio, rainbowio_module); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 33cd9e90d0..6fa9629f8c 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -189,4 +189,4 @@ const mp_obj_module_t random_module = { .globals = (mp_obj_dict_t *)&mp_module_random_globals, }; -MP_REGISTER_MODULE(MP_QSTR_random, random_module, CIRCUITPY_RANDOM); +MP_REGISTER_MODULE(MP_QSTR_random, random_module); diff --git a/shared-bindings/rgbmatrix/__init__.c b/shared-bindings/rgbmatrix/__init__.c index 1e9099adb6..d89abf17e3 100644 --- a/shared-bindings/rgbmatrix/__init__.c +++ b/shared-bindings/rgbmatrix/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t rgbmatrix_module = { .globals = (mp_obj_dict_t *)&rgbmatrix_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_rgbmatrix, rgbmatrix_module, CIRCUITPY_RGBMATRIX); +MP_REGISTER_MODULE(MP_QSTR_rgbmatrix, rgbmatrix_module); diff --git a/shared-bindings/rotaryio/__init__.c b/shared-bindings/rotaryio/__init__.c index e549ecc75e..d8348eb958 100644 --- a/shared-bindings/rotaryio/__init__.c +++ b/shared-bindings/rotaryio/__init__.c @@ -59,4 +59,4 @@ const mp_obj_module_t rotaryio_module = { .globals = (mp_obj_dict_t *)&rotaryio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_rotaryio, rotaryio_module, CIRCUITPY_ROTARYIO); +MP_REGISTER_MODULE(MP_QSTR_rotaryio, rotaryio_module); diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index 0220745c0f..e1220841eb 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -87,4 +87,4 @@ const mp_obj_module_t rtc_module = { .globals = (mp_obj_dict_t *)&rtc_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_rtc, rtc_module, CIRCUITPY_RTC); +MP_REGISTER_MODULE(MP_QSTR_rtc, rtc_module); diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index ce67834774..4bceefba45 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -92,8 +92,7 @@ STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_arg busio_spi_obj_t *spi = validate_obj_is_spi_bus(args[ARG_spi].u_obj, MP_QSTR_spi); const mcu_pin_obj_t *cs = validate_obj_is_free_pin(args[ARG_cs].u_obj, MP_QSTR_cs); - sdcardio_sdcard_obj_t *self = m_new_obj(sdcardio_sdcard_obj_t); - self->base.type = &sdcardio_SDCard_type; + sdcardio_sdcard_obj_t *self = mp_obj_malloc(sdcardio_sdcard_obj_t, &sdcardio_SDCard_type); common_hal_sdcardio_sdcard_construct(self, spi, cs, args[ARG_baudrate].u_int); diff --git a/shared-bindings/sdcardio/__init__.c b/shared-bindings/sdcardio/__init__.c index c64a8a38e4..da97af685c 100644 --- a/shared-bindings/sdcardio/__init__.c +++ b/shared-bindings/sdcardio/__init__.c @@ -46,4 +46,4 @@ const mp_obj_module_t sdcardio_module = { .globals = (mp_obj_dict_t *)&sdcardio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_sdcardio, sdcardio_module, CIRCUITPY_SDCARDIO); +MP_REGISTER_MODULE(MP_QSTR_sdcardio, sdcardio_module); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index 776b20fafe..7ff4fb750a 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -84,8 +84,7 @@ //| ... STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - sdioio_sdcard_obj_t *self = m_new_obj(sdioio_sdcard_obj_t); - self->base.type = &sdioio_SDCard_type; + sdioio_sdcard_obj_t *self = mp_obj_malloc(sdioio_sdcard_obj_t, &sdioio_SDCard_type); enum { ARG_clock, ARG_command, ARG_data, ARG_frequency, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ }, diff --git a/shared-bindings/sdioio/__init__.c b/shared-bindings/sdioio/__init__.c index 5204da22a4..0d15a3e5d3 100644 --- a/shared-bindings/sdioio/__init__.c +++ b/shared-bindings/sdioio/__init__.c @@ -46,4 +46,4 @@ const mp_obj_module_t sdioio_module = { .globals = (mp_obj_dict_t *)&sdioio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_sdioio, sdioio_module, CIRCUITPY_SDIOIO); +MP_REGISTER_MODULE(MP_QSTR_sdioio, sdioio_module); diff --git a/shared-bindings/sharpdisplay/__init__.c b/shared-bindings/sharpdisplay/__init__.c index 4726e6ea1c..90e99eea1d 100644 --- a/shared-bindings/sharpdisplay/__init__.c +++ b/shared-bindings/sharpdisplay/__init__.c @@ -48,4 +48,4 @@ const mp_obj_module_t sharpdisplay_module = { .globals = (mp_obj_dict_t *)&sharpdisplay_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_sharpdisplay, sharpdisplay_module, CIRCUITPY_SHARPDISPLAY); +MP_REGISTER_MODULE(MP_QSTR_sharpdisplay, sharpdisplay_module); diff --git a/shared-bindings/socketpool/__init__.c b/shared-bindings/socketpool/__init__.c index 48cc00245f..53993a978c 100644 --- a/shared-bindings/socketpool/__init__.c +++ b/shared-bindings/socketpool/__init__.c @@ -54,4 +54,4 @@ const mp_obj_module_t socketpool_module = { .globals = (mp_obj_dict_t *)&socketpool_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socketpool, socketpool_module, CIRCUITPY_SOCKETPOOL); +MP_REGISTER_MODULE(MP_QSTR_socketpool, socketpool_module); diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index ac5f7ad42d..cdb36685b3 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -45,8 +45,7 @@ STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); - ssl_sslcontext_obj_t *s = m_new_obj(ssl_sslcontext_obj_t); - s->base.type = &ssl_sslcontext_type; + ssl_sslcontext_obj_t *s = mp_obj_malloc(ssl_sslcontext_obj_t, &ssl_sslcontext_type); common_hal_ssl_sslcontext_construct(s); diff --git a/shared-bindings/ssl/__init__.c b/shared-bindings/ssl/__init__.c index 6967860054..2e298163be 100644 --- a/shared-bindings/ssl/__init__.c +++ b/shared-bindings/ssl/__init__.c @@ -44,8 +44,7 @@ //| STATIC mp_obj_t ssl_create_default_context(void) { - ssl_sslcontext_obj_t *s = m_new_obj(ssl_sslcontext_obj_t); - s->base.type = &ssl_sslcontext_type; + ssl_sslcontext_obj_t *s = mp_obj_malloc(ssl_sslcontext_obj_t, &ssl_sslcontext_type); common_hal_ssl_create_default_context(s); return s; @@ -67,4 +66,4 @@ const mp_obj_module_t ssl_module = { .globals = (mp_obj_dict_t *)&ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, ssl_module, CIRCUITPY_SSL); +MP_REGISTER_MODULE(MP_QSTR_ssl, ssl_module); diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index c4bd728f67..b774c5550e 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -314,4 +314,4 @@ const mp_obj_module_t storage_module = { .globals = (mp_obj_dict_t *)&storage_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_storage, storage_module, CIRCUITPY_STORAGE); +MP_REGISTER_MODULE(MP_QSTR_storage, storage_module); diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index 5b63a15f15..519b1ace66 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -178,4 +178,4 @@ const mp_obj_module_t struct_module = { .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; -MP_REGISTER_MODULE(MP_QSTR_struct, struct_module, CIRCUITPY_STRUCT); +MP_REGISTER_MODULE(MP_QSTR_struct, struct_module); diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 491cac2f17..a1820e215e 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -233,8 +233,7 @@ STATIC mp_obj_t supervisor_get_previous_traceback(void) { if (prev_traceback_allocation) { size_t len = strlen((const char *)prev_traceback_allocation->ptr); if (len > 0) { - mp_obj_str_t *o = m_new_obj(mp_obj_str_t); - o->base.type = &mp_type_str; + mp_obj_str_t *o = mp_obj_malloc(mp_obj_str_t, &mp_type_str); o->len = len; // callers probably aren't going to compare this string, so skip computing the hash o->hash = 0; @@ -356,4 +355,4 @@ const mp_obj_module_t supervisor_module = { .globals = (mp_obj_dict_t *)&supervisor_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_supervisor, supervisor_module, CIRCUITPY_SUPERVISOR); +MP_REGISTER_MODULE(MP_QSTR_supervisor, supervisor_module); diff --git a/shared-bindings/synthio/LFO.c b/shared-bindings/synthio/LFO.c index 00be16a15c..86e32999cf 100644 --- a/shared-bindings/synthio/LFO.c +++ b/shared-bindings/synthio/LFO.c @@ -88,8 +88,7 @@ STATIC mp_obj_t synthio_lfo_make_new(const mp_obj_type_t *type_in, size_t n_args mp_arg_val_t args[MP_ARRAY_SIZE(lfo_properties)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(lfo_properties), lfo_properties, args); - synthio_lfo_obj_t *self = m_new_obj(synthio_lfo_obj_t); - self->base.base.type = &synthio_lfo_type; + synthio_lfo_obj_t *self = mp_obj_malloc(synthio_lfo_obj_t, &synthio_lfo_type); self->waveform_bufinfo = ((mp_buffer_info_t) {.buf = (void *)triangle, .len = MP_ARRAY_SIZE(triangle)}); if (args[ARG_waveform].u_obj != mp_const_none) { diff --git a/shared-bindings/synthio/Math.c b/shared-bindings/synthio/Math.c index 57902b0dd0..ea75b7c4bf 100644 --- a/shared-bindings/synthio/Math.c +++ b/shared-bindings/synthio/Math.c @@ -172,8 +172,7 @@ STATIC mp_obj_t synthio_math_make_new(const mp_obj_type_t *type_in, size_t n_arg } STATIC mp_obj_t synthio_math_make_new_common(mp_arg_val_t args[MP_ARRAY_SIZE(math_properties)]) { - synthio_math_obj_t *self = m_new_obj(synthio_math_obj_t); - self->base.base.type = &synthio_math_type; + synthio_math_obj_t *self = mp_obj_malloc(synthio_math_obj_t, &synthio_math_type); self->base.last_tick = synthio_global_tick; diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 2d0d2ab69f..79af9e9744 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -88,8 +88,7 @@ STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_a mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); - synthio_miditrack_obj_t *self = m_new_obj(synthio_miditrack_obj_t); - self->base.type = &synthio_miditrack_type; + synthio_miditrack_obj_t *self = mp_obj_malloc(synthio_miditrack_obj_t, &synthio_miditrack_type); common_hal_synthio_miditrack_construct(self, (uint8_t *)bufinfo.buf, bufinfo.len, diff --git a/shared-bindings/synthio/Note.c b/shared-bindings/synthio/Note.c index 651bf8f33a..e6ce886054 100644 --- a/shared-bindings/synthio/Note.c +++ b/shared-bindings/synthio/Note.c @@ -70,8 +70,7 @@ STATIC mp_obj_t synthio_note_make_new(const mp_obj_type_t *type_in, size_t n_arg mp_arg_val_t args[MP_ARRAY_SIZE(note_properties)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(note_properties), note_properties, args); - synthio_note_obj_t *self = m_new_obj(synthio_note_obj_t); - self->base.type = &synthio_note_type; + synthio_note_obj_t *self = mp_obj_malloc(synthio_note_obj_t, &synthio_note_type); mp_obj_t result = MP_OBJ_FROM_PTR(self); properties_construct_helper(result, note_properties, args, MP_ARRAY_SIZE(note_properties)); diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c index 84882fa657..acdc1a989a 100644 --- a/shared-bindings/synthio/Synthesizer.c +++ b/shared-bindings/synthio/Synthesizer.c @@ -80,8 +80,7 @@ STATIC mp_obj_t synthio_synthesizer_make_new(const mp_obj_type_t *type, size_t n mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - synthio_synthesizer_obj_t *self = m_new_obj(synthio_synthesizer_obj_t); - self->base.type = &synthio_synthesizer_type; + synthio_synthesizer_obj_t *self = mp_obj_malloc(synthio_synthesizer_obj_t, &synthio_synthesizer_type); common_hal_synthio_synthesizer_construct(self, args[ARG_sample_rate].u_int, diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index b6185051fc..f9d9de86c7 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -252,8 +252,7 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma mp_arg_error_invalid(MP_QSTR_file); } - synthio_miditrack_obj_t *result = m_new_obj(synthio_miditrack_obj_t); - result->base.type = &synthio_miditrack_type; + synthio_miditrack_obj_t *result = mp_obj_malloc(synthio_miditrack_obj_t, &synthio_miditrack_type); common_hal_synthio_miditrack_construct(result, buffer, track_size, tempo, args[ARG_sample_rate].u_int, args[ARG_waveform].u_obj, @@ -332,4 +331,4 @@ const mp_obj_module_t synthio_module = { .globals = (mp_obj_dict_t *)&synthio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_synthio, synthio_module, CIRCUITPY_SYNTHIO); +MP_REGISTER_MODULE(MP_QSTR_synthio, synthio_module); diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 164999093a..05c10f2887 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -88,8 +88,7 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n mp_arg_validate_int_min(scroll_area->width_in_tiles, 2, MP_QSTR_scroll_area_width); mp_arg_validate_int_min(scroll_area->height_in_tiles, 2, MP_QSTR_scroll_area_height); - terminalio_terminal_obj_t *self = m_new_obj(terminalio_terminal_obj_t); - self->base.type = &terminalio_terminal_type; + terminalio_terminal_obj_t *self = mp_obj_malloc(terminalio_terminal_obj_t, &terminalio_terminal_type); common_hal_terminalio_terminal_construct(self, scroll_area, font, status_bar); return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/terminalio/__init__.c b/shared-bindings/terminalio/__init__.c index a5980a8b9b..3492390e5a 100644 --- a/shared-bindings/terminalio/__init__.c +++ b/shared-bindings/terminalio/__init__.c @@ -61,4 +61,4 @@ const mp_obj_module_t terminalio_module = { .globals = (mp_obj_dict_t *)&terminalio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_terminalio, terminalio_module, CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO); +MP_REGISTER_MODULE(MP_QSTR_terminalio, terminalio_module); diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index d02923f162..a4e5033def 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -343,4 +343,4 @@ const mp_obj_module_t time_module = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_time, time_module, CIRCUITPY_TIME); +MP_REGISTER_MODULE(MP_QSTR_time, time_module); diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 7f26149b00..64de6e18b0 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -65,8 +65,7 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, // 1st argument is the pin const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0], MP_QSTR_pin); - touchio_touchin_obj_t *self = m_new_obj(touchio_touchin_obj_t); - self->base.type = &touchio_touchin_type; + touchio_touchin_obj_t *self = mp_obj_malloc(touchio_touchin_obj_t, &touchio_touchin_type); common_hal_touchio_touchin_construct(self, pin); return (mp_obj_t)self; diff --git a/shared-bindings/touchio/__init__.c b/shared-bindings/touchio/__init__.c index 8501315ca7..502b3efa5a 100644 --- a/shared-bindings/touchio/__init__.c +++ b/shared-bindings/touchio/__init__.c @@ -71,4 +71,4 @@ const mp_obj_module_t touchio_module = { .globals = (mp_obj_dict_t *)&touchio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_touchio, touchio_module, CIRCUITPY_TOUCHIO); +MP_REGISTER_MODULE(MP_QSTR_touchio, touchio_module); diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 3ad601eb39..df1d605524 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -216,4 +216,4 @@ const mp_obj_module_t traceback_module = { .globals = (mp_obj_dict_t *)&traceback_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_traceback, traceback_module, CIRCUITPY_TRACEBACK); +MP_REGISTER_MODULE(MP_QSTR_traceback, traceback_module); diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c index 40aa869225..08a8592a4d 100644 --- a/shared-bindings/uheap/__init__.c +++ b/shared-bindings/uheap/__init__.c @@ -58,4 +58,4 @@ const mp_obj_module_t uheap_module = { .globals = (mp_obj_dict_t *)&uheap_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uheap, uheap_module, CIRCUITPY_UHEAP); +MP_REGISTER_MODULE(MP_QSTR_uheap, uheap_module); diff --git a/shared-bindings/usb/__init__.c b/shared-bindings/usb/__init__.c index 443d5cf788..224f50a46c 100644 --- a/shared-bindings/usb/__init__.c +++ b/shared-bindings/usb/__init__.c @@ -48,4 +48,4 @@ const mp_obj_module_t usb_module = { .globals = (mp_obj_dict_t *)&usb_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usb, usb_module, CIRCUITPY_USB_HOST); +MP_REGISTER_MODULE(MP_QSTR_usb, usb_module); diff --git a/shared-bindings/usb/core/__init__.c b/shared-bindings/usb/core/__init__.c index faeef23a88..6e7658aa27 100644 --- a/shared-bindings/usb/core/__init__.c +++ b/shared-bindings/usb/core/__init__.c @@ -100,8 +100,7 @@ STATIC mp_obj_t _next_device(usb_core_devices_obj_t *iter) { // We passed the filters. Now make a properly allocated object to // return to the user. - usb_core_device_obj_t *self = m_new_obj(usb_core_device_obj_t); - self->base.type = &usb_core_device_type; + usb_core_device_obj_t *self = mp_obj_malloc(usb_core_device_obj_t, &usb_core_device_type); common_hal_usb_core_device_construct(self, i); iter->next_index = i + 1; @@ -195,4 +194,4 @@ const mp_obj_module_t usb_core_module = { .globals = (mp_obj_dict_t *)&usb_core_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usb_dot_core, usb_core_module, CIRCUITPY_USB_HOST); +MP_REGISTER_MODULE(MP_QSTR_usb_dot_core, usb_core_module); diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index b4e712e854..e7a13a768a 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -142,4 +142,4 @@ void usb_cdc_set_data(mp_obj_t serial_obj) { set_module_dict_entry(MP_ROM_QSTR(MP_QSTR_data), serial_obj); } -MP_REGISTER_MODULE(MP_QSTR_usb_cdc, usb_cdc_module, CIRCUITPY_USB_CDC); +MP_REGISTER_MODULE(MP_QSTR_usb_cdc, usb_cdc_module); diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index cb88766b3e..34b496a90e 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -91,8 +91,7 @@ //| Uses Report ID 3 for its IN report.""" STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - usb_hid_device_obj_t *self = m_new_obj(usb_hid_device_obj_t); - self->base.type = &usb_hid_device_type; + usb_hid_device_obj_t *self = mp_obj_malloc(usb_hid_device_obj_t, &usb_hid_device_type); enum { ARG_report_descriptor, ARG_usage_page, ARG_usage, ARG_report_ids, ARG_in_report_lengths, ARG_out_report_lengths }; static const mp_arg_t allowed_args[] = { { MP_QSTR_report_descriptor, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 5c61cc52de..2f374084bb 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -182,4 +182,4 @@ void usb_hid_set_devices(mp_obj_t devices) { } } -MP_REGISTER_MODULE(MP_QSTR_usb_hid, usb_hid_module, CIRCUITPY_USB_HID); +MP_REGISTER_MODULE(MP_QSTR_usb_hid, usb_hid_module); diff --git a/shared-bindings/usb_host/Port.c b/shared-bindings/usb_host/Port.c index 53b1fec54f..fdb077d0e5 100644 --- a/shared-bindings/usb_host/Port.c +++ b/shared-bindings/usb_host/Port.c @@ -50,8 +50,7 @@ STATIC mp_obj_t usb_host_port_make_new(const mp_obj_type_t *type, const mcu_pin_obj_t *dp = validate_obj_is_free_pin(args[0], MP_QSTR_dp); const mcu_pin_obj_t *dm = validate_obj_is_free_pin(args[1], MP_QSTR_dm); - usb_host_port_obj_t *self = m_new_obj(usb_host_port_obj_t); - self->base.type = &usb_host_port_type; + usb_host_port_obj_t *self = mp_obj_malloc(usb_host_port_obj_t, &usb_host_port_type); common_hal_usb_host_port_construct(self, dp, dm); return (mp_obj_t)self; diff --git a/shared-bindings/usb_host/__init__.c b/shared-bindings/usb_host/__init__.c index 5c884b3ec2..f7337b1fce 100644 --- a/shared-bindings/usb_host/__init__.c +++ b/shared-bindings/usb_host/__init__.c @@ -49,4 +49,4 @@ const mp_obj_module_t usb_host_module = { .globals = (mp_obj_dict_t *)&usb_host_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usb_host, usb_host_module, CIRCUITPY_USB_HOST); +MP_REGISTER_MODULE(MP_QSTR_usb_host, usb_host_module); diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index d3d5cf2626..651f4a51d1 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -96,4 +96,4 @@ const mp_obj_module_t usb_midi_module = { .globals = (mp_obj_dict_t *)&usb_midi_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usb_midi, usb_midi_module, CIRCUITPY_USB_MIDI); +MP_REGISTER_MODULE(MP_QSTR_usb_midi, usb_midi_module); diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c index 17bdcbb1c0..b3850e42ab 100644 --- a/shared-bindings/ustack/__init__.c +++ b/shared-bindings/ustack/__init__.c @@ -86,4 +86,4 @@ const mp_obj_module_t ustack_module = { .globals = (mp_obj_dict_t *)&ustack_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ustack, ustack_module, CIRCUITPY_USTACK); +MP_REGISTER_MODULE(MP_QSTR_ustack, ustack_module); diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 9896876a8a..308e828a02 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -41,8 +41,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg mp_int_t radius = args[ARG_radius].u_int; mp_arg_validate_int_min(radius, 1, MP_QSTR_radius); - vectorio_circle_t *self = m_new_obj(vectorio_circle_t); - self->base.type = &vectorio_circle_type; + vectorio_circle_t *self = mp_obj_malloc(vectorio_circle_t, &vectorio_circle_type); uint16_t color_index = args[ARG_color_index].u_int; common_hal_vectorio_circle_construct(self, radius, color_index); diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index b188fc4955..452631eddc 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -48,8 +48,7 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar mp_obj_t points_list = mp_arg_validate_type(args[ARG_points_list].u_obj, &mp_type_list, MP_QSTR_points); - vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t); - self->base.type = &vectorio_polygon_type; + vectorio_polygon_t *self = mp_obj_malloc(vectorio_polygon_t, &vectorio_polygon_type); uint16_t color_index = args[ARG_color_index].u_int; common_hal_vectorio_polygon_construct(self, points_list, color_index); diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index ad864f2c2d..01453693f8 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -45,8 +45,7 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_ mp_int_t height = args[ARG_height].u_int; mp_arg_validate_int_min(height, 1, MP_QSTR_height); - vectorio_rectangle_t *self = m_new_obj(vectorio_rectangle_t); - self->base.type = &vectorio_rectangle_type; + vectorio_rectangle_t *self = mp_obj_malloc(vectorio_rectangle_t, &vectorio_rectangle_type); uint16_t color_index = args[ARG_color_index].u_int; common_hal_vectorio_rectangle_construct(self, width, height, color_index); diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index e5c806b943..06a8355e2d 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -47,8 +47,7 @@ mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pix mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); } - vectorio_vector_shape_t *self = m_new_obj(vectorio_vector_shape_t); - self->base.type = &vectorio_vector_shape_type; + vectorio_vector_shape_t *self = mp_obj_malloc(vectorio_vector_shape_t, &vectorio_vector_shape_type); common_hal_vectorio_vector_shape_construct(self, ishape, pixel_shader, x, y ); diff --git a/shared-bindings/vectorio/__init__.c b/shared-bindings/vectorio/__init__.c index 7ad77da681..8e6c9766c3 100644 --- a/shared-bindings/vectorio/__init__.c +++ b/shared-bindings/vectorio/__init__.c @@ -45,4 +45,4 @@ const mp_obj_module_t vectorio_module = { .globals = (mp_obj_dict_t *)&vectorio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_vectorio, vectorio_module, CIRCUITPY_VECTORIO); +MP_REGISTER_MODULE(MP_QSTR_vectorio, vectorio_module); diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c index 5281f1c3fc..70aaddc8a5 100644 --- a/shared-bindings/watchdog/__init__.c +++ b/shared-bindings/watchdog/__init__.c @@ -106,4 +106,4 @@ const mp_obj_module_t watchdog_module = { .globals = (mp_obj_dict_t *)&watchdog_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_watchdog, watchdog_module, CIRCUITPY_WATCHDOG); +MP_REGISTER_MODULE(MP_QSTR_watchdog, watchdog_module); diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index d087ec587b..acbc63ec89 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -59,8 +59,7 @@ STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, wifi_monitor_obj_t *self = MP_STATE_VM(wifi_monitor_singleton); if (common_hal_wifi_monitor_deinited()) { - self = m_new_obj(wifi_monitor_obj_t); - self->base.type = &wifi_monitor_type; + self = mp_obj_malloc(wifi_monitor_obj_t, &wifi_monitor_type); common_hal_wifi_monitor_construct(self, channel, queue); MP_STATE_VM(wifi_monitor_singleton) = self; } diff --git a/shared-bindings/wifi/__init__.c b/shared-bindings/wifi/__init__.c index f7b66c68ca..9786c594bd 100644 --- a/shared-bindings/wifi/__init__.c +++ b/shared-bindings/wifi/__init__.c @@ -70,4 +70,4 @@ const mp_obj_module_t wifi_module = { .globals = (mp_obj_dict_t *)&wifi_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_wifi, wifi_module, CIRCUITPY_WIFI); +MP_REGISTER_MODULE(MP_QSTR_wifi, wifi_module); diff --git a/shared-bindings/zlib/__init__.c b/shared-bindings/zlib/__init__.c index ba02914638..b08b4a4a8e 100644 --- a/shared-bindings/zlib/__init__.c +++ b/shared-bindings/zlib/__init__.c @@ -94,4 +94,4 @@ const mp_obj_module_t zlib_module = { .globals = (mp_obj_dict_t *)&zlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_zlib, zlib_module, CIRCUITPY_ZLIB); +MP_REGISTER_MODULE(MP_QSTR_zlib, zlib_module); diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c index 1f4dbff310..ad7841cfa9 100644 --- a/shared-module/_bleio/ScanResults.c +++ b/shared-module/_bleio/ScanResults.c @@ -35,8 +35,7 @@ #include "shared-bindings/_bleio/ScanResults.h" bleio_scanresults_obj_t *shared_module_bleio_new_scanresults(size_t buffer_size, uint8_t *prefixes, size_t prefixes_len, mp_int_t minimum_rssi) { - bleio_scanresults_obj_t *self = m_new_obj(bleio_scanresults_obj_t); - self->base.type = &bleio_scanresults_type; + bleio_scanresults_obj_t *self = mp_obj_malloc(bleio_scanresults_obj_t, &bleio_scanresults_type); ringbuf_alloc(&self->buf, buffer_size, false); self->prefixes = prefixes; self->prefix_length = prefixes_len; @@ -68,12 +67,10 @@ mp_obj_t common_hal_bleio_scanresults_next(bleio_scanresults_obj_t *self) { mp_obj_str_t *o = MP_OBJ_TO_PTR(mp_obj_new_bytes_of_zeros(len)); ringbuf_get_n(&self->buf, (uint8_t *)o->data, len); - bleio_scanentry_obj_t *entry = m_new_obj(bleio_scanentry_obj_t); - entry->base.type = &bleio_scanentry_type; + bleio_scanentry_obj_t *entry = mp_obj_malloc(bleio_scanentry_obj_t, &bleio_scanentry_type); entry->rssi = rssi; - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; + bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type); common_hal_bleio_address_construct(MP_OBJ_TO_PTR(address), peer_addr, addr_type); entry->address = address; diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c index c9a9d7d9f2..98795a28ab 100644 --- a/shared-module/displayio/OnDiskBitmap.c +++ b/shared-module/displayio/OnDiskBitmap.c @@ -67,8 +67,8 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, self->width = read_word(bmp_header, 9); self->height = read_word(bmp_header, 11); - displayio_colorconverter_t *colorconverter = m_new_obj(displayio_colorconverter_t); - colorconverter->base.type = &displayio_colorconverter_type; + displayio_colorconverter_t *colorconverter = + mp_obj_malloc(displayio_colorconverter_t, &displayio_colorconverter_type; common_hal_displayio_colorconverter_construct(colorconverter, false, DISPLAYIO_COLORSPACE_RGB888); self->colorconverter = colorconverter; @@ -88,8 +88,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, number_of_colors = 1 << bits_per_pixel; } - displayio_palette_t *palette = m_new_obj(displayio_palette_t); - palette->base.type = &displayio_palette_type; + displayio_palette_t *palette = mp_obj_malloc(displayio_palette_t, &displayio_palette_type); common_hal_displayio_palette_construct(palette, number_of_colors, false); if (number_of_colors > 1) { diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index c1e6d1f2c2..4213f475a9 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -174,8 +174,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ int bpp = 16; if (use_palette == true) { - displayio_palette_t *palette = m_new_obj(displayio_palette_t); - palette->base.type = &displayio_palette_type; + displayio_palette_t *palette = mp_obj_malloc(displayio_palette_t, &displayio_palette_type); common_hal_displayio_palette_construct(palette, 256, false); self->palette = palette; bpp = 8; @@ -183,8 +182,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ self->palette = NULL; } - displayio_bitmap_t *bitmap = m_new_obj(displayio_bitmap_t); - bitmap->base.type = &displayio_bitmap_type; + displayio_bitmap_t *bitmap = mp_obj_malloc(displayio_bitmap_t, &displayio_bitmap_type); common_hal_displayio_bitmap_construct(bitmap, self->gif.iCanvasWidth, self->gif.iCanvasHeight, bpp); self->bitmap = bitmap; diff --git a/shared-module/ipaddress/__init__.c b/shared-module/ipaddress/__init__.c index 9d98c0eb7c..4801500f74 100644 --- a/shared-module/ipaddress/__init__.c +++ b/shared-module/ipaddress/__init__.c @@ -28,8 +28,7 @@ #include "shared-bindings/ipaddress/IPv4Address.h" mp_obj_t common_hal_ipaddress_new_ipv4address(uint32_t value) { - ipaddress_ipv4address_obj_t *self = m_new_obj(ipaddress_ipv4address_obj_t); - self->base.type = &ipaddress_ipv4address_type; + ipaddress_ipv4address_obj_t *self = mp_obj_malloc(ipaddress_ipv4address_obj_t, &ipaddress_ipv4address_type); common_hal_ipaddress_ipv4address_construct(self, (uint8_t *)&value, 4); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-module/keypad/EventQueue.c b/shared-module/keypad/EventQueue.c index eeeceb78cf..d229eef264 100644 --- a/shared-module/keypad/EventQueue.c +++ b/shared-module/keypad/EventQueue.c @@ -53,8 +53,7 @@ bool common_hal_keypad_eventqueue_get_into(keypad_eventqueue_obj_t *self, keypad } mp_obj_t common_hal_keypad_eventqueue_get(keypad_eventqueue_obj_t *self) { - keypad_event_obj_t *event = m_new_obj(keypad_event_obj_t); - event->base.type = &keypad_event_type; + keypad_event_obj_t *event = mp_obj_malloc(keypad_event_obj_t, &keypad_event_type); bool result = common_hal_keypad_eventqueue_get_into(self, event); if (result) { return event; diff --git a/shared-module/keypad/KeyMatrix.c b/shared-module/keypad/KeyMatrix.c index b2520521cc..bab9fb3095 100644 --- a/shared-module/keypad/KeyMatrix.c +++ b/shared-module/keypad/KeyMatrix.c @@ -53,8 +53,8 @@ void common_hal_keypad_keymatrix_construct(keypad_keymatrix_obj_t *self, mp_uint mp_obj_t row_dios[num_row_pins]; for (size_t row = 0; row < num_row_pins; row++) { - digitalio_digitalinout_obj_t *dio = m_new_obj(digitalio_digitalinout_obj_t); - dio->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *dio = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(dio, row_pins[row]); common_hal_digitalio_digitalinout_switch_to_input(dio, columns_to_anodes ? PULL_UP : PULL_DOWN); row_dios[row] = dio; @@ -63,7 +63,8 @@ void common_hal_keypad_keymatrix_construct(keypad_keymatrix_obj_t *self, mp_uint mp_obj_t column_dios[num_column_pins]; for (size_t column = 0; column < num_column_pins; column++) { - digitalio_digitalinout_obj_t *dio = m_new_obj(digitalio_digitalinout_obj_t); + digitalio_digitalinout_obj_t *dio = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); dio->base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(dio, column_pins[column]); common_hal_digitalio_digitalinout_switch_to_input(dio, columns_to_anodes ? PULL_UP : PULL_DOWN); diff --git a/shared-module/keypad/Keys.c b/shared-module/keypad/Keys.c index d74a3ab859..aea7418b01 100644 --- a/shared-module/keypad/Keys.c +++ b/shared-module/keypad/Keys.c @@ -48,8 +48,8 @@ void common_hal_keypad_keys_construct(keypad_keys_obj_t *self, mp_uint_t num_pin mp_obj_t dios[num_pins]; for (size_t i = 0; i < num_pins; i++) { - digitalio_digitalinout_obj_t *dio = m_new_obj(digitalio_digitalinout_obj_t); - dio->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *dio = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(dio, pins[i]); if (pull) { common_hal_digitalio_digitalinout_set_pull(dio, value_when_pressed ? PULL_DOWN : PULL_UP); diff --git a/shared-module/keypad/ShiftRegisterKeys.c b/shared-module/keypad/ShiftRegisterKeys.c index b2b10c65a2..bd3b53e622 100644 --- a/shared-module/keypad/ShiftRegisterKeys.c +++ b/shared-module/keypad/ShiftRegisterKeys.c @@ -46,20 +46,20 @@ static keypad_scanner_funcs_t shiftregisterkeys_funcs = { void common_hal_keypad_shiftregisterkeys_construct(keypad_shiftregisterkeys_obj_t *self, const mcu_pin_obj_t *clock_pin, const mcu_pin_obj_t *data_pin, const mcu_pin_obj_t *latch_pin, bool value_to_latch, size_t key_count, bool value_when_pressed, mp_float_t interval, size_t max_events) { - digitalio_digitalinout_obj_t *clock = m_new_obj(digitalio_digitalinout_obj_t); - clock->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *clock = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(clock, clock_pin); common_hal_digitalio_digitalinout_switch_to_output(clock, false, DRIVE_MODE_PUSH_PULL); self->clock = clock; - digitalio_digitalinout_obj_t *data = m_new_obj(digitalio_digitalinout_obj_t); - data->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *data = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(data, data_pin); common_hal_digitalio_digitalinout_switch_to_input(data, PULL_NONE); self->data = data; - digitalio_digitalinout_obj_t *latch = m_new_obj(digitalio_digitalinout_obj_t); - latch->base.type = &digitalio_digitalinout_type; + digitalio_digitalinout_obj_t *latch = + mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(latch, latch_pin); common_hal_digitalio_digitalinout_switch_to_output(latch, true, DRIVE_MODE_PUSH_PULL); diff --git a/shared-module/keypad/__init__.c b/shared-module/keypad/__init__.c index d2f5521a25..755dbb4f2d 100644 --- a/shared-module/keypad/__init__.c +++ b/shared-module/keypad/__init__.c @@ -106,8 +106,7 @@ void keypad_construct_common(keypad_scanner_obj_t *self, mp_float_t interval, si self->interval_ticks = (mp_uint_t)(interval * 1024); // interval * 1000 * (1024/1000) - keypad_eventqueue_obj_t *events = m_new_obj(keypad_eventqueue_obj_t); - events->base.type = &keypad_eventqueue_type; + keypad_eventqueue_obj_t *events = mp_obj_malloc(keypad_eventqueue_obj_t, &keypad_eventqueue_type); common_hal_keypad_eventqueue_construct(events, max_events); self->events = events; diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index 3a34731d77..27416a29fd 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -385,8 +385,7 @@ STATIC mp_obj_t unpack_ext(msgpack_stream_t *s, size_t size, mp_obj_t ext_hook) if (ext_hook != mp_const_none) { return mp_call_function_2(ext_hook, MP_OBJ_NEW_SMALL_INT(code), data); } else { - mod_msgpack_extype_obj_t *o = m_new_obj(mod_msgpack_extype_obj_t); - o->base.type = &mod_msgpack_exttype_type; + mod_msgpack_extype_obj_t *o = mp_obj_malloc(mod_msgpack_extype_obj_t, &mod_msgpack_exttype_type); o->code = code; o->data = data; return MP_OBJ_FROM_PTR(o); diff --git a/shared-module/touchio/TouchIn.c b/shared-module/touchio/TouchIn.c index 35dd56a6e4..bc98fa05f7 100644 --- a/shared-module/touchio/TouchIn.c +++ b/shared-module/touchio/TouchIn.c @@ -71,8 +71,7 @@ static uint16_t get_raw_reading(touchio_touchin_obj_t *self) { void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self, const mcu_pin_obj_t *pin) { common_hal_mcu_pin_claim(pin); - self->digitalinout = m_new_obj(digitalio_digitalinout_obj_t); - self->digitalinout->base.type = &digitalio_digitalinout_type; + self->digitalinout = mp_obj_malloc(digitalio_digitalinout_obj_t, &digitalio_digitalinout_type); common_hal_digitalio_digitalinout_construct(self->digitalinout, pin);