Rename compressed_string_t to mp_rom_error_text_t to match upstream

This commit is contained in:
Jeff Epler 2023-10-25 08:14:13 +02:00
parent 702b4a58f8
commit 55874b6470
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
29 changed files with 100 additions and 111 deletions

View File

@ -1722,7 +1722,7 @@ void att_process_data(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) {
// FIX Do we need all of these? // FIX Do we need all of these?
static void check_att_err(uint8_t err) { static void check_att_err(uint8_t err) {
const compressed_string_t *msg = NULL; const mp_rom_error_text_t *msg = NULL;
switch (err) { switch (err) {
case 0: case 0:
return; return;

View File

@ -122,7 +122,7 @@ intptr_t common_hal_espidf_get_psram_end(void) {
} }
void raise_esp_error(esp_err_t err) { void raise_esp_error(esp_err_t err) {
const compressed_string_t *msg = NULL; const mp_rom_error_text_t *msg = NULL;
const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError; const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError;
switch (err) { switch (err) {
case ESP_FAIL: case ESP_FAIL:

View File

@ -78,7 +78,7 @@ static void wifi_monitor_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) {
} }
void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) { void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) {
const compressed_string_t *monitor_mode_init_error = translate("monitor init failed"); const mp_rom_error_text_t *monitor_mode_init_error = translate("monitor init failed");
self->queue = xQueueCreate(queue, sizeof(monitor_packet_t)); self->queue = xQueueCreate(queue, sizeof(monitor_packet_t));
if (!self->queue) { if (!self->queue) {

View File

@ -255,7 +255,7 @@ STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
} }
} }
STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const compressed_string_t *msg) { STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const mp_rom_error_text_t *msg) {
// only register the error if there has been no other error // only register the error if there has been no other error
if (comp->compile_error == MP_OBJ_NULL) { if (comp->compile_error == MP_OBJ_NULL) {
comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);

View File

@ -75,7 +75,7 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
#endif #endif
// CIRCUITPY-CHANGE // CIRCUITPY-CHANGE
STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) { STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const mp_rom_error_text_t *msg) {
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
} }

View File

@ -44,7 +44,7 @@ struct _emit_inline_asm_t {
}; };
// CIRCUITPY-CHANGE // CIRCUITPY-CHANGE
STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) { STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const mp_rom_error_text_t *msg) {
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
} }

View File

@ -595,7 +595,7 @@ def output_translation_data(encoding_table, i18ns, out):
decompressed = decompressed.replace(c, C_ESCAPES[c]) decompressed = decompressed.replace(c, C_ESCAPES[c])
formatted = ["{:d}".format(x) for x in compressed] formatted = ["{:d}".format(x) for x in compressed]
out.write( out.write(
"const compressed_string_t translation{} = {{ .data = {}, .tail = {{ {} }} }}; // {}\n".format( "const mp_rom_error_text_t translation{} = {{ .data = {}, .tail = {{ {} }} }}; // {}\n".format(
i, formatted[0], ", ".join(formatted[1:]), original, decompressed i, formatted[0], ", ".join(formatted[1:]), original, decompressed
) )
) )

View File

