diff options
author | Yonatan Goldschmidt <yon.goldschmidt@gmail.com> | 2020-01-13 23:35:07 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-01-14 23:35:22 +1100 |
commit | 176ab99180a95eeac8794828f2f751a696571bb5 (patch) | |
tree | cb572f1c13d0dbeaeada70eeb24dafdeb46404fe /py/obj.h | |
parent | 1c849d63a86782f006b73a9d570d542cfd18538e (diff) |
py/objint: Add mp_obj_int_get_uint_checked() helper.
Can be used where mp_obj_int_get_checked() will overflow due to the
sign-bit solely. This returns an mp_uint_t, so it also verifies the given
integer is not negative.
Currently implemented only for mpz configurations.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -748,6 +748,8 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj); mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); // Will raise exception if value doesn't fit into mp_int_t mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); +// Will raise exception if value is negative or doesn't fit into mp_uint_t +mp_uint_t mp_obj_int_get_uint_checked(mp_const_obj_t self_in); // exception #define mp_obj_is_native_exception_instance(o) (mp_obj_get_type(o)->make_new == mp_obj_exception_make_new) |