Skip to content

Commit

Permalink
py/viper: Truncate viper integer args so they can be up to 32-bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Jan 7, 2016
1 parent daa1a45 commit dd0a0f7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions py/nativeglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) {
switch (type & 3) {
case MP_NATIVE_TYPE_OBJ: return (mp_uint_t)obj;
case MP_NATIVE_TYPE_BOOL:
case MP_NATIVE_TYPE_INT: return mp_obj_get_int(obj);
case MP_NATIVE_TYPE_INT: return mp_obj_get_int_truncated(obj);
case MP_NATIVE_TYPE_UINT: {
mp_buffer_info_t bufinfo;
if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_RW)) {
return (mp_uint_t)bufinfo.buf;
} else {
// TODO should be mp_obj_get_uint_truncated or something
return mp_obj_get_int(obj);
return mp_obj_get_int_truncated(obj);
}
}
default: assert(0); return 0;
Expand Down

0 comments on commit dd0a0f7

Please sign in to comment.