-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonelse.h
110 lines (96 loc) · 2.67 KB
/
pythonelse.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef OTESUNKI_PYTHONELSE_H
#define OTESUNKI_PYTHONELSE_H
#ifdef PY_FOR
#undef PY_FOR
#endif
#ifdef PY_WHL
#undef PY_WHL
#endif
#ifdef __STDC__
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ >= 199901L
#include <setjmp.h>
#define PY_WHL(...) PY_FOR(;(__VA_ARGS__);)
#define PY_FOR(...) \
for (int _ftv_ = 1; _ftv_; _ftv_ = 0) \
for (jmp_buf _fbr_, _fbk_, _fct_; _ftv_; _ftv_ = 0) \
if (setjmp(_fbk_) == 0) \
if (setjmp(_fbr_) == 1) \
(void) 0; \
else \
for(;;longjmp(_fbk_, 1)) \
for (__VA_ARGS__) \
if (setjmp(_fct_) == 1) \
(void) 0; \
else \
for(;;longjmp(_fbr_, 1)) \
for(;;longjmp(_fct_, 1))
#endif
#endif
#endif
#ifndef PY_FOR
#define PY_P2(foo, bar) PY_P2_(foo, bar)
#define PY_P2_(foo, bar) foo##bar
#define PY_WHL(cond) PY_FOR(;(cond);)
#define PY_FOR(initcondinc) \
if (1) \
goto PY_P2(_fib_, __LINE__); \
else \
PY_P2(_fel_, __LINE__): if (0) \
for (;;) \
if (1) { \
goto PY_P2(_fel_, __LINE__); \
PY_P2(_fbr_, __LINE__): break; \
} else \
PY_P2(_fib_, __LINE__): \
for (initcondinc) \
if (1) { \
goto PY_P2(_fbd_, __LINE__); \
PY_P2(_fct_, __LINE__): (void) 0; \
} else \
for (;;) \
if (1) { \
goto PY_P2(_fbr_, __LINE__); \
} else \
for (;;) \
if (1) { \
goto PY_P2(_fct_, __LINE__); \
} else \
PY_P2(_fbd_, __LINE__):
#endif
#ifdef macro
#undef macro
#endif
#ifdef syntax_extension
#undef syntax_extension
#endif
#define macro 1
#define syntax_extension 2
#ifndef include_as
#define include_as macro
#endif
#if include_as == macro
#else
#ifdef for
#undef for
#endif
#ifdef while
#undef while
#endif
#ifdef __STDC__
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ >= 199901L
#define for(...) PY_FOR(__VA_ARGS__)
#define while(...) PY_WHL(__VA_ARGS__)
#endif
#endif
#endif
#ifndef for
#define for(initcondinc) PY_FOR(initcondinc)
#define while(cond) PY_WHL(cond)
#endif
#endif
#undef include_as
#undef syntax_extension
#undef macro
#endif