Skip to content

Commit a0c9781

Browse files
committed
py: Change type of .make_new and .call args: mp_uint_t becomes size_t.
This patch changes the type signature of .make_new and .call object method slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more efficient when mp_uint_t is larger than a machine word. Doesn't affect ports when size_t and mp_uint_t have the same size.
1 parent 66d0c10 commit a0c9781

35 files changed

+52
-52
lines changed

extmod/moductypes.c

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

124-
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) {
124+
STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
125125
mp_arg_check_num(n_args, n_kw, 2, 3, false);
126126
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
127127
o->base.type = MP_OBJ_TO_PTR(type_in);

extmod/moduhashlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct _mp_obj_hash_t {
4141

4242
STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg);
4343

44-
STATIC mp_obj_t hash_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
44+
STATIC mp_obj_t hash_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
4545
mp_arg_check_num(n_args, n_kw, 0, 1, false);
4646
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
4747
o->base.type = MP_OBJ_TO_PTR(type_in);

py/obj.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ typedef enum {
408408
} mp_print_kind_t;
409409

410410
typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind);
411-
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);
412-
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);
411+
typedef mp_obj_t (*mp_make_new_fun_t)(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
412+
typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args);
413413
typedef mp_obj_t (*mp_unary_op_fun_t)(mp_uint_t op, mp_obj_t);
414414
typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_t op, mp_obj_t, mp_obj_t);
415415
typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
@@ -691,7 +691,7 @@ void mp_obj_exception_clear_traceback(mp_obj_t self_in);
691691
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block);
692692
void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values);
693693
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
694-
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);
694+
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
695695
mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
696696
void mp_init_emergency_exception_buf(void);
697697

py/objarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
168168
#endif
169169

170170
#if MICROPY_PY_ARRAY
171-
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) {
171+
STATIC mp_obj_t array_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
172172
(void)type_in;
173173
mp_arg_check_num(n_args, n_kw, 1, 2, false);
174174

@@ -187,7 +187,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
187187
#endif
188188

189189
#if MICROPY_PY_BUILTINS_BYTEARRAY
190-
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) {
190+
STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
191191
(void)type_in;
192192
mp_arg_check_num(n_args, n_kw, 0, 1, false);
193193

@@ -219,7 +219,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, mp_uint_t nitems, void *items) {
219219
return MP_OBJ_FROM_PTR(self);
220220
}
221221

222-
STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
222+
STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
223223
(void)type_in;
224224

225225
// TODO possibly allow memoryview constructor to take start/stop so that one

py/objbool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
5252
}
5353
}
5454

55-
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) {
55+
STATIC mp_obj_t bool_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
5656
(void)type_in;
5757
mp_arg_check_num(n_args, n_kw, 0, 1, false);
5858

py/objboundmeth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_ki
4747
}
4848
#endif
4949

50-
STATIC 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) {
50+
STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
5151
mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
5252

5353
// 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
@@ -36,7 +36,7 @@ typedef struct _mp_obj_closure_t {
3636
mp_obj_t closed[];
3737
} mp_obj_closure_t;
3838

39-
STATIC 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) {
39+
STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
4040
mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in);
4141

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

py/objcomplex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
6969
}
7070
}
7171

72-
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) {
72+
STATIC mp_obj_t complex_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
7373
(void)type_in;
7474
mp_arg_check_num(n_args, n_kw, 0, 2, false);
7575

py/objdict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
8282
}
8383
}
8484

85-
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) {
85+
STATIC mp_obj_t dict_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
8686
mp_obj_t dict_out = mp_obj_new_dict(0);
8787
mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out);
8888
dict->base.type = MP_OBJ_TO_PTR(type_in);

py/objenumerate.c

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

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

0 commit comments

Comments
 (0)