Last change
on this file since 439 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
|
Rev | Line | |
---|
[439] | 1 | /**
|
---|
| 2 | ** @file mruby/throw.h - mruby exception throwing handler
|
---|
[270] | 3 | **
|
---|
| 4 | ** See Copyright Notice in mruby.h
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #ifndef MRB_THROW_H
|
---|
| 8 | #define MRB_THROW_H
|
---|
| 9 |
|
---|
[331] | 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
|
---|
[270] | 15 |
|
---|
[331] | 16 | #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
---|
| 17 |
|
---|
[439] | 18 | #define MRB_TRY(buf) try {
|
---|
[270] | 19 | #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
|
---|
[439] | 20 | #define MRB_END_EXC(buf) }
|
---|
[270] | 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 |
|
---|
[331] | 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 |
|
---|
[439] | 37 | #define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
|
---|
[270] | 38 | #define MRB_CATCH(buf) } else {
|
---|
[439] | 39 | #define MRB_END_EXC(buf) }
|
---|
[270] | 40 |
|
---|
[331] | 41 | #define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
|
---|
[270] | 42 | #define mrb_jmpbuf_impl jmp_buf
|
---|
| 43 |
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
| 46 | struct mrb_jmpbuf {
|
---|
| 47 | mrb_jmpbuf_impl impl;
|
---|
| 48 |
|
---|
[331] | 49 | #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
---|
[270] | 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.