diff options
author | David Lechner <david@pybricks.com> | 2022-07-01 12:29:08 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-07-18 13:48:23 +1000 |
commit | fc3d7ae11be11a7f05709ebfd439061fce9ee555 (patch) | |
tree | 8c0ec32de2abad065c7adc8b6d18d1d7d3dffc18 /py/obj.h | |
parent | a8d78cc39839aaf4a77bef05377c457c7ba75ead (diff) |
py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator.
This adds new compile-time infrastructure to parse source code files for
`MP_REGISTER_ROOT_POINTER()` and generates a new `root_pointers.h` header
file containing the collected declarations. This works the same as the
existing `MP_REGISTER_MODULE()` feature.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -416,13 +416,18 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; #define MP_DEFINE_CONST_STATICMETHOD_OBJ(obj_name, fun_name) const mp_rom_obj_static_class_method_t obj_name = {{&mp_type_staticmethod}, fun_name} #define MP_DEFINE_CONST_CLASSMETHOD_OBJ(obj_name, fun_name) const mp_rom_obj_static_class_method_t obj_name = {{&mp_type_classmethod}, fun_name} +#ifndef NO_QSTR + // 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 - -#ifndef NO_QSTR #define MP_REGISTER_MODULE(module_name, obj_module) -#endif + +// Declare a root pointer (to avoid garbage collection of a global static variable). +// param variable_declaration: a valid C variable declaration +#define MP_REGISTER_ROOT_POINTER(variable_declaration) + +#endif // NO_QSTR // Underlying map/hash table implementation (not dict object or map function) |