Skip to content

Commit 4b72b3a

Browse files
committed
py: Change type signature of builtin funs that take variable or kw args.
With this patch the n_args parameter is changed type from mp_uint_t to size_t.
1 parent a0c9781 commit 4b72b3a

34 files changed

+102
-102
lines changed

bare-arm/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mp_import_stat_t mp_import_stat(const char *path) {
4545
return MP_IMPORT_STAT_NO_EXIST;
4646
}
4747

48-
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
48+
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
4949
return mp_const_none;
5050
}
5151
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);

extmod/modubinascii.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "modubinascii.h"
3535

3636

37-
mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
37+
mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) {
3838
// Second argument is for an extension to allow a separator to be used
3939
// between values.
4040
const char *sep = NULL;

extmod/modubinascii.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#ifndef MICROPY_EXTMOD_MODUBINASCII
2828
#define MICROPY_EXTMOD_MODUBINASCII
2929

30-
extern mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args);
30+
extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args);
3131
extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data);
3232
extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data);
3333
extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data);

extmod/modure.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
115115
return MP_OBJ_FROM_PTR(match);
116116
}
117117

118-
STATIC mp_obj_t re_match(mp_uint_t n_args, const mp_obj_t *args) {
118+
STATIC mp_obj_t re_match(size_t n_args, const mp_obj_t *args) {
119119
return re_exec(true, n_args, args);
120120
}
121121
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_match_obj, 2, 4, re_match);
122122

123-
STATIC mp_obj_t re_search(mp_uint_t n_args, const mp_obj_t *args) {
123+
STATIC mp_obj_t re_search(size_t n_args, const mp_obj_t *args) {
124124
return re_exec(false, n_args, args);
125125
}
126126
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_search_obj, 2, 4, re_search);
127127

128-
STATIC mp_obj_t re_split(mp_uint_t n_args, const mp_obj_t *args) {
128+
STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
129129
mp_obj_re_t *self = MP_OBJ_TO_PTR(args[0]);
130130
Subject subj;
131131
mp_uint_t len;
@@ -182,7 +182,7 @@ STATIC const mp_obj_type_t re_type = {
182182
.locals_dict = (void*)&re_locals_dict,
183183
};
184184

185-
STATIC mp_obj_t mod_re_compile(mp_uint_t n_args, const mp_obj_t *args) {
185+
STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {
186186
const char *re_str = mp_obj_str_get_str(args[0]);
187187
int size = re1_5_sizecode(re_str);
188188
if (size == -1) {
@@ -215,12 +215,12 @@ STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args)
215215
return match;
216216
}
217217

218-
STATIC mp_obj_t mod_re_match(mp_uint_t n_args, const mp_obj_t *args) {
218+
STATIC mp_obj_t mod_re_match(size_t n_args, const mp_obj_t *args) {
219219
return mod_re_exec(true, n_args, args);
220220
}
221221
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_match_obj, 2, 4, mod_re_match);
222222

223-
STATIC mp_obj_t mod_re_search(mp_uint_t n_args, const mp_obj_t *args) {
223+
STATIC mp_obj_t mod_re_search(size_t n_args, const mp_obj_t *args) {
224224
return mod_re_exec(false, n_args, args);
225225
}
226226
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_search_obj, 2, 4, mod_re_search);

extmod/moduzlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ STATIC int mod_uzlib_grow_buf(TINF_DATA *d, unsigned alloc_req) {
4949
return 0;
5050
}
5151

52-
STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
52+
STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
5353
(void)n_args;
5454
mp_obj_t data = args[0];
5555
mp_buffer_info_t bufinfo;

py/builtin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
#include "py/obj.h"
3030

31-
mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args);
32-
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
33-
mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args);
31+
mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args);
32+
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
33+
mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args);
3434

3535
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___build_class___obj);
3636
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___import___obj);

py/builtinevex.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
7474
}
7575
}
7676

77-
STATIC mp_obj_t mp_builtin_compile(mp_uint_t n_args, const mp_obj_t *args) {
77+
STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
7878
(void)n_args;
7979

8080
// get the source
@@ -109,7 +109,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_com
109109

110110
#if MICROPY_PY_BUILTINS_EVAL_EXEC
111111

112-
STATIC mp_obj_t eval_exec_helper(mp_uint_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
112+
STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
113113
// work out the context
114114
mp_obj_dict_t *globals = mp_globals_get();
115115
mp_obj_dict_t *locals = mp_locals_get();
@@ -147,20 +147,20 @@ STATIC mp_obj_t eval_exec_helper(mp_uint_t n_args, const mp_obj_t *args, mp_pars
147147
return mp_parse_compile_execute(lex, parse_input_kind, globals, locals);
148148
}
149149

150-
STATIC mp_obj_t mp_builtin_eval(mp_uint_t n_args, const mp_obj_t *args) {
150+
STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
151151
return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT);
152152
}
153153
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval);
154154

