diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-12 17:06:25 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-12 22:04:21 +0200 |
commit | 757ac81a69cc2143a6b170367b18c75ac60249e4 (patch) | |
tree | 13302ead4c84e367f99435c067a5a96c41e11091 /py/obj.h | |
parent | c260bc58e66f5fefc03b59c80c91a550282fb47c (diff) |
Add proper checks for fits-in-small-int. Make it reusable.
We likely should make mp_obj_new_int() inline, and rely on its
encapsulated check rather than inline checks everywhere explicitly.
Also, parser for big small int values is still broken.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -34,6 +34,8 @@ typedef struct _mp_obj_base_t mp_obj_base_t; // - xxxx...xx10: a qstr, bits 2 and above are the value // - xxxx...xx00: a pointer to an mp_obj_base_t +// In SMALL_INT, next-to-highest bits is used as sign, so both must match for value in range +#define MP_OBJ_FITS_SMALL_INT(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0) #define MP_OBJ_IS_SMALL_INT(o) ((((mp_small_int_t)(o)) & 1) != 0) #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) |