Skip to content

Commit 0d2c3c3

Browse files
committed
wip: continuing compilation fixes; mp_obj_alloc everywhere
1 parent 465d1c6 commit 0d2c3c3

228 files changed

Lines changed: 377 additions & 544 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

devices/ble_hci/common-hal/_bleio/Adapter.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
8282

8383
// Generic Access Service setup.
8484

85-
bleio_uuid_obj_t *generic_access_service_uuid = m_new_obj(bleio_uuid_obj_t);
86-
generic_access_service_uuid->base.type = &bleio_uuid_type;
85+
bleio_uuid_obj_t *generic_access_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
8786
common_hal_bleio_uuid_construct(generic_access_service_uuid, 0x1800, NULL);
8887

89-
bleio_uuid_obj_t *device_name_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
90-
device_name_characteristic_uuid->base.type = &bleio_uuid_type;
88+
bleio_uuid_obj_t *device_name_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9189
common_hal_bleio_uuid_construct(device_name_characteristic_uuid, 0x2A00, NULL);
9290

93-
bleio_uuid_obj_t *appearance_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
94-
appearance_characteristic_uuid->base.type = &bleio_uuid_type;
91+
bleio_uuid_obj_t *appearance_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9592
common_hal_bleio_uuid_construct(appearance_characteristic_uuid, 0x2A01, NULL);
9693

9794
// Not implemented:
9895
// Peripheral Preferred Connection Parameters
9996
// Central Address Resolution
10097

101-
bleio_service_obj_t *generic_access_service = m_new_obj(bleio_service_obj_t);
102-
generic_access_service->base.type = &bleio_service_type;
98+
bleio_service_obj_t *generic_access_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
10399
common_hal_bleio_service_construct(generic_access_service, generic_access_service_uuid, false);
104100

105-
adapter->device_name_characteristic = m_new_obj(bleio_characteristic_obj_t);
106-
adapter->device_name_characteristic->base.type = &bleio_characteristic_type;
101+
adapter->device_name_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
107102

108103
char generic_name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 'n', 'n', 'n', 'n' };
109104
mp_buffer_info_t generic_name_bufinfo = {
@@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
132127
.len = sizeof(zero_16),
133128
};
134129

135-
adapter->appearance_characteristic = m_new_obj(bleio_characteristic_obj_t);
136-
adapter->appearance_characteristic->base.type = &bleio_characteristic_type;
130+
adapter->appearance_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
137131

138132
common_hal_bleio_characteristic_construct(
139133
adapter->appearance_characteristic,
@@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
151145

152146
// Generic Attribute Service setup.
153147

154-
bleio_uuid_obj_t *generic_attribute_service_uuid = m_new_obj(bleio_uuid_obj_t);
155-
generic_attribute_service_uuid->base.type = &bleio_uuid_type;
148+
bleio_uuid_obj_t *generic_attribute_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
156149
common_hal_bleio_uuid_construct(generic_attribute_service_uuid, 0x1801, NULL);
157150

158-
bleio_uuid_obj_t *service_changed_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
159-
service_changed_characteristic_uuid->base.type = &bleio_uuid_type;
151+
bleio_uuid_obj_t *service_changed_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
160152
common_hal_bleio_uuid_construct(service_changed_characteristic_uuid, 0x2A05, NULL);
161153

162-
bleio_service_obj_t *generic_attribute_service = m_new_obj(bleio_service_obj_t);
163-
generic_attribute_service->base.type = &bleio_service_type;
154+
bleio_service_obj_t *generic_attribute_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
164155
common_hal_bleio_service_construct(generic_attribute_service, generic_attribute_service_uuid, false);
165156

166-
adapter->service_changed_characteristic = m_new_obj(bleio_characteristic_obj_t);
167-
adapter->service_changed_characteristic->base.type = &bleio_characteristic_type;
157+
adapter->service_changed_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
168158

169159
uint32_t zero_32 = 0;
170160
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
416406
bt_addr_t addr;
417407
hci_check_error(hci_read_bd_addr(&addr));
418408

419-
bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
420-
address->base.type = &bleio_address_type;
409+
bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type);
421410

422411
common_hal_bleio_address_construct(address, addr.val, BT_ADDR_LE_PUBLIC);
423412
return address;

devices/ble_hci/common-hal/_bleio/Connection.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
453453
// for (size_t i = 0; i < response->count; ++i) {
454454
// ble_gattc_service_t *gattc_service = &response->services[i];
455455

456-
// bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
457-
// service->base.type = &bleio_service_type;
456+
// bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
458457

459458
// // Initialize several fields at once.
460459
// 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
466465

467466
// if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
468467
// // Known service UUID.
469-
// bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
470-
// uuid->base.type = &bleio_uuid_type;
468+
// bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
471469
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
472470
// service->uuid = uuid;
473471
// } else {
@@ -491,15 +489,14 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
491489
// for (size_t i = 0; i < response->count; ++i) {
492490
// ble_gattc_char_t *gattc_char = &response->chars[i];
493491

