From 17af5cd492e926c2d3a2c06b6519242bf8f3885c Mon Sep 17 00:00:00 2001 From: Rob Capellini Date: Tue, 24 Aug 2021 20:07:10 -0400 Subject: [PATCH 1/2] Use MP_REGISTER_MODULE with displayio, terminalio, and fontio Convert from using MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS to using MP_REGISTER_MODULE for displayio, terminalio, and fontio modules. Related to #5183. --- py/circuitpy_mpconfig.h | 22 +++++----------------- shared-bindings/displayio/__init__.c | 2 ++ shared-bindings/fontio/__init__.c | 2 ++ shared-bindings/terminalio/__init__.c | 2 ++ 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3aa6d34494ba..c5ebdcff17c5 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -412,27 +412,18 @@ extern const struct _mp_obj_module_t digitalio_module; #define DIGITALIO_MODULE #endif +// CIRCUITPY_DISPLAYIO uses MP_REGISTER_MODULE +// CIRCUITPY_TERMINALIO uses MP_REGISTER_MODULE +// CIRCUITPY_FONTIO uses MP_REGISTER_MODULE + #if CIRCUITPY_DISPLAYIO -extern const struct _mp_obj_module_t displayio_module; -extern const struct _mp_obj_module_t fontio_module; -extern const struct _mp_obj_module_t terminalio_module; -#define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module }, #ifndef CIRCUITPY_DISPLAY_LIMIT #define CIRCUITPY_DISPLAY_LIMIT (1) #endif #else -#define DISPLAYIO_MODULE #define CIRCUITPY_DISPLAY_LIMIT (0) #endif -#if CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO -#define FONTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_fontio), (mp_obj_t)&fontio_module }, -#define TERMINALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module }, -#else -#define FONTIO_MODULE -#define TERMINALIO_MODULE -#endif - #if CIRCUITPY_DUALBANK extern const struct _mp_obj_module_t dualbank_module; #define DUALBANK_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_dualbank), (mp_obj_t)&dualbank_module }, @@ -886,7 +877,7 @@ extern const struct _mp_obj_module_t msgpack_module; TIME_MODULE_ALT_NAME \ // This is an inclusive list that should correspond to the CIRCUITPY_XXX list above, -// including dependencies such as TERMINALIO depending on DISPLAYIO (shown by indentation). +// including dependencies (shown by indentation). // Some of these definitions will be blank depending on what is turned on and off. // Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. #define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ @@ -912,10 +903,7 @@ extern const struct _mp_obj_module_t msgpack_module; CANIO_MODULE \ COUNTIO_MODULE \ DIGITALIO_MODULE \ - DISPLAYIO_MODULE \ DUALBANK_MODULE \ - FONTIO_MODULE \ - TERMINALIO_MODULE \ VECTORIO_MODULE \ ERRNO_MODULE \ ESPIDF_MODULE \ diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index dc4971de2a1c..89d18d960951 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -136,3 +136,5 @@ const mp_obj_module_t displayio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&displayio_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO); diff --git a/shared-bindings/fontio/__init__.c b/shared-bindings/fontio/__init__.c index c80d68a8791f..fc5c011eb3ca 100644 --- a/shared-bindings/fontio/__init__.c +++ b/shared-bindings/fontio/__init__.c @@ -48,3 +48,5 @@ const mp_obj_module_t fontio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&fontio_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_fontio, fontio_module, CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO); diff --git a/shared-bindings/terminalio/__init__.c b/shared-bindings/terminalio/__init__.c index 084b76f21e89..38313dc7575a 100644 --- a/shared-bindings/terminalio/__init__.c +++ b/shared-bindings/terminalio/__init__.c @@ -56,3 +56,5 @@ const mp_obj_module_t terminalio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&terminalio_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_terminalio, terminalio_module, CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO); From deb8e2a50aa2d3632ae3b9a3916774dd4a670847 Mon Sep 17 00:00:00 2001 From: Rob Capellini Date: Tue, 24 Aug 2021 20:55:39 -0400 Subject: [PATCH 2/2] Remove comment that no longer applies --- py/circuitpy_mpconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index c5ebdcff17c5..463cad144212 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -877,7 +877,7 @@ extern const struct _mp_obj_module_t msgpack_module; TIME_MODULE_ALT_NAME \ // This is an inclusive list that should correspond to the CIRCUITPY_XXX list above, -// including dependencies (shown by indentation). +// including dependencies. // Some of these definitions will be blank depending on what is turned on and off. // Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. #define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \