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