mruby
3.3.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
include
mruby
throw.h
Go to the documentation of this file.
1
7
#ifndef MRB_THROW_H
8
#define MRB_THROW_H
9
10
#if defined(MRB_USE_CXX_ABI) && !defined(__cplusplus)
11
# error Trying to use C++ exception handling in C code
12
#endif
13
14
#if defined(MRB_USE_CXX_EXCEPTION)
15
16
# if 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
# error "need to be compiled with C++ compiler"
27
# endif
/* __cplusplus */
28
29
#else
30
31
#include <setjmp.h>
32
33
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
34
#define MRB_SETJMP _setjmp
35
#define MRB_LONGJMP _longjmp
36
#elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
37
#define MRB_SETJMP __builtin_setjmp
38
#define MRB_LONGJMP __builtin_longjmp
39
#else
40
#define MRB_SETJMP setjmp
41
#define MRB_LONGJMP longjmp
42
#endif
43
44
#define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
45
#define MRB_CATCH(buf) } else {
46
#define MRB_END_EXC(buf) }
47
48
#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
49
#define mrb_jmpbuf_impl jmp_buf
50
51
#endif
52
53
#if defined(MRB_USE_CXX_EXCEPTION)
54
extern
mrb_int mrb_jmpbuf_id;
55
#endif
56
57
struct
mrb_jmpbuf
{
58
mrb_jmpbuf_impl impl;
59
60
#if defined(MRB_USE_CXX_EXCEPTION)
61
mrb_jmpbuf
() : impl(mrb_jmpbuf_id++) {}
62
#endif
63
};
64
65
#endif
/* MRB_THROW_H */
mrb_jmpbuf
Definition
throw.h:57
Generated by
1.10.0