494-
// bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
495-
// characteristic->base.type = &bleio_characteristic_type;
492+
// bleio_characteristic_obj_t *characteristic =
493+
// mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
496494

497495
// bleio_uuid_obj_t *uuid = NULL;
498496

499497
// if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
500498
// // Known characteristic UUID.
501-
// uuid = m_new_obj(bleio_uuid_obj_t);
502-
// uuid->base.type = &bleio_uuid_type;
499+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
503500
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
504501
// } else {
505502
// // 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
557554
// break;
558555
// }
559556

560-
// bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t);
561-
// descriptor->base.type = &bleio_descriptor_type;
557+
// bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
562558

563559
// bleio_uuid_obj_t *uuid = NULL;
564560

565561
// if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
566562
// // Known descriptor UUID.
567-
// uuid = m_new_obj(bleio_uuid_obj_t);
568-
// uuid->base.type = &bleio_uuid_type;
563+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
569564
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid);
570565
// } else {
571566
// // 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
750745
if (internal->connection_obj != mp_const_none) {
751746
return internal->connection_obj;
752747
}
753-
bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t);
754-
connection->base.type = &bleio_connection_type;
748+
bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type);
755749
connection->connection = internal;
756750
internal->connection_obj = connection;
757751

devices/ble_hci/common-hal/_bleio/Service.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
101101

102102
if (characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE)) {
103103
// We need a CCCD if this characteristic is doing notify or indicate.
104-
bleio_descriptor_obj_t *cccd = m_new_obj(bleio_descriptor_obj_t);
105-
cccd->base.type = &bleio_descriptor_type;
104+
bleio_descriptor_obj_t *cccd = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
106105

107106
uint16_t zero = 0;
108107
mp_buffer_info_t zero_cccd_value = {

extmod/moduhashlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,6 @@ const mp_obj_module_t mp_module_uhashlib = {
382382
.globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals,
383383
};
384384

385-
MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib, MICROPY_PY_UHASHLIB);
385+
MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib);
386386

387387
#endif // MICROPY_PY_UHASHLIB

ports/atmel-samd/bindings/samd/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ const mp_obj_module_t samd_module = {
5757
.globals = (mp_obj_dict_t *)&samd_module_globals,
5858
};
5959

60-
MP_REGISTER_MODULE(MP_QSTR_samd, samd_module, CIRCUITPY_SAMD);
60+
MP_REGISTER_MODULE(MP_QSTR_samd, samd_module);

ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ const mp_obj_module_t _bhb_user_cmodule = {
127127
.globals = (mp_obj_dict_t *)&_bhb_module_globals,
128128
};
129129

130-
MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule, MODULE_BHB_ENABLED);
130+
MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule);

ports/atmel-samd/common-hal/canio/Listener.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
368368
int index = self->hw->RXFS.bit.F0GI;
369369
canio_can_rx_fifo_t *hw_message = &self->fifo[index];
370370
bool rtr = hw_message->rxf0.bit.RTR;
371-
canio_message_obj_t *message = m_new_obj(canio_message_obj_t);
372-
message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type;
371+
canio_message_obj_t *message =
372+
mp_obj_malloc(canio_message_obj_t, rtr ? &canio_remote_transmission_request_type : &canio_message_type);
373373
message->extended = hw_message->rxf0.bit.XTD;
374374
if (message->extended) {
375375
message->id = hw_message->rxf0.bit.ID;

ports/broadcom/bindings/videocore/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ const mp_obj_module_t videocore_module = {
4545
.globals = (mp_obj_dict_t *)&videocore_module_globals,
4646
};
4747

48-
MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module, CIRCUITPY_VIDEOCORE);
48+
MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module);

ports/espressif/bindings/espcamera/Camera.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ STATIC mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_ar
143143
mp_int_t jpeg_quality = mp_arg_validate_int_range(args[ARG_jpeg_quality].u_int, 2, 55, MP_QSTR_jpeg_quality);
144144
mp_int_t framebuffer_count = mp_arg_validate_int_range(args[ARG_framebuffer_count].u_int, 1, 2, MP_QSTR_framebuffer_count);
145145

146-
espcamera_camera_obj_t *self = m_new_obj(espcamera_camera_obj_t);
147-
self->base.type = &espcamera_camera_type;
146+
espcamera_camera_obj_t *self = mp_obj_malloc(espcamera_camera_obj_t, &espcamera_camera_type);
148147
common_hal_espcamera_camera_construct(
149148
self,
150149
data_pins,

ports/espressif/bindings/espcamera/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,4 @@ const mp_obj_module_t espcamera_module = {
285285
.globals = (mp_obj_dict_t *)&espcamera_module_globals,
286286
};
287287

288-
MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module, CIRCUITPY_ESPCAMERA);
288+
MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module);

0 commit comments

Comments
 (0)