Cython has moved to github.
pyrex
view Tests/4/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 | 12072e0e4fd5 |
| children | 94d46b3c5354 |
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; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
34 static PyObject *__pyx_m;
35 static PyObject *__pyx_b;
36 static int __pyx_lineno;
37 static char *__pyx_filename;
38 static char **__pyx_f;
40 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from tryfinally */
49 /* Declarations from implementation of tryfinally */
55 static __Pyx_StringTabEntry __pyx_string_tab[] = {
56 {0, 0, 0, 0}
57 };
61 /* Implementation of tryfinally */
63 static PyObject *__pyx_f_10tryfinally_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
64 static PyObject *__pyx_f_10tryfinally_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
65 PyObject *__pyx_v_a = 0;
66 PyObject *__pyx_v_b = 0;
67 PyObject *__pyx_v_c = 0;
68 PyObject *__pyx_v_x = 0;
69 int __pyx_v_i;
70 PyObject *__pyx_r;
71 PyObject *__pyx_1 = 0;
72 PyObject *__pyx_2 = 0;
73 static char *__pyx_argnames[] = {"a","b","c","x",0};
74 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_c, &__pyx_v_x)) return 0;
75 Py_INCREF(__pyx_v_a);
76 Py_INCREF(__pyx_v_b);
77 Py_INCREF(__pyx_v_c);
78 Py_INCREF(__pyx_v_x);
80 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":3 */
81 __pyx_1 = PyNumber_Add(__pyx_v_b, __pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
82 Py_DECREF(__pyx_v_a);
83 __pyx_v_a = __pyx_1;
84 __pyx_1 = 0;
86 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":5 */
87 /*try:*/ {
89 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":6 */
90 __pyx_r = Py_None; Py_INCREF(Py_None);
91 goto __pyx_L2;
93 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":7 */
94 __Pyx_Raise(__pyx_v_a, 0, 0);
95 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L3;}
96 }
97 /*finally:*/ {
98 int __pyx_why;
99 PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
100 int __pyx_exc_lineno;
101 __pyx_why = 0; goto __pyx_L4;
102 __pyx_L2: __pyx_why = 3; goto __pyx_L4;
103 __pyx_L3: {
104 __pyx_why = 4;
105 Py_XDECREF(__pyx_1); __pyx_1 = 0;
106 PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
107 __pyx_exc_lineno = __pyx_lineno;
108 goto __pyx_L4;
109 }
110 __pyx_L4:;
111 __pyx_1 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L5;}
112 Py_DECREF(__pyx_v_c);
113 __pyx_v_c = __pyx_1;
114 __pyx_1 = 0;
115 goto __pyx_L6;
116 __pyx_L5:;
117 if (__pyx_why == 4) {
118 Py_XDECREF(__pyx_exc_type);
119 Py_XDECREF(__pyx_exc_value);
120 Py_XDECREF(__pyx_exc_tb);
121 }
122 goto __pyx_L1;
123 __pyx_L6:;
124 switch (__pyx_why) {
125 case 3: goto __pyx_L0;
126 case 4: {
127 PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
128 __pyx_lineno = __pyx_exc_lineno;
129 __pyx_exc_type = 0;
130 __pyx_exc_value = 0;
131 __pyx_exc_tb = 0;
132 goto __pyx_L1;
133 }
134 }
135 }
137 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":11 */
138 __pyx_1 = PyObject_GetIter(__pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
139 for (;;) {
140 __pyx_2 = PyIter_Next(__pyx_1);
141 if (!__pyx_2) {
142 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
143 break;
144 }
145 Py_DECREF(__pyx_v_a);
146 __pyx_v_a = __pyx_2;
147 __pyx_2 = 0;
148 /*try:*/ {
150 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":13 */
151 goto __pyx_L9;
153 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":14 */
154 goto __pyx_L10;
156 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryfinally.pyx":15 */
157 __pyx_2 = PyNumber_Multiply(__pyx_v_a, __pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L12;}
158 Py_DECREF(__pyx_v_c);
159 __pyx_v_c = __pyx_2;
160 __pyx_2 = 0;
161 }
162 /*finally:*/ {
163 int __pyx_why;
164 PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
165 int __pyx_exc_lineno;
166 __pyx_why = 0; goto __pyx_L13;
167 __pyx_L9: __pyx_why = 1; goto __pyx_L13;
168 __pyx_L10: __pyx_why = 2; goto __pyx_L13;
169 __pyx_L12: {
170 __pyx_why = 4;
171 Py_XDECREF(__pyx_2); __pyx_2 = 0;
172 PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
173 __pyx_exc_lineno = __pyx_lineno;
174 goto __pyx_L13;
175 }
176 __pyx_L13:;
177 __pyx_v_i = 42;
178 switch (__pyx_why) {
179 case 1: goto __pyx_L7;
180 case 2: goto __pyx_L8;
181 case 4: {
182 PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
183 __pyx_lineno = __pyx_exc_lineno;
184 __pyx_exc_type = 0;
185 __pyx_exc_value = 0;
186 __pyx_exc_tb = 0;
187 goto __pyx_L1;
188 }
189 }
190 }
191 __pyx_L7:;
192 }
193 __pyx_L8:;
194 Py_DECREF(__pyx_1); __pyx_1 = 0;
196 __pyx_r = Py_None; Py_INCREF(Py_None);
197 goto __pyx_L0;
198 __pyx_L1:;
199 Py_XDECREF(__pyx_1);
200 Py_XDECREF(__pyx_2);
201 __Pyx_AddTraceback("tryfinally.f");
202 __pyx_r = 0;
203 __pyx_L0:;
204 Py_DECREF(__pyx_v_a);
205 Py_DECREF(__pyx_v_b);
206 Py_DECREF(__pyx_v_c);
207 Py_DECREF(__pyx_v_x);
208 return __pyx_r;
209 }
211 static struct PyMethodDef __pyx_methods[] = {
212 {"f", (PyCFunction)__pyx_f_10tryfinally_f, METH_VARARGS|METH_KEYWORDS, 0},
213 {0, 0, 0, 0}
214 };
216 static void __pyx_init_filenames(void); /*proto*/
218 PyMODINIT_FUNC inittryfinally(void); /*proto*/
219 PyMODINIT_FUNC inittryfinally(void) {
220 __pyx_init_filenames();
221 __pyx_m = Py_InitModule4("tryfinally", __pyx_methods, 0, 0, PYTHON_API_VERSION);
222 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
223 Py_INCREF(__pyx_m);
224 __pyx_b = PyImport_AddModule("__builtin__");
225 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
226 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
227 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
228 return;
229 __pyx_L1:;
230 __Pyx_AddTraceback("tryfinally");
231 }
233 static char *__pyx_filenames[] = {
234 "tryfinally.pyx",
235 };
237 /* Runtime support code */
239 static void __pyx_init_filenames(void) {
240 __pyx_f = __pyx_filenames;
241 }
243 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
244 Py_XINCREF(type);
245 Py_XINCREF(value);
246 Py_XINCREF(tb);
247 /* First, check the traceback argument, replacing None with NULL. */
248 if (tb == Py_None) {
249 Py_DECREF(tb);
250 tb = 0;
251 }
252 else if (tb != NULL && !PyTraceBack_Check(tb)) {
253 PyErr_SetString(PyExc_TypeError,
254 "raise: arg 3 must be a traceback or None");
255 goto raise_error;
256 }
257 /* Next, replace a missing value with None */
258 if (value == NULL) {
259 value = Py_None;
260 Py_INCREF(value);
261 }
262 #if PY_VERSION_HEX < 0x02050000
263 if (!PyClass_Check(type))
264 #else
265 if (!PyType_Check(type))
266 #endif
267 {
268 /* Raising an instance. The value should be a dummy. */
269 if (value != Py_None) {
270 PyErr_SetString(PyExc_TypeError,
271 "instance exception may not have a separate value");
272 goto raise_error;
273 }
274 /* Normalize to raise <class>, <instance> */
275 Py_DECREF(value);
276 value = type;
277 #if PY_VERSION_HEX < 0x02050000
278 if (PyInstance_Check(type)) {
279 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
280 Py_INCREF(type);
281 }
282 else {
283 PyErr_SetString(PyExc_TypeError,
284 "raise: exception must be an old-style class or instance");
285 goto raise_error;
286 }
287 #else
288 type = (PyObject*) type->ob_type;
289 Py_INCREF(type);
290 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
291 PyErr_SetString(PyExc_TypeError,
292 "raise: exception class must be a subclass of BaseException");
293 goto raise_error;
294 }
295 #endif
296 }
297 PyErr_Restore(type, value, tb);
298 return;
299 raise_error:
300 Py_XDECREF(value);
301 Py_XDECREF(type);
302 Py_XDECREF(tb);
303 return;
304 }
306 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
307 while (t->p) {
308 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
309 if (!*t->p)
310 return -1;
311 if (t->i)
312 PyString_InternInPlace(t->p);
313 ++t;
314 }
315 return 0;
316 }
318 #include "compile.h"
319 #include "frameobject.h"
320 #include "traceback.h"
322 static void __Pyx_AddTraceback(char *funcname) {
323 PyObject *py_srcfile = 0;
324 PyObject *py_funcname = 0;
325 PyObject *py_globals = 0;
326 PyObject *empty_tuple = 0;
327 PyObject *empty_string = 0;
328 PyCodeObject *py_code = 0;
329 PyFrameObject *py_frame = 0;
331 py_srcfile = PyString_FromString(__pyx_filename);
332 if (!py_srcfile) goto bad;
333 py_funcname = PyString_FromString(funcname);
334 if (!py_funcname) goto bad;
335 py_globals = PyModule_GetDict(__pyx_m);
336 if (!py_globals) goto bad;
337 empty_tuple = PyTuple_New(0);
338 if (!empty_tuple) goto bad;
339 empty_string = PyString_FromString("");
340 if (!empty_string) goto bad;
341 py_code = PyCode_New(
342 0, /*int argcount,*/
343 0, /*int nlocals,*/
344 0, /*int stacksize,*/
345 0, /*int flags,*/
346 empty_string, /*PyObject *code,*/
347 empty_tuple, /*PyObject *consts,*/
348 empty_tuple, /*PyObject *names,*/
349 empty_tuple, /*PyObject *varnames,*/
350 empty_tuple, /*PyObject *freevars,*/
351 empty_tuple, /*PyObject *cellvars,*/
352 py_srcfile, /*PyObject *filename,*/
353 py_funcname, /*PyObject *name,*/
354 __pyx_lineno, /*int firstlineno,*/
355 empty_string /*PyObject *lnotab*/
356 );
357 if (!py_code) goto bad;
358 py_frame = PyFrame_New(
359 PyThreadState_Get(), /*PyThreadState *tstate,*/
360 py_code, /*PyCodeObject *code,*/
361 py_globals, /*PyObject *globals,*/
362 0 /*PyObject *locals*/
363 );
364 if (!py_frame) goto bad;
365 py_frame->f_lineno = __pyx_lineno;
366 PyTraceBack_Here(py_frame);
367 bad:
368 Py_XDECREF(py_srcfile);
369 Py_XDECREF(py_funcname);
370 Py_XDECREF(empty_tuple);
371 Py_XDECREF(empty_string);
372 Py_XDECREF(py_code);
373 Py_XDECREF(py_frame);
374 }
