Skip to content

Commit ecc88e9

Browse files
committed
Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue adafruit#50, still some way to go yet.
1 parent 4d3fc46 commit ecc88e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+212
-212
lines changed

extmod/moductypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ STATIC NORETURN void syntax_error() {
119119
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "syntax error in uctypes descriptor"));
120120
}
121121

122-
STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
122+
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) {
123123
if (n_args < 2 || n_args > 3) {
124124
syntax_error();
125125
}

py/obj.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ typedef mp_obj_t (*mp_fun_0_t)(void);
180180
typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t);
181181
typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t);
182182
typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
183-
typedef mp_obj_t (*mp_fun_var_t)(uint n, const mp_obj_t *);
184-
typedef mp_obj_t (*mp_fun_kw_t)(uint n, const mp_obj_t *, mp_map_t *);
183+
typedef mp_obj_t (*mp_fun_var_t)(mp_uint_t n, const mp_obj_t *);
184+
typedef mp_obj_t (*mp_fun_kw_t)(mp_uint_t n, const mp_obj_t *, mp_map_t *);
185185

186186
typedef enum {
187187
PRINT_STR = 0,
@@ -191,10 +191,10 @@ typedef enum {
191191
} mp_print_kind_t;
192192

193193
typedef void (*mp_print_fun_t)(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o, mp_print_kind_t kind);
194-
typedef mp_obj_t (*mp_make_new_fun_t)(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args);
195-
typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, uint n_args, uint n_kw, const mp_obj_t *args);
196-
typedef mp_obj_t (*mp_unary_op_fun_t)(int op, mp_obj_t);
197-
typedef mp_obj_t (*mp_binary_op_fun_t)(int op, mp_obj_t, mp_obj_t);
194+
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);
195+
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);
196+
typedef mp_obj_t (*mp_unary_op_fun_t)(mp_uint_t op, mp_obj_t);
197+
typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_t op, mp_obj_t, mp_obj_t);
198198
typedef void (*mp_load_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); // for fail, do nothing; for attr, dest[0] = value; for method, dest[0] = method, dest[1] = self
199199
typedef bool (*mp_store_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t value); // return true if store succeeded; if value==MP_OBJ_NULL then delete
200200
typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
@@ -458,7 +458,7 @@ void mp_obj_exception_clear_traceback(mp_obj_t self_in);
458458
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, mp_uint_t line, qstr block);
459459
void mp_obj_exception_get_traceback(mp_obj_t self_in, mp_uint_t *n, mp_uint_t **values);
460460
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
461-
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args);
461+
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);
462462
mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
463463
void mp_init_emergency_exception_buf(void);
464464

@@ -482,11 +482,11 @@ typedef struct _mp_obj_float_t {
482482
mp_float_t value;
483483
} mp_obj_float_t;
484484
mp_float_t mp_obj_float_get(mp_obj_t self_in);
485-
mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported
485+
mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported
486486

487487
// complex
488488
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
489-
mp_obj_t mp_obj_complex_binary_op(int op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
489+
mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
490490
#endif
491491

492492
// tuple
@@ -501,7 +501,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
501501
void mp_obj_list_get(mp_obj_t self_in, uint *len, mp_obj_t **items);
502502
void mp_obj_list_set_len(mp_obj_t self_in, uint len);
503503
void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
504-
mp_obj_t mp_obj_list_sort(uint n_args, const mp_obj_t *args, mp_map_t *kwargs);
504+
mp_obj_t mp_obj_list_sort(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
505505

506506
// dict
507507
typedef struct _mp_obj_dict_t {
@@ -535,7 +535,7 @@ typedef struct _mp_obj_fun_builtin_t { // use this to make const objects that go
535535
void *fun; // must be a pointer to a callable function in ROM
536536
} mp_obj_fun_builtin_t;
537537

538-
mp_obj_t mp_obj_fun_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
538+
mp_obj_t mp_obj_fun_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
539539
const char *mp_obj_fun_get_name(mp_const_obj_t fun);
540540
const char *mp_obj_code_get_name(const byte *code_info);
541541

py/objarray.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
104104
return array;
105105
}
106106

107-
STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
107+
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) {
108108
mp_arg_check_num(n_args, n_kw, 1, 2, false);
109109

110110
// get typecode
@@ -120,7 +120,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
120120
}
121121
}
122122

123-
STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
123+
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) {
124124
mp_arg_check_num(n_args, n_kw, 0, 1, false);
125125

126126
if (n_args == 0) {
@@ -138,7 +138,7 @@ STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
138138
}
139139
}
140140

141-
STATIC mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
141+
STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) {
142142
mp_obj_array_t *o = o_in;
143143
switch (op) {
144144
case MP_UNARY_OP_BOOL: return MP_BOOL(o->len != 0);
@@ -147,7 +147,7 @@ STATIC mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
147147
}
148148
}
149149

150-
STATIC mp_obj_t array_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
150+
STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
151151
switch (op) {
152152
case MP_BINARY_OP_EQUAL: {
153153
mp_buffer_info_t lhs_bufinfo;

py/objbool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ STATIC void bool_print(void (*print)(void *env, const char *fmt, ...), void *env
4848
}
4949
}
5050

51-
STATIC mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
51+
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) {
5252
mp_arg_check_num(n_args, n_kw, 0, 1, false);
5353

5454
switch (n_args) {
@@ -60,7 +60,7 @@ STATIC mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
6060
}
6161
}
6262

