Skip to content

Commit 4d175ab

Browse files
committed
convert to MP_DEFINED_CONST_OBJ_TYPE()
1 parent 2c0fa0f commit 4d175ab

File tree

156 files changed

+1165
-1183
lines changed

Some content is hidden

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

156 files changed

+1165
-1183
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ STATIC const mp_rom_map_elem_t samd_clock_locals_dict_table[] = {
128128

129129
STATIC MP_DEFINE_CONST_DICT(samd_clock_locals_dict, samd_clock_locals_dict_table);
130130

131-
const mp_obj_type_t samd_clock_type = {
132-
{ &mp_type_type },
133-
.name = MP_QSTR_Clock,
134-
.print = samd_clock_print,
135-
.locals_dict = (mp_obj_t)&samd_clock_locals_dict,
136-
};
131+
MP_DEFINE_CONST_OBJ_TYPE(
132+
samd_clock_type,
133+
MP_QSTR_Clock,
134+
MP_TYPE_FLAG_NONE,
135+
print, samd_clock_print,
136+
locals_dict, &samd_clock_locals_dict
137+
);
137138

138139
#ifdef SAMD21
139140

ports/broadcom/bindings/videocore/Framebuffer.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,12 @@ STATIC const framebuffer_p_t videocore_framebuffer_proto = {
169169
.deinit = videocore_framebuffer_deinit_proto,
170170
};
171171

172-
const mp_obj_type_t videocore_framebuffer_type = {
173-
{ &mp_type_type },
174-
.flags = MP_TYPE_FLAG_EXTENDED,
175-
.name = MP_QSTR_Framebuffer,
176-
.locals_dict = (mp_obj_dict_t *)&videocore_framebuffer_locals_dict,
177-
.make_new = videocore_framebuffer_make_new,
178-
MP_TYPE_EXTENDED_FIELDS(
179-
.buffer_p = { .get_buffer = common_hal_videocore_framebuffer_get_buffer, },
180-
.protocol = &videocore_framebuffer_proto,
181-
),
182-
};
172+
MP_DEFINE_CONST_OBJ_TYPE(
173+
videocore_framebuffer_type,
174+
MP_QSTR_Framebuffer,
175+
MP_TYPE_FLAG_NONE,
176+
locals_dict, (mp_obj_dict_t *)&videocore_framebuffer_locals_dict,
177+
make_new, videocore_framebuffer_make_new,
178+
buffer, common_hal_videocore_framebuffer_get_buffer,
179+
protocol, &videocore_framebuffer_proto
180+
);

ports/espressif/bindings/espcamera/Camera.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,10 @@ STATIC const mp_rom_map_elem_t espcamera_camera_locals_table[] = {
992992

993993
STATIC MP_DEFINE_CONST_DICT(espcamera_camera_locals_dict, espcamera_camera_locals_table);
994994

995-
const mp_obj_type_t espcamera_camera_type = {
996-
.base = { &mp_type_type },
997-
.name = MP_QSTR_Camera,
998-
.make_new = espcamera_camera_make_new,
999-
.locals_dict = (mp_obj_t)&espcamera_camera_locals_dict,
1000-
};
995+
MP_DEFINE_CONST_OBJ_TYPE(
996+
espcamera_camera_type,
997+
MP_QSTR_Camera,
998+
MP_TYPE_FLAG_NONE,
999+
make_new, espcamera_camera_make_new,
1000+
locals_dict, &espcamera_camera_locals_dict
1001+
);

ports/espressif/bindings/espidf/__init__.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,15 @@ STATIC void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr
104104
//|
105105
//| ...
106106
//|
107-
const mp_obj_type_t mp_type_espidf_IDFError = {
108-
{ &mp_type_type },
109-
.name = MP_QSTR_IDFError,
110-
.print = espidf_exception_print,
111-
.make_new = mp_obj_exception_make_new,
112-
.attr = mp_obj_exception_attr,
113-
.parent = &mp_type_OSError,
114-
};
107+
MP_DEFINE_CONST_OBJ_TYPE(
108+
mp_type_espidf_IDFError,
109+
MP_QSTR_IDFError,
110+
MP_TYPE_FLAG_NONE,
111+
print, espidf_exception_print,
112+
make_new, mp_obj_exception_make_new,
113+
attr, mp_obj_exception_attr,
114+
parent, &mp_type_OSError
115+
);
115116

116117
//| class MemoryError(builtins.MemoryError):
117118
//| """Raised when an ``ESP-IDF`` memory allocation fails."""
@@ -122,13 +123,14 @@ NORETURN void mp_raise_espidf_MemoryError(void) {
122123
nlr_raise(mp_obj_new_exception(&mp_type_espidf_MemoryError));
123124
}
124125

125-
const mp_obj_type_t mp_type_espidf_MemoryError = {
126-
{ &mp_type_type },
127-
.name = MP_QSTR_MemoryError,
128-
.print = espidf_exception_print,
129-
.make_new = mp_obj_exception_make_new,
130-
.attr = mp_obj_exception_attr,
131-
.parent = &mp_type_MemoryError,
126+
MP_DEFINE_CONST_OBJ_TYPE(
127+
mp_type_espidf_MemoryError,
128+
MP_QSTR_MemoryError,
129+
MP_TYPE_FLAG_NONE,
130+
print, espidf_exception_print,
131+
make_new, mp_obj_exception_make_new,
132+
attr, mp_obj_exception_attr,
133+
parent, &mp_type_MemoryError
132134
};
133135

134136
//| def get_total_psram() -> int:

ports/espressif/bindings/espnow/ESPNow.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,12 @@ STATIC mp_obj_t espnow_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
359359
}
360360
}
361361

362-
const mp_obj_type_t espnow_type = {
363-
{ &mp_type_type },
364-
.name = MP_QSTR_ESPNow,
365-
.make_new = espnow_make_new,
366-
.locals_dict = (mp_obj_t)&espnow_locals_dict,
367-
.flags = MP_TYPE_FLAG_EXTENDED,
368-
MP_TYPE_EXTENDED_FIELDS(
369-
.protocol = &espnow_stream_p,
370-
.unary_op = &espnow_unary_op
371-
),
372-
};
362+
MP_DEFINE_CONST_OBJ_TYPE(
363+
espnow_type,
364+
MP_QSTR_ESPNow,
365+
MP_TYPE_FLAG_NONE,
366+
make_new, espnow_make_new,
367+
locals_dict, &espnow_locals_dict,
368+
protocol, &espnow_stream_p,
369+
unary_op, &espnow_unary_op
370+
);

ports/espressif/bindings/espnow/Peer.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,10 @@ STATIC const mp_rom_map_elem_t espnow_peer_locals_dict_table[] = {
220220
};
221221
STATIC MP_DEFINE_CONST_DICT(espnow_peer_locals_dict, espnow_peer_locals_dict_table);
222222

223-
const mp_obj_type_t espnow_peer_type = {
224-
{ &mp_type_type },
225-
.name = MP_QSTR_Peer,
226-
.make_new = espnow_peer_make_new,
227-
.locals_dict = (mp_obj_t)&espnow_peer_locals_dict,
228-
};
223+
MP_DEFINE_CONST_OBJ_TYPE(
224+
espnow_peer_type,
225+
MP_QSTR_Peer,
226+
MP_TYPE_FLAG_NONE,
227+
make_new, espnow_peer_make_new,
228+
locals_dict, &espnow_peer_locals_dict
229+
);

ports/espressif/bindings/espnow/Peers.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ espnow_peers_obj_t *espnow_peers_new(void) {
123123
return self;
124124
}
125125

126-
const mp_obj_type_t espnow_peers_type = {
127-
{ &mp_type_type },
128-
.name = MP_QSTR_Peers,
129-
.print = espnow_peers_print,
130-
.locals_dict = (mp_obj_t)&espnow_peers_locals_dict,
131-
.flags = MP_TYPE_FLAG_EXTENDED,
132-
MP_TYPE_EXTENDED_FIELDS(
133-
.unary_op = espnow_peers_unary_op,
134-
.subscr = espnow_peers_subscr,
135-
.getiter = espnow_peers_getiter,
136-
),
137-
};
126+
MP_DEFINE_CONST_OBJ_TYPE(
127+
espnow_peers_type,
128+
MP_QSTR_Peers,
129+
MP_TYPE_FLAG_NONE,
130+
print, espnow_peers_print,
131+
locals_dict, &espnow_peers_locals_dict,
132+
unary_op, espnow_peers_unary_op,
133+
subscr, espnow_peers_subscr,
134+
getiter, espnow_peers_getiter
135+
);

ports/espressif/bindings/espulp/ULP.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ STATIC const mp_rom_map_elem_t espulp_ulp_locals_table[] = {
172172
};
173173
STATIC MP_DEFINE_CONST_DICT(espulp_ulp_locals_dict, espulp_ulp_locals_table);
174174

175-
const mp_obj_type_t espulp_ulp_type = {
176-
{ &mp_type_type },
177-
.name = MP_QSTR_ULP,
178-
.make_new = espulp_ulp_make_new,
179-
.locals_dict = (mp_obj_t)&espulp_ulp_locals_dict,
180-
};
175+
MP_DEFINE_CONST_OBJ_TYPE(
176+
espulp_ulp_type,
177+
MP_QSTR_ULP,
178+
MP_TYPE_FLAG_NONE,
179+
make_new, espulp_ulp_make_new,
180+
locals_dict, &espulp_ulp_locals_dict
181+
);

ports/espressif/bindings/espulp/ULPAlarm.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ STATIC mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_arg
5959
return MP_OBJ_FROM_PTR(self);
6060
}
6161

