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 <damien@micropython.org>
This commit is contained in:
Damien George 2022-05-31 22:56:11 +10:00
parent 47f634300c
commit efe23aca71
103 changed files with 173 additions and 134 deletions

View File

@ -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

View File

@ -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

View File

@ -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),

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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[] = {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -157,4 +157,4 @@ const mp_obj_module_t microbit_module = {
.globals = (mp_obj_dict_t*)&microbit_module_globals,
};
MP_REGISTER_MODULE(MP_QSTR_microbit, microbit_module, 1);
MP_REGISTER_MODULE(MP_QSTR_microbit, microbit_module);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -509,6 +509,6 @@ const mp_obj_module_t music_module = {
.globals = (mp_obj_dict_t*)&microbit_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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -35,6 +35,8 @@
#include <jni.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -49,6 +49,8 @@
#include "extmod/vfs.h"
#include <poll.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,
)
)

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More