diff --git a/py/misc.h b/py/misc.h index 37c6caa4ae..e17616b16a 100644 --- a/py/misc.h +++ b/py/misc.h @@ -297,7 +297,6 @@ typedef union _mp_float_union_t { // So leave MP_COMPRESSED_ROM_TEXT in place for makeqstrdefs.py / makecompresseddata.py to find them. #else - // Compression enabled and doing a regular build. // Map MP_COMPRESSED_ROM_TEXT to the compressed strings. @@ -327,10 +326,9 @@ inline MP_ALWAYSINLINE const char *MP_COMPRESSED_ROM_TEXT(const char *msg) { return msg; } - #endif -#elif CIRCUITPY +#elif defined(CIRCUITPY) #include "supervisor/shared/translate/translate.h" #else @@ -339,6 +337,10 @@ inline MP_ALWAYSINLINE const char *MP_COMPRESSED_ROM_TEXT(const char *msg) { typedef const char *mp_rom_error_text_t; #define MP_COMPRESSED_ROM_TEXT(x) x -#endif // MICROPY_ROM_TEXT_COMPRESSION // CIRCUITPY +#endif // MICROPY_ROM_TEXT_COMPRESSION + +// Might add more types of compressed text in the future. +// For now, forward directly to MP_COMPRESSED_ROM_TEXT. +#define MP_ERROR_TEXT(x) (mp_rom_error_text_t)MP_COMPRESSED_ROM_TEXT(x) #endif // MICROPY_INCLUDED_PY_MISC_H diff --git a/supervisor/shared/translate/compressed_string.h b/supervisor/shared/translate/compressed_string.h index efc2c65634..1174121068 100644 --- a/supervisor/shared/translate/compressed_string.h +++ b/supervisor/shared/translate/compressed_string.h @@ -94,7 +94,7 @@ typedef struct compressed_string { uint8_t data; const uint8_t tail[]; -} mp_rom_error_text_t; +} *mp_rom_error_text_t; // Return the compressed, translated version of a source string // Usually, due to LTO, this is optimized into a load of a constant diff --git a/supervisor/shared/translate/translate.h b/supervisor/shared/translate/translate.h index 49d5b5a642..be84670776 100644 --- a/supervisor/shared/translate/translate.h +++ b/supervisor/shared/translate/translate.h @@ -33,9 +33,7 @@ #include "supervisor/shared/translate/compressed_string.h" // Map MicroPython's error messages to our translations. -#if !defined(MICROPY_ENABLE_DYNRUNTIME) || !MICROPY_ENABLE_DYNRUNTIME -#define MP_ERROR_TEXT(x) translate(x) -#endif +#define MP_COMPRESSED_ROM_TEXT(x) translate(x) // translate() is a giant function with many strcmp calls. The assumption is // that the build process will optimize this away and replace it with the