diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2019-02-18 14:58:44 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-03-08 22:46:43 +1100 |
commit | cf22f4793cb04e8e63a0d11f479a69c9be6c93ba (patch) | |
tree | d567e429710b58ad9283d3e9c1a389cde64e0e83 /py/objmodule.c | |
parent | e4ac104b7f2980114c6d1b0d8ff5917777cf8f24 (diff) |
py: Allow registration of modules at their definition.
During make, makemoduledefs.py parses the current builds c files for
MP_REGISTER_MODULE(module_name, obj_module, enabled_define)
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
Diffstat (limited to 'py/objmodule.c')
-rw-r--r-- | py/objmodule.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/py/objmodule.c b/py/objmodule.c index 9ba617707..9191c73ec 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -31,6 +31,8 @@ #include "py/runtime.h" #include "py/builtin.h" +#include "genhdr/moduledefs.h" + STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); @@ -136,9 +138,6 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { { MP_ROM_QSTR(MP_QSTR_builtins), MP_ROM_PTR(&mp_module_builtins) }, { MP_ROM_QSTR(MP_QSTR_micropython), MP_ROM_PTR(&mp_module_micropython) }, -#if MICROPY_PY_ARRAY - { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) }, -#endif #if MICROPY_PY_IO { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) }, #endif @@ -226,6 +225,11 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { // extra builtin modules as defined by a port MICROPY_PORT_BUILTIN_MODULES + + #ifdef MICROPY_REGISTERED_MODULES + // builtin modules declared with MP_REGISTER_MODULE() + MICROPY_REGISTERED_MODULES + #endif }; MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); |