diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-14 01:45:06 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-14 01:45:06 +0300 |
commit | 58676fc2c75b8dcf1661ee65eb2384bd7f59990b (patch) | |
tree | 1644449093a171e77ed747ba20a5ae2f28a42916 /py/objstr.h | |
parent | 59e269cfec51b6a7933d6e847a38c84c04056675 (diff) |
objstr: Allow to define statically allocated str objects.
Similar to tuples, lists, dicts. Statically allocated strings don't have hash
computed.
Diffstat (limited to 'py/objstr.h')
-rw-r--r-- | py/objstr.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/py/objstr.h b/py/objstr.h new file mode 100644 index 000000000..a32ba53b1 --- /dev/null +++ b/py/objstr.h @@ -0,0 +1,10 @@ +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + // XXX here we assume the hash size is 16 bits (it is at the moment; see qstr.c) + machine_uint_t hash : 16; + // len == number of bytes used in data, alloc = len + 1 because (at the moment) we also append a null byte + machine_uint_t len : 16; + const byte *data; +} mp_obj_str_t; + +#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str}; |