w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

throw.h
Go to the documentation of this file.
1 /**
2 ** @file mruby/throw.h - mruby exception throwing handler
3 **
4 ** See Copyright Notice in mruby.h
5 */
6 
7 #ifndef MRB_THROW_H
8 #define MRB_THROW_H
9 
10 #if defined(MRB_USE_CXX_ABI)
11 # if !defined(__cplusplus)
12 # error Trying to use C++ exception handling in C code
13 # endif
14 #endif
15 
16 #if defined(MRB_USE_CXX_EXCEPTION)
17 
18 # if defined(__cplusplus)
19 
20 #define MRB_TRY(buf) try {
21 #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
22 #define MRB_END_EXC(buf) }
23 
24 #define MRB_THROW(buf) throw((buf)->impl)
25 typedef mrb_int mrb_jmpbuf_impl;
26 
27 # else
28 # error "need to be compiled with C++ compiler"
29 # endif /* __cplusplus */
30 
31 #else
32 
33 #include <setjmp.h>
34 
35 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
36 #define MRB_SETJMP _setjmp
37 #define MRB_LONGJMP _longjmp
38 #elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
39 #define MRB_SETJMP __builtin_setjmp
40 #define MRB_LONGJMP __builtin_longjmp
41 #else
42 #define MRB_SETJMP setjmp
43 #define MRB_LONGJMP longjmp
44 #endif
45 
46 #define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
47 #define MRB_CATCH(buf) } else {
48 #define MRB_END_EXC(buf) }
49 
50 #define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
51 #define mrb_jmpbuf_impl jmp_buf
52 
53 #endif
54 
55 struct mrb_jmpbuf {
57 
58 #if defined(MRB_USE_CXX_EXCEPTION)
59  static mrb_int jmpbuf_id;
60 # if defined(__cplusplus)
61  mrb_jmpbuf() : impl(jmpbuf_id++) {}
62 # endif
63 #endif
64 };
65 
66 #endif /* MRB_THROW_H */
jmp_buf impl
Definition: throw.h:56
#define mrb_jmpbuf_impl
Definition: throw.h:51
int32_t mrb_int
Definition: value.h:35