Cython has moved to github.
pyrex
view Tests/4/Reference/tryfinally.c @ 86:da6e97bb7e6d
Multiple compilation fixed
| author | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| date | Sat May 24 15:50:12 2008 +1200 (4 years ago) |
| parents | 6c5f5271ebab |
| children | 3b20cb4923eb |
line source
1 /* Generated by Pyrex */
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #include "structmember.h"
6 #ifndef PY_LONG_LONG
7 #define PY_LONG_LONG LONG_LONG
8 #endif
9 #if PY_VERSION_HEX < 0x02050000
10 typedef int Py_ssize_t;
11 #define PY_SSIZE_T_MAX INT_MAX
12 #define PY_SSIZE_T_MIN INT_MIN
13 #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
14 #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
15 #endif
16 #ifndef WIN32
17 #ifndef __stdcall
18 #define __stdcall
19 #endif
20 #ifndef __cdecl
21 #define __cdecl
22 #endif
23 #endif
24 #ifdef __cplusplus
25 #define __PYX_EXTERN_C extern "C"
26 #else
27 #define __PYX_EXTERN_C extern
28 #endif
29 #include <math.h>
32 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
33 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
35 static PyObject *__pyx_m;
36 static PyObject *__pyx_b;
37 static int __pyx_lineno;
38 static char *__pyx_filename;
39 static char **__pyx_f;
41 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
43 static void __Pyx_AddTraceback(char *funcname); /*proto*/
45 /* Declarations from tryfinally */
49 static __Pyx_StringTabEntry __pyx_string_tab[] = {
50 {0, 0, 0, 0}
51 };
53 /* Implementation of tryfinally */
55 static PyObject *__pyx_f_10tryfinally_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
56 static PyObject *__pyx_f_10tryfinally_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
57 PyObject *__pyx_v_a = 0;
58 PyObject *__pyx_v_b = 0;
59 PyObject *__pyx_v_c = 0;
60 PyObject *__pyx_v_x = 0;
61 int __pyx_v_i;
62 PyObject *__pyx_r;
63 PyObject *__pyx_1 = 0;
64 PyObject *__pyx_2 = 0;
65 static char *__pyx_argnames[] = {"a","b","c","x",0};
66 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_c, &__pyx_v_x)) return 0;
67 Py_INCREF(__pyx_v_a);
68 Py_INCREF(__pyx_v_b);
69 Py_INCREF(__pyx_v_c);
70 Py_INCREF(__pyx_v_x);
72 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":3 */
73 __pyx_1 = PyNumber_Add(__pyx_v_b, __pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
74 Py_DECREF(__pyx_v_a);
75 __pyx_v_a = __pyx_1;
76 __pyx_1 = 0;
78 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":5 */
79 /*try:*/ {
81 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":6 */
82 __pyx_r = Py_None; Py_INCREF(Py_None);
83 goto __pyx_L2;
85 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":7 */
86 __Pyx_Raise(__pyx_v_a, 0, 0);
87 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L3;}
88 }
89 /*finally:*/ {
90 int __pyx_why;
91 PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
92 int __pyx_exc_lineno;
93 __pyx_why = 0; goto __pyx_L4;
94 __pyx_L2: __pyx_why = 3; goto __pyx_L4;
95 __pyx_L3: {
96 __pyx_why = 4;
97 Py_XDECREF(__pyx_1); __pyx_1 = 0;
98 PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
99 __pyx_exc_lineno = __pyx_lineno;
100 goto __pyx_L4;
101 }
102 __pyx_L4:;
103 __pyx_1 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L5;}
104 Py_DECREF(__pyx_v_c);
105 __pyx_v_c = __pyx_1;
106 __pyx_1 = 0;
107 goto __pyx_L6;
108 __pyx_L5:;
109 if (__pyx_why == 4) {
110 Py_XDECREF(__pyx_exc_type);
111 Py_XDECREF(__pyx_exc_value);
112 Py_XDECREF(__pyx_exc_tb);
113 }
114 goto __pyx_L1;
115 __pyx_L6:;
116 switch (__pyx_why) {
117 case 3: goto __pyx_L0;
118 case 4: {
119 PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
120 __pyx_lineno = __pyx_exc_lineno;
121 __pyx_exc_type = 0;
122 __pyx_exc_value = 0;
123 __pyx_exc_tb = 0;
124 goto __pyx_L1;
125 }
126 }
127 }
129 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":11 */
130 __pyx_1 = PyObject_GetIter(__pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
131 for (;;) {
132 __pyx_2 = PyIter_Next(__pyx_1);
133 if (!__pyx_2) {
134 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
135 break;
136 }
137 Py_DECREF(__pyx_v_a);
138 __pyx_v_a = __pyx_2;
139 __pyx_2 = 0;
140 /*try:*/ {
142 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":13 */
143 goto __pyx_L9;
145 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":14 */
146 goto __pyx_L10;
148 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":15 */
149 __pyx_2 = PyNumber_Multiply(__pyx_v_a, __pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L12;}
150 Py_DECREF(__pyx_v_c);
151 __pyx_v_c = __pyx_2;
152 __pyx_2 = 0;
153 }
154 /*finally:*/ {
155 int __pyx_why;
156 PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
157 int __pyx_exc_lineno;
158 __pyx_why = 0; goto __pyx_L13;
159 __pyx_L9: __pyx_why = 1; goto __pyx_L13;
160 __pyx_L10: __pyx_why = 2; goto __pyx_L13;
161 __pyx_L12: {
162 __pyx_why = 4;
163 Py_XDECREF(__pyx_2); __pyx_2 = 0;
164 PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
165 __pyx_exc_lineno = __pyx_lineno;
166 goto __pyx_L13;
167 }
168 __pyx_L13:;
169 __pyx_v_i = 42;
170 switch (__pyx_why) {
171 case 1: goto __pyx_L7;
172 case 2: goto __pyx_L8;
173 case 4: {
174 PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
175 __pyx_lineno = __pyx_exc_lineno;
176 __pyx_exc_type = 0;
177 __pyx_exc_value = 0;
178 __pyx_exc_tb = 0;
179 goto __pyx_L1;
180 }
181 }
182 }
183 __pyx_L7:;
184 }
185 __pyx_L8:;
186 Py_DECREF(__pyx_1); __pyx_1 = 0;
188 __pyx_r = Py_None; Py_INCREF(Py_None);
189 goto __pyx_L0;
190 __pyx_L1:;
191 Py_XDECREF(__pyx_1);
192 Py_XDECREF(__pyx_2);
193 __Pyx_AddTraceback("tryfinally.f");
194 __pyx_r = 0;
195 __pyx_L0:;
196 Py_DECREF(__pyx_v_a);
197 Py_DECREF(__pyx_v_b);
198 Py_DECREF(__pyx_v_c);
199 Py_DECREF(__pyx_v_x);
200 return __pyx_r;
201 }
203 static struct PyMethodDef __pyx_methods[] = {
204 {"f", (PyCFunction)__pyx_f_10tryfinally_f, METH_VARARGS|METH_KEYWORDS, 0},
205 {0, 0, 0, 0}
206 };
208 static void __pyx_init_filenames(void); /*proto*/
210 PyMODINIT_FUNC inittryfinally(void); /*proto*/
211 PyMODINIT_FUNC inittryfinally(void) {
212 __pyx_init_filenames();
213 __pyx_m = Py_InitModule4("tryfinally", __pyx_methods, 0, 0, PYTHON_API_VERSION);
214 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
215 Py_INCREF(__pyx_m);
216 __pyx_b = PyImport_AddModule("__builtin__");
217 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
218 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
219 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
220 return;
221 __pyx_L1:;
222 __Pyx_AddTraceback("tryfinally");
223 }
225 static char *__pyx_filenames[] = {
226 "tryfinally.pyx",
227 };
229 /* Runtime support code */
231 static void __pyx_init_filenames(void) {
232 __pyx_f = __pyx_filenames;
233 }
235 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
236 Py_XINCREF(type);
237 Py_XINCREF(value);
238 Py_XINCREF(tb);
239 /* First, check the traceback argument, replacing None with NULL. */
240 if (tb == Py_None) {
241 Py_DECREF(tb);
242 tb = 0;
243 }
244 else if (tb != NULL && !PyTraceBack_Check(tb)) {
245 PyErr_SetString(PyExc_TypeError,
246 "raise: arg 3 must be a traceback or None");
247 goto raise_error;
248 }
249 /* Next, replace a missing value with None */
250 if (value == NULL) {
251 value = Py_None;
252 Py_INCREF(value);
253 }
254 #if PY_VERSION_HEX < 0x02050000
255 if (!PyClass_Check(type))
256 #else
257 if (!PyType_Check(type))
258 #endif
259 {
260 /* Raising an instance. The value should be a dummy. */
261 if (value != Py_None) {
262 PyErr_SetString(PyExc_TypeError,
263 "instance exception may not have a separate value");
264 goto raise_error;
265 }
266 /* Normalize to raise <class>, <instance> */
267 Py_DECREF(value);
268 value = type;
269 #if PY_VERSION_HEX < 0x02050000
270 if (PyInstance_Check(type)) {
271 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
272 Py_INCREF(type);
273 }
274 else {
275 PyErr_SetString(PyExc_TypeError,
276 "raise: exception must be an old-style class or instance");
277 goto raise_error;
278 }
279 #else
280 type = (PyObject*) type->ob_type;
281 Py_INCREF(type);
282 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
283 PyErr_SetString(PyExc_TypeError,
284 "raise: exception class must be a subclass of BaseException");
285 goto raise_error;
286 }
287 #endif
288 }
289 PyErr_Restore(type, value, tb);
290 return;
291 raise_error:
292 Py_XDECREF(value);
293 Py_XDECREF(type);
294 Py_XDECREF(tb);
295 return;
296 }
298 #include "compile.h"
299 #include "frameobject.h"
300 #include "traceback.h"
302 static void __Pyx_AddTraceback(char *funcname) {
303 PyObject *py_srcfile = 0;
304 PyObject *py_funcname = 0;
305 PyObject *py_globals = 0;
306 PyObject *empty_tuple = 0;
307 PyObject *empty_string = 0;
308 PyCodeObject *py_code = 0;
309 PyFrameObject *py_frame = 0;
311 py_srcfile = PyString_FromString(__pyx_filename);
312 if (!py_srcfile) goto bad;
313 py_funcname = PyString_FromString(funcname);
314 if (!py_funcname) goto bad;
315 py_globals = PyModule_GetDict(__pyx_m);
316 if (!py_globals) goto bad;
317 empty_tuple = PyTuple_New(0);
318 if (!empty_tuple) goto bad;
319 empty_string = PyString_FromString("");
320 if (!empty_string) goto bad;
321 py_code = PyCode_New(
322 0, /*int argcount,*/
323 0, /*int nlocals,*/
324 0, /*int stacksize,*/
325 0, /*int flags,*/
326 empty_string, /*PyObject *code,*/
327 empty_tuple, /*PyObject *consts,*/
328 empty_tuple, /*PyObject *names,*/
329 empty_tuple, /*PyObject *varnames,*/
330 empty_tuple, /*PyObject *freevars,*/
331 empty_tuple, /*PyObject *cellvars,*/
332 py_srcfile, /*PyObject *filename,*/
333 py_funcname, /*PyObject *name,*/
334 __pyx_lineno, /*int firstlineno,*/
335 empty_string /*PyObject *lnotab*/
336 );
337 if (!py_code) goto bad;
338 py_frame = PyFrame_New(
339 PyThreadState_Get(), /*PyThreadState *tstate,*/
340 py_code, /*PyCodeObject *code,*/
341 py_globals, /*PyObject *globals,*/
342 0 /*PyObject *locals*/
343 );
344 if (!py_frame) goto bad;
345 py_frame->f_lineno = __pyx_lineno;
346 PyTraceBack_Here(py_frame);
347 bad:
348 Py_XDECREF(py_srcfile);
349 Py_XDECREF(py_funcname);
350 Py_XDECREF(empty_tuple);
351 Py_XDECREF(empty_string);
352 Py_XDECREF(py_code);
353 Py_XDECREF(py_frame);
354 }
