diff --git a/py/obj.h b/py/obj.h index 95b6ec4119..fb35b67aa4 100644 --- a/py/obj.h +++ b/py/obj.h @@ -631,7 +631,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(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_list(size_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); mp_obj_t mp_obj_new_slice(mp_obj_t start, mp_obj_t stop, mp_obj_t step); @@ -720,11 +720,11 @@ mp_int_t mp_obj_tuple_hash(mp_obj_t self_in); // list struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, mp_uint_t n); +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg); mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value); void mp_obj_list_get(mp_obj_t self_in, mp_uint_t *len, mp_obj_t **items); -void mp_obj_list_set_len(mp_obj_t self_in, mp_uint_t len); +void mp_obj_list_set_len(mp_obj_t self_in, size_t len); void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); diff --git a/py/objlist.c b/py/objlist.c index 6d4a20a507..210140388a 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -33,8 +33,8 @@ #include "py/runtime.h" #include "py/stackctrl.h" -STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, mp_uint_t cur); -STATIC mp_obj_list_t *list_new(mp_uint_t n); +STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur); +STATIC mp_obj_list_t *list_new(size_t n); STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in); STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); @@ -50,7 +50,7 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k kind = PRINT_REPR; } 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, ", "); } @@ -374,7 +374,7 @@ STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { if (index < 0) { index = 0; } - if ((mp_uint_t)index > self->len) { + if ((size_t)index > self->len) { index = self->len; } @@ -451,7 +451,7 @@ const mp_obj_type_t mp_type_list = { .locals_dict = (mp_obj_dict_t*)&list_locals_dict, }; -void mp_obj_list_init(mp_obj_list_t *o, mp_uint_t n) { +void mp_obj_list_init(mp_obj_list_t *o, size_t n) { o->base.type = &mp_type_list; o->alloc = n < LIST_MIN_ALLOC ? LIST_MIN_ALLOC : n; o->len = n; @@ -459,16 +459,16 @@ void mp_obj_list_init(mp_obj_list_t *o, mp_uint_t n) { mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items)); } -STATIC mp_obj_list_t *list_new(mp_uint_t n) { +STATIC mp_obj_list_t *list_new(size_t n) { mp_obj_list_t *o = m_new_obj(mp_obj_list_t); mp_obj_list_init(o, n); return o; } -mp_obj_t mp_obj_new_list(mp_uint_t n, mp_obj_t *items) { +mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { mp_obj_list_t *o = list_new(n); if (items != NULL) { - for (mp_uint_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { o->items[i] = items[i]; } } @@ -481,7 +481,7 @@ void mp_obj_list_get(mp_obj_t self_in, mp_uint_t *len, mp_obj_t **items) { *items = self->items; } -void mp_obj_list_set_len(mp_obj_t self_in, mp_uint_t len) { +void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { // trust that the caller knows what it's doing // TODO realloc if len got much smaller than alloc mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); @@ -501,7 +501,7 @@ typedef struct _mp_obj_list_it_t { mp_obj_base_t base; mp_fun_1_t iternext; mp_obj_t list; - mp_uint_t cur; + size_t cur; } mp_obj_list_it_t; STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) { @@ -516,7 +516,7 @@ STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) { } } -mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, mp_uint_t cur) { +mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur) { mp_obj_list_it_t *o = m_new_obj(mp_obj_list_it_t); o->base.type = &mp_type_polymorph_iter; o->iternext = list_it_iternext; diff --git a/py/objlist.h b/py/objlist.h index 443ede5743..5b2d216fc2 100644 --- a/py/objlist.h +++ b/py/objlist.h @@ -30,8 +30,8 @@ typedef struct _mp_obj_list_t { mp_obj_base_t base; - mp_uint_t alloc; - mp_uint_t len; + size_t alloc; + size_t len; mp_obj_t *items; } mp_obj_list_t;