@ -330,6 +330,8 @@ inline MP_ALWAYSINLINE const char *MP_COMPRESSED_ROM_TEXT(const char *msg) {
#endif #endif
#elif CIRCUITPY
#include "supervisor/shared/translate/translate.h"
#else #else
// Compression not enabled, just make it a no-op. // Compression not enabled, just make it a no-op.
@ -337,15 +339,6 @@ 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 #endif // MICROPY_ROM_TEXT_COMPRESSION // CIRCUITPY
// Might add more types of compressed text in the future.
// For now, forward directly to MP_COMPRESSED_ROM_TEXT.
// CIRCUITPY-CHANGE: MP_ERROR_TEXT() -> translate()
#if CIRCUITPY
#include "supervisor/shared/translate/translate.h"
#else
#define MP_ERROR_TEXT(x) (mp_rom_error_text_t)MP_COMPRESSED_ROM_TEXT(x)
#endif
#endif // MICROPY_INCLUDED_PY_MISC_H #endif // MICROPY_INCLUDED_PY_MISC_H

View File

@ -127,7 +127,7 @@ const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len) {
return NULL; return NULL;
} }
const compressed_string_t *desc = NULL; const mp_rom_error_text_t *desc = NULL;
switch (MP_OBJ_SMALL_INT_VALUE(errno_val)) { switch (MP_OBJ_SMALL_INT_VALUE(errno_val)) {
case EPERM: case EPERM:
desc = MP_ERROR_TEXT("Operation not permitted"); desc = MP_ERROR_TEXT("Operation not permitted");

View File

@ -496,7 +496,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
break; break;
} }
case 'S': { case 'S': {
compressed_string_t *arg = va_arg(args, compressed_string_t *); mp_rom_error_text_t *arg = va_arg(args, mp_rom_error_text_t *);
size_t len_with_nul = decompress_length(arg); size_t len_with_nul = decompress_length(arg);
size_t len = len_with_nul - 1; size_t len = len_with_nul - 1;
char str[len_with_nul]; char str[len_with_nul];
@ -593,7 +593,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
return chrs; return chrs;
} }
int mp_cprintf(const mp_print_t *print, const compressed_string_t *compressed_fmt, ...) { int mp_cprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, ...) {
va_list ap; va_list ap;
va_start(ap, compressed_fmt); va_start(ap, compressed_fmt);
int ret = mp_vcprintf(print, compressed_fmt, ap); int ret = mp_vcprintf(print, compressed_fmt, ap);
@ -601,7 +601,7 @@ int mp_cprintf(const mp_print_t *print, const compressed_string_t *compressed_fm
return ret; return ret;
} }
int mp_vcprintf(const mp_print_t *print, const compressed_string_t *compressed_fmt, va_list args) { int mp_vcprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, va_list args) {
char fmt[decompress_length(compressed_fmt)]; char fmt[decompress_length(compressed_fmt)];
// TODO: Optimise this to format-while-decompressing (and not require the temp stack space). // TODO: Optimise this to format-while-decompressing (and not require the temp stack space).
decompress(compressed_fmt, fmt); decompress(compressed_fmt, fmt);

View File

@ -27,6 +27,7 @@
#define MICROPY_INCLUDED_PY_MPPRINT_H #define MICROPY_INCLUDED_PY_MPPRINT_H
#include "py/mpconfig.h" #include "py/mpconfig.h"
#include "py/misc.h"
#define PF_FLAG_LEFT_ADJUST (0x001) #define PF_FLAG_LEFT_ADJUST (0x001)
#define PF_FLAG_SHOW_SIGN (0x002) #define PF_FLAG_SHOW_SIGN (0x002)
@ -79,11 +80,9 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
#endif #endif
// CIRCUITPY-CHANGE int mp_cprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, ...);
struct compressed_string;
int mp_cprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, ...);
#ifdef va_start #ifdef va_start
int mp_vcprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, va_list args); int mp_vcprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, va_list args);
#endif #endif
#endif // MICROPY_INCLUDED_PY_MPPRINT_H #endif // MICROPY_INCLUDED_PY_MPPRINT_H

View File

