Skip to content

Commit 662b976

Browse files
jimmodpgeorge
authored andcommitted
all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent cdb8807 commit 662b976

File tree

227 files changed

+2547
-2188
lines changed

Some content is hidden

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

227 files changed

+2547
-2188
lines changed

extmod/machine_i2c.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,14 @@ STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
730730
.transfer = mp_machine_soft_i2c_transfer,
731731
};
732732

733-
const mp_obj_type_t mp_machine_soft_i2c_type = {
734-
{ &mp_type_type },
735-
.name = MP_QSTR_SoftI2C,
736-
.print = mp_machine_soft_i2c_print,
737-
.make_new = mp_machine_soft_i2c_make_new,
738-
.protocol = &mp_machine_soft_i2c_p,
739-
.locals_dict = (mp_obj_dict_t *)&mp_machine_i2c_locals_dict,
740-
};
733+
MP_DEFINE_CONST_OBJ_TYPE(
734+
mp_machine_soft_i2c_type,
735+
MP_QSTR_SoftI2C,
736+
MP_TYPE_FLAG_NONE,
737+
mp_machine_soft_i2c_make_new,
738+
print, mp_machine_soft_i2c_print,
739+
protocol, &mp_machine_soft_i2c_p,
740+
locals_dict, (mp_obj_dict_t *)&mp_machine_i2c_locals_dict
741+
);
741742

742743
#endif // MICROPY_PY_MACHINE_SOFTI2C

extmod/machine_mem.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t va
101101
}
102102
}
103103

104-
const mp_obj_type_t machine_mem_type = {
105-
{ &mp_type_type },
106-
.name = MP_QSTR_mem,
107-
.print = machine_mem_print,
108-
.subscr = machine_mem_subscr,
109-
};
104+
MP_DEFINE_CONST_OBJ_TYPE(
105+
machine_mem_type,
106+
MP_QSTR_mem,
107+
MP_TYPE_FLAG_NONE,
108+
MP_TYPE_NULL_MAKE_NEW,
109+
print, machine_mem_print,
110+
subscr, machine_mem_subscr
111+
);
110112

111113
const machine_mem_obj_t machine_mem8_obj = {{&machine_mem_type}, 1};
112114
const machine_mem_obj_t machine_mem16_obj = {{&machine_mem_type}, 2};

extmod/machine_pinbase.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ STATIC const mp_pin_p_t pinbase_pin_p = {
7777
.ioctl = pinbase_ioctl,
7878
};
7979

80-
const mp_obj_type_t machine_pinbase_type = {
81-
{ &mp_type_type },
82-
.name = MP_QSTR_PinBase,
83-
.make_new = pinbase_make_new,
84-
.protocol = &pinbase_pin_p,
85-
};
80+
MP_DEFINE_CONST_OBJ_TYPE(
81+
machine_pinbase_type,
82+
MP_QSTR_PinBase,
83+
MP_TYPE_FLAG_NONE,
84+
pinbase_make_new,
85+
protocol, &pinbase_pin_p
86+
);
8687

8788
#endif // MICROPY_PY_MACHINE

extmod/machine_pwm.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ STATIC const mp_rom_map_elem_t machine_pwm_locals_dict_table[] = {
132132
};
133133
STATIC MP_DEFINE_CONST_DICT(machine_pwm_locals_dict, machine_pwm_locals_dict_table);
134134

135-
const mp_obj_type_t machine_pwm_type = {
136-
{ &mp_type_type },
137-
.name = MP_QSTR_PWM,
138-
.print = mp_machine_pwm_print,
139-
.make_new = mp_machine_pwm_make_new,
140-
.locals_dict = (mp_obj_dict_t *)&machine_pwm_locals_dict,
141-
};
135+
MP_DEFINE_CONST_OBJ_TYPE(
136+
machine_pwm_type,
137+
MP_QSTR_PWM,
138+
MP_TYPE_FLAG_NONE,
139+
mp_machine_pwm_make_new,
140+
print, mp_machine_pwm_print,
141+
locals_dict, &machine_pwm_locals_dict
142+
);
142143

143144
#endif // MICROPY_PY_MACHINE_PWM

extmod/machine_signal.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ STATIC const mp_pin_p_t signal_pin_p = {
172172
.ioctl = signal_ioctl,
173173
};
174174

