Skip to content

Commit ad103ac

Browse files
committed
Convert more modules to use MP_REGISTER_MODULE
Convert adafruit_bus_device, adafruit_pixelbuf, analogio, atexit, audiobusio, audiocore, audioio, audiomixer, and audiomp3 modules to use MP_REGISTER_MODULE. Related to #5183.
1 parent 13cba8a commit ad103ac

File tree

10 files changed

+27
-70
lines changed

10 files changed

+27
-70
lines changed

py/circuitpy_mpconfig.h

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -258,54 +258,13 @@ extern const struct _mp_obj_module_t alarm_module;
258258
#define ALARM_MODULE
259259
#endif
260260

261-
#if CIRCUITPY_ANALOGIO
262-
#define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
263-
extern const struct _mp_obj_module_t analogio_module;
264-
#else
265-
#define ANALOGIO_MODULE
266-
#endif
267-
268-
#if CIRCUITPY_ATEXIT
269-
extern const struct _mp_obj_module_t atexit_module;
270-
#define ATEXIT_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_atexit), (mp_obj_t)&atexit_module },
271-
#else
272-
#define ATEXIT_MODULE
273-
#endif
274-
275-
#if CIRCUITPY_AUDIOBUSIO
276-
#define AUDIOBUSIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiobusio), (mp_obj_t)&audiobusio_module },
277-
extern const struct _mp_obj_module_t audiobusio_module;
278-
#else
279-
#define AUDIOBUSIO_MODULE
280-
#endif
281-
282-
#if CIRCUITPY_AUDIOCORE
283-
#define AUDIOCORE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiocore), (mp_obj_t)&audiocore_module },
284-
extern const struct _mp_obj_module_t audiocore_module;
285-
#else
286-
#define AUDIOCORE_MODULE
287-
#endif
288-
289-
#if CIRCUITPY_AUDIOIO
290-
#define AUDIOIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audioio), (mp_obj_t)&audioio_module },
291-
extern const struct _mp_obj_module_t audioio_module;
292-
#else
293-
#define AUDIOIO_MODULE
294-
#endif
295-
296-
#if CIRCUITPY_AUDIOMIXER
297-
#define AUDIOMIXER_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiomixer), (mp_obj_t)&audiomixer_module },
298-
extern const struct _mp_obj_module_t audiomixer_module;
299-
#else
300-
#define AUDIOMIXER_MODULE
301-
#endif
302-
303-
#if CIRCUITPY_AUDIOMP3
304-
#define AUDIOMP3_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiomp3), (mp_obj_t)&audiomp3_module },
305-
extern const struct _mp_obj_module_t audiomp3_module;
306-
#else
307-
#define AUDIOMP3_MODULE
308-
#endif
261+
// CIRCUITPY_ANALOGIO uses MP_REGISTER_MODULE
262+
// CIRCUITPY_ATEXIT uses MP_REGISTER_MODULE
263+
// CIRCUITPY_AUDIOBUSIO uses MP_REGISTER_MODULE
264+
// CIRCUITPY_AUDIOCORE uses MP_REGISTER_MODULE
265+
// CIRCUITPY_AUDIOIO uses MP_REGISTER_MODULE
266+
// CIRCUITPY_AUDIOMIXER uses MP_REGISTER_MODULE
267+
// CIRCUITPY_AUDIOMP3 uses MP_REGISTER_MODULE
309268

310269
#if CIRCUITPY_AUDIOPWMIO
311270
#define AUDIOPWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiopwmio), (mp_obj_t)&audiopwmio_module },
@@ -370,12 +329,7 @@ extern const struct _mp_obj_module_t board_module;
370329
#define BOARD_UART_ROOT_POINTER
371330
#endif
372331

373-
#if CIRCUITPY_BUSDEVICE
374-
extern const struct _mp_obj_module_t adafruit_bus_device_module;
375-
#define BUSDEVICE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_adafruit_bus_device), (mp_obj_t)&adafruit_bus_device_module },
376-
#else
377-
#define BUSDEVICE_MODULE
378-
#endif
332+
// CIRCUITPY_BUSDEVICE (adafruit_bus_device_module) uses MP_REGISTER_MODULE
379333

380334
#if CIRCUITPY_BUSIO
381335
extern const struct _mp_obj_module_t busio_module;
@@ -614,13 +568,7 @@ extern const struct _mp_obj_module_t pew_module;
614568
#define PEW_MODULE
615569
#endif
616570

617-
#if CIRCUITPY_PIXELBUF
618-
extern const struct _mp_obj_module_t pixelbuf_module;
619-
#define PIXELBUF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_adafruit_pixelbuf),(mp_obj_t)&pixelbuf_module }, \
620-
{ MP_OBJ_NEW_QSTR(MP_QSTR__pixelbuf),(mp_obj_t)&pixelbuf_module },
621-
#else
622-
#define PIXELBUF_MODULE
623-
#endif
571+
// CIRCUITPY_PIXELBUF (pixelbuf_module) uses MP_REGISTER_MODULE
624572

