Cython has moved to github.
pyrex
view Tests/2/Reference/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 | 39259a22b0e7 |
| children | 3b20cb4923eb |
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; char *s;} __Pyx_InternTabEntry; /*proto*/
33 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
35 static PyObject *__pyx_m;
36 static PyObject *__pyx_b;
37 static int __pyx_lineno;
38 static char *__pyx_filename;
39 static char **__pyx_f;
41 static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/
43 static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/
45 static void __Pyx_AddTraceback(char *funcname); /*proto*/
47 /* Declarations from index */
51 static __Pyx_StringTabEntry __pyx_string_tab[] = {
52 {0, 0, 0, 0}
53 };
55 /* Implementation of index */
57 static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
58 static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
59 PyObject *__pyx_v_obj1 = 0;
60 PyObject *__pyx_v_obj2 = 0;
61 PyObject *__pyx_v_obj3 = 0;
62 int __pyx_v_int1;
63 int __pyx_v_int2;
64 int __pyx_v_int3;
65 float __pyx_v_flt1;
66 float *__pyx_v_ptr1;
67 int __pyx_v_array1[42];
68 PyObject *__pyx_r;
69 PyObject *__pyx_1 = 0;
70 Py_ssize_t __pyx_2;
71 static char *__pyx_argnames[] = {"obj1","obj2","obj3",0};
72 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_obj1, &__pyx_v_obj2, &__pyx_v_obj3)) return 0;
73 Py_INCREF(__pyx_v_obj1);
74 Py_INCREF(__pyx_v_obj2);
75 Py_INCREF(__pyx_v_obj3);
77 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":5 */
78 __pyx_v_int1 = (__pyx_v_array1[__pyx_v_int2]);
80 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":6 */
81 __pyx_v_flt1 = (__pyx_v_ptr1[__pyx_v_int2]);
83 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":7 */
84 (__pyx_v_array1[__pyx_v_int1]) = __pyx_v_int2;
86 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":8 */
87 (__pyx_v_ptr1[__pyx_v_int1]) = __pyx_v_int2;
89 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":9 */
90 __pyx_1 = PyObject_GetItem(__pyx_v_obj2, __pyx_v_obj3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
91 Py_DECREF(__pyx_v_obj1);
92 __pyx_v_obj1 = __pyx_1;
93 __pyx_1 = 0;
95 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":10 */
96 __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
97 __pyx_v_int1 = (__pyx_v_array1[__pyx_2]);
99 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":11 */
100 __pyx_1 = __Pyx_GetItemInt(__pyx_v_obj2, __pyx_v_int3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
101 Py_DECREF(__pyx_v_obj1);
102 __pyx_v_obj1 = __pyx_1;
103 __pyx_1 = 0;
105 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":12 */
106 if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_v_obj3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
108 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":13 */
109 __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
110 (__pyx_v_array1[__pyx_2]) = __pyx_v_int3;
112 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":14 */
113 if (__Pyx_SetItemInt(__pyx_v_obj1, __pyx_v_int2, __pyx_v_obj3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
115 /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":15 */
116 __pyx_1 = PyInt_FromLong(42); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
117 if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
118 Py_DECREF(__pyx_1); __pyx_1 = 0;
120 __pyx_r = Py_None; Py_INCREF(Py_None);
121 goto __pyx_L0;
122 __pyx_L1:;
123 Py_XDECREF(__pyx_1);
124 __Pyx_AddTraceback("index.f");
125 __pyx_r = 0;
126 __pyx_L0:;
127 Py_DECREF(__pyx_v_obj1);
128 Py_DECREF(__pyx_v_obj2);
129 Py_DECREF(__pyx_v_obj3);
130 return __pyx_r;
131 }
133 static struct PyMethodDef __pyx_methods[] = {
134 {"f", (PyCFunction)__pyx_f_5index_f, METH_VARARGS|METH_KEYWORDS, 0},
135 {0, 0, 0, 0}
136 };
138 static void __pyx_init_filenames(void); /*proto*/
140 PyMODINIT_FUNC initindex(void); /*proto*/
141 PyMODINIT_FUNC initindex(void) {
142 __pyx_init_filenames();
143 __pyx_m = Py_InitModule4("index", __pyx_methods, 0, 0, PYTHON_API_VERSION);
144 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
145 Py_INCREF(__pyx_m);
146 __pyx_b = PyImport_AddModule("__builtin__");
147 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
148 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
149 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
150 return;
151 __pyx_L1:;
152 __Pyx_AddTraceback("index");
153 }
155 static char *__pyx_filenames[] = {
156 "index.pyx",
157 };
159 /* Runtime support code */
161 static void __pyx_init_filenames(void) {
162 __pyx_f = __pyx_filenames;
163 }
165 static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
166 PyTypeObject *t = o->ob_type;
167 PyObject *r;
168 if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
169 r = PySequence_GetItem(o, i);
170 else {
171 PyObject *j = PyInt_FromLong(i);
172 if (!j)
173 return 0;
174 r = PyObject_GetItem(o, j);
175 Py_DECREF(j);
176 }
177 return r;
178 }
180 static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) {
181 PyTypeObject *t = o->ob_type;
182 int r;
183 if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
184 r = PySequence_SetItem(o, i, v);
185 else {
186 PyObject *j = PyInt_FromLong(i);
187 if (!j)
188 return -1;
189 r = PyObject_SetItem(o, j, v);
190 Py_DECREF(j);
191 }
192 return r;
193 }
195 #include "compile.h"
196 #include "frameobject.h"
197 #include "traceback.h"
199 static void __Pyx_AddTraceback(char *funcname) {
200 PyObject *py_srcfile = 0;
201 PyObject *py_funcname = 0;
202 PyObject *py_globals = 0;
203 PyObject *empty_tuple = 0;
204 PyObject *empty_string = 0;
205 PyCodeObject *py_code = 0;
206 PyFrameObject *py_frame = 0;
208 py_srcfile = PyString_FromString(__pyx_filename);
209 if (!py_srcfile) goto bad;
210 py_funcname = PyString_FromString(funcname);
211 if (!py_funcname) goto bad;
212 py_globals = PyModule_GetDict(__pyx_m);
213 if (!py_globals) goto bad;
214 empty_tuple = PyTuple_New(0);
215 if (!empty_tuple) goto bad;
216 empty_string = PyString_FromString("");
217 if (!empty_string) goto bad;
218 py_code = PyCode_New(
219 0, /*int argcount,*/
220 0, /*int nlocals,*/
221 0, /*int stacksize,*/
222 0, /*int flags,*/
223 empty_string, /*PyObject *code,*/
224 empty_tuple, /*PyObject *consts,*/
225 empty_tuple, /*PyObject *names,*/
226 empty_tuple, /*PyObject *varnames,*/
227 empty_tuple, /*PyObject *freevars,*/
228 empty_tuple, /*PyObject *cellvars,*/
229 py_srcfile, /*PyObject *filename,*/
230 py_funcname, /*PyObject *name,*/
231 __pyx_lineno, /*int firstlineno,*/
232 empty_string /*PyObject *lnotab*/
233 );
234 if (!py_code) goto bad;
235 py_frame = PyFrame_New(
236 PyThreadState_Get(), /*PyThreadState *tstate,*/
237 py_code, /*PyCodeObject *code,*/
238 py_globals, /*PyObject *globals,*/
239 0 /*PyObject *locals*/
240 );
241 if (!py_frame) goto bad;
242 py_frame->f_lineno = __pyx_lineno;
243 PyTraceBack_Here(py_frame);
244 bad:
245 Py_XDECREF(py_srcfile);
246 Py_XDECREF(py_funcname);
247 Py_XDECREF(empty_tuple);
248 Py_XDECREF(empty_string);
249 Py_XDECREF(py_code);
250 Py_XDECREF(py_frame);
251 }
