Cython has moved to github.

pyrex

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