mbed I/F binding for mruby
Dependents: mruby_mbed_web mirb_mbed
mrb_throw.h
00001 /* 00002 ** mrb_throw.h - mruby exception throwing handler 00003 ** 00004 ** See Copyright Notice in mruby.h 00005 */ 00006 00007 #ifndef MRB_THROW_H 00008 #define MRB_THROW_H 00009 00010 #ifdef MRB_ENABLE_CXX_EXCEPTION 00011 00012 #define MRB_TRY(buf) do { try { 00013 #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; } 00014 #define MRB_END_EXC(buf) } } while(0) 00015 00016 #define MRB_THROW(buf) throw((buf)->impl) 00017 typedef mrb_int mrb_jmpbuf_impl; 00018 00019 #else 00020 00021 #include <setjmp.h> 00022 00023 #define MRB_TRY(buf) do { if (setjmp((buf)->impl) == 0) { 00024 #define MRB_CATCH(buf) } else { 00025 #define MRB_END_EXC(buf) } } while(0) 00026 00027 #define MRB_THROW(buf) longjmp((buf)->impl, 1); 00028 #define mrb_jmpbuf_impl jmp_buf 00029 00030 #endif 00031 00032 struct mrb_jmpbuf { 00033 mrb_jmpbuf_impl impl; 00034 00035 #ifdef MRB_ENABLE_CXX_EXCEPTION 00036 static mrb_int jmpbuf_id; 00037 mrb_jmpbuf() : impl(jmpbuf_id++) {} 00038 #endif 00039 }; 00040 00041 #endif /* MRB_THROW_H */ 00042
Generated on Tue Jul 12 2022 18:00:34 by 1.7.2