-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_parser_except.h
More file actions
84 lines (65 loc) · 1.77 KB
/
Copy pathhtml_parser_except.h
File metadata and controls
84 lines (65 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __EXCEPT_INCLUDED__
#define __EXCEPT_INCLUDED__
#ifdef __cplusplus
extern "C" {
#endif
#include <setjmp.h>
#define T Except_T
typedef struct T {
char *reason;
} T;
/* <exported types> */
typedef struct Except_Frame Except_Frame;
struct Except_Frame {
Except_Frame *prev;
jmp_buf env;
const char *file;
int line;
const T *exception;
};
enum {Except_entered = 0, Except_raised, Except_handled,
Except_finalized};
/* <exported variables> */
extern Except_Frame *Except_stack;
/* <exported functions> */
void Except_raise(const T *e, const char *file, int line);
/* <exported macros> */
#define RAISE(e) Except_raise(&(e), __FILE__, __LINE__)
#define REREAISE Except_raise(Except_frame.exception, \
Except_frame.file, Except_frame.line)
#define RETURN switch (Except_stack = Except_stack->prev, 0) \
default: return
#define TRY do { \
volatile int Except_flag; \
Except_Frame Except_frame; \
/* <push> */ \
Except_frame.prev = Except_stack; \
Except_stack = &Except_frame; \
Except_flag = setjmp(Except_frame.env); \
if (Except_flag == Except_entered) {
#define EXCEPT(e) \
if (Except_flag == Except_entered) { \
Except_stack = Except_stack->prev; \
} else if (Except_frame.exception == &(e)) { \
Except_flag = Except_handled;
#define ELSE \
if (Except_flag == Except_entered) { \
Except_stack = Except_stack->prev; \
} else { \
Except_flag = Except_handled;
#define FINALLY \
if (Except_flag == Except_entered) { \
Except_stack = Except_stack->prev; \
} { \
if (Except_flag == Except_entered) \
Except_flag = Except_finalized;
#define END_TRY \
if (Except_flag == Except_entered) { \
Except_stack = Except_stack->prev; \
} if (Except_flag == Except_raised) RERAISE; \
} while (0)
#undef T
#ifdef __cplusplus
}
#endif
#endif /* __EXCEPT_INCLUDED__ */