diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:07:37 +0000 |
commit | b485aab7e71c1625cfc27e0f92c9509f42378458 (patch) | |
tree | ae9abe108601079d1679194de237c9a435ae5b55 /web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.tar.xz netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.zip |
Adding upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c b/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c deleted file mode 100644 index 170abb699..000000000 --- a/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-error/src/exception.c +++ /dev/null @@ -1,100 +0,0 @@ -#include <mruby.h> -#include <mruby/throw.h> -#include <mruby/error.h> - -MRB_API mrb_value -mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state) -{ - struct mrb_jmpbuf *prev_jmp = mrb->jmp; - struct mrb_jmpbuf c_jmp; - mrb_value result = mrb_nil_value(); - - if (state) { *state = FALSE; } - - MRB_TRY(&c_jmp) { - mrb->jmp = &c_jmp; - result = body(mrb, data); - mrb->jmp = prev_jmp; - } MRB_CATCH(&c_jmp) { - mrb->jmp = prev_jmp; - result = mrb_obj_value(mrb->exc); - mrb->exc = NULL; - if (state) { *state = TRUE; } - } MRB_END_EXC(&c_jmp); - - mrb_gc_protect(mrb, result); - return result; -} - -MRB_API mrb_value -mrb_ensure(mrb_state *mrb, mrb_func_t body, mrb_value b_data, mrb_func_t ensure, mrb_value e_data) -{ - struct mrb_jmpbuf *prev_jmp = mrb->jmp; - struct mrb_jmpbuf c_jmp; - mrb_value result; - - MRB_TRY(&c_jmp) { - mrb->jmp = &c_jmp; - result = body(mrb, b_data); - mrb->jmp = prev_jmp; - } MRB_CATCH(&c_jmp) { - mrb->jmp = prev_jmp; - ensure(mrb, e_data); - MRB_THROW(mrb->jmp); /* rethrow catched exceptions */ - } MRB_END_EXC(&c_jmp); - - ensure(mrb, e_data); - mrb_gc_protect(mrb, result); - return result; -} - -MRB_API mrb_value -mrb_rescue(mrb_state *mrb, mrb_func_t body, mrb_value b_data, - mrb_func_t rescue, mrb_value r_data) -{ - return mrb_rescue_exceptions(mrb, body, b_data, rescue, r_data, 1, &mrb->eStandardError_class); -} - -MRB_API mrb_value -mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_value b_data, mrb_func_t rescue, mrb_value r_data, - mrb_int len, struct RClass **classes) -{ - struct mrb_jmpbuf *prev_jmp = mrb->jmp; - struct mrb_jmpbuf c_jmp; - mrb_value result; - mrb_bool error_matched = FALSE; - mrb_int i; - - MRB_TRY(&c_jmp) { - mrb->jmp = &c_jmp; - result = body(mrb, b_data); - mrb->jmp = prev_jmp; - } MRB_CATCH(&c_jmp) { - mrb->jmp = prev_jmp; - - for (i = 0; i < len; ++i) { - if (mrb_obj_is_kind_of(mrb, mrb_obj_value(mrb->exc), classes[i])) { - error_matched = TRUE; - break; - } - } - - if (!error_matched) { MRB_THROW(mrb->jmp); } - - mrb->exc = NULL; - result = rescue(mrb, r_data); - } MRB_END_EXC(&c_jmp); - - mrb_gc_protect(mrb, result); - return result; -} - -void -mrb_mruby_error_gem_init(mrb_state *mrb) -{ -} - -void -mrb_mruby_error_gem_final(mrb_state *mrb) -{ -} |