mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
3d056d084a
| Previous Name | New Name | |------------------------------|-------------------------| | MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI | | MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION | | MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK | | MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING | | MRB_DISABLE_STDIO | MRB_NO_STDIO | | ENABLE_LINENOISE | MRB_USE_LINENOISE | | ENABLE_READLINE | MRB_USE_READLINE | | DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE | | DISABLE_GEMS | MRB_NO_GEMS | * `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed. * `MRB_` prefix is added to those without. * The previous names can also be used for compatibility.
64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
/**
|
|
** @file mruby/throw.h - mruby exception throwing handler
|
|
**
|
|
** See Copyright Notice in mruby.h
|
|
*/
|
|
|
|
#ifndef MRB_THROW_H
|
|
#define MRB_THROW_H
|
|
|
|
#if defined(MRB_USE_CXX_ABI)
|
|
# if !defined(__cplusplus)
|
|
# error Trying to use C++ exception handling in C code
|
|
# endif
|
|
#endif
|
|
|
|
#if defined(MRB_USE_CXX_EXCEPTION)
|
|
|
|
# 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_END_EXC(buf) }
|
|
|
|
#define MRB_THROW(buf) throw((buf)->impl)
|
|
typedef mrb_int mrb_jmpbuf_impl;
|
|
|
|
# else
|
|
# error "need to be compiled with C++ compiler"
|
|
# endif /* __cplusplus */
|
|
|
|
#else
|
|
|
|
#include <setjmp.h>
|
|
|
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
|
#define MRB_SETJMP _setjmp
|
|
#define MRB_LONGJMP _longjmp
|
|
#else
|
|
#define MRB_SETJMP setjmp
|
|
#define MRB_LONGJMP longjmp
|
|
#endif
|
|
|
|
#define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
|
|
#define MRB_CATCH(buf) } else {
|
|
#define MRB_END_EXC(buf) }
|
|
|
|
#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
|
|
#define mrb_jmpbuf_impl jmp_buf
|
|
|
|
#endif
|
|
|
|
struct mrb_jmpbuf {
|
|
mrb_jmpbuf_impl impl;
|
|
|
|
#if defined(MRB_USE_CXX_EXCEPTION)
|
|
static mrb_int jmpbuf_id;
|
|
# if defined(__cplusplus)
|
|
mrb_jmpbuf() : impl(jmpbuf_id++) {}
|
|
# endif
|
|
#endif
|
|
};
|
|
|
|
#endif /* MRB_THROW_H */
|