mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Removed mrb_jmpbuf_id for C++ exceptions
Use stack variable addresses as identifiers instead of global variable values. Since the stack variable address is uniquely determined within the call, there is no need to maintain a global variable.
This commit is contained in:
+3
-11
@@ -16,11 +16,11 @@
|
||||
# if defined(__cplusplus)
|
||||
|
||||
#define MRB_TRY(buf) try {
|
||||
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
|
||||
#define MRB_CATCH(buf) } catch(mrb_jmpbuf *e) { if (e != (buf)) { throw e; }
|
||||
#define MRB_END_EXC(buf) }
|
||||
|
||||
#define MRB_THROW(buf) throw((buf)->impl)
|
||||
typedef mrb_int mrb_jmpbuf_impl;
|
||||
#define MRB_THROW(buf) throw(buf)
|
||||
typedef void *mrb_jmpbuf_impl;
|
||||
|
||||
# else
|
||||
# error "need to be compiled with C++ compiler"
|
||||
@@ -50,16 +50,8 @@ typedef mrb_int mrb_jmpbuf_impl;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||
extern mrb_int mrb_jmpbuf_id;
|
||||
#endif
|
||||
|
||||
struct mrb_jmpbuf {
|
||||
mrb_jmpbuf_impl impl;
|
||||
|
||||
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||
mrb_jmpbuf() : impl(mrb_jmpbuf_id++) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* MRB_THROW_H */
|
||||
|
||||
Reference in New Issue
Block a user