From a11ceca807bd7a958c3d45ce02fe23cda0085f7d Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 19 Jan 2014 16:02:09 +0000 Subject: [PATCH] Change int to uint for n_args in function with variable arguments. --- py/builtin.c | 14 +++++++------- py/obj.h | 2 +- py/objdict.c | 8 ++++---- py/objlist.c | 4 ++-- py/objset.c | 6 +++--- py/objstr.c | 6 +++--- py/stream.c | 4 ++-- stm/main.c | 2 +- unix/socket.c | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/py/builtin.c b/py/builtin.c index fcd58d4aec..f102aa5885 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -18,7 +18,7 @@ // args[0] is function from class body // args[1] is class name // args[2:] are base objects -static mp_obj_t mp_builtin___build_class__(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) { assert(2 <= n_args); // we differ from CPython: we set the new __locals__ object here @@ -187,7 +187,7 @@ static mp_obj_t mp_builtin_len(mp_obj_t o_in) { MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_builtin_len); -static mp_obj_t mp_builtin_max(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) { if (n_args == 1) { // given an iterable mp_obj_t iterable = rt_getiter(args[0]); @@ -216,7 +216,7 @@ static mp_obj_t mp_builtin_max(int n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_max_obj, 1, mp_builtin_max); -static mp_obj_t mp_builtin_min(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) { if (n_args == 1) { // given an iterable mp_obj_t iterable = rt_getiter(args[0]); @@ -267,7 +267,7 @@ static mp_obj_t mp_builtin_ord(mp_obj_t o_in) { MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); -static mp_obj_t mp_builtin_pow(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 3); switch (n_args) { case 2: return rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]); @@ -277,7 +277,7 @@ static mp_obj_t mp_builtin_pow(int n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow); -static mp_obj_t mp_builtin_print(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) { for (int i = 0; i < n_args; i++) { if (i > 0) { printf(" "); @@ -290,7 +290,7 @@ static mp_obj_t mp_builtin_print(int n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_print_obj, 0, mp_builtin_print); -static mp_obj_t mp_builtin_range(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) { assert(1 <= n_args && n_args <= 3); switch (n_args) { case 1: return mp_obj_new_range(0, mp_obj_get_int(args[0]), 1); @@ -309,7 +309,7 @@ static mp_obj_t mp_builtin_repr(mp_obj_t o_in) { MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr); -static mp_obj_t mp_builtin_sum(int n_args, const mp_obj_t *args) { +static mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) { assert(1 <= n_args && n_args <= 2); mp_obj_t value; switch (n_args) { diff --git a/py/obj.h b/py/obj.h index 07561b41c9..510108eedb 100644 --- a/py/obj.h +++ b/py/obj.h @@ -82,7 +82,7 @@ typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t); typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t); typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t); typedef mp_obj_t (*mp_fun_t)(void); -typedef mp_obj_t (*mp_fun_var_t)(int n, const mp_obj_t *); +typedef mp_obj_t (*mp_fun_var_t)(uint n, const mp_obj_t *); typedef mp_obj_t (*mp_fun_kw_t)(uint n, const mp_obj_t *, struct _mp_map_t *); typedef enum { diff --git a/py/objdict.c b/py/objdict.c index 0d4a60a9ea..9493bc89b1 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -145,7 +145,7 @@ static mp_obj_t dict_copy(mp_obj_t self_in) { static MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy); // this is a classmethod -static mp_obj_t dict_fromkeys(int n_args, const mp_obj_t *args) { +static mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 3); mp_obj_t iter = rt_getiter(args[1]); mp_obj_t len = mp_obj_len_maybe(iter); @@ -199,7 +199,7 @@ static mp_obj_t dict_get_helper(mp_map_t *self, mp_obj_t key, mp_obj_t deflt, mp return value; } -static mp_obj_t dict_get(int n_args, const mp_obj_t *args) { +static mp_obj_t dict_get(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 3); assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); @@ -210,7 +210,7 @@ static mp_obj_t dict_get(int n_args, const mp_obj_t *args) { } static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get); -static mp_obj_t dict_pop(int n_args, const mp_obj_t *args) { +static mp_obj_t dict_pop(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 3); assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); @@ -222,7 +222,7 @@ static mp_obj_t dict_pop(int n_args, const mp_obj_t *args) { static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop); -static mp_obj_t dict_setdefault(int n_args, const mp_obj_t *args) { +static mp_obj_t dict_setdefault(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 3); assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); diff --git a/py/objlist.c b/py/objlist.c index e499d94239..0ad7b68799 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -209,7 +209,7 @@ static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { return mp_const_none; // return None, as per CPython } -static mp_obj_t list_pop(int n_args, const mp_obj_t *args) { +static mp_obj_t list_pop(uint n_args, const mp_obj_t *args) { assert(1 <= n_args && n_args <= 2); assert(MP_OBJ_IS_TYPE(args[0], &list_type)); mp_obj_list_t *self = args[0]; @@ -296,7 +296,7 @@ static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { return mp_obj_new_int(count); } -static mp_obj_t list_index(int n_args, const mp_obj_t *args) { +static mp_obj_t list_index(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 4); assert(MP_OBJ_IS_TYPE(args[0], &list_type)); mp_obj_list_t *self = args[0]; diff --git a/py/objset.c b/py/objset.c index f44c5ba9d9..a9ba2ad885 100644 --- a/py/objset.c +++ b/py/objset.c @@ -172,12 +172,12 @@ static mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) { return self; } -static mp_obj_t set_diff(int n_args, const mp_obj_t *args) { +static mp_obj_t set_diff(uint n_args, const mp_obj_t *args) { return set_diff_int(n_args, args, false); } static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff); -static mp_obj_t set_diff_update(int n_args, const mp_obj_t *args) { +static mp_obj_t set_diff_update(uint n_args, const mp_obj_t *args) { set_diff_int(n_args, args, true); return mp_const_none; } @@ -356,7 +356,7 @@ static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) { } } -static mp_obj_t set_update(int n_args, const mp_obj_t *args) { +static mp_obj_t set_update(uint n_args, const mp_obj_t *args) { assert(n_args > 0); assert(MP_OBJ_IS_TYPE(args[0], &set_type)); diff --git a/py/objstr.c b/py/objstr.c index 7c1be50cc0..c232b1c92a 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -169,7 +169,7 @@ static bool chr_in_str(const char* const str, const size_t str_len, const char c return false; } -static mp_obj_t str_find(int n_args, const mp_obj_t *args) { +static mp_obj_t str_find(uint n_args, const mp_obj_t *args) { assert(2 <= n_args && n_args <= 4); assert(MP_OBJ_IS_TYPE(args[0], &str_type)); if (!MP_OBJ_IS_TYPE(args[1], &str_type)) { @@ -209,7 +209,7 @@ static mp_obj_t str_find(int n_args, const mp_obj_t *args) { } } -mp_obj_t str_strip(int n_args, const mp_obj_t *args) { +mp_obj_t str_strip(uint n_args, const mp_obj_t *args) { assert(1 <= n_args && n_args <= 2); assert(MP_OBJ_IS_TYPE(args[0], &str_type)); const char *chars_to_del; @@ -258,7 +258,7 @@ mp_obj_t str_strip(int n_args, const mp_obj_t *args) { return mp_obj_new_str(qstr_from_str_take(stripped_str, stripped_len + 1)); } -mp_obj_t str_format(int n_args, const mp_obj_t *args) { +mp_obj_t str_format(uint n_args, const mp_obj_t *args) { assert(MP_OBJ_IS_TYPE(args[0], &str_type)); mp_obj_str_t *self = args[0]; diff --git a/py/stream.c b/py/stream.c index d5884ae819..d3a11affbc 100644 --- a/py/stream.c +++ b/py/stream.c @@ -12,7 +12,7 @@ static mp_obj_t stream_readall(mp_obj_t self_in); -static mp_obj_t stream_read(int n_args, const mp_obj_t *args) { +static mp_obj_t stream_read(uint n_args, const mp_obj_t *args) { struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0]; if (o->type->stream_p.read == NULL) { // CPython: io.UnsupportedOperation, OSError subclass @@ -99,7 +99,7 @@ static mp_obj_t stream_readall(mp_obj_t self_in) { } // Unbuffered, inefficient implementation of readline() for raw I/O files. -static mp_obj_t stream_unbuffered_readline(int n_args, const mp_obj_t *args) { +static mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) { struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0]; if (o->type->stream_p.read == NULL) { // CPython: io.UnsupportedOperation, OSError subclass diff --git a/stm/main.c b/stm/main.c index 4e1222e8fc..7c92e8e180 100644 --- a/stm/main.c +++ b/stm/main.c @@ -526,7 +526,7 @@ mp_obj_t pyb_gc(void) { return mp_const_none; } -mp_obj_t pyb_gpio(int n_args, mp_obj_t *args) { +mp_obj_t pyb_gpio(uint n_args, mp_obj_t *args) { //assert(1 <= n_args && n_args <= 2); const char *pin_name = qstr_str(mp_obj_get_qstr(args[0])); diff --git a/unix/socket.c b/unix/socket.c index 4813e75088..708cf7af52 100644 --- a/unix/socket.c +++ b/unix/socket.c @@ -212,7 +212,7 @@ static mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) { static MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_gethostbyname_obj, mod_socket_gethostbyname); #endif -static mp_obj_t mod_socket_getaddrinfo(int n_args, const mp_obj_t *args) { +static mp_obj_t mod_socket_getaddrinfo(uint n_args, const mp_obj_t *args) { // TODO: Implement all args assert(n_args == 2); assert(MP_OBJ_IS_TYPE(args[0], &str_type));