diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-12 16:32:21 -0800 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-12 16:32:21 -0800 |
commit | ec3e14e2af48432a406d840896ae4551ddff0b7f (patch) | |
tree | aa885d4d1d6840c3ecfa08ecaea5cfdc6dd0c251 /py/obj.h | |
parent | 45eb6eaa547384b595b8ef489bd5feb36e9c8ef1 (diff) | |
parent | 48b3572f7eb70a1af97f008d342ee266fdfc0717 (diff) | |
download | micropython-ec3e14e2af48432a406d840896ae4551ddff0b7f.tar.gz micropython-ec3e14e2af48432a406d840896ae4551ddff0b7f.zip |
Merge pull request #160 from pfalcon/elaborate-int
Elaborate small-int/long-int
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 4 |
1 files changed, 4 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) @@ -196,6 +198,8 @@ mp_obj_t mp_obj_new_none(void); mp_obj_t mp_obj_new_bool(bool value); mp_obj_t mp_obj_new_cell(mp_obj_t obj); mp_obj_t mp_obj_new_int(machine_int_t value); +mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value); +mp_obj_t mp_obj_new_int_from_long_str(const char *s); mp_obj_t mp_obj_new_str(qstr qstr); #if MICROPY_ENABLE_FLOAT mp_obj_t mp_obj_new_float(mp_float_t val); |