155-
STATIC mp_obj_t mp_builtin_exec(mp_uint_t n_args, const mp_obj_t *args) {
155+
STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
156156
return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT);
157157
}
158158
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
159159

160160
#endif // MICROPY_PY_BUILTINS_EVAL_EXEC
161161

162162
#if MICROPY_PY_BUILTINS_EXECFILE
163-
STATIC mp_obj_t mp_builtin_execfile(mp_uint_t n_args, const mp_obj_t *args) {
163+
STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
164164
// MP_PARSE_SINGLE_INPUT is used to indicate a file input
165165
return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT);
166166
}

py/builtinimport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ STATIC void chop_component(const char *start, const char **end) {
215215
*end = p;
216216
}
217217

218-
mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args) {
218+
mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
219219
#if DEBUG_PRINT
220220
DEBUG_printf("__import__:\n");
221221
for (mp_uint_t i = 0; i < n_args; i++) {

py/modbuiltins.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need po
4848
// args[0] is function from class body
4949
// args[1] is class name
5050
// args[2:] are base objects
51-
STATIC mp_obj_t mp_builtin___build_class__(mp_uint_t n_args, const mp_obj_t *args) {
51+
STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
5252
assert(2 <= n_args);
5353

5454
// set the new classes __locals__ object
@@ -193,7 +193,7 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
193193
}
194194
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
195195

196-
STATIC mp_obj_t mp_builtin_dir(mp_uint_t n_args, const mp_obj_t *args) {
196+
STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
197197
// TODO make this function more general and less of a hack
198198

199199
mp_obj_dict_t *dict = NULL;
@@ -264,7 +264,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
264264

265265
#if MICROPY_PY_BUILTINS_MIN_MAX
266266

267-
STATIC mp_obj_t mp_builtin_min_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
267+
STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
268268
mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
269269
mp_map_elem_t *default_elem;
270270
mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
@@ -305,12 +305,12 @@ STATIC mp_obj_t mp_builtin_min_max(mp_uint_t n_args, const mp_obj_t *args, mp_ma
305305
}
306306
}
307307

308-
STATIC mp_obj_t mp_builtin_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
308+
STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
309309
return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
310310
}
311311
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
312312

313-
STATIC mp_obj_t mp_builtin_min(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
313+
STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
314314
return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
315315
}
316316
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
@@ -375,7 +375,7 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
375375
}
376376
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
377377

378-
STATIC mp_obj_t mp_builtin_pow(mp_uint_t n_args, const mp_obj_t *args) {
378+
STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
379379
assert(2 <= n_args && n_args <= 3);
380380
switch (n_args) {
381381
case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
@@ -384,7 +384,7 @@ STATIC mp_obj_t mp_builtin_pow(mp_uint_t n_args, const mp_obj_t *args) {
384384
}
385385
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
386386

387-
STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
387+
STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
388388
mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP);
389389
mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP);
390390
const char *sep_data = " ";
@@ -456,7 +456,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
456456
}
457457
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
458458

459-
STATIC mp_obj_t mp_builtin_round(mp_uint_t n_args, const mp_obj_t *args) {
459+
STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
460460
mp_obj_t o_in = args[0];
461461
if (MP_OBJ_IS_INT(o_in)) {
462462
return o_in;
@@ -490,7 +490,7 @@ STATIC mp_obj_t mp_builtin_round(mp_uint_t n_args, const mp_obj_t *args) {
490490
}
491491
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
492492

493-
STATIC mp_obj_t mp_builtin_sum(mp_uint_t n_args, const mp_obj_t *args) {
493+
STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
494494
assert(1 <= n_args && n_args <= 2);
495495
mp_obj_t value;
496496
switch (n_args) {
@@ -506,7 +506,7 @@ STATIC mp_obj_t mp_builtin_sum(mp_uint_t n_args, const mp_obj_t *args) {
506506
}
507507
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
508508

509-
STATIC mp_obj_t mp_builtin_sorted(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
509+
STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
510510
assert(n_args >= 1);
511511
if (n_args > 1) {
512512
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
@@ -535,7 +535,7 @@ STATIC inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
535535
}
536536
}
537537

538-
STATIC mp_obj_t mp_builtin_getattr(mp_uint_t n_args, const mp_obj_t *args) {
538+
STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
539539
mp_obj_t defval = MP_OBJ_NULL;
540540
if (n_args > 2) {
541541
defval = args[2];

py/modmath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ MATH_FUN_1(lgamma, lgamma)
152152
// Function that takes a variable number of arguments
153153

154154
// log(x[, base])
155-
STATIC mp_obj_t mp_math_log(mp_uint_t n_args, const mp_obj_t *args) {
155+
STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
156156
mp_float_t x = mp_obj_get_float(args[0]);
157157
if (x <= (mp_float_t)0.0) {
158158
math_error();

0 commit comments

Comments
 (0)