@ -147,7 +147,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) {
static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_in, mp_int_t limit) { static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_in, mp_int_t limit) {
#if MICROPY_CPYTHON_EXCEPTION_CHAIN #if MICROPY_CPYTHON_EXCEPTION_CHAIN
mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); mp_obj_exception_t *self = mp_obj_exception_get_native(self_in);
const compressed_string_t *msg = MP_ERROR_TEXT("During handling of the above exception, another exception occurred:"); const mp_rom_error_text_t *msg = MP_ERROR_TEXT("During handling of the above exception, another exception occurred:");
mp_obj_exception_t *inner = NULL; mp_obj_exception_t *inner = NULL;
if (self->cause) { if (self->cause) {
msg = MP_ERROR_TEXT("The above exception was the direct cause of the following exception:"); msg = MP_ERROR_TEXT("The above exception was the direct cause of the following exception:");
@ -177,11 +177,11 @@ void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp
if (n > 0) { if (n > 0) {
assert(n % 3 == 0); assert(n % 3 == 0);
#if MICROPY_ENABLE_SOURCE_LINE #if MICROPY_ENABLE_SOURCE_LINE
const compressed_string_t *frame = MP_ERROR_TEXT(" File \"%q\", line %d"); const mp_rom_error_text_t *frame = MP_ERROR_TEXT(" File \"%q\", line %d");
#else #else
const compressed_string_t *frame = MP_ERROR_TEXT(" File \"%q\""); const mp_rom_error_text_t *frame = MP_ERROR_TEXT(" File \"%q\"");
#endif #endif
const compressed_string_t *block_fmt = MP_ERROR_TEXT(", in %q\n"); const mp_rom_error_text_t *block_fmt = MP_ERROR_TEXT(", in %q\n");
// Set traceback formatting // Set traceback formatting
// Default: Print full traceback // Default: Print full traceback

View File

@ -34,9 +34,6 @@
#include "py/mpprint.h" #include "py/mpprint.h"
#include "py/runtime0.h" #include "py/runtime0.h"
// CIRCUITPY-CHANGE
#include "supervisor/shared/translate/compressed_string.h"
// This is the definition of the opaque MicroPython object type. // This is the definition of the opaque MicroPython object type.
// All concrete objects have an encoding within this type and the // All concrete objects have an encoding within this type and the
// particular encoding is specified by MICROPY_OBJ_REPR. // particular encoding is specified by MICROPY_OBJ_REPR.
@ -1037,12 +1034,12 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
#define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type) #define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type)
#else #else
// CIRCUITPY-CHANGE // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *msg);
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!) mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
#endif #endif
#ifdef va_start #ifdef va_start
// CIRCUITPY-CHANGE // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list arg); // same fmt restrictions as above mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, va_list arg); // same fmt restrictions as above
#endif #endif
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun); mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed, const mp_obj_t *closed); mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed, const mp_obj_t *closed);

View File