175-
const mp_obj_type_t machine_signal_type = {
176-
{ &mp_type_type },
177-
.name = MP_QSTR_Signal,
178-
.make_new = signal_make_new,
179-
.call = signal_call,
180-
.protocol = &signal_pin_p,
181-
.locals_dict = (void *)&signal_locals_dict,
182-
};
175+
MP_DEFINE_CONST_OBJ_TYPE(
176+
machine_signal_type,
177+
MP_QSTR_Signal,
178+
MP_TYPE_FLAG_NONE,
179+
signal_make_new,
180+
call, signal_call,
181+
protocol, &signal_pin_p,
182+
locals_dict, (void *)&signal_locals_dict
183+
);
183184

184185
#endif // MICROPY_PY_MACHINE

extmod/machine_spi.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,14 @@ const mp_machine_spi_p_t mp_machine_soft_spi_p = {
251251
.transfer = mp_machine_soft_spi_transfer,
252252
};
253253

254-
const mp_obj_type_t mp_machine_soft_spi_type = {
255-
{ &mp_type_type },
256-
.name = MP_QSTR_SoftSPI,
257-
.print = mp_machine_soft_spi_print,
258-
.make_new = mp_machine_soft_spi_make_new,
259-
.protocol = &mp_machine_soft_spi_p,
260-
.locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
261-
};
254+
MP_DEFINE_CONST_OBJ_TYPE(
255+
mp_machine_soft_spi_type,
256+
MP_QSTR_SoftSPI,
257+
MP_TYPE_FLAG_NONE,
258+
mp_machine_soft_spi_make_new,
259+
print, mp_machine_soft_spi_print,
260+
protocol, &mp_machine_soft_spi_p,
261+
locals_dict, (mp_obj_dict_t *)&mp_machine_spi_locals_dict
262+
);
262263

263264
#endif // MICROPY_PY_MACHINE_SOFTSPI

extmod/modbluetooth.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ STATIC void ringbuf_get_uuid(ringbuf_t *ringbuf, mp_obj_bluetooth_uuid_t *uuid)
240240

241241
#endif // !MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS
242242

243-
const mp_obj_type_t mp_type_bluetooth_uuid = {
244-
{ &mp_type_type },
245-
.name = MP_QSTR_UUID,
246-
.make_new = bluetooth_uuid_make_new,
247-
.unary_op = bluetooth_uuid_unary_op,
248-
.binary_op = bluetooth_uuid_binary_op,
249-
.locals_dict = NULL,
250-
.print = bluetooth_uuid_print,
251-
.buffer = bluetooth_uuid_get_buffer,
252-
};
243+
MP_DEFINE_CONST_OBJ_TYPE(
244+
mp_type_bluetooth_uuid,
245+
MP_QSTR_UUID,
246+
MP_TYPE_FLAG_NONE,
247+
bluetooth_uuid_make_new,
248+
unary_op, bluetooth_uuid_unary_op,
249+
binary_op, bluetooth_uuid_binary_op,
250+
print, bluetooth_uuid_print,
251+
buffer, bluetooth_uuid_get_buffer
252+
);
253253

254254
// ----------------------------------------------------------------------------
255255
// Bluetooth object: General
@@ -976,12 +976,13 @@ STATIC const mp_rom_map_elem_t bluetooth_ble_locals_dict_table[] = {
976976
};
977977
STATIC MP_DEFINE_CONST_DICT(bluetooth_ble_locals_dict, bluetooth_ble_locals_dict_table);
978978

979-
STATIC const mp_obj_type_t mp_type_bluetooth_ble = {
980-
{ &mp_type_type },
981-
.name = MP_QSTR_BLE,
982-
.make_new = bluetooth_ble_make_new,
983-
.locals_dict = (void *)&bluetooth_ble_locals_dict,
984-
};
979+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
980+
mp_type_bluetooth_ble,
981+
MP_QSTR_BLE,
982+
MP_TYPE_FLAG_NONE,
983+
bluetooth_ble_make_new,
984+
locals_dict, (void *)&bluetooth_ble_locals_dict
985+
);
985986

986987
STATIC const mp_rom_map_elem_t mp_module_bluetooth_globals_table[] = {
987988
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluetooth) },

