summaryrefslogtreecommitdiff
path: root/py/misc.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-04-13 14:52:10 +1000
committerDamien George <damien.p.george@gmail.com>2020-04-14 22:13:11 +1000
commit2725a791929f901c692d09f0afe7cc6a700384d5 (patch)
tree4c2942360d6ef0831158056538f84d8b7100abb0 /py/misc.h
parent5f0661b4fe6a68c38e9eecd94845f4bd1ed3046a (diff)
py: Always give noop defines when MICROPY_ROM_TEXT_COMPRESSION disabled.
This commit provides a typedef for mp_rom_error_text_t, and a macro define for MP_COMPRESSED_ROM_TEXT, when MICROPY_ROM_TEXT_COMPRESSION is disabled. This simplifies the configuration (it no longer has a special case for MICROPY_ENABLE_DYNRUNTIME) and makes it work for other cases that don't use compression (eg examples/embedding). This commit also ensures MICROPY_ROM_TEXT_COMPRESSION is defined during qstr processing.
Diffstat (limited to 'py/misc.h')
-rw-r--r--py/misc.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/py/misc.h b/py/misc.h
index d1f8a6517..c7060ddf9 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -259,26 +259,21 @@ typedef union _mp_float_union_t {
/** ROM string compression *************/
+#if MICROPY_ROM_TEXT_COMPRESSION
+
#ifdef NO_QSTR
-// QSTR extraction sets NO_QSTR.
+// Compression enabled but doing QSTR extraction.
// So leave MP_COMPRESSED_ROM_TEXT in place for makeqstrdefs.py / makecompresseddata.py to find them.
-// However, dynamic native modules also set NO_QSTR, so provide a dummy implementation.
-#if MICROPY_ENABLE_DYNRUNTIME
-typedef const char *mp_rom_error_text_t;
-#define MP_COMPRESSED_ROM_TEXT(x) x
-#endif
-
#else
-#if MICROPY_ROM_TEXT_COMPRESSION
+// Compression enabled and doing a regular build.
+// Map MP_COMPRESSED_ROM_TEXT to the compressed strings.
// Force usage of the MP_ERROR_TEXT macro by requiring an opaque type.
typedef struct {} *mp_rom_error_text_t;
-// Regular build -- map MP_COMPRESSED_ROM_TEXT to the compressed strings.
-
#include <string.h>
inline __attribute__((always_inline)) const char *MP_COMPRESSED_ROM_TEXT(const char *msg) {
@@ -297,16 +292,17 @@ inline __attribute__((always_inline)) const char *MP_COMPRESSED_ROM_TEXT(const c
return msg;
}
+#endif
+
#else
// Compression not enabled, just make it a no-op.
+
typedef const char *mp_rom_error_text_t;
#define MP_COMPRESSED_ROM_TEXT(x) x
#endif // MICROPY_ROM_TEXT_COMPRESSION
-#endif // NO_QSTR
-
// 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)