Skip to content

Commit dbcdb9f

Browse files
committed
py/objfun: Convert mp_uint_t to size_t where appropriate.
1 parent ccc5254 commit dbcdb9f

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

py/obj.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg
626626
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
627627
mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table);
628628
mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table);
629-
mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig);
630-
mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig);
629+
mp_obj_t mp_obj_new_fun_viper(size_t n_args, void *fun_data, mp_uint_t type_sig);
630+
mp_obj_t mp_obj_new_fun_asm(size_t n_args, void *fun_data, mp_uint_t type_sig);
631631
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
632632
mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed, const mp_obj_t *closed);
633633
mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items);

py/objfun.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
181181
#endif
182182

183183
#if DEBUG_PRINT
184-
STATIC void dump_args(const mp_obj_t *a, mp_uint_t sz) {
184+
STATIC void dump_args(const mp_obj_t *a, size_t sz) {
185185
DEBUG_printf("%p: ", a);
186-
for (mp_uint_t i = 0; i < sz; i++) {
186+
for (size_t i = 0; i < sz; i++) {
187187
DEBUG_printf("%p ", a[i]);
188188
}
189189
DEBUG_printf("\n");
@@ -247,15 +247,15 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
247247
const byte *ip = self->bytecode;
248248

249249
// bytecode prelude: state size and exception stack size
250-
mp_uint_t n_state = mp_decode_uint(&ip);
251-
mp_uint_t n_exc_stack = mp_decode_uint(&ip);
250+
size_t n_state = mp_decode_uint(&ip);
251+
size_t n_exc_stack = mp_decode_uint(&ip);
252252

253253
#if VM_DETECT_STACK_OVERFLOW
254254
n_state += 1;
255255
#endif
256256

257257
// allocate state for locals and stack
258-
mp_uint_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
258+
size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
259259
mp_code_state_t *code_state = NULL;
260260
if (state_size > VM_MAX_STATE_ON_STACK) {
261261
code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size);
@@ -288,7 +288,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
288288
if (!(vm_return_kind == MP_VM_RETURN_EXCEPTION && self->n_pos_args + self->n_kwonly_args == 0)) {
289289
// Just check to see that we have at least 1 null object left in the state.
290290
bool overflow = true;
291-
for (mp_uint_t i = 0; i < n_state - self->n_pos_args - self->n_kwonly_args; i++) {
291+
for (size_t i = 0; i < n_state - self->n_pos_args - self->n_kwonly_args; i++) {
292292
if (code_state->state[i] == MP_OBJ_NULL) {
293293
overflow = false;
294294
break;
@@ -350,8 +350,8 @@ const mp_obj_type_t mp_type_fun_bc = {
350350
};
351351

352352
mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) {
353-
mp_uint_t n_def_args = 0;
354-
mp_uint_t n_extra_args = 0;
353+
size_t n_def_args = 0;
354+
size_t n_extra_args = 0;
355355
mp_obj_tuple_t *def_args = MP_OBJ_TO_PTR(def_args_in);
356356
if (def_args_in != MP_OBJ_NULL) {
357357
assert(MP_OBJ_IS_TYPE(def_args_in, &mp_type_tuple));
@@ -409,7 +409,7 @@ mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const
409409

410410
typedef struct _mp_obj_fun_viper_t {
411411
mp_obj_base_t base;
412-
mp_uint_t n_args;
412+
size_t n_args;
413413
void *fun_data; // GC must be able to trace this pointer
414414
mp_uint_t type_sig;
415415
} mp_obj_fun_viper_t;
@@ -457,7 +457,7 @@ STATIC const mp_obj_type_t mp_type_fun_viper = {
457457
.unary_op = mp_generic_unary_op,
458458
};
459459

460-
mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig) {
460+
mp_obj_t mp_obj_new_fun_viper(size_t n_args, void *fun_data, mp_uint_t type_sig) {
461461
mp_obj_fun_viper_t *o = m_new_obj(mp_obj_fun_viper_t);
462462
o->base.type = &mp_type_fun_viper;
463463
o->n_args = n_args;
@@ -475,7 +475,7 @@ mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_s
475475

476476
typedef struct _mp_obj_fun_asm_t {
477477
mp_obj_base_t base;
478-
mp_uint_t n_args;
478+
size_t n_args;
479479
void *fun_data; // GC must be able to trace this pointer
480480
mp_uint_t type_sig;
481481
} mp_obj_fun_asm_t;
@@ -573,7 +573,7 @@ STATIC const mp_obj_type_t mp_type_fun_asm = {
573573
.unary_op = mp_generic_unary_op,
574574
};
575575

576-
mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig) {
576+
mp_obj_t mp_obj_new_fun_asm(size_t n_args, void *fun_data, mp_uint_t type_sig) {
577577
mp_obj_fun_asm_t *o = m_new_obj(mp_obj_fun_asm_t);
578578
o->base.type = &mp_type_fun_asm;
579579
o->n_args = n_args;

0 commit comments

Comments
 (0)