Skip to content

Commit 4abff75

Browse files
committed
py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.
Part of code cleanup, working towards resolving issue adafruit#50.
1 parent 4d91723 commit 4abff75

21 files changed

+62
-63
lines changed

py/argcheck.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "obj.h"
3535
#include "runtime.h"
3636

37-
void mp_arg_check_num(uint n_args, uint n_kw, uint n_args_min, uint n_args_max, bool takes_kw) {
37+
void mp_arg_check_num(mp_uint_t n_args, mp_uint_t n_kw, mp_uint_t n_args_min, mp_uint_t n_args_max, bool takes_kw) {
3838
// TODO maybe take the function name as an argument so we can print nicer error messages
3939

4040
if (n_kw && !takes_kw) {
@@ -60,9 +60,9 @@ void mp_arg_check_num(uint n_args, uint n_kw, uint n_args_min, uint n_args_max,
6060
}
6161
}
6262

63-
void mp_arg_parse_all(uint n_pos, const mp_obj_t *pos, mp_map_t *kws, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals) {
64-
uint pos_found = 0, kws_found = 0;
65-
for (uint i = 0; i < n_allowed; i++) {
63+
void mp_arg_parse_all(mp_uint_t n_pos, const mp_obj_t *pos, mp_map_t *kws, mp_uint_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals) {
64+
mp_uint_t pos_found = 0, kws_found = 0;
65+
for (mp_uint_t i = 0; i < n_allowed; i++) {
6666
mp_obj_t given_arg;
6767
if (i < n_pos) {
6868
if (allowed[i].flags & MP_ARG_KW_ONLY) {
@@ -104,7 +104,7 @@ void mp_arg_parse_all(uint n_pos, const mp_obj_t *pos, mp_map_t *kws, uint n_all
104104
}
105105
}
106106

107-
void mp_arg_parse_all_kw_array(uint n_pos, uint n_kw, const mp_obj_t *args, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals) {
107+
void mp_arg_parse_all_kw_array(mp_uint_t n_pos, mp_uint_t n_kw, const mp_obj_t *args, mp_uint_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals) {
108108
mp_map_t kw_args;
109109
mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos);
110110
mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals);

py/binary.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define alignof(type) offsetof(struct { char c; type t; }, t)
4343
#endif
4444

45-
int mp_binary_get_size(char struct_type, char val_type, uint *palign) {
45+
int mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
4646
int size = 0;
4747
int align = 1;
4848
switch (struct_type) {
@@ -134,7 +134,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, int index) {
134134
return MP_OBJ_NEW_SMALL_INT(val);
135135
}
136136

137-
mp_int_t mp_binary_get_int(uint size, bool is_signed, bool big_endian, byte *p) {
137+
mp_int_t mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, byte *p) {
138138
int delta;
139139
if (!big_endian) {
140140
delta = -1;
@@ -159,7 +159,7 @@ mp_int_t mp_binary_get_int(uint size, bool is_signed, bool big_endian, byte *p)
159159
#define is_signed(typecode) (typecode > 'Z')
160160
mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
161161
byte *p = *ptr;
162-
uint align;
162+
mp_uint_t align;
163163

164164
int size = mp_binary_get_size(struct_type, val_type, &align);
165165
if (struct_type == '@') {
@@ -186,7 +186,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
186186
}
187187
}
188188

189-
void mp_binary_set_int(uint val_sz, bool big_endian, byte *p, byte *val_ptr) {
189+
void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *p, byte *val_ptr) {
190190
int in_delta, out_delta;
191191
if (big_endian) {
192192
in_delta = -1;
@@ -205,7 +205,7 @@ void mp_binary_set_int(uint val_sz, bool big_endian, byte *p, byte *val_ptr) {
205205

206206
void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr) {
207207
byte *p = *ptr;
208-
uint align;
208+
mp_uint_t align;
209209

210210
int size = mp_binary_get_size(struct_type, val_type, &align);
211211
if (struct_type == '@') {

py/binary.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
// (underlyingly they're same).
2929
#define BYTEARRAY_TYPECODE 0
3030

31-
int mp_binary_get_size(char struct_type, char val_type, uint *palign);
31+
int mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign);
3232
mp_obj_t mp_binary_get_val_array(char typecode, void *p, int index);
3333
void mp_binary_set_val_array(char typecode, void *p, int index, mp_obj_t val_in);
3434
void mp_binary_set_val_array_from_int(char typecode, void *p, int index, mp_int_t val);
3535
mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr);
3636
void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr);
37-
mp_int_t mp_binary_get_int(uint size, bool is_signed, bool big_endian, byte *p);
38-
void mp_binary_set_int(uint val_sz, bool big_endian, byte *p, byte *val_ptr);
37+
mp_int_t mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, byte *p);
38+
void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *p, byte *val_ptr);

py/builtin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_
401401
#if MICROPY_PY_IO
402402
mp_stream_write(stream_obj, sep_data, sep_len);
403403
#else
404-
printf("%.*s", sep_len, sep_data);
404+
printf("%.*s", (int)sep_len, sep_data);
405405
#endif
406406
}
407407
#if MICROPY_PY_IO
@@ -413,7 +413,7 @@ STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_
413413
#if MICROPY_PY_IO
414414
mp_stream_write(stream_obj, end_data, end_len);
415415
#else
416-
printf("%.*s", end_len, end_data);
416+
printf("%.*s", (int)end_len, end_data);
417417
#endif
418418
return mp_const_none;
419419
}

py/builtin.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args);
28-
mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args);
29-
mp_obj_t mp_builtin_len(mp_obj_t o);
27+
mp_obj_t mp_builtin___import__(mp_uint_t n_args, mp_obj_t *args);
28+
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args);
3029

3130
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___build_class___obj);
3231
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___import___obj);

py/builtinimport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
165165
mp_globals_set(old_globals);
166166
}
167167

