mp_obj_t call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { return mp_call_function_2(fun, arg1, arg2); } else { mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); return (mp_obj_t)nlr.ret_val; } }
mp_obj_t micropy_call_2(mp_obj_t module_obj, const char *func, uint64_t code, uint64_t type) { nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { mp_obj_t py_func = mp_load_attr(module_obj, qstr_from_str(func)); mp_obj_t arg0 = mp_obj_new_int_from_ll((long long)code); mp_obj_t arg1 = mp_obj_new_int_from_ll((long long)type); mp_obj_t ret = mp_call_function_2(py_func, arg0, arg1); nlr_pop(); return ret; } else { mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); // uncaught exception return 0; } }