diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-08 17:33:12 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-08 17:33:12 +0000 |
commit | 38a2da68c2e02b8fc5ae308ca9e3b667f8a0aedc (patch) | |
tree | 8bf705c9aff2013e1949e5edd803893113d385d3 /py/obj.h | |
parent | ea9e441a75d7ea6633b0ea95b21667c48a6f7b6a (diff) | |
download | micropython-38a2da68c2e02b8fc5ae308ca9e3b667f8a0aedc.tar.gz micropython-38a2da68c2e02b8fc5ae308ca9e3b667f8a0aedc.zip |
py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -29,13 +29,21 @@ typedef struct _mp_obj_base_t mp_obj_base_t; #define MP_OBJ_NULL ((mp_obj_t)NULL) -// These macros check for small int or object, and access small int values +// These macros check for small int, qstr or object, and access small int and qstr values +// - xxxx...xxx1: a small int, bits 1 and above are the value +// - xxxx...xx10: a qstr, bits 2 and above are the value +// - xxxx...xx00: a pointer to an mp_obj_base_t -#define MP_OBJ_IS_OBJ(o) ((((mp_small_int_t)(o)) & 1) == 0) #define MP_OBJ_IS_SMALL_INT(o) ((((mp_small_int_t)(o)) & 1) != 0) -#define MP_OBJ_IS_TYPE(o, t) (((((mp_small_int_t)(o)) & 1) == 0) && (((mp_obj_base_t*)(o))->type == (t))) +#define MP_OBJ_IS_QSTR(o) ((((mp_small_int_t)(o)) & 3) == 2) +#define MP_OBJ_IS_OBJ(o) ((((mp_small_int_t)(o)) & 3) == 0) +#define MP_OBJ_IS_TYPE(o, t) (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)(o))->type == (t))) + #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_small_int_t)(o)) >> 1) -#define MP_OBJ_NEW_SMALL_INT(o) ((mp_obj_t)(((o) << 1) | 1)) +#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)(((small_int) << 1) | 1)) + +#define MP_OBJ_QSTR_VALUE(o) (((mp_small_int_t)(o)) >> 2) +#define MP_OBJ_NEW_QSTR(qstr) ((mp_obj_t)((((machine_uint_t)qstr) << 2) | 2)) // These macros are used to declare and define constant function objects // You can put "static" in front of the definitions to make them local |