// args are in reverse order in the array mp_obj_t gen_wrap_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) { mp_obj_gen_wrap_t *self = self_in; mp_obj_t self_fun = self->fun; assert(MP_OBJ_IS_TYPE(self_fun, &fun_bc_type)); int bc_n_args; uint bc_n_state; const byte *bc_code; mp_obj_fun_bc_get(self_fun, &bc_n_args, &bc_n_state, &bc_code); if (n_args != bc_n_args) { nlr_jump(mp_obj_new_exception_msg_2_args(rt_q_TypeError, "function takes %d positional arguments but %d were given", (const char*)(machine_int_t)bc_n_args, (const char*)(machine_int_t)n_args)); } return mp_obj_new_gen_instance(bc_code, self->n_state, n_args, args); }
STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) { mp_obj_gen_wrap_t *self = self_in; mp_obj_t self_fun = self->fun; assert(MP_OBJ_IS_TYPE(self_fun, &mp_type_fun_bc)); int bc_n_args; const byte *bc_code; mp_obj_fun_bc_get(self_fun, &bc_n_args, &bc_code); const mp_obj_t *args1, *args2; uint len1, len2; if (!mp_obj_fun_prepare_simple_args(self_fun, n_args, n_kw, args, &len1, &args1, &len2, &args2)) { assert(0); } return mp_obj_new_gen_instance(bc_code, len1, args1, len2, args2); }