extmod/modbtree.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,19 @@ STATIC const mp_rom_map_elem_t btree_locals_dict_table[] = {
319319

320320
STATIC MP_DEFINE_CONST_DICT(btree_locals_dict, btree_locals_dict_table);
321321

322-
STATIC const mp_obj_type_t btree_type = {
323-
{ &mp_type_type },
322+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
323+
btree_type,
324+
MP_QSTR_btree,
325+
MP_TYPE_FLAG_NONE,
326+
MP_TYPE_NULL_MAKE_NEW,
324327
// Save on qstr's, reuse same as for module
325-
.name = MP_QSTR_btree,
326-
.print = btree_print,
327-
.getiter = btree_getiter,
328-
.iternext = btree_iternext,
329-
.binary_op = btree_binary_op,
330-
.subscr = btree_subscr,
331-
.locals_dict = (void *)&btree_locals_dict,
332-
};
328+
print, btree_print,
329+
getiter, btree_getiter,
330+
iternext, btree_iternext,
331+
binary_op, btree_binary_op,
332+
subscr, btree_subscr,
333+
locals_dict, (void *)&btree_locals_dict
334+
);
333335
#endif
334336

335337
STATIC const FILEVTABLE btree_stream_fvtable = {

extmod/modframebuf.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -829,13 +829,14 @@ STATIC const mp_rom_map_elem_t framebuf_locals_dict_table[] = {
829829
};
830830
STATIC MP_DEFINE_CONST_DICT(framebuf_locals_dict, framebuf_locals_dict_table);
831831

832-
STATIC const mp_obj_type_t mp_type_framebuf = {
833-
{ &mp_type_type },
834-
.name = MP_QSTR_FrameBuffer,
835-
.make_new = framebuf_make_new,
836-
.buffer = framebuf_get_buffer,
837-
.locals_dict = (mp_obj_dict_t *)&framebuf_locals_dict,
838-
};
832+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
833+
mp_type_framebuf,
834+
MP_QSTR_FrameBuffer,
835+
MP_TYPE_FLAG_NONE,
836+
framebuf_make_new,
837+
buffer, framebuf_get_buffer,
838+
locals_dict, (mp_obj_dict_t *)&framebuf_locals_dict
839+
);
839840
#endif
840841

841842
// this factory function is provided for backwards compatibility with old FrameBuffer1 class

extmod/modlwip.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ STATIC const mp_rom_map_elem_t lwip_slip_locals_dict_table[] = {
177177

178178
STATIC MP_DEFINE_CONST_DICT(lwip_slip_locals_dict, lwip_slip_locals_dict_table);
179179

180-
STATIC const mp_obj_type_t lwip_slip_type = {
181-
{ &mp_type_type },
182-
.name = MP_QSTR_slip,
183-
.make_new = lwip_slip_make_new,
184-
.locals_dict = (mp_obj_dict_t *)&lwip_slip_locals_dict,
185-
};
180+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
181+
lwip_slip_type,
182+
MP_QSTR_slip,
183+
MP_TYPE_FLAG_NONE,
184+
lwip_slip_make_new,
185+
locals_dict, (mp_obj_dict_t *)&lwip_slip_locals_dict
186+
);
186187

187188
#endif // MICROPY_PY_LWIP_SLIP
188189

@@ -1594,14 +1595,15 @@ STATIC const mp_stream_p_t lwip_socket_stream_p = {
15941595
.ioctl = lwip_socket_ioctl,
15951596
};
15961597

1597-
STATIC const mp_obj_type_t lwip_socket_type = {
1598-
{ &mp_type_type },
1599-
.name = MP_QSTR_socket,
1600-
.print = lwip_socket_print,
1601-
.make_new = lwip_socket_make_new,
1602-
.protocol = &lwip_socket_stream_p,
1603-
.locals_dict = (mp_obj_dict_t *)&lwip_socket_locals_dict,
1604-
};
1598+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
1599+
lwip_socket_type,
1600+
MP_QSTR_socket,
1601+
MP_TYPE_FLAG_NONE,
1602+
lwip_socket_make_new,
1603+
print, lwip_socket_print,
1604+
protocol, &lwip_socket_stream_p,
1605+
locals_dict, (mp_obj_dict_t *)&lwip_socket_locals_dict
1606+
);
16051607

