From efe23aca7154d21a9e8f283313c7a1ac29e05d86 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 31 May 2022 22:56:11 +1000 Subject: [PATCH] all: Remove third argument to MP_REGISTER_MODULE. It's no longer needed because this macro is now processed after preprocessing the source code via cpp (in the qstr extraction stage), which means unused MP_REGISTER_MODULE's are filtered out by the preprocessor. Signed-off-by: Damien George --- docs/develop/cmodules.rst | 12 ++++++---- docs/develop/library.rst | 2 +- docs/develop/porting.rst | 7 +----- examples/usercmodule/cexample/examplemodule.c | 5 +--- .../usercmodule/cppexample/examplemodule.c | 5 +--- extmod/modbluetooth.c | 2 +- extmod/modbtree.c | 2 +- extmod/modframebuf.c | 2 +- extmod/modlwip.c | 4 ++-- extmod/modnetwork.c | 2 +- extmod/modonewire.c | 2 +- extmod/moduasyncio.c | 2 +- extmod/modubinascii.c | 2 +- extmod/moducryptolib.c | 2 +- extmod/moductypes.c | 2 +- extmod/moduhashlib.c | 2 +- extmod/moduheapq.c | 2 +- extmod/modujson.c | 2 +- extmod/moduos.c | 2 +- extmod/moduplatform.c | 2 +- extmod/modurandom.c | 2 +- extmod/modure.c | 2 +- extmod/moduselect.c | 2 +- extmod/modusocket.c | 2 +- extmod/modussl_axtls.c | 2 +- extmod/modussl_mbedtls.c | 2 +- extmod/modutimeq.c | 3 ++- extmod/moduwebsocket.c | 2 +- extmod/moduzlib.c | 2 +- extmod/modwebrepl.c | 2 +- ports/cc3200/mods/modmachine.c | 2 +- ports/cc3200/mods/modnetwork.c | 2 +- ports/cc3200/mods/moduos.c | 2 +- ports/cc3200/mods/modusocket.c | 2 +- ports/cc3200/mods/modussl.c | 2 +- ports/cc3200/mods/modutime.c | 2 +- ports/cc3200/mods/modwipy.c | 2 +- ports/esp32/modesp.c | 2 +- ports/esp32/modesp32.c | 2 +- ports/esp32/modmachine.c | 2 +- ports/esp32/modnetwork.c | 2 +- ports/esp32/modsocket.c | 2 +- ports/esp32/modutime.c | 2 +- ports/esp8266/modesp.c | 2 +- ports/esp8266/modmachine.c | 2 +- ports/esp8266/modnetwork.c | 2 +- ports/esp8266/modutime.c | 2 +- ports/javascript/modutime.c | 2 +- ports/mimxrt/modmachine.c | 6 ++++- ports/mimxrt/modmimxrt.c | 2 +- ports/mimxrt/modutime.c | 2 +- .../nrf/boards/microbit/modules/modmicrobit.c | 2 +- ports/nrf/modules/ble/modble.c | 2 +- ports/nrf/modules/board/modboard.c | 2 +- ports/nrf/modules/machine/modmachine.c | 6 ++++- ports/nrf/modules/music/modmusic.c | 2 +- ports/nrf/modules/nrf/modnrf.c | 2 +- ports/nrf/modules/ubluepy/modubluepy.c | 2 +- ports/nrf/modules/uos/moduos.c | 2 +- ports/nrf/modules/utime/modutime.c | 2 +- ports/pic16bit/modpyb.c | 2 +- ports/qemu-arm/modmachine.c | 6 ++++- ports/renesas-ra/modmachine.c | 5 +++- ports/renesas-ra/modutime.c | 6 ++++- ports/rp2/modmachine.c | 6 ++++- ports/rp2/modrp2.c | 2 +- ports/rp2/modutime.c | 2 +- ports/samd/modmachine.c | 6 ++++- ports/samd/modsamd.c | 2 +- ports/samd/modutime.c | 2 +- ports/stm32/modmachine.c | 6 ++++- ports/stm32/modpyb.c | 6 ++++- ports/stm32/modstm.c | 2 +- ports/stm32/modutime.c | 6 ++++- ports/teensy/modpyb.c | 2 +- ports/unix/modffi.c | 6 ++++- ports/unix/modjni.c | 6 ++++- ports/unix/modmachine.c | 2 +- ports/unix/modtermios.c | 6 ++++- ports/unix/modtime.c | 2 +- ports/unix/moduselect.c | 2 +- ports/unix/modusocket.c | 6 ++++- ports/zephyr/modmachine.c | 2 +- ports/zephyr/modusocket.c | 2 +- ports/zephyr/modutime.c | 2 +- ports/zephyr/modzephyr.c | 2 +- ports/zephyr/modzsensor.c | 2 +- py/makemoduledefs.py | 23 +++++++------------ py/makeqstrdefs.py | 2 +- py/modarray.c | 2 +- py/modbuiltins.c | 2 +- py/modcmath.c | 2 +- py/modcollections.c | 2 +- py/modgc.c | 2 +- py/modio.c | 2 +- py/modmath.c | 2 +- py/modmicropython.c | 2 +- py/modstruct.c | 2 +- py/modsys.c | 2 +- py/modthread.c | 2 +- py/moduerrno.c | 2 +- py/obj.h | 3 +-- py/runtime.c | 2 +- 103 files changed, 173 insertions(+), 134 deletions(-) diff --git a/docs/develop/cmodules.rst b/docs/develop/cmodules.rst index 38225e868..143057f7f 100644 --- a/docs/develop/cmodules.rst +++ b/docs/develop/cmodules.rst @@ -221,23 +221,25 @@ as described above. If a module is not enabled by default then the corresponding C preprocessor macro must be enabled. This macro name can be found by searching for the ``MP_REGISTER_MODULE`` line in the module's source code (it usually appears at the end of the main source file). -The third argument to ``MP_REGISTER_MODULE`` is the macro name, and this must be set -to 1 using ``CFLAGS_EXTRA`` to make the module available. If the third argument is just -the number 1 then the module is enabled by default. +This macro should be surrounded by a ``#if X`` / ``#endif`` pair, and the configuration +option ``X`` must be set to 1 using ``CFLAGS_EXTRA`` to make the module available. If +there is no ``#if X`` / ``#endif`` pair then the module is enabled by default. For example, the ``examples/usercmodule/cexample`` module is enabled by default so has the following line in its source code: .. code-block:: c - MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, 1); + MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule); Alternatively, to make this module disabled by default but selectable through a preprocessor configuration option, it would be: .. code-block:: c - MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, MODULE_CEXAMPLE_ENABLED); + #if MODULE_CEXAMPLE_ENABLED + MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule); + #endif In this case the module is enabled by adding ``CFLAGS_EXTRA=-DMODULE_CEXAMPLE_ENABLED=1`` to the ``make`` command, or editing ``mpconfigport.h`` or ``mpconfigboard.h`` to add diff --git a/docs/develop/library.rst b/docs/develop/library.rst index 47ea2dc8d..c2a86ea16 100644 --- a/docs/develop/library.rst +++ b/docs/develop/library.rst @@ -64,7 +64,7 @@ hypothetical new module ``subsystem`` in the file ``modsubsystem.c``: .globals = (mp_obj_dict_t *)&mp_module_subsystem_globals, }; - MP_REGISTER_MODULE(MP_QSTR_subsystem, mp_module_subsystem, MICROPY_PY_SUBSYSTEM); + MP_REGISTER_MODULE(MP_QSTR_subsystem, mp_module_subsystem); #endif diff --git a/docs/develop/porting.rst b/docs/develop/porting.rst index d08fd74e4..bc25f47ed 100644 --- a/docs/develop/porting.rst +++ b/docs/develop/porting.rst @@ -280,12 +280,7 @@ To add a custom module like ``myport``, first add the module definition in a fil .globals = (mp_obj_dict_t *)&myport_module_globals, }; - MP_REGISTER_MODULE(MP_QSTR_myport, myport_module, 1); - -Note: the "1" as the third argument in ``MP_REGISTER_MODULE`` enables this new module -unconditionally. To allow it to be conditionally enabled, replace the "1" by -``MICROPY_PY_MYPORT`` and then add ``#define MICROPY_PY_MYPORT (1)`` in ``mpconfigport.h`` -accordingly. + MP_REGISTER_MODULE(MP_QSTR_myport, myport_module); You will also need to edit the Makefile to add ``modmyport.c`` to the ``SRC_C`` list, and a new line adding the same file to ``SRC_QSTR`` (so qstrs are searched for in this new file), diff --git a/examples/usercmodule/cexample/examplemodule.c b/examples/usercmodule/cexample/examplemodule.c index 49ebc7aaa..93a58be2e 100644 --- a/examples/usercmodule/cexample/examplemodule.c +++ b/examples/usercmodule/cexample/examplemodule.c @@ -31,7 +31,4 @@ const mp_obj_module_t example_user_cmodule = { }; // Register the module to make it available in Python. -// Note: the "1" in the third argument means this module is always enabled. -// This "1" can be optionally replaced with a macro like MODULE_CEXAMPLE_ENABLED -// which can then be used to conditionally enable this module. -MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, 1); +MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule); diff --git a/examples/usercmodule/cppexample/examplemodule.c b/examples/usercmodule/cppexample/examplemodule.c index dfb785683..5c84eccd7 100644 --- a/examples/usercmodule/cppexample/examplemodule.c +++ b/examples/usercmodule/cppexample/examplemodule.c @@ -22,7 +22,4 @@ const mp_obj_module_t cppexample_user_cmodule = { }; // Register the module to make it available in Python. -// Note: the "1" in the third argument means this module is always enabled. -// This "1" can be optionally replaced with a macro like MODULE_CPPEXAMPLE_ENABLED -// which can then be used to conditionally enable this module. -MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, 1); +MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule); diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index aecf48fd4..6bdea1616 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -1004,7 +1004,7 @@ const mp_obj_module_t mp_module_ubluetooth = { .globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubluetooth, mp_module_ubluetooth, MICROPY_PY_BLUETOOTH); +MP_REGISTER_MODULE(MP_QSTR_ubluetooth, mp_module_ubluetooth); // Helpers diff --git a/extmod/modbtree.c b/extmod/modbtree.c index df33d765e..60a5beec6 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -380,7 +380,7 @@ const mp_obj_module_t mp_module_btree = { .globals = (mp_obj_dict_t *)&mp_module_btree_globals, }; -MP_REGISTER_MODULE(MP_QSTR_btree, mp_module_btree, MICROPY_PY_BTREE); +MP_REGISTER_MODULE(MP_QSTR_btree, mp_module_btree); #endif #endif // MICROPY_PY_BTREE diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 4dfdb7eea..5b6575d5a 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -668,7 +668,7 @@ const mp_obj_module_t mp_module_framebuf = { .globals = (mp_obj_dict_t *)&framebuf_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_framebuf, mp_module_framebuf, MICROPY_PY_FRAMEBUF); +MP_REGISTER_MODULE(MP_QSTR_framebuf, mp_module_framebuf); #endif #endif // MICROPY_PY_FRAMEBUF diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 47d5bcdbb..ec5f3bfd6 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1778,9 +1778,9 @@ const mp_obj_module_t mp_module_lwip = { .globals = (mp_obj_dict_t *)&mp_module_lwip_globals, }; -MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip, MICROPY_PY_LWIP); +MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip); // On LWIP-ports, this is the usocket module (replaces extmod/modusocket.c). -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_lwip, MICROPY_PY_LWIP); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_lwip); #endif // MICROPY_PY_LWIP diff --git a/extmod/modnetwork.c b/extmod/modnetwork.c index f63f708a2..87e155e09 100644 --- a/extmod/modnetwork.c +++ b/extmod/modnetwork.c @@ -102,7 +102,7 @@ const mp_obj_module_t mp_module_network = { .globals = (mp_obj_dict_t *)&mp_module_network_globals, }; -MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, MICROPY_PY_NETWORK); +MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network); /*******************************************************************************/ // Implementations of network methods that can be used by any interface diff --git a/extmod/modonewire.c b/extmod/modonewire.c index 1cfddc830..f440f75a8 100644 --- a/extmod/modonewire.c +++ b/extmod/modonewire.c @@ -163,6 +163,6 @@ const mp_obj_module_t mp_module_onewire = { .globals = (mp_obj_dict_t *)&onewire_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__onewire, mp_module_onewire, MICROPY_PY_ONEWIRE); +MP_REGISTER_MODULE(MP_QSTR__onewire, mp_module_onewire); #endif // MICROPY_PY_ONEWIRE diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index b09b8d67b..6e3603fa1 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -310,6 +310,6 @@ const mp_obj_module_t mp_module_uasyncio = { .globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals, }; -MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio, MICROPY_PY_UASYNCIO); +MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio); #endif // MICROPY_PY_UASYNCIO diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index a362a2d6e..c0e2c587f 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -258,6 +258,6 @@ const mp_obj_module_t mp_module_ubinascii = { .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii, MICROPY_PY_UBINASCII); +MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii); #endif // MICROPY_PY_UBINASCII diff --git a/extmod/moducryptolib.c b/extmod/moducryptolib.c index ba04a7bde..c58abaada 100644 --- a/extmod/moducryptolib.c +++ b/extmod/moducryptolib.c @@ -374,6 +374,6 @@ const mp_obj_module_t mp_module_ucryptolib = { .globals = (mp_obj_dict_t *)&mp_module_ucryptolib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ucryptolib, mp_module_ucryptolib, MICROPY_PY_UCRYPTOLIB); +MP_REGISTER_MODULE(MP_QSTR_ucryptolib, mp_module_ucryptolib); #endif // MICROPY_PY_UCRYPTOLIB diff --git a/extmod/moductypes.c b/extmod/moductypes.c index a6ebd92eb..547453c48 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -717,6 +717,6 @@ const mp_obj_module_t mp_module_uctypes = { .globals = (mp_obj_dict_t *)&mp_module_uctypes_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uctypes, mp_module_uctypes, MICROPY_PY_UCTYPES); +MP_REGISTER_MODULE(MP_QSTR_uctypes, mp_module_uctypes); #endif diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index ded9972ca..39488788f 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -371,6 +371,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/extmod/moduheapq.c b/extmod/moduheapq.c index 42871f2c0..bfa6ba608 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -118,7 +118,7 @@ const mp_obj_module_t mp_module_uheapq = { .globals = (mp_obj_dict_t *)&mp_module_uheapq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq, MICROPY_PY_UHEAPQ); +MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq); #endif #endif // MICROPY_PY_UHEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index befa351f1..bee432db2 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -381,6 +381,6 @@ const mp_obj_module_t mp_module_ujson = { .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson, MICROPY_PY_UJSON); +MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson); #endif // MICROPY_PY_UJSON diff --git a/extmod/moduos.c b/extmod/moduos.c index 2b902eb21..87a611148 100644 --- a/extmod/moduos.c +++ b/extmod/moduos.c @@ -176,6 +176,6 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos, MICROPY_PY_UOS); +MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); #endif // MICROPY_PY_UOS diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index 16e45078f..1b35b08aa 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_uplatform = { .globals = (mp_obj_dict_t *)&modplatform_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform, MICROPY_PY_UPLATFORM); +MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform); #endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 6e5f99de7..2e29f7ca6 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_urandom = { .globals = (mp_obj_dict_t *)&mp_module_urandom_globals, }; -MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom, MICROPY_PY_URANDOM); +MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom); #endif #endif // MICROPY_PY_URANDOM diff --git a/extmod/modure.c b/extmod/modure.c index 1d9d82c7b..6bd898984 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -448,7 +448,7 @@ const mp_obj_module_t mp_module_ure = { .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure, MICROPY_PY_URE); +MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 296d38a5d..70a1de2e4 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -373,6 +373,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect, MICROPY_PY_USELECT); +MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect); #endif // MICROPY_PY_USELECT diff --git a/extmod/modusocket.c b/extmod/modusocket.c index c5db80f37..ebddb1ec7 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -637,6 +637,6 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); #endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index c9ce629b6..9ba613a3e 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -358,6 +358,6 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl, MICROPY_PY_USSL && MICROPY_SSL_AXTLS); +MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); #endif // MICROPY_PY_USSL && MICROPY_SSL_AXTLS diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index 8496642d0..0d5d4197c 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -418,6 +418,6 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl, MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS); +MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); #endif // MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 93a9d09b0..1dde90bd1 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -229,5 +229,6 @@ const mp_obj_module_t mp_module_utimeq = { .globals = (mp_obj_dict_t *)&mp_module_utimeq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq, MICROPY_PY_UTIMEQ); +MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq); + #endif // MICROPY_PY_UTIMEQ diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index 48f4cc78e..a9ad0c22e 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -310,6 +310,6 @@ const mp_obj_module_t mp_module_uwebsocket = { .globals = (mp_obj_dict_t *)&uwebsocket_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uwebsocket, mp_module_uwebsocket, MICROPY_PY_UWEBSOCKET); +MP_REGISTER_MODULE(MP_QSTR_uwebsocket, mp_module_uwebsocket); #endif // MICROPY_PY_UWEBSOCKET diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index b74c6b7b1..0161b9f49 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -223,7 +223,7 @@ const mp_obj_module_t mp_module_uzlib = { }; -MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib, MICROPY_PY_UZLIB); +MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index e5fa5128c..1a2a718ac 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -363,6 +363,6 @@ const mp_obj_module_t mp_module_webrepl = { .globals = (mp_obj_dict_t *)&webrepl_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__webrepl, mp_module_webrepl, MICROPY_PY_WEBREPL); +MP_REGISTER_MODULE(MP_QSTR__webrepl, mp_module_webrepl); #endif // MICROPY_PY_WEBREPL diff --git a/ports/cc3200/mods/modmachine.c b/ports/cc3200/mods/modmachine.c index be8b7d6b5..782ccc55a 100644 --- a/ports/cc3200/mods/modmachine.c +++ b/ports/cc3200/mods/modmachine.c @@ -214,4 +214,4 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); diff --git a/ports/cc3200/mods/modnetwork.c b/ports/cc3200/mods/modnetwork.c index 61996feb5..d6ccc7c6a 100644 --- a/ports/cc3200/mods/modnetwork.c +++ b/ports/cc3200/mods/modnetwork.c @@ -159,7 +159,7 @@ const mp_obj_module_t mp_module_network = { .globals = (mp_obj_dict_t*)&mp_module_network_globals, }; -MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, 1); +MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network); #if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP) STATIC const mp_rom_map_elem_t network_server_locals_dict_table[] = { diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/moduos.c index 5825ca691..cd01b59b3 100644 --- a/ports/cc3200/mods/moduos.c +++ b/ports/cc3200/mods/moduos.c @@ -180,4 +180,4 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos, 1); +MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index 65fc3ae29..32849c51d 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -817,4 +817,4 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t*)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, 1); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); diff --git a/ports/cc3200/mods/modussl.c b/ports/cc3200/mods/modussl.c index 7bfb02b1d..cd2c62dcb 100644 --- a/ports/cc3200/mods/modussl.c +++ b/ports/cc3200/mods/modussl.c @@ -161,4 +161,4 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t*)&mp_module_ussl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl, 1); +MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); diff --git a/ports/cc3200/mods/modutime.c b/ports/cc3200/mods/modutime.c index 4f4c36340..237a80065 100644 --- a/ports/cc3200/mods/modutime.c +++ b/ports/cc3200/mods/modutime.c @@ -156,4 +156,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t*)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/cc3200/mods/modwipy.c b/ports/cc3200/mods/modwipy.c index c85958375..110c3cfd3 100644 --- a/ports/cc3200/mods/modwipy.c +++ b/ports/cc3200/mods/modwipy.c @@ -29,4 +29,4 @@ const mp_obj_module_t wipy_module = { .globals = (mp_obj_dict_t*)&wipy_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_wipy, wipy_module, 1); +MP_REGISTER_MODULE(MP_QSTR_wipy, wipy_module); diff --git a/ports/esp32/modesp.c b/ports/esp32/modesp.c index fc9b0ec08..0c6429be7 100644 --- a/ports/esp32/modesp.c +++ b/ports/esp32/modesp.c @@ -143,4 +143,4 @@ const mp_obj_module_t esp_module = { .globals = (mp_obj_dict_t *)&esp_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_esp, esp_module, 1); +MP_REGISTER_MODULE(MP_QSTR_esp, esp_module); diff --git a/ports/esp32/modesp32.c b/ports/esp32/modesp32.c index 1cdf234f4..0dbd7efda 100644 --- a/ports/esp32/modesp32.c +++ b/ports/esp32/modesp32.c @@ -225,4 +225,4 @@ const mp_obj_module_t esp32_module = { .globals = (mp_obj_dict_t *)&esp32_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_esp32, esp32_module, 1); +MP_REGISTER_MODULE(MP_QSTR_esp32, esp32_module); diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index f1e261634..aee3be0e7 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -337,6 +337,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/esp32/modnetwork.c b/ports/esp32/modnetwork.c index 199836e36..45231c423 100644 --- a/ports/esp32/modnetwork.c +++ b/ports/esp32/modnetwork.c @@ -298,4 +298,4 @@ const mp_obj_module_t mp_module_network = { // Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict // with the common implementation provided by extmod/modnetwork.c. -MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, 1); +MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network); diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index aa3a8d1b6..819ea26e9 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -871,4 +871,4 @@ const mp_obj_module_t mp_module_usocket = { // Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by // extmod/mod{lwip,usocket}.c. -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, 1); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); diff --git a/ports/esp32/modutime.c b/ports/esp32/modutime.c index ca0d6b827..631d0fe29 100644 --- a/ports/esp32/modutime.c +++ b/ports/esp32/modutime.c @@ -107,4 +107,4 @@ const mp_obj_module_t utime_module = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, utime_module, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, utime_module); diff --git a/ports/esp8266/modesp.c b/ports/esp8266/modesp.c index a6084e48b..645de7fe9 100644 --- a/ports/esp8266/modesp.c +++ b/ports/esp8266/modesp.c @@ -380,4 +380,4 @@ const mp_obj_module_t esp_module = { .globals = (mp_obj_dict_t *)&esp_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_esp, esp_module, 1); +MP_REGISTER_MODULE(MP_QSTR_esp, esp_module); diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c index ef1b50f63..1dd87b9af 100644 --- a/ports/esp8266/modmachine.c +++ b/ports/esp8266/modmachine.c @@ -453,6 +453,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/esp8266/modnetwork.c b/ports/esp8266/modnetwork.c index d24bc147e..dc1b435fb 100644 --- a/ports/esp8266/modnetwork.c +++ b/ports/esp8266/modnetwork.c @@ -548,4 +548,4 @@ const mp_obj_module_t network_module = { // Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict // with the common implementation provided by extmod/modnetwork.c. -MP_REGISTER_MODULE(MP_QSTR_network, network_module, 1); +MP_REGISTER_MODULE(MP_QSTR_network, network_module); diff --git a/ports/esp8266/modutime.c b/ports/esp8266/modutime.c index 7f498ef1e..08508f881 100644 --- a/ports/esp8266/modutime.c +++ b/ports/esp8266/modutime.c @@ -130,4 +130,4 @@ const mp_obj_module_t utime_module = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, utime_module, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, utime_module); diff --git a/ports/javascript/modutime.c b/ports/javascript/modutime.c index 92ddd4729..76fe8df37 100644 --- a/ports/javascript/modutime.c +++ b/ports/javascript/modutime.c @@ -55,4 +55,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/mimxrt/modmachine.c b/ports/mimxrt/modmachine.c index fd83ebaad..ad4e4a594 100644 --- a/ports/mimxrt/modmachine.c +++ b/ports/mimxrt/modmachine.c @@ -39,6 +39,8 @@ #include "fsl_clock.h" #include "fsl_wdog.h" +#if MICROPY_PY_MACHINE + #include CPU_HEADER_H typedef enum { @@ -160,4 +162,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/mimxrt/modmimxrt.c b/ports/mimxrt/modmimxrt.c index 0091c36ff..9dd38ee07 100644 --- a/ports/mimxrt/modmimxrt.c +++ b/ports/mimxrt/modmimxrt.c @@ -42,4 +42,4 @@ const mp_obj_module_t mp_module_mimxrt = { .globals = (mp_obj_dict_t *)&mimxrt_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_mimxrt, mp_module_mimxrt, 1); +MP_REGISTER_MODULE(MP_QSTR_mimxrt, mp_module_mimxrt); diff --git a/ports/mimxrt/modutime.c b/ports/mimxrt/modutime.c index f24ce43c0..b1defff77 100644 --- a/ports/mimxrt/modutime.c +++ b/ports/mimxrt/modutime.c @@ -135,4 +135,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/nrf/boards/microbit/modules/modmicrobit.c b/ports/nrf/boards/microbit/modules/modmicrobit.c index bb721357d..c6aa445b1 100644 --- a/ports/nrf/boards/microbit/modules/modmicrobit.c +++ b/ports/nrf/boards/microbit/modules/modmicrobit.c @@ -157,4 +157,4 @@ const mp_obj_module_t microbit_module = { .globals = (mp_obj_dict_t*)µbit_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_microbit, microbit_module, 1); +MP_REGISTER_MODULE(MP_QSTR_microbit, microbit_module); diff --git a/ports/nrf/modules/ble/modble.c b/ports/nrf/modules/ble/modble.c index 6726c63c4..3a9c6b20d 100644 --- a/ports/nrf/modules/ble/modble.c +++ b/ports/nrf/modules/ble/modble.c @@ -102,6 +102,6 @@ const mp_obj_module_t ble_module = { .globals = (mp_obj_dict_t*)&ble_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ble, ble_module, MICROPY_PY_BLE); +MP_REGISTER_MODULE(MP_QSTR_ble, ble_module); #endif // MICROPY_PY_BLE diff --git a/ports/nrf/modules/board/modboard.c b/ports/nrf/modules/board/modboard.c index 45dd9f30e..1fe3dcc5c 100644 --- a/ports/nrf/modules/board/modboard.c +++ b/ports/nrf/modules/board/modboard.c @@ -54,4 +54,4 @@ const mp_obj_module_t board_module = { .globals = (mp_obj_dict_t*)&board_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_board, board_module, 1); +MP_REGISTER_MODULE(MP_QSTR_board, board_module); diff --git a/ports/nrf/modules/machine/modmachine.c b/ports/nrf/modules/machine/modmachine.c index 65297548a..1378ba8f4 100644 --- a/ports/nrf/modules/machine/modmachine.c +++ b/ports/nrf/modules/machine/modmachine.c @@ -55,6 +55,8 @@ #include "rtcounter.h" #endif +#if MICROPY_PY_MACHINE + #define PYB_RESET_HARD (0) #define PYB_RESET_WDT (1) #define PYB_RESET_SOFT (2) @@ -249,4 +251,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/nrf/modules/music/modmusic.c b/ports/nrf/modules/music/modmusic.c index c8c6775de..a950b0392 100644 --- a/ports/nrf/modules/music/modmusic.c +++ b/ports/nrf/modules/music/modmusic.c @@ -509,6 +509,6 @@ const mp_obj_module_t music_module = { .globals = (mp_obj_dict_t*)µbit_music_locals_dict, }; -MP_REGISTER_MODULE(MP_QSTR_music, music_module, MICROPY_PY_MUSIC); +MP_REGISTER_MODULE(MP_QSTR_music, music_module); #endif // MICROPY_PY_MUSIC diff --git a/ports/nrf/modules/nrf/modnrf.c b/ports/nrf/modules/nrf/modnrf.c index ab7d043f4..6533fa121 100644 --- a/ports/nrf/modules/nrf/modnrf.c +++ b/ports/nrf/modules/nrf/modnrf.c @@ -95,6 +95,6 @@ const mp_obj_module_t nrf_module = { .globals = (mp_obj_dict_t *)&nrf_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_nrf, nrf_module, MICROPY_PY_NRF); +MP_REGISTER_MODULE(MP_QSTR_nrf, nrf_module); #endif // MICROPY_PY_NRF diff --git a/ports/nrf/modules/ubluepy/modubluepy.c b/ports/nrf/modules/ubluepy/modubluepy.c index d888b6dd5..fd42c4940 100644 --- a/ports/nrf/modules/ubluepy/modubluepy.c +++ b/ports/nrf/modules/ubluepy/modubluepy.c @@ -67,6 +67,6 @@ const mp_obj_module_t mp_module_ubluepy = { .globals = (mp_obj_dict_t*)&mp_module_ubluepy_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubluepy, mp_module_ubluepy, MICROPY_PY_UBLUEPY); +MP_REGISTER_MODULE(MP_QSTR_ubluepy, mp_module_ubluepy); #endif // MICROPY_PY_UBLUEPY diff --git a/ports/nrf/modules/uos/moduos.c b/ports/nrf/modules/uos/moduos.c index ea60df7a6..184f833ef 100644 --- a/ports/nrf/modules/uos/moduos.c +++ b/ports/nrf/modules/uos/moduos.c @@ -197,4 +197,4 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos, 1); +MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); diff --git a/ports/nrf/modules/utime/modutime.c b/ports/nrf/modules/utime/modutime.c index 6fe2da474..efbae3f58 100644 --- a/ports/nrf/modules/utime/modutime.c +++ b/ports/nrf/modules/utime/modutime.c @@ -55,4 +55,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t*)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/pic16bit/modpyb.c b/ports/pic16bit/modpyb.c index 61955509e..9774105d6 100644 --- a/ports/pic16bit/modpyb.c +++ b/ports/pic16bit/modpyb.c @@ -69,4 +69,4 @@ const mp_obj_module_t pyb_module = { .globals = (mp_obj_dict_t *)&pyb_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module, 1); +MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module); diff --git a/ports/qemu-arm/modmachine.c b/ports/qemu-arm/modmachine.c index 1168e74a1..515452f41 100644 --- a/ports/qemu-arm/modmachine.c +++ b/ports/qemu-arm/modmachine.c @@ -28,6 +28,8 @@ #include "extmod/machine_pinbase.h" #include "extmod/machine_signal.h" +#if MICROPY_PY_MACHINE + STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, @@ -46,4 +48,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/renesas-ra/modmachine.c b/ports/renesas-ra/modmachine.c index e505a49ff..cd6e75034 100644 --- a/ports/renesas-ra/modmachine.c +++ b/ports/renesas-ra/modmachine.c @@ -55,6 +55,7 @@ #include "spi.h" #include "uart.h" +#if MICROPY_PY_MACHINE #define PYB_RESET_SOFT (0) #define PYB_RESET_POWER_ON (1) @@ -303,4 +304,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/renesas-ra/modutime.c b/ports/renesas-ra/modutime.c index 2bd0adfa2..d0b670df4 100644 --- a/ports/renesas-ra/modutime.c +++ b/ports/renesas-ra/modutime.c @@ -35,6 +35,8 @@ #include "systick.h" #include "rtc.h" +#if MICROPY_PY_UTIME + /// \module time - time related functions /// /// The `time` module provides functions for getting the current time and date, @@ -157,4 +159,6 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MICROPY_PY_UTIME); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); + +#endif // MICROPY_PY_UTIME diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c index d6941bcfe..fbaf29ee1 100644 --- a/ports/rp2/modmachine.c +++ b/ports/rp2/modmachine.c @@ -43,6 +43,8 @@ #include "pico/stdlib.h" #include "pico/unique_id.h" +#if MICROPY_PY_MACHINE + #define RP2_RESET_PWRON (1) #define RP2_RESET_WDT (3) @@ -188,4 +190,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/rp2/modrp2.c b/ports/rp2/modrp2.c index 9c5223587..5dc066d65 100644 --- a/ports/rp2/modrp2.c +++ b/ports/rp2/modrp2.c @@ -43,4 +43,4 @@ const mp_obj_module_t mp_module_rp2 = { .globals = (mp_obj_dict_t *)&rp2_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR__rp2, mp_module_rp2, 1); +MP_REGISTER_MODULE(MP_QSTR__rp2, mp_module_rp2); diff --git a/ports/rp2/modutime.c b/ports/rp2/modutime.c index b73eacf87..ac291c893 100644 --- a/ports/rp2/modutime.c +++ b/ports/rp2/modutime.c @@ -126,4 +126,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/samd/modmachine.c b/ports/samd/modmachine.c index 8da83b7d2..74e357175 100644 --- a/ports/samd/modmachine.c +++ b/ports/samd/modmachine.c @@ -35,6 +35,8 @@ #include "hpl_gclk_base.h" #include "hpl_pm_base.h" +#if MICROPY_PY_MACHINE + #if defined(MCU_SAMD21) #define DBL_TAP_ADDR ((volatile uint32_t *)(0x20000000 + 32 * 1024 - 4)) #elif defined(MCU_SAMD51) @@ -129,4 +131,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/samd/modsamd.c b/ports/samd/modsamd.c index 387ced5cf..68fd6b53e 100644 --- a/ports/samd/modsamd.c +++ b/ports/samd/modsamd.c @@ -40,4 +40,4 @@ const mp_obj_module_t mp_module_samd = { .globals = (mp_obj_dict_t *)&samd_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_samd, mp_module_samd, 1); +MP_REGISTER_MODULE(MP_QSTR_samd, mp_module_samd); diff --git a/ports/samd/modutime.c b/ports/samd/modutime.c index 0b872a297..bbeedcfda 100644 --- a/ports/samd/modutime.c +++ b/ports/samd/modutime.c @@ -100,4 +100,4 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, 1); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c index 20140ed10..5fca9b3e0 100644 --- a/ports/stm32/modmachine.c +++ b/ports/stm32/modmachine.c @@ -396,6 +396,8 @@ STATIC mp_obj_t machine_reset_cause(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause); +#if MICROPY_PY_MACHINE + STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, { MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, @@ -481,4 +483,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); + +#endif // MICROPY_PY_MACHINE diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c index d23065e4b..96e719c6b 100644 --- a/ports/stm32/modpyb.c +++ b/ports/stm32/modpyb.c @@ -58,6 +58,8 @@ char pyb_country_code[2]; +#if MICROPY_PY_PYB + STATIC mp_obj_t pyb_fault_debug(mp_obj_t value) { pyb_hard_fault_debug = mp_obj_is_true(value); return mp_const_none; @@ -266,4 +268,6 @@ const mp_obj_module_t pyb_module = { .globals = (mp_obj_dict_t *)&pyb_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module, MICROPY_PY_PYB); +MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module); + +#endif // MICROPY_PY_PYB diff --git a/ports/stm32/modstm.c b/ports/stm32/modstm.c index 185ec1a2f..94d56d4d0 100644 --- a/ports/stm32/modstm.c +++ b/ports/stm32/modstm.c @@ -60,6 +60,6 @@ const mp_obj_module_t stm_module = { .globals = (mp_obj_dict_t *)&stm_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_stm, stm_module, MICROPY_PY_STM); +MP_REGISTER_MODULE(MP_QSTR_stm, stm_module); #endif // MICROPY_PY_STM diff --git a/ports/stm32/modutime.c b/ports/stm32/modutime.c index d8ac156de..72a2be303 100644 --- a/ports/stm32/modutime.c +++ b/ports/stm32/modutime.c @@ -129,6 +129,8 @@ STATIC mp_obj_t time_time(void) { } MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); +#if MICROPY_PY_UTIME + STATIC const mp_rom_map_elem_t time_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) }, @@ -154,4 +156,6 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&time_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MICROPY_PY_UTIME); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); + +#endif // MICROPY_PY_UTIME diff --git a/ports/teensy/modpyb.c b/ports/teensy/modpyb.c index b8fcfaaa5..3939607ad 100644 --- a/ports/teensy/modpyb.c +++ b/ports/teensy/modpyb.c @@ -361,4 +361,4 @@ const mp_obj_module_t pyb_module = { .globals = (mp_obj_dict_t *)&pyb_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module, 1); +MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module); diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c index b692af4df..d82d5270f 100644 --- a/ports/unix/modffi.c +++ b/ports/unix/modffi.c @@ -38,6 +38,8 @@ #include "py/objint.h" #include "py/gc.h" +#if MICROPY_PY_FFI + /* * modffi uses character codes to encode a value type, based on "struct" * module type codes, with some extensions and overridings. @@ -632,4 +634,6 @@ const mp_obj_module_t mp_module_ffi = { .globals = (mp_obj_dict_t *)&mp_module_ffi_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ffi, mp_module_ffi, MICROPY_PY_FFI); +MP_REGISTER_MODULE(MP_QSTR_ffi, mp_module_ffi); + +#endif // MICROPY_PY_FFI diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 5d2beaa8d..c86f30653 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -35,6 +35,8 @@ #include +#if MICROPY_PY_JNI + #define JJ(call, ...) (*env)->call(env, __VA_ARGS__) #define JJ1(call) (*env)->call(env) #define MATCH(s, static) (!strncmp(s, static, sizeof(static) - 1)) @@ -713,4 +715,6 @@ const mp_obj_module_t mp_module_jni = { .globals = (mp_obj_dict_t *)&mp_module_jni_globals, }; -MP_REGISTER_MODULE(MP_QSTR_jni, mp_module_jni, MICROPY_PY_JNI); +MP_REGISTER_MODULE(MP_QSTR_jni, mp_module_jni); + +#endif // MICROPY_PY_JNI diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c index 3d4d9eebc..542ff5002 100644 --- a/ports/unix/modmachine.c +++ b/ports/unix/modmachine.c @@ -110,6 +110,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/unix/modtermios.c b/ports/unix/modtermios.c index cce8c28ab..687bf1abf 100644 --- a/ports/unix/modtermios.c +++ b/ports/unix/modtermios.c @@ -33,6 +33,8 @@ #include "py/runtime.h" #include "py/mphal.h" +#if MICROPY_PY_TERMIOS + STATIC mp_obj_t mod_termios_tcgetattr(mp_obj_t fd_in) { struct termios term; int fd = mp_obj_get_int(fd_in); @@ -149,4 +151,6 @@ const mp_obj_module_t mp_module_termios = { .globals = (mp_obj_dict_t *)&mp_module_termios_globals, }; -MP_REGISTER_MODULE(MP_QSTR_termios, mp_module_termios, MICROPY_PY_TERMIOS); +MP_REGISTER_MODULE(MP_QSTR_termios, mp_module_termios); + +#endif // MICROPY_PY_TERMIOS diff --git a/ports/unix/modtime.c b/ports/unix/modtime.c index 00b3f9436..c9eb09c15 100644 --- a/ports/unix/modtime.c +++ b/ports/unix/modtime.c @@ -232,6 +232,6 @@ const mp_obj_module_t mp_module_time = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time, MICROPY_PY_UTIME); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time); #endif // MICROPY_PY_UTIME diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index d3e0eff03..2de4a316e 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -351,6 +351,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect, MICROPY_PY_USELECT_POSIX); +MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect); #endif // MICROPY_PY_USELECT_POSIX diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index 7526d9679..03d069cb8 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -49,6 +49,8 @@ #include "extmod/vfs.h" #include +#if MICROPY_PY_SOCKET + /* The idea of this module is to implement reasonable minimum of socket-related functions to write typical clients and servers. @@ -702,4 +704,6 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_socket, MICROPY_PY_SOCKET); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_socket); + +#endif // MICROPY_PY_SOCKET diff --git a/ports/zephyr/modmachine.c b/ports/zephyr/modmachine.c index c8b07c023..f4b1c0849 100644 --- a/ports/zephyr/modmachine.c +++ b/ports/zephyr/modmachine.c @@ -89,6 +89,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE); +MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modusocket.c index fbcd7e87a..29240ad15 100644 --- a/ports/zephyr/modusocket.c +++ b/ports/zephyr/modusocket.c @@ -472,6 +472,6 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, MICROPY_PY_USOCKET); +MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); #endif // MICROPY_PY_USOCKET diff --git a/ports/zephyr/modutime.c b/ports/zephyr/modutime.c index c9864a443..16ac9af6e 100644 --- a/ports/zephyr/modutime.c +++ b/ports/zephyr/modutime.c @@ -64,6 +64,6 @@ const mp_obj_module_t mp_module_time = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time, MICROPY_PY_UTIME); +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time); #endif // MICROPY_PY_UTIME diff --git a/ports/zephyr/modzephyr.c b/ports/zephyr/modzephyr.c index fc883ddc4..541dfe0b3 100644 --- a/ports/zephyr/modzephyr.c +++ b/ports/zephyr/modzephyr.c @@ -89,6 +89,6 @@ const mp_obj_module_t mp_module_zephyr = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_zephyr, mp_module_zephyr, MICROPY_PY_ZEPHYR); +MP_REGISTER_MODULE(MP_QSTR_zephyr, mp_module_zephyr); #endif // MICROPY_PY_ZEPHYR diff --git a/ports/zephyr/modzsensor.c b/ports/zephyr/modzsensor.c index 2286a46fd..6e8a5ca07 100644 --- a/ports/zephyr/modzsensor.c +++ b/ports/zephyr/modzsensor.c @@ -142,6 +142,6 @@ const mp_obj_module_t mp_module_zsensor = { .globals = (mp_obj_dict_t *)&mp_module_zsensor_globals, }; -MP_REGISTER_MODULE(MP_QSTR_zsensor, mp_module_zsensor, MICROPY_PY_ZSENSOR); +MP_REGISTER_MODULE(MP_QSTR_zsensor, mp_module_zsensor); #endif // MICROPY_PY_UHASHLIB diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index 8d045c0d0..657809db4 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # This pre-processor parses a single file containing a list of -# MP_REGISTER_MODULE(module_name, obj_module, enabled_define) +# MP_REGISTER_MODULE(module_name, obj_module) # These are used to generate a header with the required entries for # "mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c @@ -12,14 +12,14 @@ import io import argparse -pattern = re.compile(r"\s*MP_REGISTER_MODULE\((.*?),\s*(.*?),\s*(.*?)\);", flags=re.DOTALL) +pattern = re.compile(r"\s*MP_REGISTER_MODULE\((.*?),\s*(.*?)\);", flags=re.DOTALL) def find_module_registrations(filename): """Find any MP_REGISTER_MODULE definitions in the provided file. :param str filename: path to file to check - :return: List[(module_name, obj_module, enabled_define)] + :return: List[(module_name, obj_module)] """ global pattern @@ -30,31 +30,24 @@ def find_module_registrations(filename): def generate_module_table_header(modules): """Generate header with module table entries for builtin modules. - :param List[(module_name, obj_module, enabled_define)] modules: module defs + :param List[(module_name, obj_module)] modules: module defs :return: None """ # Print header file for all external modules. mod_defs = set() print("// Automatically generated by makemoduledefs.py.\n") - for module_name, obj_module, enabled_define in modules: + for module_name, obj_module in modules: mod_def = "MODULE_DEF_{}".format(module_name.upper()) mod_defs.add(mod_def) print( ( - "#if ({enabled_define})\n" - " extern const struct _mp_obj_module_t {obj_module};\n" - " #undef {mod_def}\n" - " #define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n" - "#else\n" - " #ifndef {mod_def}\n" - " #define {mod_def}\n" - " #endif\n" - "#endif\n" + "extern const struct _mp_obj_module_t {obj_module};\n" + "#undef {mod_def}\n" + "#define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n" ).format( module_name=module_name, obj_module=obj_module, - enabled_define=enabled_define, mod_def=mod_def, ) ) diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index 85e04b944..4c416a874 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -89,7 +89,7 @@ def process_file(f): elif args.mode == _MODE_COMPRESS: re_match = re.compile(r'MP_COMPRESSED_ROM_TEXT\("([^"]*)"\)') elif args.mode == _MODE_MODULE: - re_match = re.compile(r"MP_REGISTER_MODULE\(.*?,\s*.*?,\s*.*?\);") + re_match = re.compile(r"MP_REGISTER_MODULE\(.*?,\s*.*?\);") output = [] last_fname = None for line in f: diff --git a/py/modarray.c b/py/modarray.c index 9ab1795f8..d9f7a0452 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -40,6 +40,6 @@ const mp_obj_module_t mp_module_uarray = { .globals = (mp_obj_dict_t *)&mp_module_array_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uarray, mp_module_uarray, MICROPY_PY_ARRAY); +MP_REGISTER_MODULE(MP_QSTR_uarray, mp_module_uarray); #endif diff --git a/py/modbuiltins.c b/py/modbuiltins.c index adb9ea40a..f3caccbc8 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -788,4 +788,4 @@ const mp_obj_module_t mp_module_builtins = { .globals = (mp_obj_dict_t *)&mp_module_builtins_globals, }; -MP_REGISTER_MODULE(MP_QSTR_builtins, mp_module_builtins, 1); +MP_REGISTER_MODULE(MP_QSTR_builtins, mp_module_builtins); diff --git a/py/modcmath.c b/py/modcmath.c index 44a4736e0..1418362ad 100644 --- a/py/modcmath.c +++ b/py/modcmath.c @@ -149,6 +149,6 @@ const mp_obj_module_t mp_module_cmath = { .globals = (mp_obj_dict_t *)&mp_module_cmath_globals, }; -MP_REGISTER_MODULE(MP_QSTR_cmath, mp_module_cmath, MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH); +MP_REGISTER_MODULE(MP_QSTR_cmath, mp_module_cmath); #endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH diff --git a/py/modcollections.c b/py/modcollections.c index 0c008579f..8c62f34db 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -46,6 +46,6 @@ const mp_obj_module_t mp_module_collections = { .globals = (mp_obj_dict_t *)&mp_module_collections_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ucollections, mp_module_collections, MICROPY_PY_COLLECTIONS); +MP_REGISTER_MODULE(MP_QSTR_ucollections, mp_module_collections); #endif // MICROPY_PY_COLLECTIONS diff --git a/py/modgc.c b/py/modgc.c index 0ae3a84ae..c11bcaecd 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -115,6 +115,6 @@ const mp_obj_module_t mp_module_gc = { .globals = (mp_obj_dict_t *)&mp_module_gc_globals, }; -MP_REGISTER_MODULE(MP_QSTR_gc, mp_module_gc, MICROPY_PY_GC && MICROPY_ENABLE_GC); +MP_REGISTER_MODULE(MP_QSTR_gc, mp_module_gc); #endif diff --git a/py/modio.c b/py/modio.c index 72e633bd9..50af0b6a4 100644 --- a/py/modio.c +++ b/py/modio.c @@ -233,6 +233,6 @@ const mp_obj_module_t mp_module_io = { .globals = (mp_obj_dict_t *)&mp_module_io_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uio, mp_module_io, MICROPY_PY_IO); +MP_REGISTER_MODULE(MP_QSTR_uio, mp_module_io); #endif diff --git a/py/modmath.c b/py/modmath.c index 764f59e1c..72b5dde51 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -435,6 +435,6 @@ const mp_obj_module_t mp_module_math = { .globals = (mp_obj_dict_t *)&mp_module_math_globals, }; -MP_REGISTER_MODULE(MP_QSTR_math, mp_module_math, MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH); +MP_REGISTER_MODULE(MP_QSTR_math, mp_module_math); #endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/py/modmicropython.c b/py/modmicropython.c index a2faa9a9f..eafff90c6 100644 --- a/py/modmicropython.c +++ b/py/modmicropython.c @@ -210,4 +210,4 @@ const mp_obj_module_t mp_module_micropython = { .globals = (mp_obj_dict_t *)&mp_module_micropython_globals, }; -MP_REGISTER_MODULE(MP_QSTR_micropython, mp_module_micropython, 1); +MP_REGISTER_MODULE(MP_QSTR_micropython, mp_module_micropython); diff --git a/py/modstruct.c b/py/modstruct.c index 2cbf691af..69c7279e3 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_ustruct = { .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ustruct, mp_module_ustruct, MICROPY_PY_STRUCT); +MP_REGISTER_MODULE(MP_QSTR_ustruct, mp_module_ustruct); #endif diff --git a/py/modsys.c b/py/modsys.c index e3fb697eb..a090f1212 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -284,6 +284,6 @@ const mp_obj_module_t mp_module_sys = { .globals = (mp_obj_dict_t *)&mp_module_sys_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys, MICROPY_PY_SYS); +MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys); #endif diff --git a/py/modthread.c b/py/modthread.c index 11d0405e7..bad94fbf2 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -300,6 +300,6 @@ const mp_obj_module_t mp_module_thread = { .globals = (mp_obj_dict_t *)&mp_module_thread_globals, }; -MP_REGISTER_MODULE(MP_QSTR__thread, mp_module_thread, MICROPY_PY_THREAD); +MP_REGISTER_MODULE(MP_QSTR__thread, mp_module_thread); #endif // MICROPY_PY_THREAD diff --git a/py/moduerrno.c b/py/moduerrno.c index 4b61e0bda..1b16fd9d9 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -99,7 +99,7 @@ const mp_obj_module_t mp_module_uerrno = { .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno, MICROPY_PY_UERRNO); +MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno); qstr mp_errno_to_str(mp_obj_t errno_val) { #if MICROPY_PY_UERRNO_ERRORCODE diff --git a/py/obj.h b/py/obj.h index aa5ed179b..29cd1855c 100644 --- a/py/obj.h +++ b/py/obj.h @@ -419,10 +419,9 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; // Declare a module as a builtin, processed by makemoduledefs.py // param module_name: MP_QSTR_ // param obj_module: mp_obj_module_t instance -// prarm enabled_define: used as `#if (enabled_define) around entry` #ifndef NO_QSTR -#define MP_REGISTER_MODULE(module_name, obj_module, enabled_define) +#define MP_REGISTER_MODULE(module_name, obj_module) #endif // Underlying map/hash table implementation (not dict object or map function) diff --git a/py/runtime.c b/py/runtime.c index 8c857fec2..e6d8c6807 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -59,7 +59,7 @@ const mp_obj_module_t mp_module___main__ = { .globals = (mp_obj_dict_t *)&MP_STATE_VM(dict_main), }; -MP_REGISTER_MODULE(MP_QSTR___main__, mp_module___main__, 1); +MP_REGISTER_MODULE(MP_QSTR___main__, mp_module___main__); void mp_init(void) { qstr_init();