@ -479,7 +479,7 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
} }
#if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE #if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *msg) {
// CIRCUITPY-CHANGE: is different here and for many lines below. // CIRCUITPY-CHANGE: is different here and for many lines below.
return mp_obj_new_exception_msg_varg(exc_type, msg); return mp_obj_new_exception_msg_varg(exc_type, msg);
} }
@ -517,7 +517,7 @@ STATIC void exc_add_strn(void *data, const char *str, size_t len) {
pr->len += len; pr->len += len;
} }
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) { mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
mp_obj_t exc = mp_obj_new_exception_msg_vlist(exc_type, fmt, args); mp_obj_t exc = mp_obj_new_exception_msg_vlist(exc_type, fmt, args);
@ -525,7 +525,7 @@ mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const comp
return exc; return exc;
} }
mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list ap) { mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, va_list ap) {
assert(fmt != NULL); assert(fmt != NULL);
// Check that the given type is an exception type // Check that the given type is an exception type

View File

@ -1744,7 +1744,7 @@ NORETURN MP_COLD void mp_raise_NotImplementedError_no_msg(void) {
#else #else
NORETURN MP_COLD void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_msg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *msg) {
if (msg == NULL) { if (msg == NULL) {
nlr_raise(mp_obj_new_exception(exc_type)); nlr_raise(mp_obj_new_exception(exc_type));
} else { } else {
@ -1752,12 +1752,12 @@ NORETURN MP_COLD void mp_raise_msg(const mp_obj_type_t *exc_type, const compress
} }
} }
NORETURN MP_COLD void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr) { NORETURN MP_COLD void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, va_list argptr) {
mp_obj_t exception = mp_obj_new_exception_msg_vlist(exc_type, fmt, argptr); mp_obj_t exception = mp_obj_new_exception_msg_vlist(exc_type, fmt, argptr);
nlr_raise(exception); nlr_raise(exception);
} }
NORETURN MP_COLD void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(exc_type, fmt, argptr); mp_raise_msg_vlist(exc_type, fmt, argptr);
@ -1772,59 +1772,59 @@ NORETURN MP_COLD void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char
} }
} }
NORETURN MP_COLD void mp_raise_AttributeError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_AttributeError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_AttributeError, msg); mp_raise_msg(&mp_type_AttributeError, msg);
} }
NORETURN MP_COLD void mp_raise_RuntimeError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_RuntimeError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_RuntimeError, msg); mp_raise_msg(&mp_type_RuntimeError, msg);
} }
NORETURN MP_COLD void mp_raise_RuntimeError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_RuntimeError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_RuntimeError, fmt, argptr); mp_raise_msg_vlist(&mp_type_RuntimeError, fmt, argptr);
va_end(argptr); va_end(argptr);
} }
NORETURN MP_COLD void mp_raise_ImportError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_ImportError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_ImportError, msg); mp_raise_msg(&mp_type_ImportError, msg);
} }
NORETURN MP_COLD void mp_raise_IndexError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_IndexError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_IndexError, msg); mp_raise_msg(&mp_type_IndexError, msg);
} }
NORETURN MP_COLD void mp_raise_IndexError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_IndexError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_IndexError, fmt, argptr); mp_raise_msg_vlist(&mp_type_IndexError, fmt, argptr);
va_end(argptr); va_end(argptr);
} }
NORETURN MP_COLD void mp_raise_ValueError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_ValueError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_ValueError, msg); mp_raise_msg(&mp_type_ValueError, msg);
} }
NORETURN MP_COLD void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_ValueError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_ValueError, fmt, argptr); mp_raise_msg_vlist(&mp_type_ValueError, fmt, argptr);
va_end(argptr); va_end(argptr);
} }
NORETURN MP_COLD void mp_raise_TypeError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_TypeError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_TypeError, msg); mp_raise_msg(&mp_type_TypeError, msg);
} }
NORETURN MP_COLD void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_TypeError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_TypeError, fmt, argptr); mp_raise_msg_vlist(&mp_type_TypeError, fmt, argptr);
va_end(argptr); va_end(argptr);
} }
NORETURN MP_COLD void mp_raise_OSError_msg(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_OSError_msg(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_OSError, msg); mp_raise_msg(&mp_type_OSError, msg);
} }
@ -1836,14 +1836,14 @@ NORETURN MP_COLD void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) {
nlr_raise(mp_obj_new_exception_args(&mp_type_OSError, 2, args)); nlr_raise(mp_obj_new_exception_args(&mp_type_OSError, 2, args));
} }
NORETURN MP_COLD void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_OSError_msg_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_OSError, fmt, argptr); mp_raise_msg_vlist(&mp_type_OSError, fmt, argptr);
va_end(argptr); va_end(argptr);
} }
NORETURN MP_COLD void mp_raise_ConnectionError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_ConnectionError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_ConnectionError, msg); mp_raise_msg(&mp_type_ConnectionError, msg);
} }
@ -1851,11 +1851,11 @@ NORETURN MP_COLD void mp_raise_BrokenPipeError(void) {
mp_raise_type_arg(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)); mp_raise_type_arg(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE));
} }
NORETURN MP_COLD void mp_raise_NotImplementedError(const compressed_string_t *msg) { NORETURN MP_COLD void mp_raise_NotImplementedError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_NotImplementedError, msg); mp_raise_msg(&mp_type_NotImplementedError, msg);
} }
NORETURN MP_COLD void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_NotImplementedError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_NotImplementedError, fmt, argptr); mp_raise_msg_vlist(&mp_type_NotImplementedError, fmt, argptr);
@ -1863,7 +1863,7 @@ NORETURN MP_COLD void mp_raise_NotImplementedError_varg(const compressed_string_
} }
NORETURN MP_COLD void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) { NORETURN MP_COLD void mp_raise_OverflowError_varg(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_raise_msg_vlist(&mp_type_OverflowError, fmt, argptr); mp_raise_msg_vlist(&mp_type_OverflowError, fmt, argptr);

View File

@ -242,44 +242,44 @@ NORETURN void mp_raise_NotImplementedError_no_msg(void);
#define mp_raise_NotImplementedError(msg) mp_raise_NotImplementedError_no_msg() #define mp_raise_NotImplementedError(msg) mp_raise_NotImplementedError_no_msg()
#else #else
#define mp_raise_type(exc_type) mp_raise_msg(exc_type, NULL) #define mp_raise_type(exc_type) mp_raise_msg(exc_type, NULL)
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *msg);
NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_ValueError(const compressed_string_t *msg); NORETURN void mp_raise_ValueError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_TypeError(const compressed_string_t *msg); NORETURN void mp_raise_TypeError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); NORETURN void mp_raise_NotImplementedError(const mp_rom_error_text_t *msg);
#endif #endif
NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg); NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg);
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *msg);
NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt
, ...); , ...);
NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr); NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, va_list argptr);
// Only use this string version in native mpy files. Otherwise, use the compressed string version. // Only use this string version in native mpy files. Otherwise, use the compressed string version.
NORETURN void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char *msg); NORETURN void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char *msg);
NORETURN void mp_raise_AttributeError(const compressed_string_t *msg); NORETURN void mp_raise_AttributeError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_BrokenPipeError(void); NORETURN void mp_raise_BrokenPipeError(void);
NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg); NORETURN void mp_raise_ConnectionError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_ImportError(const compressed_string_t *msg); NORETURN void mp_raise_ImportError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_IndexError(const compressed_string_t *msg); NORETURN void mp_raise_IndexError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_IndexError_varg(const compressed_string_t *msg, ...); NORETURN void mp_raise_IndexError_varg(const mp_rom_error_text_t *msg, ...);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); NORETURN void mp_raise_NotImplementedError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_NotImplementedError_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str); NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str);
NORETURN void mp_raise_OSError(int errno_); NORETURN void mp_raise_OSError(int errno_);
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg); NORETURN void mp_raise_OSError_msg(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_OSError_msg_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_OSError_with_filename(int errno_, const char *filename); NORETURN void mp_raise_OSError_with_filename(int errno_, const char *filename);
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_OverflowError_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_recursion_depth(void); NORETURN void mp_raise_recursion_depth(void);
NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg); NORETURN void mp_raise_RuntimeError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_RuntimeError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_RuntimeError_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_StopIteration(mp_obj_t arg); NORETURN void mp_raise_StopIteration(mp_obj_t arg);
NORETURN void mp_raise_TypeError(const compressed_string_t *msg); NORETURN void mp_raise_TypeError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_TypeError_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_TypeError_int_conversion(mp_const_obj_t arg); NORETURN void mp_raise_TypeError_int_conversion(mp_const_obj_t arg);
NORETURN void mp_raise_ValueError(const compressed_string_t *msg); NORETURN void mp_raise_ValueError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_ValueError_varg(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_ZeroDivisionError(void); NORETURN void mp_raise_ZeroDivisionError(void);
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG #if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG

View File

@ -66,7 +66,7 @@
//| ... //| ...
//| //|
MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception) MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception)
NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *fmt, ...) { NORETURN void mp_raise_bleio_BluetoothError(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_BluetoothError, fmt, argptr); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_BluetoothError, fmt, argptr);
@ -81,7 +81,7 @@ NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *fmt, ...)
//| ... //| ...
//| //|
MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError) MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError)
NORETURN void mp_raise_bleio_RoleError(const compressed_string_t *msg) { NORETURN void mp_raise_bleio_RoleError(const mp_rom_error_text_t *msg) {
mp_raise_msg(&mp_type_bleio_RoleError, msg); mp_raise_msg(&mp_type_bleio_RoleError, msg);
} }
@ -91,7 +91,7 @@ NORETURN void mp_raise_bleio_RoleError(const compressed_string_t *msg) {
//| ... //| ...
//| //|
MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError) MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError)
NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t *fmt, ...) { NORETURN void mp_raise_bleio_SecurityError(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_SecurityError, fmt, argptr); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_SecurityError, fmt, argptr);

View File

@ -62,9 +62,9 @@ void bleio_reset(void);
extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj); extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj);
NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *msg, ...); NORETURN void mp_raise_bleio_BluetoothError(const mp_rom_error_text_t *msg, ...);
NORETURN void mp_raise_bleio_RoleError(const compressed_string_t *msg); NORETURN void mp_raise_bleio_RoleError(const mp_rom_error_text_t *msg);
NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t *msg, ...); NORETURN void mp_raise_bleio_SecurityError(const mp_rom_error_text_t *msg, ...);
bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void); bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void);
void common_hal_bleio_check_connected(uint16_t conn_handle); void common_hal_bleio_check_connected(uint16_t conn_handle);

View File

@ -43,7 +43,7 @@
//| //|
MP_DEFINE_MEMORYMONITOR_EXCEPTION(AllocationError, Exception) MP_DEFINE_MEMORYMONITOR_EXCEPTION(AllocationError, Exception)
NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t *fmt, ...) { NORETURN void mp_raise_memorymonitor_AllocationError(const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_memorymonitor_AllocationError, fmt, argptr); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_memorymonitor_AllocationError, fmt, argptr);

View File

@ -44,6 +44,6 @@ void memorymonitor_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr
extern const mp_obj_type_t mp_type_memorymonitor_AllocationError; extern const mp_obj_type_t mp_type_memorymonitor_AllocationError;
NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t *msg, ...); NORETURN void mp_raise_memorymonitor_AllocationError(const mp_rom_error_text_t *msg, ...);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H #endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H