625573
#if CIRCUITPY_PS2IO
626574
extern const struct _mp_obj_module_t ps2io_module;
@@ -883,21 +831,13 @@ extern const struct _mp_obj_module_t msgpack_module;
883831
#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \
884832
AESIO_MODULE \
885833
ALARM_MODULE \
886-
ANALOGIO_MODULE \
887-
ATEXIT_MODULE \
888-
AUDIOBUSIO_MODULE \
889-
AUDIOCORE_MODULE \
890-
AUDIOIO_MODULE \
891-
AUDIOMIXER_MODULE \
892-
AUDIOMP3_MODULE \
893834
AUDIOPWMIO_MODULE \
894835
BINASCII_MODULE \
895836
BITBANGIO_MODULE \
896837
BITMAPTOOLS_MODULE \
897838
BITOPS_MODULE \
898839
BLEIO_MODULE \
899840
BOARD_MODULE \
900-
BUSDEVICE_MODULE \
901841
BUSIO_MODULE \
902842
CAMERA_MODULE \
903843
CANIO_MODULE \
@@ -925,7 +865,6 @@ extern const struct _mp_obj_module_t msgpack_module;
925865
NEOPIXEL_WRITE_MODULE \
926866
ONEWIREIO_MODULE \
927867
PEW_MODULE \
928-
PIXELBUF_MODULE \
929868
PS2IO_MODULE \
930869
PULSEIO_MODULE \
931870
PWMIO_MODULE \

shared-bindings/adafruit_bus_device/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,5 @@ const mp_obj_module_t adafruit_bus_device_module = {
7676
.base = { &mp_type_module },
7777
.globals = (mp_obj_dict_t *)&adafruit_bus_device_module_globals,
7878
};
79+
80+
MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device, adafruit_bus_device_module, CIRCUITPY_BUSDEVICE);

shared-bindings/adafruit_pixelbuf/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ const mp_obj_module_t pixelbuf_module = {
5454
.base = { &mp_type_module },
5555
.globals = (mp_obj_dict_t *)&pixelbuf_module_globals,
5656
};
57+
58+
MP_REGISTER_MODULE(MP_QSTR_adafruit_pixelbuf, pixelbuf_module, CIRCUITPY_PIXELBUF);

shared-bindings/analogio/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ const mp_obj_module_t analogio_module = {
7272
.base = { &mp_type_module },
7373
.globals = (mp_obj_dict_t *)&analogio_module_globals,
7474
};
75+
76+
MP_REGISTER_MODULE(MP_QSTR_analogio, analogio_module, CIRCUITPY_ANALOGIO);

shared-bindings/atexit/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ const mp_obj_module_t atexit_module = {
9191
.base = { &mp_type_module },
9292
.globals = (mp_obj_dict_t *)&atexit_module_globals,
9393
};
94+
95+
MP_REGISTER_MODULE(MP_QSTR_atexit, atexit_module, CIRCUITPY_ATEXIT);

shared-bindings/audiobusio/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ const mp_obj_module_t audiobusio_module = {
5858
.base = { &mp_type_module },
5959
.globals = (mp_obj_dict_t *)&audiobusio_module_globals,
6060
};
61+
62+
MP_REGISTER_MODULE(MP_QSTR_audiobusio, audiobusio_module, CIRCUITPY_AUDIOBUSIO);

shared-bindings/audiocore/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ const mp_obj_module_t audiocore_module = {
5050
.base = { &mp_type_module },
5151
.globals = (mp_obj_dict_t *)&audiocore_module_globals,
5252
};
53+
54+
MP_REGISTER_MODULE(MP_QSTR_audiocore, audiocore_module, CIRCUITPY_AUDIOCORE);

shared-bindings/audioio/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ const mp_obj_module_t audioio_module = {
6161
.base = { &mp_type_module },
6262
.globals = (mp_obj_dict_t *)&audioio_module_globals,
6363
};
64+
65+
MP_REGISTER_MODULE(MP_QSTR_audioio, audioio_module, CIRCUITPY_AUDIOIO);

shared-bindings/audiomixer/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ const mp_obj_module_t audiomixer_module = {
4646
.base = { &mp_type_module },
4747
.globals = (mp_obj_dict_t *)&audiomixer_module_globals,
4848
};
49+
50+
MP_REGISTER_MODULE(MP_QSTR_audiomixer, audiomixer_module, CIRCUITPY_AUDIOMIXER);

shared-bindings/audiomp3/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ const mp_obj_module_t audiomp3_module = {
4545
.base = { &mp_type_module },
4646
.globals = (mp_obj_dict_t *)&audiomp3_module_globals,
4747
};
48+
49+
MP_REGISTER_MODULE(MP_QSTR_audiomp3, audiomp3_module, CIRCUITPY_AUDIOMP3);

0 commit comments

Comments
 (0)