Revert "Add a new function `mrb_exc_protect()`."

This reverts commit 8746a6fe4e7bda8a0fbc0eaece9314ec51a0c255.

We already have `mrb_protect()`, `mrb_ensure()` and `mrb_rescue()`
functions. If you need to handle exceptions from C functions, use those
functions above.
parent 3d6adccf
......@@ -1293,9 +1293,6 @@ MRB_API void mrb_print_backtrace(mrb_state *mrb);
MRB_API void mrb_print_error(mrb_state *mrb);
/* function for `raisef` formatting */
MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
/* function to protect errors during execution */
MRB_API mrb_value mrb_exc_protect(mrb_state *mrb, mrb_value (*body)(mrb_state*, void*), void *a, mrb_value (*resc)(mrb_state*, void*, mrb_value), void *b);
/* macros to get typical exception objects
note:
......
......@@ -555,29 +555,6 @@ mrb_argnum_error(mrb_state *mrb, mrb_int argc, int min, int max)
#undef FMT
}
MRB_API mrb_value
mrb_exc_protect(mrb_state *mrb, mrb_value (*body)(mrb_state*, void*), void *a,
mrb_value (*resc)(mrb_state*, void*, mrb_value), void *b)
{
struct mrb_jmpbuf *prev_jmp = mrb->jmp;
struct mrb_jmpbuf c_jmp;
mrb_value v = mrb_undef_value();
MRB_TRY(&c_jmp) {
mrb->jmp = &c_jmp;
v = body(mrb, a);
} MRB_CATCH(&c_jmp) {
if (mrb->exc) {
v = resc(mrb, b, mrb_obj_value(mrb->exc));
mrb->exc = NULL;
}
} MRB_END_EXC(&c_jmp);
mrb->jmp = prev_jmp;
return v;
}
void mrb_core_init_printabort(void);
int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment