From 47e84751fb55fb522557ca3f2349c8a25295498a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 23 Nov 2023 09:43:06 +1100 Subject: [PATCH] py/objstr: Add a macro to define a bytes object at compile time. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton --- py/objstr.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/objstr.h b/py/objstr.h index 72fe1cfef0..028fc9597f 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -100,6 +100,8 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s mp_obj_t index, bool is_slice); const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); +#define MP_DEFINE_BYTES_OBJ(obj_name, target, len) mp_obj_str_t obj_name = {{&mp_type_bytes}, 0, (len), (const byte *)(target)} + mp_obj_t mp_obj_bytes_hex(size_t n_args, const mp_obj_t *args, const mp_obj_type_t *type); mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data);