error.h: rename `mrb_protect_raw` to `mrb_protect_error`;
`_raw` does not describe the nature of the function
the function protect errors during C function execution
MODIFY
include/mruby/error.h
include/mruby/error.h
@@ -104,6 +104,13 @@ mrb_break_tag_set(struct RBreak *brk, uint32_t tag)
/**
* Protect
*
+ */
+typedef mrb_value mrb_protect_error_func(mrb_state *mrb, void *userdata);
+MRB_API mrb_value mrb_protect_error(mrb_state *mrb, mrb_protect_error_func *body, void *userdata, mrb_bool *error);
+
+/**
+ * Protect (takes mrb_value for body argument)
+ *
* Implemented in the mruby-error mrbgem
*/
MRB_API mrb_value mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state);
@@ -133,14 +140,6 @@ MRB_API mrb_value mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_val
mrb_func_t rescue, mrb_value r_data,
mrb_int len, struct RClass **classes);
-typedef mrb_value mrb_protect_raw_func(mrb_state *mrb, void *userdata);
-
-/**
- * This API function behaves like `mrb_protect()`.
- * The advantage is that it avoids objectifying the user data.
- */
-MRB_API mrb_value mrb_protect_raw(mrb_state *mrb, mrb_protect_raw_func *body, void *userdata, mrb_bool *error);
-
MRB_END_DECL
#endif /* MRUBY_ERROR_H */

MODIFY
mrbgems/mruby-error/src/exception.c
mrbgems/mruby-error/src/exception.c
@@ -17,7 +17,7 @@ MRB_API mrb_value
mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state)
{
struct protect_data protect_data = { body, data };
- return mrb_protect_raw(mrb, protect_body, &protect_data, state);
+ return mrb_protect_error(mrb, protect_body, &protect_data, state);
}
MRB_API mrb_value
@@ -26,7 +26,7 @@ mrb_ensure(mrb_state *mrb, mrb_func_t body, mrb_value b_data, mrb_func_t ensure,
int ai = mrb_gc_arena_save(mrb);
struct protect_data protect_data = { body, b_data };
mrb_bool error;
- mrb_value result = mrb_protect_raw(mrb, protect_body, &protect_data, &error);
+ mrb_value result = mrb_protect_error(mrb, protect_body, &protect_data, &error);
ensure(mrb, e_data);
mrb_gc_arena_restore(mrb, ai);
mrb_gc_protect(mrb, result);
@@ -50,7 +50,7 @@ mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_value b_data, mrb_fun
int ai = mrb_gc_arena_save(mrb);
struct protect_data protect_data = { body, b_data };
mrb_bool error;
- mrb_value result = mrb_protect_raw(mrb, protect_body, &protect_data, &error);
+ mrb_value result = mrb_protect_error(mrb, protect_body, &protect_data, &error);
if (error) {
mrb_bool error_matched = FALSE;
for (mrb_int i = 0; i < len; ++i) {

MODIFY
src/vm.c
src/vm.c
@@ -307,7 +307,7 @@ cipop(mrb_state *mrb)
}
MRB_API mrb_value
-mrb_protect_raw(mrb_state *mrb, mrb_protect_raw_func *body, void *userdata, mrb_bool *error)
+mrb_protect_error(mrb_state *mrb, mrb_protect_error_func *body, void *userdata, mrb_bool *error)
{
struct mrb_jmpbuf *prev_jmp = mrb->jmp;
struct mrb_jmpbuf c_jmp;

error.h: rename `mrb_protect_raw` to `mrb_protect_error`; #5415

- `_raw` does not describe the nature of the function
- the function protect errors during C function execution