Cython has moved to github.
pyrex
view Tests/4/for.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_UnpackItem(PyObject *); /*proto*/
41 static int __Pyx_EndUnpack(PyObject *); /*proto*/
43 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
45 static void __Pyx_AddTraceback(char *funcname); /*proto*/
47 /* Declarations from for */
50 /* Declarations from implementation of for */
53 static char __pyx_k1[] = "spam";
55 static PyObject *__pyx_n_spam;
58 static __Pyx_StringTabEntry __pyx_string_tab[] = {
59 {&__pyx_n_spam, 1, __pyx_k1, sizeof(__pyx_k1)},
60 {0, 0, 0, 0}
61 };
65 /* Implementation of for */
67 static PyObject *__pyx_f_3for_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
68 static PyObject *__pyx_f_3for_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
69 PyObject *__pyx_v_a = 0;
70 PyObject *__pyx_v_b = 0;
71 PyObject *__pyx_v_c = 0;
72 int __pyx_v_i;
73 PyObject *__pyx_r;
74 PyObject *__pyx_1 = 0;
75 PyObject *__pyx_2 = 0;
76 int __pyx_3;
77 PyObject *__pyx_4 = 0;
78 static char *__pyx_argnames[] = {"a","b","c",0};
79 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_c)) return 0;
80 Py_INCREF(__pyx_v_a);
81 Py_INCREF(__pyx_v_b);
82 Py_INCREF(__pyx_v_c);
84 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":3 */
85 __pyx_1 = PyObject_GetIter(__pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
86 for (;;) {
87 __pyx_2 = PyIter_Next(__pyx_1);
88 if (!__pyx_2) {
89 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
90 break;
91 }
92 Py_DECREF(__pyx_v_a);
93 __pyx_v_a = __pyx_2;
94 __pyx_2 = 0;
96 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":4 */
97 __pyx_v_i = 1;
99 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":5 */
100 goto __pyx_L2;
102 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":6 */
103 __pyx_v_i = 2;
105 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":7 */
106 goto __pyx_L3;
108 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":8 */
109 __pyx_v_i = 3;
110 __pyx_L2:;
111 }
112 __pyx_L3:;
113 Py_DECREF(__pyx_1); __pyx_1 = 0;
115 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":10 */
116 __pyx_2 = PyObject_GetIter(__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
117 for (;;) {
118 __pyx_1 = PyIter_Next(__pyx_2);
119 if (!__pyx_1) {
120 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
121 break;
122 }
123 __pyx_3 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
124 Py_DECREF(__pyx_1); __pyx_1 = 0;
125 __pyx_v_i = __pyx_3;
126 __pyx_v_i = 1;
127 }
128 Py_DECREF(__pyx_2); __pyx_2 = 0;
130 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":13 */
131 __pyx_1 = PyObject_GetIter(__pyx_n_spam); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
132 for (;;) {
133 __pyx_2 = PyIter_Next(__pyx_1);
134 if (!__pyx_2) {
135 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
136 break;
137 }
138 Py_DECREF(__pyx_v_a);
139 __pyx_v_a = __pyx_2;
140 __pyx_2 = 0;
141 __pyx_v_i = 1;
142 }
143 Py_DECREF(__pyx_1); __pyx_1 = 0;
145 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":16 */
146 __pyx_2 = PyObject_GetIter(__pyx_v_c); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
147 for (;;) {
148 __pyx_1 = PyIter_Next(__pyx_2);
149 if (!__pyx_1) {
150 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
151 break;
152 }
153 if (PyObject_SetItem(__pyx_v_a, __pyx_v_b, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
154 Py_DECREF(__pyx_1); __pyx_1 = 0;
155 __pyx_v_i = 1;
156 }
157 Py_DECREF(__pyx_2); __pyx_2 = 0;
159 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":19 */
160 __pyx_1 = PyObject_GetIter(__pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
161 for (;;) {
162 __pyx_2 = PyIter_Next(__pyx_1);
163 if (!__pyx_2) {
164 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
165 break;
166 }
167 __pyx_4 = PyObject_GetIter(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
168 Py_DECREF(__pyx_2); __pyx_2 = 0;
169 __pyx_2 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
170 Py_DECREF(__pyx_v_a);
171 __pyx_v_a = __pyx_2;
172 __pyx_2 = 0;
173 __pyx_2 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
174 Py_DECREF(__pyx_v_b);
175 __pyx_v_b = __pyx_2;
176 __pyx_2 = 0;
177 if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
178 Py_DECREF(__pyx_4); __pyx_4 = 0;
179 __pyx_v_i = 1;
180 }
181 Py_DECREF(__pyx_1); __pyx_1 = 0;
183 /* "/Local/Projects/D/Pyrex/Source/Tests/4/for.pyx":22 */
184 __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
185 Py_INCREF(__pyx_v_b);
186 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
187 Py_INCREF(__pyx_v_c);
188 PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_c);
189 __pyx_4 = PyObject_GetIter(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
190 Py_DECREF(__pyx_2); __pyx_2 = 0;
191 for (;;) {
192 __pyx_1 = PyIter_Next(__pyx_4);
193 if (!__pyx_1) {
194 if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
195 break;
196 }
197 Py_DECREF(__pyx_v_a);
198 __pyx_v_a = __pyx_1;
199 __pyx_1 = 0;
200 __pyx_v_i = 1;
201 }
202 Py_DECREF(__pyx_4); __pyx_4 = 0;
204 __pyx_r = Py_None; Py_INCREF(Py_None);
205 goto __pyx_L0;
206 __pyx_L1:;
207 Py_XDECREF(__pyx_1);
208 Py_XDECREF(__pyx_2);
209 Py_XDECREF(__pyx_4);
210 __Pyx_AddTraceback("for.f");
211 __pyx_r = 0;
212 __pyx_L0:;
213 Py_DECREF(__pyx_v_a);
214 Py_DECREF(__pyx_v_b);
215 Py_DECREF(__pyx_v_c);
216 return __pyx_r;
217 }
219 static struct PyMethodDef __pyx_methods[] = {
220 {"f", (PyCFunction)__pyx_f_3for_f, METH_VARARGS|METH_KEYWORDS, 0},
221 {0, 0, 0, 0}
222 };
224 static void __pyx_init_filenames(void); /*proto*/
226 PyMODINIT_FUNC initfor(void); /*proto*/
227 PyMODINIT_FUNC initfor(void) {
228 __pyx_init_filenames();
229 __pyx_m = Py_InitModule4("for", __pyx_methods, 0, 0, PYTHON_API_VERSION);
230 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
231 Py_INCREF(__pyx_m);
232 __pyx_b = PyImport_AddModule("__builtin__");
233 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
234 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
235 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
236 return;
237 __pyx_L1:;
238 __Pyx_AddTraceback("for");
239 }
241 static char *__pyx_filenames[] = {
242 "for.pyx",
243 };
245 /* Runtime support code */
247 static void __pyx_init_filenames(void) {
248 __pyx_f = __pyx_filenames;
249 }
251 static void __Pyx_UnpackError(void) {
252 PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size");
253 }
255 static PyObject *__Pyx_UnpackItem(PyObject *iter) {
256 PyObject *item;
257 if (!(item = PyIter_Next(iter))) {
258 if (!PyErr_Occurred())
259 __Pyx_UnpackError();
260 }
261 return item;
262 }
264 static int __Pyx_EndUnpack(PyObject *iter) {
265 PyObject *item;
266 if ((item = PyIter_Next(iter))) {
267 Py_DECREF(item);
268 __Pyx_UnpackError();
269 return -1;
270 }
271 else if (!PyErr_Occurred())
272 return 0;
273 else
274 return -1;
275 }
277 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
278 while (t->p) {
279 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
280 if (!*t->p)
281 return -1;
282 if (t->i)
283 PyString_InternInPlace(t->p);
284 ++t;
285 }
286 return 0;
287 }
289 #include "compile.h"
290 #include "frameobject.h"
291 #include "traceback.h"
293 static void __Pyx_AddTraceback(char *funcname) {
294 PyObject *py_srcfile = 0;
295 PyObject *py_funcname = 0;
296 PyObject *py_globals = 0;
297 PyObject *empty_tuple = 0;
298 PyObject *empty_string = 0;
299 PyCodeObject *py_code = 0;
300 PyFrameObject *py_frame = 0;
302 py_srcfile = PyString_FromString(__pyx_filename);
303 if (!py_srcfile) goto bad;
304 py_funcname = PyString_FromString(funcname);
305 if (!py_funcname) goto bad;
306 py_globals = PyModule_GetDict(__pyx_m);
307 if (!py_globals) goto bad;
308 empty_tuple = PyTuple_New(0);
309 if (!empty_tuple) goto bad;
310 empty_string = PyString_FromString("");
311 if (!empty_string) goto bad;
312 py_code = PyCode_New(
313 0, /*int argcount,*/
314 0, /*int nlocals,*/
315 0, /*int stacksize,*/
316 0, /*int flags,*/
317 empty_string, /*PyObject *code,*/
318 empty_tuple, /*PyObject *consts,*/
319 empty_tuple, /*PyObject *names,*/
320 empty_tuple, /*PyObject *varnames,*/
321 empty_tuple, /*PyObject *freevars,*/
322 empty_tuple, /*PyObject *cellvars,*/
323 py_srcfile, /*PyObject *filename,*/
324 py_funcname, /*PyObject *name,*/
325 __pyx_lineno, /*int firstlineno,*/
326 empty_string /*PyObject *lnotab*/
327 );
328 if (!py_code) goto bad;
329 py_frame = PyFrame_New(
330 PyThreadState_Get(), /*PyThreadState *tstate,*/
331 py_code, /*PyCodeObject *code,*/
332 py_globals, /*PyObject *globals,*/
333 0 /*PyObject *locals*/
334 );
335 if (!py_frame) goto bad;
336 py_frame->f_lineno = __pyx_lineno;
337 PyTraceBack_Here(py_frame);
338 bad:
339 Py_XDECREF(py_srcfile);
340 Py_XDECREF(py_funcname);
341 Py_XDECREF(empty_tuple);
342 Py_XDECREF(empty_string);
343 Py_XDECREF(py_code);
344 Py_XDECREF(py_frame);
345 }