62-
const mp_obj_type_t espulp_ulpalarm_type = {
63-
{ &mp_type_type },
64-
.name = MP_QSTR_ULPAlarm,
65-
.make_new = espulp_ulpalarm_make_new,
66-
};
62+
MP_DEFINE_CONST_OBJ_TYPE(
63+
espulp_ulpalarm_type,
64+
MP_QSTR_ULPAlarm,
65+
MP_TYPE_FLAG_NONE,
66+
make_new, espulp_ulpalarm_make_new
67+
);

ports/raspberrypi/bindings/cyw43/__init__.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ void bindings_cyw43_wifi_enforce_pm() {
5252
//| in :py:mod:`board`. A `CywPin` can be used as a DigitalInOut, but not with other
5353
//| peripherals such as `PWMOut`."""
5454
//|
55-
const mp_obj_type_t cyw43_pin_type = {
56-
{ &mp_type_type },
57-
.flags = MP_TYPE_FLAG_EXTENDED,
58-
.name = MP_QSTR_CywPin,
59-
.print = shared_bindings_microcontroller_pin_print,
60-
MP_TYPE_EXTENDED_FIELDS(
61-
.unary_op = mp_generic_unary_op,
62-
)
63-
};
55+
MP_DEFINE_CONST_OBJ_TYPE(
56+
cyw43_pin_type,
57+
MP_TYPE_FLAG_EXTENDED,
58+
MP_TYPE_FLAG_NONE,
59+
name, MP_QSTR_CywPin,
60+
print, shared_bindings_microcontroller_pin_print,
61+
unary_op, mp_generic_unary_op,
62+
);
6463

6564
//| PM_STANDARD: int
6665
//| """The standard power management mode"""

0 commit comments

Comments
 (0)