Skip to content

Commit

Permalink
py/objstr: Add a macro to define a bytes object at compile time.
Browse files Browse the repository at this point in the history
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
  • Loading branch information
projectgus authored and dpgeorge committed Mar 15, 2024
1 parent fff66c3 commit 47e8475
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions py/objstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 47e8475

Please sign in to comment.