16061608
/******************************************************************************/
16071609
// Support functions for memory protection. lwIP has its own memory management

extmod/moduasyncio.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ STATIC const mp_rom_map_elem_t task_queue_locals_dict_table[] = {
144144
};
145145
STATIC MP_DEFINE_CONST_DICT(task_queue_locals_dict, task_queue_locals_dict_table);
146146

147-
STATIC const mp_obj_type_t task_queue_type = {
148-
{ &mp_type_type },
149-
.name = MP_QSTR_TaskQueue,
150-
.make_new = task_queue_make_new,
151-
.locals_dict = (mp_obj_dict_t *)&task_queue_locals_dict,
152-
};
147+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
148+
task_queue_type,
149+
MP_QSTR_TaskQueue,
150+
MP_TYPE_FLAG_NONE,
151+
task_queue_make_new,
152+
locals_dict, (mp_obj_dict_t *)&task_queue_locals_dict
153+
);
153154

154155
/******************************************************************************/
155156
// Task class
@@ -286,14 +287,15 @@ STATIC mp_obj_t task_iternext(mp_obj_t self_in) {
286287
return mp_const_none;
287288
}
288289

289-
STATIC const mp_obj_type_t task_type = {
290-
{ &mp_type_type },
291-
.name = MP_QSTR_Task,
292-
.make_new = task_make_new,
293-
.attr = task_attr,
294-
.getiter = task_getiter,
295-
.iternext = task_iternext,
296-
};
290+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
291+
task_type,
292+
MP_QSTR_Task,
293+
MP_TYPE_FLAG_NONE,
294+
task_make_new,
295+
attr, task_attr,
296+
getiter, task_getiter,
297+
iternext, task_iternext
298+
);
297299

298300
/******************************************************************************/
299301
// C-level uasyncio module

extmod/moducryptolib.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,13 @@ STATIC const mp_rom_map_elem_t ucryptolib_aes_locals_dict_table[] = {
348348
};
349349
STATIC MP_DEFINE_CONST_DICT(ucryptolib_aes_locals_dict, ucryptolib_aes_locals_dict_table);
350350

351-
STATIC const mp_obj_type_t ucryptolib_aes_type = {
352-
{ &mp_type_type },
353-
.name = MP_QSTR_aes,
354-
.make_new = ucryptolib_aes_make_new,
355-
.locals_dict = (void *)&ucryptolib_aes_locals_dict,
356-
};
351+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
352+
ucryptolib_aes_type,
353+
MP_QSTR_aes,
354+
MP_TYPE_FLAG_NONE,
355+
ucryptolib_aes_make_new,
356+
locals_dict, (void *)&ucryptolib_aes_locals_dict
357+
);
357358

358359
STATIC const mp_rom_map_elem_t mp_module_ucryptolib_globals_table[] = {
359360
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucryptolib) },

extmod/moductypes.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,17 @@ STATIC mp_obj_t uctypes_struct_bytes_at(mp_obj_t ptr, mp_obj_t size) {
634634
}
635635
MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytes_at_obj, uctypes_struct_bytes_at);
636636

637-
STATIC const mp_obj_type_t uctypes_struct_type = {
638-
{ &mp_type_type },
639-
.name = MP_QSTR_struct,
640-
.print = uctypes_struct_print,
641-
.make_new = uctypes_struct_make_new,
642-
.attr = uctypes_struct_attr,
643-
.subscr = uctypes_struct_subscr,
644-
.unary_op = uctypes_struct_unary_op,
645-
.buffer = uctypes_get_buffer,
646-
};
637+
STATIC MP_DEFINE_CONST_OBJ_TYPE(
638+
uctypes_struct_type,
639+
MP_QSTR_struct,
640+
MP_TYPE_FLAG_NONE,
641+
uctypes_struct_make_new,
642+
print, uctypes_struct_print,
643+
attr, uctypes_struct_attr,
644+
subscr, uctypes_struct_subscr,
645+
unary_op, uctypes_struct_unary_op,
646+
buffer, uctypes_get_buffer
647+
);
647648

648649
STATIC const mp_rom_map_elem_t mp_module_uctypes_globals_table[] = {
649650
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uctypes) },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy