py/objarray: Convert mp_uint_t to size_t where appropriate.
diff --git a/py/objarray.c b/py/objarray.c
index ed666df..f237918 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -56,7 +56,7 @@
#if MICROPY_PY_BUILTINS_MEMORYVIEW
#define TYPECODE_MASK (0x7f)
#else
-#define TYPECODE_MASK (~(mp_uint_t)0)
+#define TYPECODE_MASK (~(size_t)0)
#endif
STATIC mp_obj_t array_iterator_new(mp_obj_t array_in);
@@ -78,7 +78,7 @@
mp_printf(print, "array('%c'", o->typecode);
if (o->len > 0) {
mp_print_str(print, ", [");
- for (mp_uint_t i = 0; i < o->len; i++) {
+ for (size_t i = 0; i < o->len; i++) {
if (i > 0) {
mp_print_str(print, ", ");
}
@@ -92,7 +92,7 @@
#endif
#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
-STATIC mp_obj_array_t *array_new(char typecode, mp_uint_t n) {
+STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
int typecode_size = mp_binary_get_size('@', typecode, NULL);
mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
#if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY
@@ -124,13 +124,13 @@
// construct array from raw bytes
// we round-down the len to make it a multiple of sz (CPython raises error)
size_t sz = mp_binary_get_size('@', typecode, NULL);
- mp_uint_t len = bufinfo.len / sz;
+ size_t len = bufinfo.len / sz;
mp_obj_array_t *o = array_new(typecode, len);
memcpy(o->items, bufinfo.buf, len * sz);
return MP_OBJ_FROM_PTR(o);
}
- mp_uint_t len;
+ size_t len;
// Try to create array of exact len if initializer len is known
mp_obj_t len_in = mp_obj_len_maybe(initializer);
if (len_in == MP_OBJ_NULL) {
@@ -143,7 +143,7 @@
mp_obj_t iterable = mp_getiter(initializer);
mp_obj_t item;
- mp_uint_t i = 0;
+ size_t i = 0;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (len == 0) {
array_append(MP_OBJ_FROM_PTR(array), item);
@@ -198,7 +198,7 @@
#if MICROPY_PY_BUILTINS_MEMORYVIEW
-mp_obj_t mp_obj_new_memoryview(byte typecode, mp_uint_t nitems, void *items) {
+mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) {
mp_obj_array_t *self = m_new_obj(mp_obj_array_t);
self->base.type = &mp_type_memoryview;
self->typecode = typecode;
@@ -254,7 +254,7 @@
size_t sz = mp_binary_get_size('@', lhs_bufinfo.typecode, NULL);
// convert byte count to element count (in case rhs is not multiple of sz)
- mp_uint_t rhs_len = rhs_bufinfo.len / sz;
+ size_t rhs_len = rhs_bufinfo.len / sz;
// note: lhs->len is element count of lhs, lhs_bufinfo.len is byte count
mp_obj_array_t *res = array_new(lhs_bufinfo.typecode, lhs->len + rhs_len);
@@ -345,7 +345,7 @@
size_t sz = mp_binary_get_size('@', self->typecode, NULL);
// convert byte count to element count
- mp_uint_t len = arg_bufinfo.len / sz;
+ size_t len = arg_bufinfo.len / sz;
// make sure we have enough room to extend
// TODO: alloc policy; at the moment we go conservative
@@ -384,7 +384,7 @@
if (value != MP_OBJ_SENTINEL) {
#if MICROPY_PY_ARRAY_SLICE_ASSIGN
// Assign
- mp_uint_t src_len;
+ size_t src_len;
void *src_items;
size_t item_sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL);
if (MP_OBJ_IS_OBJ(value) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(value))->type->subscr == array_subscr) {
@@ -501,7 +501,7 @@
// read-only memoryview
return 1;
}
- bufinfo->buf = (uint8_t*)bufinfo->buf + (mp_uint_t)o->free * sz;
+ bufinfo->buf = (uint8_t*)bufinfo->buf + (size_t)o->free * sz;
}
#else
(void)flags;
@@ -562,20 +562,20 @@
#endif
/* unused
-mp_uint_t mp_obj_array_len(mp_obj_t self_in) {
+size_t mp_obj_array_len(mp_obj_t self_in) {
return ((mp_obj_array_t *)self_in)->len;
}
*/
#if MICROPY_PY_BUILTINS_BYTEARRAY
-mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items) {
+mp_obj_t mp_obj_new_bytearray(size_t n, void *items) {
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
memcpy(o->items, items, n);
return MP_OBJ_FROM_PTR(o);
}
// Create bytearray which references specified memory area
-mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items) {
+mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items) {
mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
o->base.type = &mp_type_bytearray;
o->typecode = BYTEARRAY_TYPECODE;
@@ -592,8 +592,8 @@
typedef struct _mp_obj_array_it_t {
mp_obj_base_t base;
mp_obj_array_t *array;
- mp_uint_t offset;
- mp_uint_t cur;
+ size_t offset;
+ size_t cur;
} mp_obj_array_it_t;
STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {