summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2023-11-23 09:43:06 +1100
committerDamien George <damien@micropython.org>2024-03-15 13:37:31 +1100
commit47e84751fb55fb522557ca3f2349c8a25295498a (patch)
tree7bd32a42f5dbba98f8a9b423453a7c6745be6619 /py
parentfff66c3069dd2f2b1152cf3412dfbcb073ea804b (diff)
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 <angus@redyak.com.au>
Diffstat (limited to 'py')
-rw-r--r--py/objstr.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/objstr.h b/py/objstr.h
index 72fe1cfef..028fc9597 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);