Cython has moved to github.
pyrex
view Tests/2/index.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_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/
42 static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/
44 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
46 static void __Pyx_AddTraceback(char *funcname); /*proto*/
48 /* Declarations from index */
51 /* Declarations from implementation of index */
57 static __Pyx_StringTabEntry __pyx_string_tab[] = {
58 {0, 0, 0, 0}
59 };
63 /* Implementation of index */
65 static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
66 static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
67 PyObject *__pyx_v_obj1 = 0;
68 PyObject *__pyx_v_obj2 = 0;
69 PyObject *__pyx_v_obj3 = 0;
70 int __pyx_v_int1;
71 int __pyx_v_int2;
72 int __pyx_v_int3;
73 float __pyx_v_flt1;
74 float *__pyx_v_ptr1;
75 int __pyx_v_array1[42];
76 PyObject *__pyx_r;
77 PyObject *__pyx_1 = 0;
78 Py_ssize_t __pyx_2;
79 static char *__pyx_argnames[] = {"obj1","obj2","obj3",0};
80 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_obj1, &__pyx_v_obj2, &__pyx_v_obj3)) return 0;
81 Py_INCREF(__pyx_v_obj1);
82 Py_INCREF(__pyx_v_obj2);
83 Py_INCREF(__pyx_v_obj3);
85 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":5 */
86 __pyx_v_int1 = (__pyx_v_array1[__pyx_v_int2]);
88 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":6 */
89 __pyx_v_flt1 = (__pyx_v_ptr1[__pyx_v_int2]);
91 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":7 */
92 (__pyx_v_array1[__pyx_v_int1]) = __pyx_v_int2;
94 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":8 */
95 (__pyx_v_ptr1[__pyx_v_int1]) = __pyx_v_int2;
97 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":9 */
98 __pyx_1 = PyObject_GetItem(__pyx_v_obj2, __pyx_v_obj3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
99 Py_DECREF(__pyx_v_obj1);
100 __pyx_v_obj1 = __pyx_1;
101 __pyx_1 = 0;
103 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":10 */
104 __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
105 __pyx_v_int1 = (__pyx_v_array1[__pyx_2]);
107 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":11 */
108 __pyx_1 = __Pyx_GetItemInt(__pyx_v_obj2, __pyx_v_int3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
109 Py_DECREF(__pyx_v_obj1);
110 __pyx_v_obj1 = __pyx_1;
111 __pyx_1 = 0;
113 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":12 */
114 if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_v_obj3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
116 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":13 */
117 __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
118 (__pyx_v_array1[__pyx_2]) = __pyx_v_int3;
120 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":14 */
121 if (__Pyx_SetItemInt(__pyx_v_obj1, __pyx_v_int2, __pyx_v_obj3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
123 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":15 */
124 __pyx_1 = PyInt_FromLong(42); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
125 if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
126 Py_DECREF(__pyx_1); __pyx_1 = 0;
128 __pyx_r = Py_None; Py_INCREF(Py_None);
129 goto __pyx_L0;
130 __pyx_L1:;
131 Py_XDECREF(__pyx_1);
132 __Pyx_AddTraceback("index.f");
133 __pyx_r = 0;
134 __pyx_L0:;
135 Py_DECREF(__pyx_v_obj1);
136 Py_DECREF(__pyx_v_obj2);
137 Py_DECREF(__pyx_v_obj3);
138 return __pyx_r;
139 }
141 static struct PyMethodDef __pyx_methods[] = {
142 {"f", (PyCFunction)__pyx_f_5index_f, METH_VARARGS|METH_KEYWORDS, 0},
143 {0, 0, 0, 0}
144 };
146 static void __pyx_init_filenames(void); /*proto*/
148 PyMODINIT_FUNC initindex(void); /*proto*/
149 PyMODINIT_FUNC initindex(void) {
150 __pyx_init_filenames();
151 __pyx_m = Py_InitModule4("index", __pyx_methods, 0, 0, PYTHON_API_VERSION);
152 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
153 Py_INCREF(__pyx_m);
154 __pyx_b = PyImport_AddModule("__builtin__");
155 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
156 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
157 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
158 return;
159 __pyx_L1:;
160 __Pyx_AddTraceback("index");
161 }
163 static char *__pyx_filenames[] = {
164 "index.pyx",
165 };
167 /* Runtime support code */
169 static void __pyx_init_filenames(void) {
170 __pyx_f = __pyx_filenames;
171 }
173 static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
174 PyTypeObject *t = o->ob_type;
175 PyObject *r;
176 if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
177 r = PySequence_GetItem(o, i);
178 else {
179 PyObject *j = PyInt_FromLong(i);
180 if (!j)
181 return 0;
182 r = PyObject_GetItem(o, j);
183 Py_DECREF(j);
184 }
185 return r;
186 }
188 static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) {
189 PyTypeObject *t = o->ob_type;
190 int r;
191 if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
192 r = PySequence_SetItem(o, i, v);
193 else {
194 PyObject *j = PyInt_FromLong(i);
195 if (!j)
196 return -1;
197 r = PyObject_SetItem(o, j, v);
198 Py_DECREF(j);
199 }
200 return r;
201 }
203 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
204 while (t->p) {
205 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
206 if (!*t->p)
207 return -1;
208 if (t->i)
209 PyString_InternInPlace(t->p);
210 ++t;
211 }
212 return 0;
213 }
215 #include "compile.h"
216 #include "frameobject.h"
217 #include "traceback.h"
219 static void __Pyx_AddTraceback(char *funcname) {
220 PyObject *py_srcfile = 0;
221 PyObject *py_funcname = 0;
222 PyObject *py_globals = 0;
223 PyObject *empty_tuple = 0;
224 PyObject *empty_string = 0;
225 PyCodeObject *py_code = 0;
226 PyFrameObject *py_frame = 0;
228 py_srcfile = PyString_FromString(__pyx_filename);
229 if (!py_srcfile) goto bad;
230 py_funcname = PyString_FromString(funcname);
231 if (!py_funcname) goto bad;
232 py_globals = PyModule_GetDict(__pyx_m);
233 if (!py_globals) goto bad;
234 empty_tuple = PyTuple_New(0);
235 if (!empty_tuple) goto bad;
236 empty_string = PyString_FromString("");
237 if (!empty_string) goto bad;
238 py_code = PyCode_New(
239 0, /*int argcount,*/
240 0, /*int nlocals,*/
241 0, /*int stacksize,*/
242 0, /*int flags,*/
243 empty_string, /*PyObject *code,*/
244 empty_tuple, /*PyObject *consts,*/
245 empty_tuple, /*PyObject *names,*/
246 empty_tuple, /*PyObject *varnames,*/
247 empty_tuple, /*PyObject *freevars,*/
248 empty_tuple, /*PyObject *cellvars,*/
249 py_srcfile, /*PyObject *filename,*/
250 py_funcname, /*PyObject *name,*/
251 __pyx_lineno, /*int firstlineno,*/
252 empty_string /*PyObject *lnotab*/
253 );
254 if (!py_code) goto bad;
255 py_frame = PyFrame_New(
256 PyThreadState_Get(), /*PyThreadState *tstate,*/
257 py_code, /*PyCodeObject *code,*/
258 py_globals, /*PyObject *globals,*/
259 0 /*PyObject *locals*/
260 );
261 if (!py_frame) goto bad;
262 py_frame->f_lineno = __pyx_lineno;
263 PyTraceBack_Here(py_frame);
264 bad:
265 Py_XDECREF(py_srcfile);
266 Py_XDECREF(py_funcname);
267 Py_XDECREF(empty_tuple);
268 Py_XDECREF(empty_string);
269 Py_XDECREF(py_code);
270 Py_XDECREF(py_frame);
271 }
