Last change
on this file was 439, checked in by coas-nagasima, 4 years ago |
mrubyを2.1.1に更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-chdr;charset=UTF-8
|
File size:
1.2 KB
|
Line | |
---|
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_ENABLE_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_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
---|
17 |
|
---|
18 | #define MRB_TRY(buf) try {
|
---|
19 | #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
|
---|
20 | #define MRB_END_EXC(buf) }
|
---|
21 |
|
---|
22 | #define MRB_THROW(buf) throw((buf)->impl)
|
---|
23 | typedef mrb_int mrb_jmpbuf_impl;
|
---|
24 |
|
---|
25 | #else
|
---|
26 |
|
---|
27 | #include <setjmp.h>
|
---|
28 |
|
---|
29 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
---|
30 | #define MRB_SETJMP _setjmp
|
---|
31 | #define MRB_LONGJMP _longjmp
|
---|
32 | #else
|
---|
33 | #define MRB_SETJMP setjmp
|
---|
34 | #define MRB_LONGJMP longjmp
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
|
---|
38 | #define MRB_CATCH(buf) } else {
|
---|
39 | #define MRB_END_EXC(buf) }
|
---|
40 |
|
---|
41 | #define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
|
---|
42 | #define mrb_jmpbuf_impl jmp_buf
|
---|
43 |
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | struct mrb_jmpbuf {
|
---|
47 | mrb_jmpbuf_impl impl;
|
---|
48 |
|
---|
49 | #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
---|
50 | static mrb_int jmpbuf_id;
|
---|
51 | mrb_jmpbuf() : impl(jmpbuf_id++) {}
|
---|
52 | #endif
|
---|
53 | };
|
---|
54 |
|
---|
55 | #endif /* MRB_THROW_H */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.