diff options
Diffstat (limited to 'py')
| -rw-r--r-- | py/makemoduledefs.py | 23 | ||||
| -rw-r--r-- | py/makeqstrdefs.py | 2 | ||||
| -rw-r--r-- | py/modarray.c | 2 | ||||
| -rw-r--r-- | py/modbuiltins.c | 2 | ||||
| -rw-r--r-- | py/modcmath.c | 2 | ||||
| -rw-r--r-- | py/modcollections.c | 2 | ||||
| -rw-r--r-- | py/modgc.c | 2 | ||||
| -rw-r--r-- | py/modio.c | 2 | ||||
| -rw-r--r-- | py/modmath.c | 2 | ||||
| -rw-r--r-- | py/modmicropython.c | 2 | ||||
| -rw-r--r-- | py/modstruct.c | 2 | ||||
| -rw-r--r-- | py/modsys.c | 2 | ||||
| -rw-r--r-- | py/modthread.c | 2 | ||||
| -rw-r--r-- | py/moduerrno.c | 2 | ||||
| -rw-r--r-- | py/obj.h | 3 | ||||
| -rw-r--r-- | py/runtime.c | 2 |
16 files changed, 23 insertions, 31 deletions
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 @@ -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_<module name> // 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(); |
