diff options
author | Damien George <damien.p.george@gmail.com> | 2014-09-10 22:10:33 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-09-10 22:10:33 +0100 |
commit | 953074315e594f5a30f455dc6a1a67340a3e6ea7 (patch) | |
tree | 9bce234da3c55224ee5cb6edd9cfd830be3e7960 /py/objint_longlong.c | |
parent | 6eae861685e8860e7542097ad20f69168e639a93 (diff) |
py: Enable struct/binary-helper to parse q and Q sized ints.
Addresses issue #848.
Diffstat (limited to 'py/objint_longlong.c')
-rw-r--r-- | py/objint_longlong.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c index 43bdcabdc..8d47308b0 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -178,7 +178,16 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) { return o; } -mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint base) { +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { + // TODO raise an exception if the unsigned long long won't fit + assert(val >> (sizeof(unsigned long long) * 8 - 1) == 0); + mp_obj_int_t *o = m_new_obj(mp_obj_int_t); + o->base.type = &mp_type_int; + o->val = val; + return o; +} + +mp_obj_t mp_obj_new_int_from_str_len(const char **str, mp_uint_t len, bool neg, mp_uint_t base) { // TODO this does not honor the given length of the string, but it all cases it should anyway be null terminated // TODO check overflow mp_obj_int_t *o = m_new_obj(mp_obj_int_t); |