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>
This commit is contained in:
David Lechner
2022-07-01 12:29:08 -05:00
committed by Damien George
parent a8d78cc398
commit fc3d7ae11b
10 changed files with 154 additions and 12 deletions

View File

@@ -192,6 +192,13 @@ typedef struct _mp_state_vm_t {
// include any root pointers defined by a port
MICROPY_PORT_ROOT_POINTERS
// Include any root pointers registered with MP_REGISTER_ROOT_POINTER().
#ifndef NO_QSTR
// Only include root pointer definitions when not doing qstr extraction, because
// the qstr extraction stage also generates the root pointers header file.
#include "genhdr/root_pointers.h"
#endif
// root pointers for extmod
#if MICROPY_REPL_EVENT_DRIVEN