View File

@ -48,7 +48,7 @@
//| ... //| ...
//| //|
MP_DEFINE_USB_CORE_EXCEPTION(USBError, OSError) MP_DEFINE_USB_CORE_EXCEPTION(USBError, OSError)
NORETURN void mp_raise_usb_core_USBError(const compressed_string_t *fmt, ...) { NORETURN void mp_raise_usb_core_USBError(const mp_rom_error_text_t *fmt, ...) {
mp_obj_t exception; mp_obj_t exception;
if (fmt == NULL) { if (fmt == NULL) {
exception = mp_obj_new_exception(&mp_type_usb_core_USBError); exception = mp_obj_new_exception(&mp_type_usb_core_USBError);

View File

@ -45,7 +45,7 @@ void usb_core_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_k
extern const mp_obj_type_t mp_type_usb_core_USBError; extern const mp_obj_type_t mp_type_usb_core_USBError;
extern const mp_obj_type_t mp_type_usb_core_USBTimeoutError; extern const mp_obj_type_t mp_type_usb_core_USBTimeoutError;
NORETURN void mp_raise_usb_core_USBError(const compressed_string_t *fmt, ...); NORETURN void mp_raise_usb_core_USBError(const mp_rom_error_text_t *fmt, ...);
NORETURN void mp_raise_usb_core_USBTimeoutError(void); NORETURN void mp_raise_usb_core_USBTimeoutError(void);
// Find is all Python object oriented so we don't need a separate common-hal API // Find is all Python object oriented so we don't need a separate common-hal API

View File

@ -314,7 +314,7 @@ STATIC os_getenv_err_t os_getenv_buf_terminated(const char *key, char *value, si
return result; return result;
} }
STATIC void print_dont_raise(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) { STATIC void print_dont_raise(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...) {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
mp_vcprintf(&mp_plat_print, fmt, argptr); mp_vcprintf(&mp_plat_print, fmt, argptr);
@ -322,7 +322,7 @@ STATIC void print_dont_raise(const mp_obj_type_t *exc_type, const compressed_str
va_end(argptr); va_end(argptr);
} }
STATIC void handle_getenv_error(os_getenv_err_t error, void (*handle)(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...)) { STATIC void handle_getenv_error(os_getenv_err_t error, void (*handle)(const mp_obj_type_t *exc_type, const mp_rom_error_text_t *fmt, ...)) {
if (error == GETENV_OK) { if (error == GETENV_OK) {
return; return;
} }

View File

@ -199,7 +199,7 @@ STATIC int block_cmd(sdcardio_sdcard_obj_t *self, int cmd_, int block, void *res
return cmd(self, cmd_, block * self->cdv, response_buf, response_len, true, true); return cmd(self, cmd_, block * self->cdv, response_buf, response_len, true, true);
} }
STATIC const compressed_string_t *init_card_v1(sdcardio_sdcard_obj_t *self) { STATIC const mp_rom_error_text_t *init_card_v1(sdcardio_sdcard_obj_t *self) {
for (int i = 0; i < CMD_TIMEOUT; i++) { for (int i = 0; i < CMD_TIMEOUT; i++) {
if (cmd(self, 41, 0, NULL, 0, true, true) == 0) { if (cmd(self, 41, 0, NULL, 0, true, true) == 0) {
return NULL; return NULL;
@ -208,7 +208,7 @@ STATIC const compressed_string_t *init_card_v1(sdcardio_sdcard_obj_t *self) {
return translate("timeout waiting for v1 card"); return translate("timeout waiting for v1 card");
} }
STATIC const compressed_string_t *init_card_v2(sdcardio_sdcard_obj_t *self) { STATIC const mp_rom_error_text_t *init_card_v2(sdcardio_sdcard_obj_t *self) {
for (int i = 0; i < CMD_TIMEOUT; i++) { for (int i = 0; i < CMD_TIMEOUT; i++) {
uint8_t ocr[4]; uint8_t ocr[4];
common_hal_time_delay_ms(50); common_hal_time_delay_ms(50);
@ -225,7 +225,7 @@ STATIC const compressed_string_t *init_card_v2(sdcardio_sdcard_obj_t *self) {
return translate("timeout waiting for v2 card"); return translate("timeout waiting for v2 card");
} }
STATIC const compressed_string_t *init_card(sdcardio_sdcard_obj_t *self) { STATIC const mp_rom_error_text_t *init_card(sdcardio_sdcard_obj_t *self) {
clock_card(self, 10); clock_card(self, 10);
common_hal_digitalio_digitalinout_set_value(&self->cs, false); common_hal_digitalio_digitalinout_set_value(&self->cs, false);
@ -256,12 +256,12 @@ STATIC const compressed_string_t *init_card(sdcardio_sdcard_obj_t *self) {
uint8_t rb7[4]; uint8_t rb7[4];
int response = cmd(self, 8, 0x1AA, rb7, sizeof(rb7), false, true); int response = cmd(self, 8, 0x1AA, rb7, sizeof(rb7), false, true);
if (response == R1_IDLE_STATE) { if (response == R1_IDLE_STATE) {
const compressed_string_t *result = init_card_v2(self); const mp_rom_error_text_t *result = init_card_v2(self);
if (result != NULL) { if (result != NULL) {
return result; return result;
} }
} else if (response == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) { } else if (response == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) {
const compressed_string_t *result = init_card_v1(self); const mp_rom_error_text_t *result = init_card_v1(self);
if (result != NULL) { if (result != NULL) {
return result; return result;
} }
@ -314,7 +314,7 @@ void common_hal_sdcardio_sdcard_construct(sdcardio_sdcard_obj_t *self, busio_spi
self->baudrate = 250000; self->baudrate = 250000;
lock_bus_or_throw(self); lock_bus_or_throw(self);
const compressed_string_t *result = init_card(self); const mp_rom_error_text_t *result = init_card(self);
extraclock_and_unlock_bus(self); extraclock_and_unlock_bus(self);
if (result != NULL) { if (result != NULL) {

View File

@ -148,7 +148,7 @@ void print_safe_mode_message(safe_mode_t reason) {
serial_write_compressed(translate("\nYou are in safe mode because:\n")); serial_write_compressed(translate("\nYou are in safe mode because:\n"));
const compressed_string_t *message = NULL; const mp_rom_error_text_t *message = NULL;
// First check for safe mode reasons that do not necessarily reflect bugs. // First check for safe mode reasons that do not necessarily reflect bugs.

View File

@ -94,12 +94,12 @@
typedef struct compressed_string { typedef struct compressed_string {
uint8_t data; uint8_t data;
const uint8_t tail[]; const uint8_t tail[];
} compressed_string_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
// pointer. // pointer.
// const compressed_string_t *translate(const char *c); // const mp_rom_error_text_t *translate(const char *c);
void serial_write_compressed(const compressed_string_t *compressed); void serial_write_compressed(const mp_rom_error_text_t *compressed);
char *decompress(const compressed_string_t *compressed, char *decompressed); char *decompress(const mp_rom_error_text_t *compressed, char *decompressed);
uint16_t decompress_length(const compressed_string_t *compressed); uint16_t decompress_length(const mp_rom_error_text_t *compressed);

View File

@ -39,7 +39,7 @@
#include "py/mpprint.h" #include "py/mpprint.h"
#include "supervisor/serial.h" #include "supervisor/serial.h"
void serial_write_compressed(const compressed_string_t *compressed) { void serial_write_compressed(const mp_rom_error_text_t *compressed) {
mp_printf(MP_PYTHON_PRINTER, "%S", compressed); mp_printf(MP_PYTHON_PRINTER, "%S", compressed);
} }
@ -90,7 +90,7 @@ STATIC int put_utf8(char *buf, int u) {
} }
} }
uint16_t decompress_length(const compressed_string_t *compressed) { uint16_t decompress_length(const mp_rom_error_text_t *compressed) {
#ifndef NO_QSTR #ifndef NO_QSTR
#if (compress_max_length_bits <= 8) #if (compress_max_length_bits <= 8)
return 1 + (compressed->data >> (8 - compress_max_length_bits)); return 1 + (compressed->data >> (8 - compress_max_length_bits));
@ -123,7 +123,7 @@ static int get_nbits(bitstream_state_t *st, int n) {
return r; return r;
} }
char *decompress(const compressed_string_t *compressed, char *decompressed) { char *decompress(const mp_rom_error_text_t *compressed, char *decompressed) {
bitstream_state_t b = { bitstream_state_t b = {
.ptr = &(compressed->data) + (compress_max_length_bits >> 3), .ptr = &(compressed->data) + (compress_max_length_bits >> 3),
.bit = 1 << (7 - ((compress_max_length_bits) & 0x7)), .bit = 1 << (7 - ((compress_max_length_bits) & 0x7)),

View File

@ -49,5 +49,5 @@
#else #else
// In link time optimized (LTO) builds, we can compile this once into a .o and // In link time optimized (LTO) builds, we can compile this once into a .o and
// at link time the calls will be optimized. // at link time the calls will be optimized.
const compressed_string_t *translate(const char *c); const mp_rom_error_text_t *translate(const char *c);
#endif #endif

View File

@ -34,7 +34,7 @@
#ifndef NO_QSTR #ifndef NO_QSTR
#define QDEF(id, hash, len, str) #define QDEF(id, hash, len, str)
#define TRANSLATION(english_id, number) extern compressed_string_t translation##number; #define TRANSLATION(english_id, number) extern mp_rom_error_text_t translation##number;
#include "genhdr/qstrdefs.generated.h" #include "genhdr/qstrdefs.generated.h"
#undef TRANSLATION #undef TRANSLATION
#undef QDEF #undef QDEF
@ -50,7 +50,7 @@ __attribute__((always_inline))
#endif #endif
// Prevent instrumenting this because that disables the inlining we rely of for code size // Prevent instrumenting this because that disables the inlining we rely of for code size
// optimization. // optimization.
__attribute__((no_instrument_function)) const compressed_string_t *translate(const char *original) { __attribute__((no_instrument_function)) const mp_rom_error_text_t *translate(const char *original) {
#ifndef NO_QSTR #ifndef NO_QSTR
#define QDEF(id, hash, len, str) #define QDEF(id, hash, len, str)
#define TRANSLATION(english_id, number) if (strcmp(original, english_id) == 0) { return &translation##number; } else #define TRANSLATION(english_id, number) if (strcmp(original, english_id) == 0) { return &translation##number; } else