Cython has moved to github.

pyrex

view Tests/Bugs/behnel/behnel7.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_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from behnel7 */
49 /* Declarations from implementation of behnel7 */
55 static __Pyx_StringTabEntry __pyx_string_tab[] = {
56 {0, 0, 0, 0}
57 };
59 static PyObject *__pyx_d1;
62 /* Implementation of behnel7 */
64 static PyObject *__pyx_f_7behnel7_test(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
65 static PyObject *__pyx_f_7behnel7_test(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
66 PyObject *__pyx_v_arg = 0;
67 PyObject *__pyx_v_kw = 0;
68 PyObject *__pyx_r;
69 static char *__pyx_argnames[] = {"arg","kw",0};
70 __pyx_v_kw = __pyx_d1;
71 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 1, 0, 0, 0) < 0) return 0;
72 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_arg, &__pyx_v_kw)) {
73 Py_XDECREF(__pyx_args);
74 Py_XDECREF(__pyx_kwds);
75 return 0;
76 }
77 Py_INCREF(__pyx_v_arg);
78 Py_INCREF(__pyx_v_kw);
80 __pyx_r = Py_None; Py_INCREF(Py_None);
81 Py_DECREF(__pyx_v_arg);
82 Py_DECREF(__pyx_v_kw);
83 Py_XDECREF(__pyx_args);
84 Py_XDECREF(__pyx_kwds);
85 return __pyx_r;
86 }
88 static struct PyMethodDef __pyx_methods[] = {
89 {"test", (PyCFunction)__pyx_f_7behnel7_test, METH_VARARGS|METH_KEYWORDS, 0},
90 {0, 0, 0, 0}
91 };
93 static void __pyx_init_filenames(void); /*proto*/
95 PyMODINIT_FUNC initbehnel7(void); /*proto*/
96 PyMODINIT_FUNC initbehnel7(void) {
97 __pyx_init_filenames();
98 __pyx_m = Py_InitModule4("behnel7", __pyx_methods, 0, 0, PYTHON_API_VERSION);
99 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
100 Py_INCREF(__pyx_m);
101 __pyx_b = PyImport_AddModule("__builtin__");
102 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
103 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
104 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
105 Py_INCREF(Py_None);
106 __pyx_d1 = Py_None;
107 return;
108 __pyx_L1:;
109 __Pyx_AddTraceback("behnel7");
110 }
112 static char *__pyx_filenames[] = {
113 "behnel7.pyx",
114 };
116 /* Runtime support code */
118 static void __pyx_init_filenames(void) {
119 __pyx_f = __pyx_filenames;
120 }
122 static int __Pyx_GetStarArgs(
123 PyObject **args,
124 PyObject **kwds,
125 char *kwd_list[],
126 Py_ssize_t nargs,
127 PyObject **args2,
128 PyObject **kwds2,
129 char rqd_kwds[])
130 {
131 PyObject *x = 0, *args1 = 0, *kwds1 = 0;
132 int i;
133 char **p;
135 if (args2)
136 *args2 = 0;
137 if (kwds2)
138 *kwds2 = 0;
140 if (args2) {
141 args1 = PyTuple_GetSlice(*args, 0, nargs);
142 if (!args1)
143 goto bad;
144 *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
145 if (!*args2)
146 goto bad;
147 }
148 else if (PyTuple_GET_SIZE(*args) > nargs) {
149 int m = nargs;
150 int n = PyTuple_GET_SIZE(*args);
151 PyErr_Format(PyExc_TypeError,
152 "function takes at most %d positional arguments (%d given)",
153 m, n);
154 goto bad;
155 }
156 else {
157 args1 = *args;
158 Py_INCREF(args1);
159 }
161 if (rqd_kwds && !*kwds)
162 for (i = 0, p = kwd_list; *p; i++, p++)
163 if (rqd_kwds[i])
164 goto missing_kwarg;
166 if (kwds2) {
167 if (*kwds) {
168 kwds1 = PyDict_New();
169 if (!kwds1)
170 goto bad;
171 *kwds2 = PyDict_Copy(*kwds);
172 if (!*kwds2)
173 goto bad;
174 for (i = 0, p = kwd_list; *p; i++, p++) {
175 x = PyDict_GetItemString(*kwds, *p);
176 if (x) {
177 if (PyDict_SetItemString(kwds1, *p, x) < 0)
178 goto bad;
179 if (PyDict_DelItemString(*kwds2, *p) < 0)
180 goto bad;
181 }
182 else if (rqd_kwds && rqd_kwds[i])
183 goto missing_kwarg;
184 }
185 }
186 else {
187 *kwds2 = PyDict_New();
188 if (!*kwds2)
189 goto bad;
190 }
191 }
192 else {
193 kwds1 = *kwds;
194 Py_XINCREF(kwds1);
195 if (rqd_kwds && *kwds)
196 for (i = 0, p = kwd_list; *p; i++, p++)
197 if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
198 goto missing_kwarg;
199 }
201 *args = args1;
202 *kwds = kwds1;
203 return 0;
204 missing_kwarg:
205 PyErr_Format(PyExc_TypeError,
206 "required keyword argument '%s' is missing", *p);
207 bad:
208 Py_XDECREF(args1);
209 Py_XDECREF(kwds1);
210 if (args2) {
211 Py_XDECREF(*args2);
212 }
213 if (kwds2) {
214 Py_XDECREF(*kwds2);
215 }
216 return -1;
217 }
219 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
220 while (t->p) {
221 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
222 if (!*t->p)
223 return -1;
224 if (t->i)
225 PyString_InternInPlace(t->p);
226 ++t;
227 }
228 return 0;
229 }
231 #include "compile.h"
232 #include "frameobject.h"
233 #include "traceback.h"
235 static void __Pyx_AddTraceback(char *funcname) {
236 PyObject *py_srcfile = 0;
237 PyObject *py_funcname = 0;
238 PyObject *py_globals = 0;
239 PyObject *empty_tuple = 0;
240 PyObject *empty_string = 0;
241 PyCodeObject *py_code = 0;
242 PyFrameObject *py_frame = 0;
244 py_srcfile = PyString_FromString(__pyx_filename);
245 if (!py_srcfile) goto bad;
246 py_funcname = PyString_FromString(funcname);
247 if (!py_funcname) goto bad;
248 py_globals = PyModule_GetDict(__pyx_m);
249 if (!py_globals) goto bad;
250 empty_tuple = PyTuple_New(0);
251 if (!empty_tuple) goto bad;
252 empty_string = PyString_FromString("");
253 if (!empty_string) goto bad;
254 py_code = PyCode_New(
255 0, /*int argcount,*/
256 0, /*int nlocals,*/
257 0, /*int stacksize,*/
258 0, /*int flags,*/
259 empty_string, /*PyObject *code,*/
260 empty_tuple, /*PyObject *consts,*/
261 empty_tuple, /*PyObject *names,*/
262 empty_tuple, /*PyObject *varnames,*/
263 empty_tuple, /*PyObject *freevars,*/
264 empty_tuple, /*PyObject *cellvars,*/
265 py_srcfile, /*PyObject *filename,*/
266 py_funcname, /*PyObject *name,*/
267 __pyx_lineno, /*int firstlineno,*/
268 empty_string /*PyObject *lnotab*/
269 );
270 if (!py_code) goto bad;
271 py_frame = PyFrame_New(
272 PyThreadState_Get(), /*PyThreadState *tstate,*/
273 py_code, /*PyCodeObject *code,*/
274 py_globals, /*PyObject *globals,*/
275 0 /*PyObject *locals*/
276 );
277 if (!py_frame) goto bad;
278 py_frame->f_lineno = __pyx_lineno;
279 PyTraceBack_Here(py_frame);
280 bad:
281 Py_XDECREF(py_srcfile);
282 Py_XDECREF(py_funcname);
283 Py_XDECREF(empty_tuple);
284 Py_XDECREF(empty_string);
285 Py_XDECREF(py_code);
286 Py_XDECREF(py_frame);
287 }