63-
STATIC mp_obj_t bool_unary_op(int op, mp_obj_t o_in) {
63+
STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
6464
mp_int_t value = ((mp_obj_bool_t*)o_in)->value;
6565
switch (op) {
6666
case MP_UNARY_OP_BOOL: return o_in;
@@ -72,7 +72,7 @@ STATIC mp_obj_t bool_unary_op(int op, mp_obj_t o_in) {
7272
}
7373
}
7474

75-
STATIC mp_obj_t bool_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
75+
STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
7676
if (MP_BINARY_OP_OR <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
7777
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(mp_obj_is_true(lhs_in)), rhs_in);
7878
}

py/objboundmeth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ STATIC void bound_meth_print(void (*print)(void *env, const char *fmt, ...), voi
5050
}
5151
#endif
5252

53-
mp_obj_t bound_meth_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
53+
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) {
5454
mp_obj_bound_meth_t *self = self_in;
5555

5656
// need to insert self->self before all other args and then call self->meth

py/objclosure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct _mp_obj_closure_t {
4141
mp_obj_t closed[];
4242
} mp_obj_closure_t;
4343

44-
mp_obj_t closure_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
44+
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) {
4545
mp_obj_closure_t *self = self_in;
4646

4747
// need to concatenate closed-over-vars and args

py/objcomplex.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
7474
#endif
7575
}
7676

77-
STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
77+
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) {
7878
mp_arg_check_num(n_args, n_kw, 0, 2, false);
7979

8080
switch (n_args) {
@@ -117,7 +117,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
117117
}
118118
}
119119

120-
STATIC mp_obj_t complex_unary_op(int op, mp_obj_t o_in) {
120+
STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) {
121121
mp_obj_complex_t *o = o_in;
122122
switch (op) {
123123
case MP_UNARY_OP_BOOL: return MP_BOOL(o->real != 0 || o->imag != 0);
@@ -127,7 +127,7 @@ STATIC mp_obj_t complex_unary_op(int op, mp_obj_t o_in) {
127127
}
128128
}
129129

130-
STATIC mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
130+
STATIC mp_obj_t complex_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
131131
mp_obj_complex_t *lhs = lhs_in;
132132
return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
133133
}
@@ -166,7 +166,7 @@ void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) {
166166
*imag = self->imag;
167167
}
168168

169-
mp_obj_t mp_obj_complex_binary_op(int op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) {
169+
mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) {
170170
mp_float_t rhs_real, rhs_imag;
171171
mp_obj_get_complex(rhs_in, &rhs_real, &rhs_imag); // can be any type, this function will convert to float (if possible)
172172
switch (op) {

py/objdict.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ STATIC void dict_print(void (*print)(void *env, const char *fmt, ...), void *env
6060
print(env, "}");
6161
}
6262

63-
STATIC mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
63+
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) {
6464
mp_obj_t dict = mp_obj_new_dict(0);
6565
if (n_args > 0 || n_kw > 0) {
6666
mp_obj_t args2[2] = {dict, args[0]}; // args[0] is always valid, even if it's not a positional arg
@@ -71,7 +71,7 @@ STATIC mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
7171
return dict;
7272
}
7373

74-
STATIC mp_obj_t dict_unary_op(int op, mp_obj_t self_in) {
74+
STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) {
7575
mp_obj_dict_t *self = self_in;
7676
switch (op) {
7777
case MP_UNARY_OP_BOOL: return MP_BOOL(self->map.used != 0);
@@ -80,7 +80,7 @@ STATIC mp_obj_t dict_unary_op(int op, mp_obj_t self_in) {
8080
}
8181
}
8282

83-
STATIC mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
83+
STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
8484
mp_obj_dict_t *o = lhs_in;
8585
switch (op) {
8686
case MP_BINARY_OP_IN: {
@@ -472,7 +472,7 @@ STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void
472472
print(env, "])");
473473
}
474474

475-
STATIC mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
475+
STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
476476
// only supported for the 'keys' kind until sets and dicts are refactored
477477
mp_obj_dict_view_t *o = lhs_in;
478478
if (o->kind != MP_DICT_VIEW_KEYS) {

py/objenumerate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ STATIC const mp_arg_t enumerate_make_new_args[] = {
4747
};
4848
#define ENUMERATE_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(enumerate_make_new_args)
4949

50-
STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
50+
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) {
5151
#if MICROPY_CPYTHON_COMPAT
5252
// parse args
5353
mp_arg_val_t vals[ENUMERATE_MAKE_NEW_NUM_ARGS];

py/objexcept.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...
130130
mp_obj_tuple_print(print, env, o->args, kind);
131131
}
132132

133-
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
133+
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) {
134134
mp_obj_type_t *type = type_in;
135135

136136
if (n_kw != 0) {
@@ -171,7 +171,7 @@ STATIC void exception_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
171171
}
172172
}
173173

174-
STATIC mp_obj_t exc___init__(uint n_args, const mp_obj_t *args) {
174+
STATIC mp_obj_t exc___init__(mp_uint_t n_args, const mp_obj_t *args) {
175175
mp_obj_exception_t *self = args[0];
176176
mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1);
177177
self->args = argst;

0 commit comments

Comments
 (0)