summaryrefslogtreecommitdiff
path: root/py/nativeglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/nativeglue.c')
-rw-r--r--py/nativeglue.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/py/nativeglue.c b/py/nativeglue.c
index 235c4a4db..05fadb7b0 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -51,8 +51,16 @@ 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:
- case MP_NATIVE_TYPE_UINT: return mp_obj_get_int(obj);
+ case MP_NATIVE_TYPE_INT: return mp_obj_get_int(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);
+ }
+ }
default: assert(0); return 0;
}
}