From a0c97814dfcb0debbde8be99539e3d5ca2334e54 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 3 Jan 2016 09:59:18 +0000 Subject: [PATCH] py: Change type of .make_new and .call args: mp_uint_t becomes size_t. This patch changes the type signature of .make_new and .call object method slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more efficient when mp_uint_t is larger than a machine word. Doesn't affect ports when size_t and mp_uint_t have the same size. --- extmod/moductypes.c | 2 +- extmod/moduhashlib.c | 2 +- py/obj.h | 6 +++--- py/objarray.c | 6 +++--- py/objbool.c | 2 +- py/objboundmeth.c | 2 +- py/objclosure.c | 2 +- py/objcomplex.c | 2 +- py/objdict.c | 2 +- py/objenumerate.c | 2 +- py/objexcept.c | 2 +- py/objfilter.c | 2 +- py/objfloat.c | 2 +- py/objfun.c | 10 +++++----- py/objgenerator.c | 2 +- py/objint.c | 2 +- py/objlist.c | 2 +- py/objmap.c | 2 +- py/objnamedtuple.c | 2 +- py/objobject.c | 2 +- py/objproperty.c | 2 +- py/objrange.c | 2 +- py/objreversed.c | 2 +- py/objset.c | 2 +- py/objstr.c | 4 ++-- py/objstr.h | 2 +- py/objstringio.c | 2 +- py/objtuple.c | 2 +- py/objtype.c | 14 +++++++------- py/objtype.h | 4 ++-- py/objzip.c | 2 +- py/runtime.c | 2 +- unix/file.c | 2 +- unix/modffi.c | 4 ++-- unix/modsocket.c | 2 +- 35 files changed, 52 insertions(+), 52 deletions(-) diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 48cbfad52d..cd7e9d1782 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -121,7 +121,7 @@ STATIC NORETURN void syntax_error(void) { nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "syntax error in uctypes descriptor")); } -STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 2, 3, false); mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); o->base.type = MP_OBJ_TO_PTR(type_in); diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index a824bd0eb3..6ddfa6141b 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -41,7 +41,7 @@ typedef struct _mp_obj_hash_t { STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg); -STATIC mp_obj_t hash_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hash_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); o->base.type = MP_OBJ_TO_PTR(type_in); diff --git a/py/obj.h b/py/obj.h index 58221bf06d..88767bf1ae 100644 --- a/py/obj.h +++ b/py/obj.h @@ -408,8 +408,8 @@ typedef enum { } mp_print_kind_t; typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind); -typedef mp_obj_t (*mp_make_new_fun_t)(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); -typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +typedef mp_obj_t (*mp_make_new_fun_t)(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args); typedef mp_obj_t (*mp_unary_op_fun_t)(mp_uint_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); @@ -691,7 +691,7 @@ void mp_obj_exception_clear_traceback(mp_obj_t self_in); void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block); void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values); mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); -mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); void mp_init_emergency_exception_buf(void); diff --git a/py/objarray.c b/py/objarray.c index 3445bff82e..2c4813f54f 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -168,7 +168,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) { #endif #if MICROPY_PY_ARRAY -STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t array_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 1, 2, false); @@ -187,7 +187,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k #endif #if MICROPY_PY_BUILTINS_BYTEARRAY -STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); @@ -219,7 +219,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, mp_uint_t nitems, void *items) { return MP_OBJ_FROM_PTR(self); } -STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; // TODO possibly allow memoryview constructor to take start/stop so that one diff --git a/py/objbool.c b/py/objbool.c index 4276335635..09878a7505 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -52,7 +52,7 @@ STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ } } -STATIC mp_obj_t bool_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t bool_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); diff --git a/py/objboundmeth.c b/py/objboundmeth.c index c191923979..c0e75eae97 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -47,7 +47,7 @@ STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_ki } #endif -STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in); // need to insert self->self before all other args and then call self->meth diff --git a/py/objclosure.c b/py/objclosure.c index e331a659bb..d556b3b8ae 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -36,7 +36,7 @@ typedef struct _mp_obj_closure_t { mp_obj_t closed[]; } mp_obj_closure_t; -STATIC mp_obj_t closure_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in); // need to concatenate closed-over-vars and args diff --git a/py/objcomplex.c b/py/objcomplex.c index e9a15d2547..df0467e324 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -69,7 +69,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_ } } -STATIC mp_obj_t complex_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t complex_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 2, false); diff --git a/py/objdict.c b/py/objdict.c index f3217507a9..4010d9ce3f 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -82,7 +82,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ } } -STATIC mp_obj_t dict_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t dict_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_t dict_out = mp_obj_new_dict(0); mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out); dict->base.type = MP_OBJ_TO_PTR(type_in); diff --git a/py/objenumerate.c b/py/objenumerate.c index 3629c1a20b..46c3e801df 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -45,7 +45,7 @@ STATIC const mp_arg_t enumerate_make_new_args[] = { }; #define ENUMERATE_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(enumerate_make_new_args) -STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { #if MICROPY_CPYTHON_COMPAT // parse args mp_arg_val_t vals[ENUMERATE_MAKE_NEW_NUM_ARGS]; diff --git a/py/objexcept.c b/py/objexcept.c index ffe5ea0416..6e28a980bd 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -114,7 +114,7 @@ STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind); } -mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0); if (o == NULL) { diff --git a/py/objfilter.c b/py/objfilter.c index cc3083c96c..168f0e7612 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -34,7 +34,7 @@ typedef struct _mp_obj_filter_t { mp_obj_t iter; } mp_obj_filter_t; -STATIC mp_obj_t filter_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t filter_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 2, 2, false); mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t); o->base.type = MP_OBJ_TO_PTR(type_in); diff --git a/py/objfloat.c b/py/objfloat.c index 051c0f61c3..f144bfd864 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -69,7 +69,7 @@ STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } } -STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t float_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); diff --git a/py/objfun.c b/py/objfun.c index a574926ba5..f2cc34fad6 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -52,7 +52,7 @@ // mp_obj_fun_builtin_t defined in obj.h -STATIC mp_obj_t fun_builtin_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fun_builtin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin)); mp_obj_fun_builtin_t *self = MP_OBJ_TO_PTR(self_in); @@ -196,7 +196,7 @@ mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args, } #endif -STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { MP_STACK_CHECK(); DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw); @@ -353,7 +353,7 @@ mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byt #if MICROPY_EMIT_NATIVE -STATIC mp_obj_t fun_native_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { MP_STACK_CHECK(); mp_obj_fun_bc_t *self = self_in; mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void*)self->bytecode); @@ -393,7 +393,7 @@ typedef mp_uint_t (*viper_fun_2_t)(mp_uint_t, mp_uint_t); typedef mp_uint_t (*viper_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t); typedef mp_uint_t (*viper_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); -STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_fun_viper_t *self = self_in; mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); @@ -514,7 +514,7 @@ STATIC mp_obj_t convert_val_from_inline_asm(mp_uint_t val) { return MP_OBJ_NEW_SMALL_INT(val); } -STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_fun_asm_t *self = self_in; mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); diff --git a/py/objgenerator.c b/py/objgenerator.c index 0a68485628..91936f92f3 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -49,7 +49,7 @@ typedef struct _mp_obj_gen_instance_t { mp_code_state code_state; } mp_obj_gen_instance_t; -STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_gen_wrap_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; assert(self_fun->base.type == &mp_type_fun_bc); diff --git a/py/objint.c b/py/objint.c index 57fe364dcf..7ee7653cad 100644 --- a/py/objint.c +++ b/py/objint.c @@ -42,7 +42,7 @@ #endif // This dispatcher function is expected to be independent of the implementation of long int -STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 2, false); diff --git a/py/objlist.c b/py/objlist.c index d0641f21c2..059fec1b25 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -68,7 +68,7 @@ STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { return list; } -STATIC mp_obj_t list_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t list_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); diff --git a/py/objmap.c b/py/objmap.c index 6dbfaca05f..a0293c36f8 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -36,7 +36,7 @@ typedef struct _mp_obj_map_t { mp_obj_t iters[]; } mp_obj_map_t; -STATIC mp_obj_t map_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t map_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false); mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); o->base.type = MP_OBJ_TO_PTR(type_in); diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index 167e23b4a4..3e34603263 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -77,7 +77,7 @@ STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t namedtuple_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t namedtuple_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_namedtuple_type_t *type = MP_OBJ_TO_PTR(type_in); mp_uint_t num_fields = type->n_fields; if (n_args + n_kw != num_fields) { diff --git a/py/objobject.c b/py/objobject.c index afb9d5af72..5cd3773940 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -33,7 +33,7 @@ typedef struct _mp_obj_object_t { mp_obj_base_t base; } mp_obj_object_t; -STATIC mp_obj_t object_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t object_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)args; mp_arg_check_num(n_args, n_kw, 0, 0, false); mp_obj_object_t *o = m_new_obj(mp_obj_object_t); diff --git a/py/objproperty.c b/py/objproperty.c index fb814cba1a..323696cf15 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -37,7 +37,7 @@ typedef struct _mp_obj_property_t { mp_obj_t proxy[3]; // getter, setter, deleter } mp_obj_property_t; -STATIC mp_obj_t property_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t property_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 4, false); mp_obj_property_t *o = m_new_obj(mp_obj_property_t); diff --git a/py/objrange.c b/py/objrange.c index 7a4aaa72cd..bec026ff6f 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -90,7 +90,7 @@ STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind } } -STATIC mp_obj_t range_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t range_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 3, false); mp_obj_range_t *o = m_new_obj(mp_obj_range_t); diff --git a/py/objreversed.c b/py/objreversed.c index 2b16f0893f..b0da00a885 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -38,7 +38,7 @@ typedef struct _mp_obj_reversed_t { mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0) } mp_obj_reversed_t; -STATIC mp_obj_t reversed_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t reversed_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); // check if __reversed__ exists, and if so delegate to it diff --git a/py/objset.c b/py/objset.c index fbcf0cdae9..6ac9c580ab 100644 --- a/py/objset.c +++ b/py/objset.c @@ -119,7 +119,7 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t #endif } -STATIC mp_obj_t set_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t set_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { diff --git a/py/objstr.c b/py/objstr.c index c4335bbac7..55c7cdd5f7 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -131,7 +131,7 @@ STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t } } -mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { #if MICROPY_CPYTHON_COMPAT if (n_kw != 0) { mp_arg_error_unimpl_kw(); @@ -169,7 +169,7 @@ mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, } } -STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; #if MICROPY_CPYTHON_COMPAT diff --git a/py/objstr.h b/py/objstr.h index d9cc85ef0b..d9327b1ab8 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -60,7 +60,7 @@ const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len); else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->data; } #endif -mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs); mp_obj_t mp_obj_str_split(mp_uint_t n_args, const mp_obj_t *args); diff --git a/py/objstringio.c b/py/objstringio.c index 5a8f43da13..d046cdd80d 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -128,7 +128,7 @@ STATIC mp_obj_stringio_t *stringio_new(mp_obj_t type_in) { return o; } -STATIC mp_obj_t stringio_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t stringio_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)n_kw; // TODO check n_kw==0 mp_obj_stringio_t *o = stringio_new(type_in); diff --git a/py/objtuple.c b/py/objtuple.c index de2bfc31d2..8337b67042 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -61,7 +61,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } } -STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 0, 1, false); diff --git a/py/objtype.c b/py/objtype.c index ca52006f25..c9ab59642f 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -43,7 +43,7 @@ #define DEBUG_printf(...) (void)0 #endif -STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); /******************************************************************************/ // instance object @@ -235,7 +235,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self_in); } -mp_obj_t mp_obj_instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_instance_make_new(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(MP_OBJ_IS_TYPE(self_in, &mp_type_type)); mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); assert(mp_obj_is_instance_type(self)); @@ -707,7 +707,7 @@ bool mp_obj_instance_is_callable(mp_obj_t self_in) { return mp_obj_instance_get_call(self_in) != MP_OBJ_NULL; } -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_t call = mp_obj_instance_get_call(self_in); if (call == MP_OBJ_NULL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { @@ -778,7 +778,7 @@ STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_printf(print, "", self->name); } -STATIC mp_obj_t type_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t type_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; mp_arg_check_num(n_args, n_kw, 1, 3, false); @@ -798,7 +798,7 @@ STATIC mp_obj_t type_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw } } -STATIC mp_obj_t type_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { // instantiate an instance of a class mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); @@ -957,7 +957,7 @@ STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind mp_print_str(print, ">"); } -STATIC mp_obj_t super_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t super_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; // 0 arguments are turned into 2 in the compiler // 1 argument is not yet implemented @@ -1108,7 +1108,7 @@ mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t /******************************************************************************/ // staticmethod and classmethod types (probably should go in a different file) -STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); assert(self == &mp_type_staticmethod || self == &mp_type_classmethod); diff --git a/py/objtype.h b/py/objtype.h index 6023e8dfe5..06227cf5a3 100644 --- a/py/objtype.h +++ b/py/objtype.h @@ -42,11 +42,11 @@ void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); // these need to be exposed so mp_obj_is_callable can work correctly bool mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); #define mp_obj_is_instance_type(type) ((type)->make_new == mp_obj_instance_make_new) #define mp_obj_is_native_type(type) ((type)->make_new != mp_obj_instance_make_new) // this needs to be exposed for the above macros to work correctly -mp_obj_t mp_obj_instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); +mp_obj_t mp_obj_instance_make_new(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); #endif // __MICROPY_INCLUDED_PY_OBJTYPE_H__ diff --git a/py/objzip.c b/py/objzip.c index 3ac6af15cd..4b240fbbf7 100644 --- a/py/objzip.c +++ b/py/objzip.c @@ -36,7 +36,7 @@ typedef struct _mp_obj_zip_t { mp_obj_t iters[]; } mp_obj_zip_t; -STATIC mp_obj_t zip_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t zip_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args); diff --git a/py/runtime.c b/py/runtime.c index c97710bc90..b0f407a150 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -894,7 +894,7 @@ typedef struct _mp_obj_checked_fun_t { mp_obj_t fun; } mp_obj_checked_fun_t; -STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_checked_fun_t *self = MP_OBJ_TO_PTR(self_in); if (n_args > 0) { const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]); diff --git a/unix/file.c b/unix/file.c index 7f113d6712..751d62fd51 100644 --- a/unix/file.c +++ b/unix/file.c @@ -202,7 +202,7 @@ STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *args) { return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); return fdfile_open(MP_OBJ_TO_PTR(type_in), arg_vals); diff --git a/unix/modffi.c b/unix/modffi.c index c998a809e4..be12974979 100644 --- a/unix/modffi.c +++ b/unix/modffi.c @@ -301,7 +301,7 @@ STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) { } MP_DEFINE_CONST_FUN_OBJ_2(ffimod_addr_obj, ffimod_addr); -STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)n_args; (void)n_kw; @@ -345,7 +345,7 @@ STATIC void ffifunc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki mp_printf(print, "", self->func); } -STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_ffifunc_t *self = MP_OBJ_TO_PTR(self_in); assert(n_kw == 0); assert(n_args == self->cif.nargs); diff --git a/unix/modsocket.c b/unix/modsocket.c index 6a7c3f5510..0857d05733 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -313,7 +313,7 @@ STATIC mp_obj_t socket_makefile(mp_uint_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 3, socket_makefile); -STATIC mp_obj_t socket_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t socket_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; (void)n_kw;