Cython has moved to github.

pyrex

view Tests/4/tryexceptelse.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 PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
42 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
44 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
46 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
48 static void __Pyx_AddTraceback(char *funcname); /*proto*/
50 /* Declarations from tryexceptelse */
53 /* Declarations from implementation of tryexceptelse */
56 static char __pyx_k1[] = "x";
57 static char __pyx_k2[] = "y";
58 static char __pyx_k3[] = "a";
60 static PyObject *__pyx_n_a;
61 static PyObject *__pyx_n_x;
62 static PyObject *__pyx_n_y;
65 static __Pyx_StringTabEntry __pyx_string_tab[] = {
66 {&__pyx_n_a, 1, __pyx_k3, sizeof(__pyx_k3)},
67 {&__pyx_n_x, 1, __pyx_k1, sizeof(__pyx_k1)},
68 {&__pyx_n_y, 1, __pyx_k2, sizeof(__pyx_k2)},
69 {0, 0, 0, 0}
70 };
74 /* Implementation of tryexceptelse */
76 static PyObject *__pyx_f_13tryexceptelse_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
77 static PyObject *__pyx_f_13tryexceptelse_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
78 int __pyx_v_i;
79 PyObject *__pyx_r;
80 PyObject *__pyx_1 = 0;
81 static char *__pyx_argnames[] = {0};
82 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
84 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":3 */
85 /*try:*/ {
87 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":4 */
88 __pyx_v_i = 1;
90 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":5 */
91 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L2;}
92 __Pyx_Raise(__pyx_1, 0, 0);
93 Py_DECREF(__pyx_1); __pyx_1 = 0;
94 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L2;}
96 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":6 */
97 __pyx_v_i = 2;
98 }
99 /*else:*/ {
101 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":8 */
102 __pyx_v_i = 3;
104 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":9 */
105 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
106 __Pyx_Raise(__pyx_1, 0, 0);
107 Py_DECREF(__pyx_1); __pyx_1 = 0;
108 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
110 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":10 */
111 __pyx_v_i = 4;
112 }
113 goto __pyx_L3;
114 __pyx_L2:;
115 Py_XDECREF(__pyx_1); __pyx_1 = 0;
116 goto __pyx_L1;
117 __pyx_L3:;
119 __pyx_r = Py_None; Py_INCREF(Py_None);
120 goto __pyx_L0;
121 __pyx_L1:;
122 Py_XDECREF(__pyx_1);
123 __Pyx_AddTraceback("tryexceptelse.f");
124 __pyx_r = 0;
125 __pyx_L0:;
126 return __pyx_r;
127 }
129 static PyObject *__pyx_f_13tryexceptelse_g(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
130 static PyObject *__pyx_f_13tryexceptelse_g(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
131 int __pyx_v_i;
132 PyObject *__pyx_r;
133 PyObject *__pyx_1 = 0;
134 int __pyx_2;
135 PyObject *__pyx_3 = 0;
136 PyObject *__pyx_4 = 0;
137 static char *__pyx_argnames[] = {0};
138 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
140 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":14 */
141 /*try:*/ {
143 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":15 */
144 __pyx_v_i = 1;
146 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":16 */
147 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L2;}
148 __Pyx_Raise(__pyx_1, 0, 0);
149 Py_DECREF(__pyx_1); __pyx_1 = 0;
150 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L2;}
152 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":17 */
153 __pyx_v_i = 2;
154 }
155 /*else:*/ {
157 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":21 */
158 __pyx_v_i = 4;
160 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":22 */
161 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
162 __Pyx_Raise(__pyx_1, 0, 0);
163 Py_DECREF(__pyx_1); __pyx_1 = 0;
164 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
166 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":23 */
167 __pyx_v_i = 5;
168 }
169 goto __pyx_L3;
170 __pyx_L2:;
171 Py_XDECREF(__pyx_1); __pyx_1 = 0;
173 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":18 */
174 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_a); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;}
175 __pyx_2 = PyErr_ExceptionMatches(__pyx_1);
176 Py_DECREF(__pyx_1); __pyx_1 = 0;
177 if (__pyx_2) {
178 __Pyx_AddTraceback("tryexceptelse.g");
179 if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;}
180 __pyx_v_i = 3;
181 Py_DECREF(__pyx_1); __pyx_1 = 0;
182 Py_DECREF(__pyx_3); __pyx_3 = 0;
183 Py_DECREF(__pyx_4); __pyx_4 = 0;
184 goto __pyx_L3;
185 }
186 goto __pyx_L1;
187 __pyx_L3:;
189 __pyx_r = Py_None; Py_INCREF(Py_None);
190 goto __pyx_L0;
191 __pyx_L1:;
192 Py_XDECREF(__pyx_1);
193 Py_XDECREF(__pyx_3);
194 Py_XDECREF(__pyx_4);
195 __Pyx_AddTraceback("tryexceptelse.g");
196 __pyx_r = 0;
197 __pyx_L0:;
198 return __pyx_r;
199 }
201 static struct PyMethodDef __pyx_methods[] = {
202 {"f", (PyCFunction)__pyx_f_13tryexceptelse_f, METH_VARARGS|METH_KEYWORDS, 0},
203 {"g", (PyCFunction)__pyx_f_13tryexceptelse_g, METH_VARARGS|METH_KEYWORDS, 0},
204 {0, 0, 0, 0}
205 };
207 static void __pyx_init_filenames(void); /*proto*/
209 PyMODINIT_FUNC inittryexceptelse(void); /*proto*/
210 PyMODINIT_FUNC inittryexceptelse(void) {
211 __pyx_init_filenames();
212 __pyx_m = Py_InitModule4("tryexceptelse", __pyx_methods, 0, 0, PYTHON_API_VERSION);
213 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
214 Py_INCREF(__pyx_m);
215 __pyx_b = PyImport_AddModule("__builtin__");
216 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
217 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
218 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
220 /* "/Local/Projects/D/Pyrex/Source/Tests/4/tryexceptelse.pyx":12 */
221 return;
222 __pyx_L1:;
223 __Pyx_AddTraceback("tryexceptelse");
224 }
226 static char *__pyx_filenames[] = {
227 "tryexceptelse.pyx",
228 };
230 /* Runtime support code */
232 static void __pyx_init_filenames(void) {
233 __pyx_f = __pyx_filenames;
234 }
236 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
237 PyObject *result;
238 result = PyObject_GetAttr(dict, name);
239 if (!result)
240 PyErr_SetObject(PyExc_NameError, name);
241 return result;
242 }
244 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
245 Py_XINCREF(type);
246 Py_XINCREF(value);
247 Py_XINCREF(tb);
248 /* First, check the traceback argument, replacing None with NULL. */
249 if (tb == Py_None) {
250 Py_DECREF(tb);
251 tb = 0;
252 }
253 else if (tb != NULL && !PyTraceBack_Check(tb)) {
254 PyErr_SetString(PyExc_TypeError,
255 "raise: arg 3 must be a traceback or None");
256 goto raise_error;
257 }
258 /* Next, replace a missing value with None */
259 if (value == NULL) {
260 value = Py_None;
261 Py_INCREF(value);
262 }
263 #if PY_VERSION_HEX < 0x02050000
264 if (!PyClass_Check(type))
265 #else
266 if (!PyType_Check(type))
267 #endif
268 {
269 /* Raising an instance. The value should be a dummy. */
270 if (value != Py_None) {
271 PyErr_SetString(PyExc_TypeError,
272 "instance exception may not have a separate value");
273 goto raise_error;
274 }
275 /* Normalize to raise <class>, <instance> */
276 Py_DECREF(value);
277 value = type;
278 #if PY_VERSION_HEX < 0x02050000
279 if (PyInstance_Check(type)) {
280 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
281 Py_INCREF(type);
282 }
283 else {
284 PyErr_SetString(PyExc_TypeError,
285 "raise: exception must be an old-style class or instance");
286 goto raise_error;
287 }
288 #else
289 type = (PyObject*) type->ob_type;
290 Py_INCREF(type);
291 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
292 PyErr_SetString(PyExc_TypeError,
293 "raise: exception class must be a subclass of BaseException");
294 goto raise_error;
295 }
296 #endif
297 }
298 PyErr_Restore(type, value, tb);
299 return;
300 raise_error:
301 Py_XDECREF(value);
302 Py_XDECREF(type);
303 Py_XDECREF(tb);
304 return;
305 }
307 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
308 PyThreadState *tstate = PyThreadState_Get();
309 PyErr_Fetch(type, value, tb);
310 PyErr_NormalizeException(type, value, tb);
311 if (PyErr_Occurred())
312 goto bad;
313 Py_INCREF(*type);
314 Py_INCREF(*value);
315 Py_INCREF(*tb);
316 Py_XDECREF(tstate->exc_type);
317 Py_XDECREF(tstate->exc_value);
318 Py_XDECREF(tstate->exc_traceback);
319 tstate->exc_type = *type;
320 tstate->exc_value = *value;
321 tstate->exc_traceback = *tb;
322 return 0;
323 bad:
324 Py_XDECREF(*type);
325 Py_XDECREF(*value);
326 Py_XDECREF(*tb);
327 return -1;
328 }
330 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
331 while (t->p) {
332 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
333 if (!*t->p)
334 return -1;
335 if (t->i)
336 PyString_InternInPlace(t->p);
337 ++t;
338 }
339 return 0;
340 }
342 #include "compile.h"
343 #include "frameobject.h"
344 #include "traceback.h"
346 static void __Pyx_AddTraceback(char *funcname) {
347 PyObject *py_srcfile = 0;
348 PyObject *py_funcname = 0;
349 PyObject *py_globals = 0;
350 PyObject *empty_tuple = 0;
351 PyObject *empty_string = 0;
352 PyCodeObject *py_code = 0;
353 PyFrameObject *py_frame = 0;
355 py_srcfile = PyString_FromString(__pyx_filename);
356 if (!py_srcfile) goto bad;
357 py_funcname = PyString_FromString(funcname);
358 if (!py_funcname) goto bad;
359 py_globals = PyModule_GetDict(__pyx_m);
360 if (!py_globals) goto bad;
361 empty_tuple = PyTuple_New(0);
362 if (!empty_tuple) goto bad;
363 empty_string = PyString_FromString("");
364 if (!empty_string) goto bad;
365 py_code = PyCode_New(
366 0, /*int argcount,*/
367 0, /*int nlocals,*/
368 0, /*int stacksize,*/
369 0, /*int flags,*/
370 empty_string, /*PyObject *code,*/
371 empty_tuple, /*PyObject *consts,*/
372 empty_tuple, /*PyObject *names,*/
373 empty_tuple, /*PyObject *varnames,*/
374 empty_tuple, /*PyObject *freevars,*/
375 empty_tuple, /*PyObject *cellvars,*/
376 py_srcfile, /*PyObject *filename,*/
377 py_funcname, /*PyObject *name,*/
378 __pyx_lineno, /*int firstlineno,*/
379 empty_string /*PyObject *lnotab*/
380 );
381 if (!py_code) goto bad;
382 py_frame = PyFrame_New(
383 PyThreadState_Get(), /*PyThreadState *tstate,*/
384 py_code, /*PyCodeObject *code,*/
385 py_globals, /*PyObject *globals,*/
386 0 /*PyObject *locals*/
387 );
388 if (!py_frame) goto bad;
389 py_frame->f_lineno = __pyx_lineno;
390 PyTraceBack_Here(py_frame);
391 bad:
392 Py_XDECREF(py_srcfile);
393 Py_XDECREF(py_funcname);
394 Py_XDECREF(empty_tuple);
395 Py_XDECREF(empty_string);
396 Py_XDECREF(py_code);
397 Py_XDECREF(py_frame);
398 }