From 22cf0940e134453dee6fd6c617b28ecd1ec50943 Mon Sep 17 00:00:00 2001 From: stijn Date: Wed, 5 Jan 2022 16:04:58 +0100 Subject: [PATCH] py/modbuiltins: Add additional macro for extending builtins. Mainly useful for defining additional globals in boards and variants. --- py/modbuiltins.c | 1 + py/mpconfig.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index a7e49a1ed9..26a84f57b3 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -775,6 +775,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { // Extra builtins as defined by a port MICROPY_PORT_BUILTINS + MICROPY_PORT_EXTRA_BUILTINS }; MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table); diff --git a/py/mpconfig.h b/py/mpconfig.h index d93100bb83..2aa6f634e2 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1581,6 +1581,12 @@ typedef double mp_float_t; #define MICROPY_PORT_BUILTINS #endif +// Additional builtin function definitions for extension by command-line, boards or variants. +// See modbuiltins.c:mp_module_builtins_globals_table for format. +#ifndef MICROPY_PORT_EXTRA_BUILTINS +#define MICROPY_PORT_EXTRA_BUILTINS +#endif + // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format. #ifndef MICROPY_PORT_BUILTIN_MODULES #define MICROPY_PORT_BUILTIN_MODULES