Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue #50, still some way to go yet.
This commit is contained in:
parent
4d3fc46326
commit
ecc88e949c
@ -119,7 +119,7 @@ STATIC NORETURN void syntax_error() {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "syntax error in uctypes descriptor"));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
if (n_args < 2 || n_args > 3) {
|
||||
syntax_error();
|
||||
}
|
||||
|
22
py/obj.h
22
py/obj.h
@ -180,8 +180,8 @@ typedef mp_obj_t (*mp_fun_0_t)(void);
|
||||
typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t);
|
||||
typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t);
|
||||
typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
|
||||
typedef mp_obj_t (*mp_fun_var_t)(uint n, const mp_obj_t *);
|
||||
typedef mp_obj_t (*mp_fun_kw_t)(uint n, const mp_obj_t *, mp_map_t *);
|
||||
typedef mp_obj_t (*mp_fun_var_t)(mp_uint_t n, const mp_obj_t *);
|
||||
typedef mp_obj_t (*mp_fun_kw_t)(mp_uint_t n, const mp_obj_t *, mp_map_t *);
|
||||
|
||||
typedef enum {
|
||||
PRINT_STR = 0,
|
||||
@ -191,10 +191,10 @@ typedef enum {
|
||||
} mp_print_kind_t;
|
||||
|
||||
typedef void (*mp_print_fun_t)(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o, mp_print_kind_t kind);
|
||||
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);
|
||||
typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, uint n_args, uint n_kw, const mp_obj_t *args);
|
||||
typedef mp_obj_t (*mp_unary_op_fun_t)(int op, mp_obj_t);
|
||||
typedef mp_obj_t (*mp_binary_op_fun_t)(int op, mp_obj_t, mp_obj_t);
|
||||
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);
|
||||
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);
|
||||
typedef mp_obj_t (*mp_unary_op_fun_t)(mp_uint_t op, mp_obj_t);
|
||||
typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_t op, mp_obj_t, mp_obj_t);
|
||||
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
|
||||
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
|
||||
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);
|
||||
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, mp_uint_t line, qstr block);
|
||||
void mp_obj_exception_get_traceback(mp_obj_t self_in, mp_uint_t *n, mp_uint_t **values);
|
||||
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args);
|
||||
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);
|
||||
mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
|
||||
void mp_init_emergency_exception_buf(void);
|
||||
|
||||
@ -482,11 +482,11 @@ typedef struct _mp_obj_float_t {
|
||||
mp_float_t value;
|
||||
} mp_obj_float_t;
|
||||
mp_float_t mp_obj_float_get(mp_obj_t self_in);
|
||||
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
|
||||
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
|
||||
|
||||
// complex
|
||||
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
|
||||
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
|
||||
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
|
||||
#endif
|
||||
|
||||
// tuple
|
||||
@ -501,7 +501,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
|
||||
void mp_obj_list_get(mp_obj_t self_in, uint *len, mp_obj_t **items);
|
||||
void mp_obj_list_set_len(mp_obj_t self_in, uint len);
|
||||
void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
|
||||
mp_obj_t mp_obj_list_sort(uint n_args, const mp_obj_t *args, mp_map_t *kwargs);
|
||||
mp_obj_t mp_obj_list_sort(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
|
||||
|
||||
// dict
|
||||
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
|
||||
void *fun; // must be a pointer to a callable function in ROM
|
||||
} mp_obj_fun_builtin_t;
|
||||
|
||||
mp_obj_t mp_obj_fun_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_obj_t mp_obj_fun_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
const char *mp_obj_fun_get_name(mp_const_obj_t fun);
|
||||
const char *mp_obj_code_get_name(const byte *code_info);
|
||||
|
||||
|
@ -104,7 +104,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
|
||||
return array;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
|
||||
STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_obj_array_t *o = o_in;
|
||||
switch (op) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t array_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_EQUAL: {
|
||||
mp_buffer_info_t lhs_bufinfo;
|
||||
|
@ -48,7 +48,7 @@ STATIC void bool_print(void (*print)(void *env, const char *fmt, ...), void *env
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bool_unary_op(int op, mp_obj_t o_in) {
|
||||
STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_int_t value = ((mp_obj_bool_t*)o_in)->value;
|
||||
switch (op) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bool_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
if (MP_BINARY_OP_OR <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
|
||||
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(mp_obj_is_true(lhs_in)), rhs_in);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ STATIC void bound_meth_print(void (*print)(void *env, const char *fmt, ...), voi
|
||||
}
|
||||
#endif
|
||||
|
||||
mp_obj_t bound_meth_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_obj_bound_meth_t *self = self_in;
|
||||
|
||||
// need to insert self->self before all other args and then call self->meth
|
||||
|
@ -41,7 +41,7 @@ typedef struct _mp_obj_closure_t {
|
||||
mp_obj_t closed[];
|
||||
} mp_obj_closure_t;
|
||||
|
||||
mp_obj_t closure_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_obj_closure_t *self = self_in;
|
||||
|
||||
// need to concatenate closed-over-vars and args
|
||||
|
@ -74,7 +74,7 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 2, false);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t complex_unary_op(int op, mp_obj_t o_in) {
|
||||
STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_obj_complex_t *o = o_in;
|
||||
switch (op) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t complex_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_complex_t *lhs = lhs_in;
|
||||
return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
|
||||
}
|
||||
@ -166,7 +166,7 @@ void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) {
|
||||
*imag = self->imag;
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
mp_float_t rhs_real, rhs_imag;
|
||||
mp_obj_get_complex(rhs_in, &rhs_real, &rhs_imag); // can be any type, this function will convert to float (if possible)
|
||||
switch (op) {
|
||||
|
@ -60,7 +60,7 @@ STATIC void dict_print(void (*print)(void *env, const char *fmt, ...), void *env
|
||||
print(env, "}");
|
||||
}
|
||||
|
||||
STATIC mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_obj_t dict = mp_obj_new_dict(0);
|
||||
if (n_args > 0 || n_kw > 0) {
|
||||
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
|
||||
return dict;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t dict_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_dict_t *self = self_in;
|
||||
switch (op) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_dict_t *o = lhs_in;
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_IN: {
|
||||
@ -472,7 +472,7 @@ STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void
|
||||
print(env, "])");
|
||||
}
|
||||
|
||||
STATIC mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
// only supported for the 'keys' kind until sets and dicts are refactored
|
||||
mp_obj_dict_view_t *o = lhs_in;
|
||||
if (o->kind != MP_DICT_VIEW_KEYS) {
|
||||
|
@ -47,7 +47,7 @@ STATIC const mp_arg_t enumerate_make_new_args[] = {
|
||||
};
|
||||
#define ENUMERATE_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(enumerate_make_new_args)
|
||||
|
||||
STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
// parse args
|
||||
mp_arg_val_t vals[ENUMERATE_MAKE_NEW_NUM_ARGS];
|
||||
|
@ -130,7 +130,7 @@ STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...
|
||||
mp_obj_tuple_print(print, env, o->args, kind);
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
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) {
|
||||
mp_obj_type_t *type = type_in;
|
||||
|
||||
if (n_kw != 0) {
|
||||
@ -171,7 +171,7 @@ STATIC void exception_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t exc___init__(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t exc___init__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_exception_t *self = args[0];
|
||||
mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1);
|
||||
self->args = argst;
|
||||
|
@ -40,7 +40,7 @@ typedef struct _mp_obj_filter_t {
|
||||
mp_obj_t iter;
|
||||
} mp_obj_filter_t;
|
||||
|
||||
STATIC mp_obj_t filter_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t filter_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
if (n_args != 2 || n_kw != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "filter expected 2 arguments"));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -90,7 +90,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t float_unary_op(int op, mp_obj_t o_in) {
|
||||
STATIC mp_obj_t float_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_obj_float_t *o = o_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(o->value != 0);
|
||||
@ -100,7 +100,7 @@ STATIC mp_obj_t float_unary_op(int op, mp_obj_t o_in) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t float_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t float_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_float_t *lhs = lhs_in;
|
||||
#if MICROPY_PY_BUILTINS_COMPLEX
|
||||
if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) {
|
||||
@ -134,7 +134,7 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in) {
|
||||
return self->value;
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs_in) {
|
||||
mp_float_t rhs_val = mp_obj_get_float(rhs_in); // can be any type, this function will convert to float (if possible)
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_ADD:
|
||||
|
12
py/objfun.c
12
py/objfun.c
@ -49,7 +49,7 @@
|
||||
|
||||
// This binary_op method is used for all function types, and is also
|
||||
// used to determine if an object is of generic function type.
|
||||
mp_obj_t mp_obj_fun_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_fun_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_EQUAL:
|
||||
// These objects can be equal only if it's the same underlying structure,
|
||||
@ -64,7 +64,7 @@ mp_obj_t mp_obj_fun_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
|
||||
// mp_obj_fun_builtin_t defined in obj.h
|
||||
|
||||
STATIC mp_obj_t fun_builtin_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fun_builtin_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin));
|
||||
mp_obj_fun_builtin_t *self = self_in;
|
||||
|
||||
@ -348,7 +348,7 @@ continue2:;
|
||||
}
|
||||
|
||||
|
||||
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
MP_STACK_CHECK();
|
||||
|
||||
DEBUG_printf("Input n_args: %d, n_kw: %d\n", n_args, n_kw);
|
||||
@ -510,7 +510,7 @@ typedef mp_obj_t (*native_fun_1_t)(mp_obj_t);
|
||||
typedef mp_obj_t (*native_fun_2_t)(mp_obj_t, mp_obj_t);
|
||||
typedef mp_obj_t (*native_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
|
||||
|
||||
STATIC mp_obj_t fun_native_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fun_native_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fun_native_t *self = self_in;
|
||||
|
||||
mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
|
||||
@ -571,7 +571,7 @@ typedef mp_uint_t (*viper_fun_1_t)(mp_uint_t);
|
||||
typedef mp_uint_t (*viper_fun_2_t)(mp_uint_t, mp_uint_t);
|
||||
typedef mp_uint_t (*viper_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t);
|
||||
|
||||
STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fun_viper_t *self = self_in;
|
||||
|
||||
mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
|
||||
@ -682,7 +682,7 @@ STATIC mp_obj_t convert_val_from_inline_asm(mp_uint_t val) {
|
||||
return MP_OBJ_NEW_SMALL_INT(val);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fun_asm_t *self = self_in;
|
||||
|
||||
mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
|
||||
|
@ -52,7 +52,7 @@ typedef struct _mp_obj_gen_instance_t {
|
||||
mp_code_state code_state;
|
||||
} mp_obj_gen_instance_t;
|
||||
|
||||
STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_gen_wrap_t *self = self_in;
|
||||
mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun;
|
||||
assert(MP_OBJ_IS_TYPE(self_fun, &mp_type_fun_bc));
|
||||
@ -197,7 +197,7 @@ STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
|
||||
|
||||
STATIC mp_obj_t gen_instance_close(mp_obj_t self_in);
|
||||
STATIC mp_obj_t gen_instance_throw(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t gen_instance_throw(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t exc = (n_args == 2) ? args[1] : args[2];
|
||||
exc = mp_make_raise_obj(exc);
|
||||
|
||||
|
12
py/objint.c
12
py/objint.c
@ -47,7 +47,7 @@
|
||||
#endif
|
||||
|
||||
// This dispatcher function is expected to be independent of the implementation of long int
|
||||
STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 2, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -225,12 +225,12 @@ bool mp_obj_int_is_positive(mp_obj_t self_in) {
|
||||
}
|
||||
|
||||
// This is called for operations on SMALL_INT that are not handled by mp_unary_op
|
||||
mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in) {
|
||||
mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
}
|
||||
|
||||
// This is called for operations on SMALL_INT that are not handled by mp_binary_op
|
||||
mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ mp_float_t mp_obj_int_as_float(mp_obj_t self_in) {
|
||||
|
||||
// This dispatcher function is expected to be independent of the implementation of long int
|
||||
// It handles the extra cases for integer-like arithmetic
|
||||
mp_obj_t mp_obj_int_binary_op_extra_cases(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
if (rhs_in == mp_const_false) {
|
||||
// false acts as 0
|
||||
return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(0));
|
||||
@ -299,7 +299,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(int op, mp_obj_t lhs_in, mp_obj_t rhs_
|
||||
}
|
||||
|
||||
// this is a classmethod
|
||||
STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t int_from_bytes(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: Support long ints
|
||||
// TODO: Support byteorder param (assumes 'little' at the moment)
|
||||
// TODO: Support signed param (assumes signed=False at the moment)
|
||||
@ -320,7 +320,7 @@ STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 2, 3, int_from_bytes);
|
||||
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, (const mp_obj_t)&int_from_bytes_fun_obj);
|
||||
|
||||
STATIC mp_obj_t int_to_bytes(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t int_to_bytes(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_int_t val = mp_obj_int_get_checked(args[0]);
|
||||
|
||||
uint len = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
||||
|
@ -40,6 +40,6 @@ char *mp_obj_int_formatted_impl(char **buf, int *buf_size, int *fmt_size, mp_con
|
||||
int base, const char *prefix, char base_char, char comma);
|
||||
mp_int_t mp_obj_int_hash(mp_obj_t self_in);
|
||||
bool mp_obj_int_is_positive(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in);
|
||||
mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_obj_t mp_obj_int_binary_op_extra_cases(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in);
|
||||
mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
|
@ -73,7 +73,7 @@ bool mp_obj_int_is_positive(mp_obj_t self_in) {
|
||||
return self->val >= 0;
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in) {
|
||||
mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_obj_int_t *o = o_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(o->val != 0);
|
||||
@ -84,7 +84,7 @@ mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
long long lhs_val;
|
||||
long long rhs_val;
|
||||
|
||||
|
@ -112,7 +112,7 @@ bool mp_obj_int_is_positive(mp_obj_t self_in) {
|
||||
return !self->mpz.neg;
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in) {
|
||||
mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
mp_obj_int_t *o = o_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(!mpz_is_zero(&o->mpz));
|
||||
@ -123,7 +123,7 @@ mp_obj_t mp_obj_int_unary_op(int op, mp_obj_t o_in) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
const mpz_t *zlhs;
|
||||
const mpz_t *zrhs;
|
||||
mpz_t z_int;
|
||||
|
24
py/objlist.c
24
py/objlist.c
@ -39,7 +39,7 @@
|
||||
STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, int cur);
|
||||
STATIC mp_obj_list_t *list_new(uint n);
|
||||
STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
|
||||
STATIC mp_obj_t list_pop(uint n_args, const mp_obj_t *args);
|
||||
STATIC mp_obj_t list_pop(mp_uint_t n_args, const mp_obj_t *args);
|
||||
|
||||
// TODO: Move to mpconfig.h
|
||||
#define LIST_MIN_ALLOC 4
|
||||
@ -68,7 +68,7 @@ STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
|
||||
return list;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t list_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -87,7 +87,7 @@ STATIC mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
|
||||
}
|
||||
|
||||
// Don't pass MP_BINARY_OP_NOT_EQUAL here
|
||||
STATIC bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
STATIC bool list_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_list));
|
||||
if (!MP_OBJ_IS_TYPE(another_in, &mp_type_list)) {
|
||||
return false;
|
||||
@ -98,7 +98,7 @@ STATIC bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_list_t *self = self_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
|
||||
@ -107,7 +107,7 @@ STATIC mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
STATIC mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_list_t *o = lhs;
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_ADD: {
|
||||
@ -264,7 +264,7 @@ STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
|
||||
return mp_const_none; // return None, as per CPython
|
||||
}
|
||||
|
||||
STATIC mp_obj_t list_pop(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t list_pop(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(1 <= n_args && n_args <= 2);
|
||||
assert(MP_OBJ_IS_TYPE(args[0], &mp_type_list));
|
||||
mp_obj_list_t *self = args[0];
|
||||
@ -307,7 +307,7 @@ STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, bool r
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_list_sort(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
mp_obj_t mp_obj_list_sort(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
assert(n_args >= 1);
|
||||
assert(MP_OBJ_IS_TYPE(args[0], &mp_type_list));
|
||||
if (n_args > 1) {
|
||||
@ -347,7 +347,7 @@ STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
|
||||
return mp_seq_count_obj(self->items, self->len, value);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t list_index(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t list_index(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(2 <= n_args && n_args <= 4);
|
||||
assert(MP_OBJ_IS_TYPE(args[0], &mp_type_list));
|
||||
mp_obj_list_t *self = args[0];
|
||||
@ -358,7 +358,7 @@ STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
|
||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_list));
|
||||
mp_obj_list_t *self = self_in;
|
||||
// insert has its own strange index logic
|
||||
int index = MP_OBJ_SMALL_INT_VALUE(idx);
|
||||
mp_int_t index = MP_OBJ_SMALL_INT_VALUE(idx);
|
||||
if (index < 0) {
|
||||
index += self->len;
|
||||
}
|
||||
@ -371,7 +371,7 @@ STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
|
||||
|
||||
mp_obj_list_append(self_in, mp_const_none);
|
||||
|
||||
for (int i = self->len-1; i > index; i--) {
|
||||
for (mp_int_t i = self->len-1; i > index; i--) {
|
||||
self->items[i] = self->items[i-1];
|
||||
}
|
||||
self->items[index] = obj;
|
||||
@ -392,8 +392,8 @@ STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
|
||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_list));
|
||||
mp_obj_list_t *self = self_in;
|
||||
|
||||
int len = self->len;
|
||||
for (int i = 0; i < len/2; i++) {
|
||||
mp_int_t len = self->len;
|
||||
for (mp_int_t i = 0; i < len/2; i++) {
|
||||
mp_obj_t *a = self->items[i];
|
||||
self->items[i] = self->items[len-i-1];
|
||||
self->items[len-i-1] = a;
|
||||
|
@ -41,7 +41,7 @@ typedef struct _mp_obj_map_t {
|
||||
mp_obj_t iters[];
|
||||
} mp_obj_map_t;
|
||||
|
||||
STATIC mp_obj_t map_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t map_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
if (n_args < 2 || n_kw != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "map must have at least 2 arguments and no keyword arguments"));
|
||||
}
|
||||
@ -50,7 +50,7 @@ STATIC mp_obj_t map_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
|
||||
o->base.type = &mp_type_map;
|
||||
o->n_iters = n_args - 1;
|
||||
o->fun = args[0];
|
||||
for (int i = 0; i < n_args - 1; i++) {
|
||||
for (mp_uint_t i = 0; i < n_args - 1; i++) {
|
||||
o->iters[i] = mp_getiter(args[i + 1]);
|
||||
}
|
||||
return o;
|
||||
@ -61,7 +61,7 @@ STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
|
||||
mp_obj_map_t *self = self_in;
|
||||
mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters);
|
||||
|
||||
for (int i = 0; i < self->n_iters; i++) {
|
||||
for (mp_uint_t i = 0; i < self->n_iters; i++) {
|
||||
mp_obj_t next = mp_iternext(self->iters[i]);
|
||||
if (next == MP_OBJ_STOP_ITERATION) {
|
||||
m_del(mp_obj_t, nextses, self->n_iters);
|
||||
|
@ -134,7 +134,7 @@ STATIC bool namedtuple_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_AttributeError, "can't set attribute"));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t namedtuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t namedtuple_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_namedtuple_type_t *type = type_in;
|
||||
uint num_fields = namedtuple_count_fields(type->fields);
|
||||
if (n_args != num_fields) {
|
||||
|
@ -41,7 +41,7 @@ STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env
|
||||
print(env, "None");
|
||||
}
|
||||
|
||||
STATIC mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
|
||||
STATIC mp_obj_t none_unary_op(mp_uint_t op, mp_obj_t o_in) {
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return mp_const_false;
|
||||
default: return MP_OBJ_NULL; // op not supported
|
||||
|
@ -33,13 +33,13 @@
|
||||
#include "obj.h"
|
||||
#include "runtime0.h"
|
||||
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args);
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
|
||||
|
||||
typedef struct _mp_obj_object_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_object_t;
|
||||
|
||||
STATIC mp_obj_t object_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t object_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
if (n_args != 0 || n_kw != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object takes no arguments"));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ typedef struct _mp_obj_property_t {
|
||||
mp_obj_t proxy[3]; // getter, setter, deleter
|
||||
} mp_obj_property_t;
|
||||
|
||||
STATIC mp_obj_t property_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t property_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 4, false);
|
||||
|
||||
mp_obj_property_t *o = m_new_obj(mp_obj_property_t);
|
||||
|
@ -93,7 +93,7 @@ STATIC void range_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t range_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t range_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 3, false);
|
||||
|
||||
mp_obj_range_t *o = m_new_obj(mp_obj_range_t);
|
||||
@ -130,7 +130,7 @@ STATIC mp_int_t range_len(mp_obj_range_t *self) {
|
||||
return len;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t range_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_range_t *self = self_in;
|
||||
mp_int_t len = range_len(self);
|
||||
switch (op) {
|
||||
|
@ -40,7 +40,7 @@ typedef struct _mp_obj_reversed_t {
|
||||
mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0)
|
||||
} mp_obj_reversed_t;
|
||||
|
||||
STATIC mp_obj_t reversed_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t reversed_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
mp_obj_reversed_t *o = m_new_obj(mp_obj_reversed_t);
|
||||
|
14
py/objset.c
14
py/objset.c
@ -122,7 +122,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
}
|
||||
|
||||
|
||||
STATIC mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t set_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -234,7 +234,7 @@ STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
|
||||
|
||||
STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
|
||||
STATIC mp_obj_t set_diff_int(mp_uint_t n_args, const mp_obj_t *args, bool update) {
|
||||
assert(n_args > 0);
|
||||
|
||||
mp_obj_set_t *self;
|
||||
@ -264,12 +264,12 @@ STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
|
||||
return self;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t set_diff(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t set_diff(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return set_diff_int(n_args, args, false);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
|
||||
|
||||
STATIC mp_obj_t set_diff_update(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t set_diff_update(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
set_diff_int(n_args, args, true);
|
||||
return mp_const_none;
|
||||
}
|
||||
@ -453,7 +453,7 @@ STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t set_update(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t set_update(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(n_args > 0);
|
||||
|
||||
for (int i = 1; i < n_args; i++) {
|
||||
@ -472,7 +472,7 @@ STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
|
||||
|
||||
STATIC mp_obj_t set_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t set_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_set_t *self = self_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(self->set.used != 0);
|
||||
@ -481,7 +481,7 @@ STATIC mp_obj_t set_unary_op(int op, mp_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
STATIC mp_obj_t set_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_t args[] = {lhs, rhs};
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_OR:
|
||||
|
46
py/objstr.c
46
py/objstr.c
@ -41,7 +41,7 @@
|
||||
#include "objstr.h"
|
||||
#include "objlist.h"
|
||||
|
||||
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, uint n_args, const mp_obj_t *args, mp_obj_t dict);
|
||||
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict);
|
||||
const mp_obj_t mp_const_empty_bytes;
|
||||
|
||||
mp_obj_t mp_obj_new_str_iterator(mp_obj_t str);
|
||||
@ -105,7 +105,7 @@ STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (n_kw != 0) {
|
||||
mp_arg_error_unimpl_kw();
|
||||
@ -145,7 +145,7 @@ STATIC mp_obj_t str_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
if (n_args == 0) {
|
||||
return mp_const_empty_bytes;
|
||||
}
|
||||
@ -250,7 +250,7 @@ STATIC const byte *find_subbytes(const byte *haystack, mp_uint_t hlen, const byt
|
||||
// Note: this function is used to check if an object is a str or bytes, which
|
||||
// works because both those types use it as their binary_op method. Revisit
|
||||
// MP_OBJ_IS_STR_OR_BYTES if this fact changes.
|
||||
mp_obj_t mp_obj_str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len);
|
||||
mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in);
|
||||
mp_obj_type_t *rhs_type = mp_obj_get_type(rhs_in);
|
||||
@ -440,7 +440,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
|
||||
|
||||
#define is_ws(c) ((c) == ' ' || (c) == '\t')
|
||||
|
||||
STATIC mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_split(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
|
||||
mp_int_t splits = -1;
|
||||
mp_obj_t sep = mp_const_none;
|
||||
@ -515,7 +515,7 @@ STATIC mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
|
||||
return res;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_rsplit(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args < 3) {
|
||||
// If we don't have split limit, it doesn't matter from which side
|
||||
// we split.
|
||||
@ -576,7 +576,7 @@ STATIC mp_obj_t str_rsplit(uint n_args, const mp_obj_t *args) {
|
||||
return res;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_finder(uint n_args, const mp_obj_t *args, mp_int_t direction, bool is_index) {
|
||||
STATIC mp_obj_t str_finder(mp_uint_t n_args, const mp_obj_t *args, mp_int_t direction, bool is_index) {
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
|
||||
assert(2 <= n_args && n_args <= 4);
|
||||
assert(MP_OBJ_IS_STR(args[0]));
|
||||
@ -613,24 +613,24 @@ STATIC mp_obj_t str_finder(uint n_args, const mp_obj_t *args, mp_int_t direction
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_find(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_find(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_finder(n_args, args, 1, false);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_rfind(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_rfind(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_finder(n_args, args, -1, false);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_index(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_index(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_finder(n_args, args, 1, true);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_rindex(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_rindex(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_finder(n_args, args, -1, true);
|
||||
}
|
||||
|
||||
// TODO: (Much) more variety in args
|
||||
STATIC mp_obj_t str_startswith(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_startswith(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
|
||||
GET_STR_DATA_LEN(args[0], str, str_len);
|
||||
GET_STR_DATA_LEN(args[1], prefix, prefix_len);
|
||||
@ -644,7 +644,7 @@ STATIC mp_obj_t str_startswith(uint n_args, const mp_obj_t *args) {
|
||||
return MP_BOOL(memcmp(start, prefix, prefix_len) == 0);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_endswith(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_endswith(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
GET_STR_DATA_LEN(args[0], str, str_len);
|
||||
GET_STR_DATA_LEN(args[1], suffix, suffix_len);
|
||||
assert(n_args == 2);
|
||||
@ -657,7 +657,7 @@ STATIC mp_obj_t str_endswith(uint n_args, const mp_obj_t *args) {
|
||||
|
||||
enum { LSTRIP, RSTRIP, STRIP };
|
||||
|
||||
STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_uni_strip(int type, mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(1 <= n_args && n_args <= 2);
|
||||
assert(MP_OBJ_IS_STR_OR_BYTES(args[0]));
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
|
||||
@ -725,15 +725,15 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) {
|
||||
return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_strip(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_uni_strip(STRIP, n_args, args);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_lstrip(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_lstrip(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_uni_strip(LSTRIP, n_args, args);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_rstrip(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_rstrip(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return str_uni_strip(RSTRIP, n_args, args);
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ static mp_obj_t arg_as_int(mp_obj_t arg) {
|
||||
return arg;
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(MP_OBJ_IS_STR(args[0]));
|
||||
|
||||
GET_STR_DATA_LEN(args[0], str, len);
|
||||
@ -1148,7 +1148,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
|
||||
return s;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, uint n_args, const mp_obj_t *args, mp_obj_t dict) {
|
||||
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict) {
|
||||
assert(MP_OBJ_IS_STR(pattern));
|
||||
|
||||
GET_STR_DATA_LEN(pattern, str, len);
|
||||
@ -1336,7 +1336,7 @@ not_enough_args:
|
||||
return s;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_replace(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(MP_OBJ_IS_STR(args[0]));
|
||||
|
||||
mp_int_t max_rep = -1;
|
||||
@ -1438,7 +1438,7 @@ STATIC mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
|
||||
return mp_obj_str_builder_end(replaced_str);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_count(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_count(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
|
||||
assert(2 <= n_args && n_args <= 4);
|
||||
assert(MP_OBJ_IS_STR(args[0]));
|
||||
@ -1595,7 +1595,7 @@ STATIC mp_obj_t str_islower(mp_obj_t self_in) {
|
||||
// These methods are superfluous in the presense of str() and bytes()
|
||||
// constructors.
|
||||
// TODO: should accept kwargs too
|
||||
STATIC mp_obj_t bytes_decode(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t bytes_decode(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t new_args[2];
|
||||
if (n_args == 1) {
|
||||
new_args[0] = args[0];
|
||||
@ -1607,7 +1607,7 @@ STATIC mp_obj_t bytes_decode(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
|
||||
// TODO: should accept kwargs too
|
||||
STATIC mp_obj_t str_encode(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_encode(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t new_args[2];
|
||||
if (n_args == 1) {
|
||||
new_args[0] = args[0];
|
||||
|
@ -50,10 +50,10 @@ typedef struct _mp_obj_str_t {
|
||||
{ str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } \
|
||||
else { str_len = ((mp_obj_str_t*)str_obj_in)->len; str_data = ((mp_obj_str_t*)str_obj_in)->data; }
|
||||
|
||||
mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args);
|
||||
mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args);
|
||||
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, uint len);
|
||||
|
||||
mp_obj_t mp_obj_str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
|
||||
mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, int flags);
|
||||
|
||||
const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, uint self_len,
|
||||
|
@ -95,7 +95,7 @@ STATIC mp_obj_t stringio_close(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_close_obj, stringio_close);
|
||||
|
||||
mp_obj_t stringio___exit__(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t stringio___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return stringio_close(args[0]);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__);
|
||||
@ -108,7 +108,7 @@ STATIC mp_obj_stringio_t *stringio_new(mp_obj_t type_in) {
|
||||
return o;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t stringio_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stringio_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_stringio_t *o = stringio_new(type_in);
|
||||
|
||||
if (n_args > 0) {
|
||||
|
@ -100,7 +100,7 @@ STATIC void uni_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uni_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
GET_STR_DATA_LEN(self_in, str_data, str_len);
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL:
|
||||
@ -112,7 +112,7 @@ STATIC mp_obj_t uni_unary_op(int op, mp_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t str_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (n_kw != 0) {
|
||||
mp_arg_error_unimpl_kw();
|
||||
|
@ -56,7 +56,7 @@ void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
print(env, ")");
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -96,7 +96,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw,
|
||||
}
|
||||
|
||||
// Don't pass MP_BINARY_OP_NOT_EQUAL here
|
||||
STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
mp_obj_type_t *self_type = mp_obj_get_type(self_in);
|
||||
if (self_type->getiter != mp_obj_tuple_getiter) {
|
||||
assert(0);
|
||||
@ -115,7 +115,7 @@ STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in) {
|
||||
mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_tuple_t *self = self_in;
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
|
||||
@ -124,7 +124,7 @@ mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_tuple_t *o = lhs;
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_ADD: {
|
||||
@ -194,7 +194,7 @@ STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
|
||||
|
||||
STATIC mp_obj_t tuple_index(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t tuple_index(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
assert(MP_OBJ_IS_TYPE(args[0], &mp_type_tuple));
|
||||
mp_obj_tuple_t *self = args[0];
|
||||
return mp_seq_index_obj(self->items, self->len, n_args, args);
|
||||
|
@ -31,7 +31,7 @@ typedef struct _mp_obj_tuple_t {
|
||||
} mp_obj_tuple_t;
|
||||
|
||||
void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
|
||||
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs);
|
||||
mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
|
||||
mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
|
||||
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in);
|
||||
|
22
py/objtype.c
22
py/objtype.c
@ -46,14 +46,14 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args);
|
||||
STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
|
||||
|
||||
/******************************************************************************/
|
||||
// instance object
|
||||
|
||||
#define is_instance_type(type) ((type)->make_new == instance_make_new)
|
||||
#define is_native_type(type) ((type)->make_new != instance_make_new)
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args);
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
|
||||
STATIC void instance_convert_return_attr(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest);
|
||||
|
||||
STATIC mp_obj_t mp_obj_new_instance(mp_obj_t class, uint subobjs) {
|
||||
@ -236,7 +236,7 @@ STATIC void instance_print(void (*print)(void *env, const char *fmt, ...), void
|
||||
print(env, "<%s object at %p>", mp_obj_get_type_str(self_in), self_in);
|
||||
}
|
||||
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_type));
|
||||
mp_obj_type_t *self = self_in;
|
||||
|
||||
@ -327,7 +327,7 @@ STATIC const qstr unary_op_method_name[] = {
|
||||
[MP_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size
|
||||
};
|
||||
|
||||
STATIC mp_obj_t instance_unary_op(int op, mp_obj_t self_in) {
|
||||
STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_instance_t *self = self_in;
|
||||
qstr op_name = unary_op_method_name[op];
|
||||
/* Still try to lookup native slot
|
||||
@ -421,7 +421,7 @@ STATIC void instance_convert_return_attr(mp_obj_t self, const mp_obj_type_t *typ
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t instance_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
// Note: For ducktyping, CPython does not look in the instance members or use
|
||||
// __getattr__ or __getattribute__. It only looks in the class dictionary.
|
||||
mp_obj_instance_t *lhs = lhs_in;
|
||||
@ -583,7 +583,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t instance_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t instance_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_instance_t *self = self_in;
|
||||
mp_obj_t member[2] = {MP_OBJ_NULL};
|
||||
struct class_lookup_data lookup = {
|
||||
@ -643,7 +643,7 @@ STATIC void type_print(void (*print)(void *env, const char *fmt, ...), void *env
|
||||
print(env, "<class '%s'>", qstr_str(self->name));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t type_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 3, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -661,7 +661,7 @@ STATIC mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t type_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// instantiate an instance of a class
|
||||
|
||||
mp_obj_type_t *self = self_in;
|
||||
@ -725,7 +725,7 @@ STATIC bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t type_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
STATIC mp_obj_t type_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_EQUAL:
|
||||
// Types can be equal only if it's the same type structure,
|
||||
@ -819,7 +819,7 @@ STATIC void super_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
print(env, ">");
|
||||
}
|
||||
|
||||
STATIC mp_obj_t super_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t super_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
if (n_args != 2 || n_kw != 0) {
|
||||
// 0 arguments are turned into 2 in the compiler
|
||||
// 1 argument is not yet implemented
|
||||
@ -968,7 +968,7 @@ mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t
|
||||
/******************************************************************************/
|
||||
// staticmethod and classmethod types (probably should go in a different file)
|
||||
|
||||
STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
assert(self_in == &mp_type_staticmethod || self_in == &mp_type_classmethod);
|
||||
|
||||
if (n_args != 1 || n_kw != 0) {
|
||||
|
@ -39,7 +39,7 @@ typedef struct _mp_obj_zip_t {
|
||||
mp_obj_t iters[];
|
||||
} mp_obj_zip_t;
|
||||
|
||||
STATIC mp_obj_t zip_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t zip_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false);
|
||||
|
||||
mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args);
|
||||
|
@ -132,7 +132,7 @@ STATIC pyb_accel_obj_t pyb_accel_obj;
|
||||
/// accel = pyb.Accel()
|
||||
/// pyb.delay(20)
|
||||
/// print(accel.x())
|
||||
STATIC mp_obj_t pyb_accel_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_accel_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
|
@ -152,7 +152,7 @@ STATIC void adc_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
/// \classmethod \constructor(pin)
|
||||
/// Create an ADC object associated with the given pin.
|
||||
/// This allows you to then read analog values on that pin.
|
||||
STATIC mp_obj_t adc_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t adc_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check number of arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
@ -372,7 +372,7 @@ float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) {
|
||||
/******************************************************************************/
|
||||
/* Micro Python bindings : adc_all object */
|
||||
|
||||
STATIC mp_obj_t adc_all_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t adc_all_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check number of arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
|
@ -111,7 +111,7 @@ typedef struct _pyb_dac_obj_t {
|
||||
/// Construct a new DAC object.
|
||||
///
|
||||
/// `id` can be 1 or 2: DAC 1 is on pin X5 and DAC 2 is on pin X6.
|
||||
STATIC mp_obj_t pyb_dac_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_dac_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
@ -246,7 +246,7 @@ STATIC const mp_arg_t pyb_dac_write_timed_args[] = {
|
||||
};
|
||||
#define PYB_DAC_WRITE_TIMED_NUM_ARGS MP_ARRAY_SIZE(pyb_dac_write_timed_args)
|
||||
|
||||
mp_obj_t pyb_dac_write_timed(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_obj_t pyb_dac_write_timed(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
pyb_dac_obj_t *self = args[0];
|
||||
|
||||
// parse args
|
||||
|
@ -298,7 +298,7 @@ STATIC const mp_arg_t pyb_extint_make_new_args[] = {
|
||||
};
|
||||
#define PYB_EXTINT_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(pyb_extint_make_new_args)
|
||||
|
||||
STATIC mp_obj_t extint_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t extint_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// type_in == extint_obj_type
|
||||
|
||||
// parse args
|
||||
|
@ -109,12 +109,12 @@ mp_obj_t file_obj_close(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_close_obj, file_obj_close);
|
||||
|
||||
mp_obj_t file_obj___exit__(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t file_obj___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return file_obj_close(args[0]);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(file_obj___exit___obj, 4, 4, file_obj___exit__);
|
||||
|
||||
mp_obj_t file_obj_seek(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t file_obj_seek(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_file_obj_t *self = args[0];
|
||||
mp_int_t offset = mp_obj_get_int(args[1]);
|
||||
mp_int_t whence = 0;
|
||||
@ -160,7 +160,7 @@ mp_obj_t file_obj_tell(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_tell_obj, file_obj_tell);
|
||||
|
||||
STATIC mp_obj_t file_obj_make_new(mp_obj_t type, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t file_obj_make_new(mp_obj_t type, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||
|
||||
const char *fname = mp_obj_str_get_str(args[0]);
|
||||
@ -272,7 +272,7 @@ const mp_obj_type_t mp_type_textio = {
|
||||
};
|
||||
|
||||
// Factory function for I/O stream classes
|
||||
STATIC mp_obj_t pyb_io_open(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_io_open(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: analyze mode and buffering args and instantiate appropriate type
|
||||
return file_obj_make_new((mp_obj_t)&mp_type_textio, n_args, 0, args);
|
||||
}
|
||||
|
14
stmhal/i2c.c
14
stmhal/i2c.c
@ -222,7 +222,7 @@ STATIC const mp_arg_t pyb_i2c_init_args[] = {
|
||||
};
|
||||
#define PYB_I2C_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_init_args)
|
||||
|
||||
STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_I2C_INIT_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args, args, kw_args, PYB_I2C_INIT_NUM_ARGS, pyb_i2c_init_args, vals);
|
||||
@ -263,7 +263,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, uint n_args, cons
|
||||
///
|
||||
/// - `I2C(1)` is on the X position: `(SCL, SDA) = (X9, X10) = (PB6, PB7)`
|
||||
/// - `I2C(2)` is on the Y position: `(SCL, SDA) = (Y9, Y10) = (PB10, PB11)`
|
||||
STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
@ -288,7 +288,7 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
|
||||
return (mp_obj_t)i2c_obj;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pyb_i2c_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
return pyb_i2c_init_helper(args[0], n_args - 1, args + 1, kw_args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init);
|
||||
@ -365,7 +365,7 @@ STATIC const mp_arg_t pyb_i2c_send_args[] = {
|
||||
};
|
||||
#define PYB_I2C_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_send_args)
|
||||
|
||||
STATIC mp_obj_t pyb_i2c_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
pyb_i2c_obj_t *self = args[0];
|
||||
|
||||
// parse args
|
||||
@ -416,7 +416,7 @@ STATIC const mp_arg_t pyb_i2c_recv_args[] = {
|
||||
};
|
||||
#define PYB_I2C_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_recv_args)
|
||||
|
||||
STATIC mp_obj_t pyb_i2c_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
pyb_i2c_obj_t *self = args[0];
|
||||
|
||||
// parse args
|
||||
@ -474,7 +474,7 @@ STATIC const mp_arg_t pyb_i2c_mem_read_args[] = {
|
||||
};
|
||||
#define PYB_I2C_MEM_READ_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_mem_read_args)
|
||||
|
||||
STATIC mp_obj_t pyb_i2c_mem_read(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_mem_read(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
pyb_i2c_obj_t *self = args[0];
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
@ -526,7 +526,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_mem_read_obj, 1, pyb_i2c_mem_read);
|
||||
///
|
||||
/// Returns `None`.
|
||||
/// This is only valid in master mode.
|
||||
STATIC mp_obj_t pyb_i2c_mem_write(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_i2c_mem_write(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
pyb_i2c_obj_t *self = args[0];
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
|
@ -198,7 +198,7 @@ STATIC void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len
|
||||
///
|
||||
/// Construct an LCD object in the given skin position. `skin_position` can be 'X' or 'Y', and
|
||||
/// should match the position where the LCD pyskin is plugged in.
|
||||
STATIC mp_obj_t pyb_lcd_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_lcd_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
@ -437,7 +437,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get);
|
||||
/// Set the pixel at `(x, y)` to the given colour (0 or 1).
|
||||
///
|
||||
/// This method writes to the hidden buffer. Use `show()` to show the buffer.
|
||||
STATIC mp_obj_t pyb_lcd_pixel(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_lcd_pixel(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_lcd_obj_t *self = args[0];
|
||||
int x = mp_obj_get_int(args[1]);
|
||||
int y = mp_obj_get_int(args[2]);
|
||||
@ -458,7 +458,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe
|
||||
/// Draw the given text to the position `(x, y)` using the given colour (0 or 1).
|
||||
///
|
||||
/// This method writes to the hidden buffer. Use `show()` to show the buffer.
|
||||
STATIC mp_obj_t pyb_lcd_text(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_lcd_text(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// extract arguments
|
||||
pyb_lcd_obj_t *self = args[0];
|
||||
uint len;
|
||||
|
@ -221,7 +221,7 @@ void led_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp
|
||||
/// Create an LED object associated with the given LED:
|
||||
///
|
||||
/// - `id` is the LED number, 1-4.
|
||||
STATIC mp_obj_t led_obj_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t led_obj_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
@ -265,7 +265,7 @@ mp_obj_t led_obj_toggle(mp_obj_t self_in) {
|
||||
/// Get or set the LED intensity. Intensity ranges between 0 (off) and 255 (full on).
|
||||
/// If no argument is given, return the LED intensity.
|
||||
/// If an argument is given, set the LED intensity and return `None`.
|
||||
mp_obj_t led_obj_intensity(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t led_obj_intensity(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_led_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
return mp_obj_new_int(led_get_intensity(self->led_id));
|
||||
|
@ -104,7 +104,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd);
|
||||
|
||||
/// \function listdir([dir])
|
||||
/// With no argument, list the current directory. Otherwise list the given directory.
|
||||
STATIC mp_obj_t os_listdir(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t os_listdir(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
bool is_str_type = true;
|
||||
const char *path;
|
||||
if (n_args == 1) {
|
||||
|
@ -188,7 +188,7 @@ STATIC void mod_time_seconds_since_2000_to_struct_time(mp_uint_t t, mod_struct_t
|
||||
/// second is 0-59
|
||||
/// weekday is 0-6 for Mon-Sun.
|
||||
/// yearday is 1-366
|
||||
STATIC mp_obj_t time_localtime(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t time_localtime(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args == 0 || args[0] == mp_const_none) {
|
||||
// get current date and time
|
||||
// note: need to call get time then get date to correctly access the registers
|
||||
|
16
stmhal/pin.c
16
stmhal/pin.c
@ -245,12 +245,12 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *pin, uint n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
||||
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *pin, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
||||
|
||||
/// \classmethod \constructor(id, ...)
|
||||
/// Create a new Pin object associated with the id. If additional arguments are given,
|
||||
/// they are used to initialise the pin. See `init`.
|
||||
STATIC mp_obj_t pin_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pin_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
// Run an argument through the mapper and return the result.
|
||||
@ -268,7 +268,7 @@ STATIC mp_obj_t pin_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_
|
||||
|
||||
/// \classmethod mapper([fun])
|
||||
/// Get or set the pin mapper function.
|
||||
STATIC mp_obj_t pin_mapper(uint n_args, mp_obj_t *args) {
|
||||
STATIC mp_obj_t pin_mapper(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args > 1) {
|
||||
pin_class_mapper = args[1];
|
||||
return mp_const_none;
|
||||
@ -280,7 +280,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_mapper_obj, (mp_obj_t)&pin_mapper_fun
|
||||
|
||||
/// \classmethod dict([dict])
|
||||
/// Get or set the pin mapper dictionary.
|
||||
STATIC mp_obj_t pin_map_dict(uint n_args, mp_obj_t *args) {
|
||||
STATIC mp_obj_t pin_map_dict(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args > 1) {
|
||||
pin_class_map_dict = args[1];
|
||||
return mp_const_none;
|
||||
@ -306,7 +306,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_af_list_obj, pin_af_list);
|
||||
|
||||
/// \classmethod debug([state])
|
||||
/// Get or set the debugging state (`True` or `False` for on or off).
|
||||
STATIC mp_obj_t pin_debug(uint n_args, mp_obj_t *args) {
|
||||
STATIC mp_obj_t pin_debug(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args > 1) {
|
||||
pin_class_debug = mp_obj_is_true(args[1]);
|
||||
return mp_const_none;
|
||||
@ -341,7 +341,7 @@ STATIC const mp_arg_t pin_init_args[] = {
|
||||
};
|
||||
#define PIN_INIT_NUM_ARGS MP_ARRAY_SIZE(pin_init_args)
|
||||
|
||||
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PIN_INIT_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args, args, kw_args, PIN_INIT_NUM_ARGS, pin_init_args, vals);
|
||||
@ -410,7 +410,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pin_obj_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pin_obj_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
return pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
|
||||
@ -422,7 +422,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
|
||||
/// - With `value` given, set the logic level of the pin. `value` can be
|
||||
/// anything that converts to a boolean. If it converts to `True`, the pin
|
||||
/// is set high, otherwise it is set low.
|
||||
STATIC mp_obj_t pin_value(uint n_args, mp_obj_t *args) {
|
||||
STATIC mp_obj_t pin_value(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pin_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get pin
|
||||
|
@ -140,7 +140,7 @@ STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size,
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t stdio_obj___exit__(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t stdio_obj___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__);
|
||||
|
@ -253,7 +253,7 @@ STATIC const pyb_rtc_obj_t pyb_rtc_obj = {{&pyb_rtc_type}};
|
||||
|
||||
/// \classmethod \constructor()
|
||||
/// Create an RTC object.
|
||||
STATIC mp_obj_t pyb_rtc_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_rtc_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
@ -287,7 +287,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pyb_rtc_info_obj, pyb_rtc_info);
|
||||
/// `weekday` is 1-7 for Monday through Sunday.
|
||||
///
|
||||
/// `subseconds` counts down from 255 to 0
|
||||
mp_obj_t pyb_rtc_datetime(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
// get date and time
|
||||
// note: need to call get time then get date to correctly access the registers
|
||||
|
@ -189,7 +189,7 @@ STATIC void pyb_servo_print(void (*print)(void *env, const char *fmt, ...), void
|
||||
|
||||
/// \classmethod \constructor(id)
|
||||
/// Create a servo object. `id` is 1-4.
|
||||
STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
@ -212,7 +212,7 @@ STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
|
||||
|
||||
/// \method pulse_width([value])
|
||||
/// Get or set the pulse width in milliseconds.
|
||||
STATIC mp_obj_t pyb_servo_pulse_width(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_servo_pulse_width(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_servo_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get pulse width, in us
|
||||
@ -230,7 +230,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_pulse_width_obj, 1, 2, pyb_
|
||||
/// \method calibration([pulse_min, pulse_max, pulse_centre, [pulse_angle_90, pulse_speed_100]])
|
||||
/// Get or set the calibration of the servo timing.
|
||||
// TODO should accept 1 arg, a 5-tuple of values to set
|
||||
STATIC mp_obj_t pyb_servo_calibration(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_servo_calibration(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_servo_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get calibration values
|
||||
@ -265,7 +265,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_calibration_obj, 1, 6, pyb_
|
||||
///
|
||||
/// - `angle` is the angle to move to in degrees.
|
||||
/// - `time` is the number of milliseconds to take to get to the specified angle.
|
||||
STATIC mp_obj_t pyb_servo_angle(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_servo_angle(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_servo_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get angle
|
||||
@ -295,7 +295,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_angle_obj, 1, 3, pyb_servo_
|
||||
///
|
||||
/// - `speed` is the speed to move to change to, between -100 and 100.
|
||||
/// - `time` is the number of milliseconds to take to get to the specified speed.
|
||||
STATIC mp_obj_t pyb_servo_speed(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_servo_speed(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_servo_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get speed
|
||||
|
12
stmhal/spi.c
12
stmhal/spi.c
@ -244,7 +244,7 @@ STATIC const mp_arg_t pyb_spi_init_args[] = {
|
||||
};
|
||||
#define PYB_SPI_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_init_args)
|
||||
|
||||
STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_SPI_INIT_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args, args, kw_args, PYB_SPI_INIT_NUM_ARGS, pyb_spi_init_args, vals);
|
||||
@ -309,7 +309,7 @@ STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, cons
|
||||
///
|
||||
/// At the moment, the NSS pin is not used by the SPI driver and is free
|
||||
/// for other use.
|
||||
STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
@ -334,7 +334,7 @@ STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
|
||||
return (mp_obj_t)spi_obj;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pyb_spi_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_spi_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
return pyb_spi_init_helper(args[0], n_args - 1, args + 1, kw_args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_spi_init_obj, 1, pyb_spi_init);
|
||||
@ -361,7 +361,7 @@ STATIC const mp_arg_t pyb_spi_send_args[] = {
|
||||
};
|
||||
#define PYB_SPI_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_args)
|
||||
|
||||
STATIC mp_obj_t pyb_spi_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_spi_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// TODO assumes transmission size is 8-bits wide
|
||||
|
||||
pyb_spi_obj_t *self = args[0];
|
||||
@ -403,7 +403,7 @@ STATIC const mp_arg_t pyb_spi_recv_args[] = {
|
||||
};
|
||||
#define PYB_SPI_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_recv_args)
|
||||
|
||||
STATIC mp_obj_t pyb_spi_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_spi_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// TODO assumes transmission size is 8-bits wide
|
||||
|
||||
pyb_spi_obj_t *self = args[0];
|
||||
@ -451,7 +451,7 @@ STATIC const mp_arg_t pyb_spi_send_recv_args[] = {
|
||||
};
|
||||
#define PYB_SPI_SEND_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_recv_args)
|
||||
|
||||
STATIC mp_obj_t pyb_spi_send_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_spi_send_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// TODO assumes transmission size is 8-bits wide
|
||||
|
||||
pyb_spi_obj_t *self = args[0];
|
||||
|
@ -249,7 +249,7 @@ STATIC const mp_arg_t pyb_timer_init_args[] = {
|
||||
};
|
||||
#define PYB_TIMER_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_timer_init_args)
|
||||
|
||||
STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_TIMER_INIT_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args, args, kw_args, PYB_TIMER_INIT_NUM_ARGS, pyb_timer_init_args, vals);
|
||||
@ -331,7 +331,7 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, uint n_args, const
|
||||
/// Construct a new timer object of the given id. If additional
|
||||
/// arguments are given, then the timer is initialised by `init(...)`.
|
||||
/// `id` can be 1 to 14, excluding 3.
|
||||
STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
@ -377,7 +377,7 @@ STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
|
||||
return (mp_obj_t)tim;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pyb_timer_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_timer_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
return pyb_timer_init_helper(args[0], n_args - 1, args + 1, kw_args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
|
||||
@ -400,7 +400,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
|
||||
|
||||
/// \method counter([value])
|
||||
/// Get or set the timer counter.
|
||||
mp_obj_t pyb_timer_counter(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_timer_counter(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_timer_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get
|
||||
@ -415,7 +415,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_counter_obj, 1, 2, pyb_time
|
||||
|
||||
/// \method prescaler([value])
|
||||
/// Get or set the prescaler for the timer.
|
||||
mp_obj_t pyb_timer_prescaler(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_timer_prescaler(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_timer_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get
|
||||
@ -430,7 +430,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_prescaler_obj, 1, 2, pyb_ti
|
||||
|
||||
/// \method period([value])
|
||||
/// Get or set the period of the timer.
|
||||
mp_obj_t pyb_timer_period(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_timer_period(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pyb_timer_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get
|
||||
|
@ -266,7 +266,7 @@ STATIC const mp_arg_t pyb_uart_init_args[] = {
|
||||
};
|
||||
#define PYB_UART_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_init_args)
|
||||
|
||||
STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_UART_INIT_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args, args, kw_args, PYB_UART_INIT_NUM_ARGS, pyb_uart_init_args, vals);
|
||||
@ -313,7 +313,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp
|
||||
/// - `UART(6)` is on `YA`: `(TX, RX) = (Y1, Y2) = (PC6, PC7)`
|
||||
/// - `UART(3)` is on `YB`: `(TX, RX) = (Y9, Y10) = (PB10, PB11)`
|
||||
/// - `UART(2)` is on: `(TX, RX) = (X3, X4) = (PA2, PA3)`
|
||||
STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
@ -353,7 +353,7 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, uint n_args, uint n_kw, cons
|
||||
return o;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pyb_uart_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_uart_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
return pyb_uart_init_helper(args[0], n_args - 1, args + 1, kw_args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init);
|
||||
@ -392,7 +392,7 @@ STATIC const mp_arg_t pyb_uart_send_args[] = {
|
||||
};
|
||||
#define PYB_UART_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_send_args)
|
||||
|
||||
STATIC mp_obj_t pyb_uart_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_uart_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// TODO assumes transmission size is 8-bits wide
|
||||
|
||||
pyb_uart_obj_t *self = args[0];
|
||||
@ -434,7 +434,7 @@ STATIC const mp_arg_t pyb_uart_recv_args[] = {
|
||||
};
|
||||
#define PYB_UART_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_recv_args)
|
||||
|
||||
STATIC mp_obj_t pyb_uart_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_uart_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// TODO assumes transmission size is 8-bits wide
|
||||
|
||||
pyb_uart_obj_t *self = args[0];
|
||||
|
@ -159,7 +159,7 @@ STATIC void pyb_usb_vcp_print(void (*print)(void *env, const char *fmt, ...), vo
|
||||
|
||||
/// \classmethod \constructor()
|
||||
/// Create a new USB_VCP object.
|
||||
STATIC mp_obj_t pyb_usb_vcp_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_usb_vcp_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
@ -191,7 +191,7 @@ STATIC const mp_arg_t pyb_usb_vcp_send_args[] = {
|
||||
};
|
||||
#define PYB_USB_VCP_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_usb_vcp_send_args)
|
||||
|
||||
STATIC mp_obj_t pyb_usb_vcp_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_usb_vcp_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_USB_VCP_SEND_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args - 1, args + 1, kw_args, PYB_USB_VCP_SEND_NUM_ARGS, pyb_usb_vcp_send_args, vals);
|
||||
@ -218,7 +218,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_usb_vcp_send_obj, 1, pyb_usb_vcp_send);
|
||||
///
|
||||
/// Return value: if `data` is an integer then a new buffer of the bytes received,
|
||||
/// otherwise the number of bytes read into `data` is returned.
|
||||
STATIC mp_obj_t pyb_usb_vcp_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pyb_usb_vcp_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// parse args
|
||||
mp_arg_val_t vals[PYB_USB_VCP_SEND_NUM_ARGS];
|
||||
mp_arg_parse_all(n_args - 1, args + 1, kw_args, PYB_USB_VCP_SEND_NUM_ARGS, pyb_usb_vcp_send_args, vals);
|
||||
@ -249,7 +249,7 @@ STATIC mp_uint_t pyb_usb_vcp_write(mp_obj_t self_in, const void *buf, mp_uint_t
|
||||
return ret;
|
||||
}
|
||||
|
||||
mp_obj_t pyb_usb_vcp___exit__(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_usb_vcp___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_usb_vcp___exit___obj, 4, 4, pyb_usb_vcp___exit__);
|
||||
|
@ -88,7 +88,7 @@ void pyb_switch_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
||||
|
||||
/// \classmethod \constructor()
|
||||
/// Create and return a switch object.
|
||||
STATIC mp_obj_t pyb_switch_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pyb_switch_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
@ -105,7 +105,7 @@ STATIC mp_obj_t pyb_switch_make_new(mp_obj_t type_in, uint n_args, uint n_kw, co
|
||||
|
||||
/// \method \call()
|
||||
/// Return the switch state: `True` if pressed down, `False` otherwise.
|
||||
mp_obj_t pyb_switch_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
mp_obj_t pyb_switch_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// get switch state
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
return switch_get() ? mp_const_true : mp_const_false;
|
||||
|
@ -106,7 +106,7 @@ STATIC mp_obj_t fdfile_close(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
|
||||
|
||||
mp_obj_t fdfile___exit__(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t fdfile___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return fdfile_close(args[0]);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
|
||||
@ -118,7 +118,7 @@ STATIC mp_obj_t fdfile_fileno(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
|
||||
|
||||
STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fdfile_t *o = m_new_obj(mp_obj_fdfile_t);
|
||||
mp_const_obj_t type = type_in;
|
||||
|
||||
@ -224,7 +224,7 @@ const mp_obj_type_t mp_type_textio = {
|
||||
};
|
||||
|
||||
// Factory function for I/O stream classes
|
||||
mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: analyze mode and buffering args and instantiate appropriate type
|
||||
return fdfile_make_new((mp_obj_t)&mp_type_textio, n_args, 0, args);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ STATIC mp_obj_t ffimod_close(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(ffimod_close_obj, ffimod_close);
|
||||
|
||||
STATIC mp_obj_t ffimod_func(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t ffimod_func(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_ffimod_t *self = args[0];
|
||||
const char *rettype = mp_obj_str_get_str(args[1]);
|
||||
const char *symname = mp_obj_str_get_str(args[2]);
|
||||
@ -264,7 +264,7 @@ STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symna
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_3(ffimod_var_obj, ffimod_var);
|
||||
|
||||
STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
const char *fname = mp_obj_str_get_str(args[0]);
|
||||
void *mod = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
|
||||
|
||||
@ -300,7 +300,7 @@ STATIC void ffifunc_print(void (*print)(void *env, const char *fmt, ...), void *
|
||||
print(env, "<ffifunc %p>", self->func);
|
||||
}
|
||||
|
||||
mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
mp_obj_t ffifunc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_ffifunc_t *self = self_in;
|
||||
assert(n_kw == 0);
|
||||
assert(n_args == self->cif.nargs);
|
||||
@ -406,7 +406,7 @@ STATIC const mp_obj_type_t opaque_type = {
|
||||
};
|
||||
*/
|
||||
|
||||
mp_obj_t mod_ffi_open(uint n_args, const mp_obj_t *args) {
|
||||
mp_obj_t mod_ffi_open(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return ffimod_make_new((mp_obj_t)&ffimod_type, n_args, 0, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_ffi_open_obj, 1, 2, mod_ffi_open);
|
||||
|
@ -171,7 +171,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_accept_obj, socket_accept);
|
||||
// Note: besides flag param, this differs from read() in that
|
||||
// this does not swallow blocking errors (EAGAIN, EWOULDBLOCK) -
|
||||
// these would be thrown as exceptions.
|
||||
STATIC mp_obj_t socket_recv(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t socket_recv(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_socket_t *self = args[0];
|
||||
int sz = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
||||
int flags = 0;
|
||||
@ -193,7 +193,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_obj, 2, 3, socket_recv);
|
||||
// Note: besides flag param, this differs from write() in that
|
||||
// this does not swallow blocking errors (EAGAIN, EWOULDBLOCK) -
|
||||
// these would be thrown as exceptions.
|
||||
STATIC mp_obj_t socket_send(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t socket_send(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_socket_t *self = args[0];
|
||||
int flags = 0;
|
||||
|
||||
@ -210,7 +210,7 @@ STATIC mp_obj_t socket_send(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_send_obj, 2, 3, socket_send);
|
||||
|
||||
STATIC mp_obj_t socket_setsockopt(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_socket_t *self = args[0];
|
||||
int level = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
||||
int option = mp_obj_get_int(args[2]);
|
||||
@ -249,7 +249,7 @@ STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking);
|
||||
|
||||
STATIC mp_obj_t socket_makefile(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t socket_makefile(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: CPython explicitly says that closing returned object doesn't close
|
||||
// the original socket (Python2 at all says that fd is dup()ed). But we
|
||||
// save on the bloat.
|
||||
@ -261,7 +261,7 @@ STATIC mp_obj_t socket_makefile(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 3, socket_makefile);
|
||||
|
||||
STATIC mp_obj_t socket_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t socket_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
int family = AF_INET;
|
||||
int type = SOCK_STREAM;
|
||||
int proto = 0;
|
||||
@ -352,7 +352,7 @@ STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_gethostbyname_obj, mod_socket_gethostbyname);
|
||||
#endif // MICROPY_SOCKET_EXTRA
|
||||
|
||||
STATIC mp_obj_t mod_socket_getaddrinfo(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mod_socket_getaddrinfo(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: Implement all args
|
||||
assert(n_args == 2);
|
||||
assert(MP_OBJ_IS_STR(args[0]));
|
||||
|
Loading…
Reference in New Issue
Block a user