This commit is contained in:
Jeff Epler 2023-10-25 21:24:52 +02:00
parent acf350a1b7
commit 54a5878ee0
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 8 additions and 8 deletions

View File

@ -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. // So leave MP_COMPRESSED_ROM_TEXT in place for makeqstrdefs.py / makecompresseddata.py to find them.
#else #else
// Compression enabled and doing a regular build. // Compression enabled and doing a regular build.
// Map MP_COMPRESSED_ROM_TEXT to the compressed strings. // 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; return msg;
} }
#endif #endif
#elif CIRCUITPY #elif defined(CIRCUITPY)
#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/translate/translate.h"
#else #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; typedef const char *mp_rom_error_text_t;
#define MP_COMPRESSED_ROM_TEXT(x) x #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 #endif // MICROPY_INCLUDED_PY_MISC_H

View File

@ -94,7 +94,7 @@
typedef struct compressed_string { typedef struct compressed_string {
uint8_t data; uint8_t data;
const uint8_t tail[]; const uint8_t tail[];
} mp_rom_error_text_t; } *mp_rom_error_text_t;
// Return the compressed, translated version of a source string // Return the compressed, translated version of a source string
// Usually, due to LTO, this is optimized into a load of a constant // Usually, due to LTO, this is optimized into a load of a constant

View File

@ -33,9 +33,7 @@
#include "supervisor/shared/translate/compressed_string.h" #include "supervisor/shared/translate/compressed_string.h"
// Map MicroPython's error messages to our translations. // Map MicroPython's error messages to our translations.
#if !defined(MICROPY_ENABLE_DYNRUNTIME) || !MICROPY_ENABLE_DYNRUNTIME #define MP_COMPRESSED_ROM_TEXT(x) translate(x)
#define MP_ERROR_TEXT(x) translate(x)
#endif
// translate() is a giant function with many strcmp calls. The assumption is // 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 // that the build process will optimize this away and replace it with the