py/objtuple: Convert mp_uint_t to size_t where appropriate.
diff --git a/py/obj.h b/py/obj.h
index 071e385..95b6ec4 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -630,7 +630,7 @@
mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig);
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed, const mp_obj_t *closed);
-mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items);
+mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items);
mp_obj_t mp_obj_new_list(mp_uint_t n, mp_obj_t *items);
mp_obj_t mp_obj_new_dict(mp_uint_t n_args);
mp_obj_t mp_obj_new_set(mp_uint_t n_args, mp_obj_t *items);
diff --git a/py/objattrtuple.c b/py/objattrtuple.c
index c6dd3ae..8c5e795 100644
--- a/py/objattrtuple.c
+++ b/py/objattrtuple.c
@@ -34,7 +34,7 @@
#endif
void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) {
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, ", ");
}
@@ -59,9 +59,9 @@
if (dest[0] == MP_OBJ_NULL) {
// load attribute
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
- mp_uint_t len = self->len;
+ size_t len = self->len;
const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(self->items[len]);
- for (mp_uint_t i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (fields[i] == attr) {
dest[0] = self->items[i];
return;
@@ -70,11 +70,11 @@
}
}
-mp_obj_t mp_obj_new_attrtuple(const qstr *fields, mp_uint_t n, const mp_obj_t *items) {
+mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) {
mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, n + 1);
o->base.type = &mp_type_attrtuple;
o->len = n;
- for (mp_uint_t i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
o->items[i] = items[i];
}
o->items[n] = MP_OBJ_FROM_PTR(fields);
diff --git a/py/objtuple.c b/py/objtuple.c
index c547da9..1935a67 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -32,7 +32,7 @@
#include "py/runtime0.h"
#include "py/runtime.h"
-STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, mp_uint_t cur);
+STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, size_t cur);
/******************************************************************************/
/* tuple */
@@ -45,7 +45,7 @@
mp_print_str(print, "(");
kind = PRINT_REPR;
}
- 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, ", ");
}
@@ -80,8 +80,8 @@
// TODO optimise for cases where we know the length of the iterator
- mp_uint_t alloc = 4;
- mp_uint_t len = 0;
+ size_t alloc = 4;
+ size_t len = 0;
mp_obj_t *items = m_new(mp_obj_t, alloc);
mp_obj_t iterable = mp_getiter(args[0]);
@@ -127,7 +127,7 @@
case MP_UNARY_OP_HASH: {
// start hash with pointer to empty tuple, to make it fairly unique
mp_int_t hash = (mp_int_t)mp_const_empty_tuple;
- for (mp_uint_t i = 0; i < self->len; i++) {
+ for (size_t i = 0; i < self->len; i++) {
hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, self->items[i]));
}
return MP_OBJ_NEW_SMALL_INT(hash);
@@ -235,7 +235,7 @@
// the zero-length tuple
const mp_obj_tuple_t mp_const_empty_tuple_obj = {{&mp_type_tuple}, 0};
-mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items) {
+mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) {
if (n == 0) {
return mp_const_empty_tuple;
}
@@ -243,7 +243,7 @@
o->base.type = &mp_type_tuple;
o->len = n;
if (items) {
- for (mp_uint_t i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
o->items[i] = items[i];
}
}
@@ -270,7 +270,7 @@
mp_obj_base_t base;
mp_fun_1_t iternext;
mp_obj_tuple_t *tuple;
- mp_uint_t cur;
+ size_t cur;
} mp_obj_tuple_it_t;
STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
@@ -284,7 +284,7 @@
}
}
-STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, mp_uint_t cur) {
+STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, size_t cur) {
mp_obj_tuple_it_t *o = m_new_obj(mp_obj_tuple_it_t);
o->base.type = &mp_type_polymorph_iter;
o->iternext = tuple_it_iternext;
diff --git a/py/objtuple.h b/py/objtuple.h
index ebfc5c4..760135f 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -30,13 +30,13 @@
typedef struct _mp_obj_tuple_t {
mp_obj_base_t base;
- mp_uint_t len;
+ size_t len;
mp_obj_t items[];
} mp_obj_tuple_t;
typedef struct _mp_rom_obj_tuple_t {
mp_obj_base_t base;
- mp_uint_t len;
+ size_t len;
mp_rom_obj_t items[];
} mp_rom_obj_tuple_t;
@@ -59,6 +59,6 @@
void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o);
#endif
-mp_obj_t mp_obj_new_attrtuple(const qstr *fields, mp_uint_t n, const mp_obj_t *items);
+mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items);
#endif // __MICROPY_INCLUDED_PY_OBJTUPLE_H__