32 void mp_arg_check_num(
size_t n_args,
size_t n_kw,
size_t n_args_min,
size_t n_args_max,
bool takes_kw) {
35 if (n_kw && !takes_kw) {
43 if (n_args_min == n_args_max) {
44 if (n_args != n_args_min) {
49 "function takes %d positional arguments but %d were given",
54 if (n_args < n_args_min) {
59 "function missing %d required positional arguments",
60 n_args_min - n_args));
62 }
else if (n_args > n_args_max) {
67 "function expected at most %d arguments, got %d",
75 size_t pos_found = 0, kws_found = 0;
76 for (
size_t i = 0; i < n_allowed; i++) {
80 goto extra_positional;
92 "'%q' argument required", allowed[i].qst));
95 out_vals[i] = allowed[i].
defval;
99 given_arg = kw->
value;
108 out_vals[i].
u_obj = given_arg;
111 if (pos_found < n_pos) {
120 if (kws_found < kws->used) {
140 #if MICROPY_CPYTHON_COMPAT
#define MICROPY_ERROR_REPORTING_TERSE
NORETURN void mp_raise_NotImplementedError(const char *msg)
NORETURN void mp_arg_error_unimpl_kw(void)
const mp_obj_type_t mp_type_TypeError
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt,...)
void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table)
void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals)
#define MP_OBJ_NEW_QSTR(qst)
void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw)
mp_int_t mp_obj_get_int(mp_const_obj_t arg)
mp_map_elem_t * mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind)
void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals)
#define MICROPY_ERROR_REPORTING
NORETURN void mp_arg_error_terse_mismatch(void)
NORETURN void mp_raise_TypeError(const char *msg)
bool mp_obj_is_true(mp_obj_t arg)