Cython has moved to github.
pyrex
view Tests/3/while.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 int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
42 static void __Pyx_AddTraceback(char *funcname); /*proto*/
44 /* Declarations from while */
47 /* Declarations from implementation of while */
53 static __Pyx_StringTabEntry __pyx_string_tab[] = {
54 {0, 0, 0, 0}
55 };
59 /* Implementation of while */
61 static PyObject *__pyx_f_5while_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
62 static PyObject *__pyx_f_5while_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
63 PyObject *__pyx_v_a = 0;
64 PyObject *__pyx_v_b = 0;
65 int __pyx_v_i;
66 PyObject *__pyx_v_x;
67 PyObject *__pyx_r;
68 int __pyx_1;
69 PyObject *__pyx_2 = 0;
70 static char *__pyx_argnames[] = {"a","b",0};
71 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b)) return 0;
72 Py_INCREF(__pyx_v_a);
73 Py_INCREF(__pyx_v_b);
74 __pyx_v_x = Py_None; Py_INCREF(Py_None);
76 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":4 */
77 while (1) {
78 __pyx_1 = PyObject_IsTrue(__pyx_v_a); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
79 if (!__pyx_1) break;
80 __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
81 Py_DECREF(__pyx_v_x);
82 __pyx_v_x = __pyx_2;
83 __pyx_2 = 0;
84 }
86 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":7 */
87 while (1) {
88 __pyx_2 = PyNumber_Add(__pyx_v_a, __pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
89 __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
90 Py_DECREF(__pyx_2); __pyx_2 = 0;
91 if (!__pyx_1) break;
92 __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
93 Py_DECREF(__pyx_v_x);
94 __pyx_v_x = __pyx_2;
95 __pyx_2 = 0;
96 }
98 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":10 */
99 while (1) {
100 __pyx_1 = __pyx_v_i;
101 if (!__pyx_1) break;
102 __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
103 Py_DECREF(__pyx_v_x);
104 __pyx_v_x = __pyx_2;
105 __pyx_2 = 0;
106 }
107 /*else*/ {
108 __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
109 Py_DECREF(__pyx_v_x);
110 __pyx_v_x = __pyx_2;
111 __pyx_2 = 0;
112 }
114 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":15 */
115 while (1) {
116 __pyx_1 = __pyx_v_i;
117 if (!__pyx_1) break;
119 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":16 */
120 __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
121 Py_DECREF(__pyx_v_x);
122 __pyx_v_x = __pyx_2;
123 __pyx_2 = 0;
125 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":17 */
126 goto __pyx_L9;
128 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":18 */
129 __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;}
130 Py_DECREF(__pyx_v_x);
131 __pyx_v_x = __pyx_2;
132 __pyx_2 = 0;
133 }
134 /*else*/ {
135 __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
136 Py_DECREF(__pyx_v_x);
137 __pyx_v_x = __pyx_2;
138 __pyx_2 = 0;
139 }
140 __pyx_L9:;
142 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":22 */
143 while (1) {
144 __pyx_1 = __pyx_v_i;
145 if (!__pyx_1) break;
147 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":23 */
148 __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
149 Py_DECREF(__pyx_v_x);
150 __pyx_v_x = __pyx_2;
151 __pyx_2 = 0;
153 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":24 */
154 goto __pyx_L10;
156 /* "/Local/Projects/D/Pyrex/Source/Tests/3/while.pyx":25 */
157 __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
158 Py_DECREF(__pyx_v_x);
159 __pyx_v_x = __pyx_2;
160 __pyx_2 = 0;
161 __pyx_L10:;
162 }
164 __pyx_r = Py_None; Py_INCREF(Py_None);
165 goto __pyx_L0;
166 __pyx_L1:;
167 Py_XDECREF(__pyx_2);
168 __Pyx_AddTraceback("while.f");
169 __pyx_r = 0;
170 __pyx_L0:;
171 Py_DECREF(__pyx_v_x);
172 Py_DECREF(__pyx_v_a);
173 Py_DECREF(__pyx_v_b);
174 return __pyx_r;
175 }
177 static struct PyMethodDef __pyx_methods[] = {
178 {"f", (PyCFunction)__pyx_f_5while_f, METH_VARARGS|METH_KEYWORDS, 0},
179 {0, 0, 0, 0}
180 };
182 static void __pyx_init_filenames(void); /*proto*/
184 PyMODINIT_FUNC initwhile(void); /*proto*/
185 PyMODINIT_FUNC initwhile(void) {
186 __pyx_init_filenames();
187 __pyx_m = Py_InitModule4("while", __pyx_methods, 0, 0, PYTHON_API_VERSION);
188 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
189 Py_INCREF(__pyx_m);
190 __pyx_b = PyImport_AddModule("__builtin__");
191 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
192 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
193 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
194 return;
195 __pyx_L1:;
196 __Pyx_AddTraceback("while");
197 }
199 static char *__pyx_filenames[] = {
200 "while.pyx",
201 };
203 /* Runtime support code */
205 static void __pyx_init_filenames(void) {
206 __pyx_f = __pyx_filenames;
207 }
209 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
210 while (t->p) {
211 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
212 if (!*t->p)
213 return -1;
214 if (t->i)
215 PyString_InternInPlace(t->p);
216 ++t;
217 }
218 return 0;
219 }
221 #include "compile.h"
222 #include "frameobject.h"
223 #include "traceback.h"
225 static void __Pyx_AddTraceback(char *funcname) {
226 PyObject *py_srcfile = 0;
227 PyObject *py_funcname = 0;
228 PyObject *py_globals = 0;
229 PyObject *empty_tuple = 0;
230 PyObject *empty_string = 0;
231 PyCodeObject *py_code = 0;
232 PyFrameObject *py_frame = 0;
234 py_srcfile = PyString_FromString(__pyx_filename);
235 if (!py_srcfile) goto bad;
236 py_funcname = PyString_FromString(funcname);
237 if (!py_funcname) goto bad;
238 py_globals = PyModule_GetDict(__pyx_m);
239 if (!py_globals) goto bad;
240 empty_tuple = PyTuple_New(0);
241 if (!empty_tuple) goto bad;
242 empty_string = PyString_FromString("");
243 if (!empty_string) goto bad;
244 py_code = PyCode_New(
245 0, /*int argcount,*/
246 0, /*int nlocals,*/
247 0, /*int stacksize,*/
248 0, /*int flags,*/
249 empty_string, /*PyObject *code,*/
250 empty_tuple, /*PyObject *consts,*/
251 empty_tuple, /*PyObject *names,*/
252 empty_tuple, /*PyObject *varnames,*/
253 empty_tuple, /*PyObject *freevars,*/
254 empty_tuple, /*PyObject *cellvars,*/
255 py_srcfile, /*PyObject *filename,*/
256 py_funcname, /*PyObject *name,*/
257 __pyx_lineno, /*int firstlineno,*/
258 empty_string /*PyObject *lnotab*/
259 );
260 if (!py_code) goto bad;
261 py_frame = PyFrame_New(
262 PyThreadState_Get(), /*PyThreadState *tstate,*/
263 py_code, /*PyCodeObject *code,*/
264 py_globals, /*PyObject *globals,*/
265 0 /*PyObject *locals*/
266 );
267 if (!py_frame) goto bad;
268 py_frame->f_lineno = __pyx_lineno;
269 PyTraceBack_Here(py_frame);
270 bad:
271 Py_XDECREF(py_srcfile);
272 Py_XDECREF(py_funcname);
273 Py_XDECREF(empty_tuple);
274 Py_XDECREF(empty_string);
275 Py_XDECREF(py_code);
276 Py_XDECREF(py_frame);
277 }