168-
mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
168+
mp_obj_t mp_builtin___import__(mp_uint_t n_args, mp_obj_t *args) {
169169
#if DEBUG_PRINT
170170
printf("__import__:\n");
171171
for (int i = 0; i < n_args; i++) {

py/modstruct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
101101
char fmt_type = get_fmt_type(&fmt);
102102
mp_uint_t size;
103103
for (size = 0; *fmt; fmt++) {
104-
uint align = 1;
104+
mp_uint_t align = 1;
105105
mp_uint_t cnt = 1;
106106
if (unichar_isdigit(*fmt)) {
107107
cnt = get_fmt_num(&fmt);

py/nativeglue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) {
7171

7272
// wrapper that accepts n_args and n_kw in one argument
7373
// (native emitter can only pass at most 3 arguments to a function)
74-
mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, uint n_args_kw, const mp_obj_t *args) {
74+
mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, mp_uint_t n_args_kw, const mp_obj_t *args) {
7575
return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args);
7676
}
7777

py/objarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef struct _mp_obj_array_t {
5050
} mp_obj_array_t;
5151

5252
STATIC mp_obj_t array_iterator_new(mp_obj_t array_in);
53-
STATIC mp_obj_array_t *array_new(char typecode, uint n);
53+
STATIC mp_obj_array_t *array_new(char typecode, mp_uint_t n);
5454
STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
5555
STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
5656

@@ -263,7 +263,7 @@ const mp_obj_type_t mp_type_bytearray = {
263263
.locals_dict = (mp_obj_t)&array_locals_dict,
264264
};
265265

266-
STATIC mp_obj_array_t *array_new(char typecode, uint n) {
266+
STATIC mp_obj_array_t *array_new(char typecode, mp_uint_t n) {
267267
int typecode_size = mp_binary_get_size('@', typecode, NULL);
268268
if (typecode_size <= 0) {
269269
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "bad typecode"));
@@ -281,7 +281,7 @@ mp_uint_t mp_obj_array_len(mp_obj_t self_in) {
281281
return ((mp_obj_array_t *)self_in)->len;
282282
}
283283

284-
mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
284+
mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items) {
285285
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
286286
memcpy(o->items, items, n);
287287
return o;

py/objarray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
mp_obj_t mp_obj_new_bytearray(uint n, void *items);
27+
mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy