4646// args[0] is function from class body
4747// args[1] is class name
4848// args[2:] are base objects
49- STATIC mp_obj_t mp_builtin___build_class__ (uint n_args , const mp_obj_t * args ) {
49+ STATIC mp_obj_t mp_builtin___build_class__ (mp_uint_t n_args , const mp_obj_t * args ) {
5050 assert (2 <= n_args );
5151
5252 // set the new classes __locals__ object
@@ -86,7 +86,6 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
8686
8787 return new_class ;
8888}
89-
9089MP_DEFINE_CONST_FUN_OBJ_VAR (mp_builtin___build_class___obj , 2 , mp_builtin___build_class__ );
9190
9291STATIC mp_obj_t mp_builtin___repl_print__ (mp_obj_t o ) {
@@ -96,7 +95,6 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
9695 }
9796 return mp_const_none ;
9897}
99-
10098MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin___repl_print___obj , mp_builtin___repl_print__ );
10199
102100STATIC mp_obj_t mp_builtin_abs (mp_obj_t o_in ) {
@@ -127,7 +125,6 @@ STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
127125 return mp_const_none ;
128126 }
129127}
130-
131128MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_abs_obj , mp_builtin_abs );
132129
133130STATIC mp_obj_t mp_builtin_all (mp_obj_t o_in ) {
@@ -140,7 +137,6 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
140137 }
141138 return mp_const_true ;
142139}
143-
144140MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_all_obj , mp_builtin_all );
145141
146142STATIC mp_obj_t mp_builtin_any (mp_obj_t o_in ) {
@@ -153,14 +149,12 @@ STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
153149 }
154150 return mp_const_false ;
155151}
156-
157152MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_any_obj , mp_builtin_any );
158153
159154STATIC mp_obj_t mp_builtin_bin (mp_obj_t o_in ) {
160155 mp_obj_t args [] = { MP_OBJ_NEW_QSTR (MP_QSTR__brace_open__colon__hash_b_brace_close_ ), o_in };
161156 return mp_obj_str_format (MP_ARRAY_SIZE (args ), args );
162157}
163-
164158MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_bin_obj , mp_builtin_bin );
165159
166160STATIC mp_obj_t mp_builtin_callable (mp_obj_t o_in ) {
@@ -170,7 +164,6 @@ STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
170164 return mp_const_false ;
171165 }
172166}
173-
174167MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_callable_obj , mp_builtin_callable );
175168
176169STATIC mp_obj_t mp_builtin_chr (mp_obj_t o_in ) {
@@ -209,10 +202,9 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
209202 }
210203 #endif
211204}
212-
213205MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_chr_obj , mp_builtin_chr );
214206
215- STATIC mp_obj_t mp_builtin_dir (uint n_args , const mp_obj_t * args ) {
207+ STATIC mp_obj_t mp_builtin_dir (mp_uint_t n_args , const mp_obj_t * args ) {
216208 // TODO make this function more general and less of a hack
217209
218210 mp_obj_dict_t * dict = NULL ;
@@ -238,7 +230,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
238230
239231 mp_obj_t dir = mp_obj_new_list (0 , NULL );
240232 if (dict != NULL ) {
241- for (uint i = 0 ; i < dict -> map .alloc ; i ++ ) {
233+ for (mp_uint_t i = 0 ; i < dict -> map .alloc ; i ++ ) {
242234 if (MP_MAP_SLOT_IS_FILLED (& dict -> map , i )) {
243235 mp_obj_list_append (dir , dict -> map .table [i ].key );
244236 }
@@ -247,7 +239,6 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
247239
248240 return dir ;
249241}
250-
251242MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_dir_obj , 0 , 1 , mp_builtin_dir );
252243
253244STATIC mp_obj_t mp_builtin_divmod (mp_obj_t o1_in , mp_obj_t o2_in ) {
@@ -262,29 +253,25 @@ STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
262253 nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError , "unsupported operand type(s) for divmod(): '%s' and '%s'" , mp_obj_get_type_str (o1_in ), mp_obj_get_type_str (o2_in )));
263254 }
264255}
265-
266256MP_DEFINE_CONST_FUN_OBJ_2 (mp_builtin_divmod_obj , mp_builtin_divmod );
267257
268258STATIC mp_obj_t mp_builtin_hash (mp_obj_t o_in ) {
269259 // TODO hash will generally overflow small integer; can we safely truncate it?
270260 return mp_obj_new_int (mp_obj_hash (o_in ));
271261}
272-
273262MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_hash_obj , mp_builtin_hash );
274263
275264STATIC mp_obj_t mp_builtin_hex (mp_obj_t o_in ) {
276265 return mp_binary_op (MP_BINARY_OP_MODULO , MP_OBJ_NEW_QSTR (MP_QSTR__percent__hash_x ), o_in );
277266}
278-
279267MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_hex_obj , mp_builtin_hex );
280268
281269STATIC mp_obj_t mp_builtin_iter (mp_obj_t o_in ) {
282270 return mp_getiter (o_in );
283271}
284-
285272MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_iter_obj , mp_builtin_iter );
286273
287- STATIC mp_obj_t mp_builtin_min_max (uint n_args , const mp_obj_t * args , mp_map_t * kwargs , int op ) {
274+ 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 ) {
288275 mp_map_elem_t * key_elem = mp_map_lookup (kwargs , MP_OBJ_NEW_QSTR (MP_QSTR_key ), MP_MAP_LOOKUP );
289276 mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem -> value ;
290277 if (n_args == 1 ) {
@@ -319,12 +306,12 @@ STATIC mp_obj_t mp_builtin_min_max(uint n_args, const mp_obj_t *args, mp_map_t *
319306 }
320307}
321308
322- STATIC mp_obj_t mp_builtin_max (uint n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
309+ STATIC mp_obj_t mp_builtin_max (mp_uint_t n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
323310 return mp_builtin_min_max (n_args , args , kwargs , MP_BINARY_OP_MORE );
324311}
325312MP_DEFINE_CONST_FUN_OBJ_KW (mp_builtin_max_obj , 1 , mp_builtin_max );
326313
327- STATIC mp_obj_t mp_builtin_min (uint n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
314+ STATIC mp_obj_t mp_builtin_min (mp_uint_t n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
328315 return mp_builtin_min_max (n_args , args , kwargs , MP_BINARY_OP_LESS );
329316}
330317MP_DEFINE_CONST_FUN_OBJ_KW (mp_builtin_min_obj , 1 , mp_builtin_min );
@@ -337,17 +324,15 @@ STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
337324 return ret ;
338325 }
339326}
340-
341327MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_next_obj , mp_builtin_next );
342328
343329STATIC mp_obj_t mp_builtin_oct (mp_obj_t o_in ) {
344330 return mp_binary_op (MP_BINARY_OP_MODULO , MP_OBJ_NEW_QSTR (MP_QSTR__percent__hash_o ), o_in );
345331}
346-
347332MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_oct_obj , mp_builtin_oct );
348333
349334STATIC mp_obj_t mp_builtin_ord (mp_obj_t o_in ) {
350- uint len ;
335+ mp_uint_t len ;
351336 const char * str = mp_obj_str_get_data (o_in , & len );
352337 #if MICROPY_PY_BUILTINS_STR_UNICODE
353338 mp_uint_t charlen = unichar_charlen (str , len );
@@ -376,26 +361,24 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
376361 }
377362 #endif
378363}
379-
380364MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_ord_obj , mp_builtin_ord );
381365
382- STATIC mp_obj_t mp_builtin_pow (uint n_args , const mp_obj_t * args ) {
366+ STATIC mp_obj_t mp_builtin_pow (mp_uint_t n_args , const mp_obj_t * args ) {
383367 assert (2 <= n_args && n_args <= 3 );
384368 switch (n_args ) {
385369 case 2 : return mp_binary_op (MP_BINARY_OP_POWER , args [0 ], args [1 ]);
386370 default : return mp_binary_op (MP_BINARY_OP_MODULO , mp_binary_op (MP_BINARY_OP_POWER , args [0 ], args [1 ]), args [2 ]); // TODO optimise...
387371 }
388372}
389-
390373MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_pow_obj , 2 , 3 , mp_builtin_pow );
391374
392- STATIC mp_obj_t mp_builtin_print (uint n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
375+ STATIC mp_obj_t mp_builtin_print (mp_uint_t n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
393376 mp_map_elem_t * sep_elem = mp_map_lookup (kwargs , MP_OBJ_NEW_QSTR (MP_QSTR_sep ), MP_MAP_LOOKUP );
394377 mp_map_elem_t * end_elem = mp_map_lookup (kwargs , MP_OBJ_NEW_QSTR (MP_QSTR_end ), MP_MAP_LOOKUP );
395378 const char * sep_data = " " ;
396- uint sep_len = 1 ;
379+ mp_uint_t sep_len = 1 ;
397380 const char * end_data = "\n" ;
398- uint end_len = 1 ;
381+ mp_uint_t end_len = 1 ;
399382 if (sep_elem != NULL && sep_elem -> value != mp_const_none ) {
400383 sep_data = mp_obj_str_get_data (sep_elem -> value , & sep_len );
401384 }
@@ -434,7 +417,6 @@ STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args, mp_map_t *kw
434417 #endif
435418 return mp_const_none ;
436419}
437-
438420MP_DEFINE_CONST_FUN_OBJ_KW (mp_builtin_print_obj , 0 , mp_builtin_print );
439421
440422STATIC mp_obj_t mp_builtin_repr (mp_obj_t o_in ) {
@@ -447,7 +429,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
447429
448430MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_repr_obj , mp_builtin_repr );
449431
450- STATIC mp_obj_t mp_builtin_sum (uint n_args , const mp_obj_t * args ) {
432+ STATIC mp_obj_t mp_builtin_sum (mp_uint_t n_args , const mp_obj_t * args ) {
451433 assert (1 <= n_args && n_args <= 2 );
452434 mp_obj_t value ;
453435 switch (n_args ) {
@@ -461,10 +443,9 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
461443 }
462444 return value ;
463445}
464-
465446MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_sum_obj , 1 , 2 , mp_builtin_sum );
466447
467- STATIC mp_obj_t mp_builtin_sorted (uint n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
448+ STATIC mp_obj_t mp_builtin_sorted (mp_uint_t n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
468449 assert (n_args >= 1 );
469450 if (n_args > 1 ) {
470451 nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
@@ -475,7 +456,6 @@ STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *k
475456
476457 return self ;
477458}
478-
479459MP_DEFINE_CONST_FUN_OBJ_KW (mp_builtin_sorted_obj , 1 , mp_builtin_sorted );
480460
481461STATIC mp_obj_t mp_builtin_id (mp_obj_t o_in ) {
@@ -495,7 +475,6 @@ STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
495475 return mp_obj_new_int_from_uint ((mp_uint_t )id );
496476 }
497477}
498-
499478MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_id_obj , mp_builtin_id );
500479
501480// See mp_load_attr() if making any changes
@@ -514,7 +493,7 @@ STATIC inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
514493 }
515494}
516495
517- STATIC mp_obj_t mp_builtin_getattr (uint n_args , const mp_obj_t * args ) {
496+ STATIC mp_obj_t mp_builtin_getattr (mp_uint_t n_args , const mp_obj_t * args ) {
518497 mp_obj_t attr = args [1 ];
519498 if (MP_OBJ_IS_TYPE (attr , & mp_type_str )) {
520499 attr = mp_obj_str_intern (attr );
@@ -527,7 +506,6 @@ STATIC mp_obj_t mp_builtin_getattr(uint n_args, const mp_obj_t *args) {
527506 }
528507 return mp_load_attr_default (args [0 ], MP_OBJ_QSTR_VALUE (attr ), defval );
529508}
530-
531509MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_getattr_obj , 2 , 3 , mp_builtin_getattr );
532510
533511STATIC mp_obj_t mp_builtin_hasattr (mp_obj_t object_in , mp_obj_t attr_in ) {
@@ -542,7 +520,6 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
542520
543521 return MP_BOOL (dest [0 ] != MP_OBJ_NULL );
544522}
545-
546523MP_DEFINE_CONST_FUN_OBJ_2 (mp_builtin_hasattr_obj , mp_builtin_hasattr );
547524
548525// These are defined in terms of MicroPython API functions right away
0 commit comments