Cython has moved to github.
pyrex
view Tests/10/builtinslice.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 builtinslice */
47 /* Declarations from implementation of builtinslice */
49 static int __pyx_f_12builtinslice_f(void); /*proto*/
51 static char __pyx_k1[] = "indices";
53 static PyObject *__pyx_n_indices;
56 static __Pyx_StringTabEntry __pyx_string_tab[] = {
57 {&__pyx_n_indices, 1, __pyx_k1, sizeof(__pyx_k1)},
58 {0, 0, 0, 0}
59 };
63 /* Implementation of builtinslice */
65 static int __pyx_f_12builtinslice_f(void) {
66 PySliceObject *__pyx_v_s;
67 PyObject *__pyx_v_z;
68 int __pyx_v_i;
69 int __pyx_r;
70 PyObject *__pyx_1 = 0;
71 PyObject *__pyx_2 = 0;
72 PyObject *__pyx_3 = 0;
73 PyObject *__pyx_4 = 0;
74 int __pyx_5;
75 __pyx_v_s = ((PySliceObject *)Py_None); Py_INCREF(Py_None);
76 __pyx_v_z = Py_None; Py_INCREF(Py_None);
78 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":5 */
79 Py_INCREF(((PyObject *)(&PySlice_Type)));
80 Py_DECREF(__pyx_v_z);
81 __pyx_v_z = ((PyObject *)(&PySlice_Type));
83 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":6 */
84 __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
85 __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
86 __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
87 __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
88 PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
89 PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
90 PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
91 __pyx_1 = 0;
92 __pyx_2 = 0;
93 __pyx_3 = 0;
94 __pyx_1 = PyObject_CallObject(((PyObject *)(&PySlice_Type)), __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
95 Py_DECREF(__pyx_4); __pyx_4 = 0;
96 Py_DECREF(((PyObject *)__pyx_v_s));
97 __pyx_v_s = ((PySliceObject *)__pyx_1);
98 __pyx_1 = 0;
100 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":7 */
101 __pyx_2 = PyObject_GetAttr(((PyObject *)(&PySlice_Type)), __pyx_n_indices); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
102 __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
103 Py_DECREF(__pyx_2); __pyx_2 = 0;
104 Py_DECREF(__pyx_v_z);
105 __pyx_v_z = __pyx_3;
106 __pyx_3 = 0;
108 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":8 */
109 __pyx_5 = PyInt_AsLong(__pyx_v_s->start); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
110 __pyx_v_i = __pyx_5;
112 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":9 */
113 __pyx_5 = PyInt_AsLong(__pyx_v_s->stop); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
114 __pyx_v_i = __pyx_5;
116 /* "/Local/Projects/D/Pyrex/Source/Tests/10/builtinslice.pyx":10 */
117 __pyx_5 = PyInt_AsLong(__pyx_v_s->step); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
118 __pyx_v_i = __pyx_5;
120 __pyx_r = 0;
121 goto __pyx_L0;
122 __pyx_L1:;
123 Py_XDECREF(__pyx_1);
124 Py_XDECREF(__pyx_2);
125 Py_XDECREF(__pyx_3);
126 Py_XDECREF(__pyx_4);
127 __Pyx_AddTraceback("builtinslice.f");
128 __pyx_r = (-1);
129 __pyx_L0:;
130 Py_DECREF(__pyx_v_s);
131 Py_DECREF(__pyx_v_z);
132 return __pyx_r;
133 }
135 static struct PyMethodDef __pyx_methods[] = {
136 {0, 0, 0, 0}
137 };
139 static void __pyx_init_filenames(void); /*proto*/
141 PyMODINIT_FUNC initbuiltinslice(void); /*proto*/
142 PyMODINIT_FUNC initbuiltinslice(void) {
143 __pyx_init_filenames();
144 __pyx_m = Py_InitModule4("builtinslice", __pyx_methods, 0, 0, PYTHON_API_VERSION);
145 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
146 Py_INCREF(__pyx_m);
147 __pyx_b = PyImport_AddModule("__builtin__");
148 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
149 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
150 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
151 return;
152 __pyx_L1:;
153 __Pyx_AddTraceback("builtinslice");
154 }
156 static char *__pyx_filenames[] = {
157 "builtinslice.pyx",
158 };
160 /* Runtime support code */
162 static void __pyx_init_filenames(void) {
163 __pyx_f = __pyx_filenames;
164 }
166 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
167 while (t->p) {
168 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
169 if (!*t->p)
170 return -1;
171 if (t->i)
172 PyString_InternInPlace(t->p);
173 ++t;
174 }
175 return 0;
176 }
178 #include "compile.h"
179 #include "frameobject.h"
180 #include "traceback.h"
182 static void __Pyx_AddTraceback(char *funcname) {
183 PyObject *py_srcfile = 0;
184 PyObject *py_funcname = 0;
185 PyObject *py_globals = 0;
186 PyObject *empty_tuple = 0;
187 PyObject *empty_string = 0;
188 PyCodeObject *py_code = 0;
189 PyFrameObject *py_frame = 0;
191 py_srcfile = PyString_FromString(__pyx_filename);
192 if (!py_srcfile) goto bad;
193 py_funcname = PyString_FromString(funcname);
194 if (!py_funcname) goto bad;
195 py_globals = PyModule_GetDict(__pyx_m);
196 if (!py_globals) goto bad;
197 empty_tuple = PyTuple_New(0);
198 if (!empty_tuple) goto bad;
199 empty_string = PyString_FromString("");
200 if (!empty_string) goto bad;
201 py_code = PyCode_New(
202 0, /*int argcount,*/
203 0, /*int nlocals,*/
204 0, /*int stacksize,*/
205 0, /*int flags,*/
206 empty_string, /*PyObject *code,*/
207 empty_tuple, /*PyObject *consts,*/
208 empty_tuple, /*PyObject *names,*/
209 empty_tuple, /*PyObject *varnames,*/
210 empty_tuple, /*PyObject *freevars,*/
211 empty_tuple, /*PyObject *cellvars,*/
212 py_srcfile, /*PyObject *filename,*/
213 py_funcname, /*PyObject *name,*/
214 __pyx_lineno, /*int firstlineno,*/
215 empty_string /*PyObject *lnotab*/
216 );
217 if (!py_code) goto bad;
218 py_frame = PyFrame_New(
219 PyThreadState_Get(), /*PyThreadState *tstate,*/
220 py_code, /*PyCodeObject *code,*/
221 py_globals, /*PyObject *globals,*/
222 0 /*PyObject *locals*/
223 );
224 if (!py_frame) goto bad;
225 py_frame->f_lineno = __pyx_lineno;
226 PyTraceBack_Here(py_frame);
227 bad:
228 Py_XDECREF(py_srcfile);
229 Py_XDECREF(py_funcname);
230 Py_XDECREF(empty_tuple);
231 Py_XDECREF(empty_string);
232 Py_XDECREF(py_code);
233 Py_XDECREF(py_frame);
234 }
