Cython has moved to github.
pyrex
view Tests/3/simpcall.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 PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from simpcall */
49 /* Declarations from implementation of simpcall */
51 static void __pyx_f_8simpcall_g(int,float,char *); /*proto*/
52 static PyObject *__pyx_f_8simpcall_h(int,PyObject *); /*proto*/
54 static char __pyx_k1[] = "f";
55 static char __pyx_k2[] = "spam";
56 static char __pyx_k3[] = "eggs";
58 static PyObject *__pyx_n_eggs;
59 static PyObject *__pyx_n_f;
62 static __Pyx_StringTabEntry __pyx_string_tab[] = {
63 {&__pyx_n_eggs, 1, __pyx_k3, sizeof(__pyx_k3)},
64 {&__pyx_n_f, 1, __pyx_k1, sizeof(__pyx_k1)},
65 {0, 0, 0, 0}
66 };
70 /* Implementation of simpcall */
72 static PyObject *__pyx_f_8simpcall_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
73 static PyObject *__pyx_f_8simpcall_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
74 PyObject *__pyx_v_x = 0;
75 PyObject *__pyx_v_y = 0;
76 PyObject *__pyx_r;
77 static char *__pyx_argnames[] = {"x","y",0};
78 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y)) return 0;
79 Py_INCREF(__pyx_v_x);
80 Py_INCREF(__pyx_v_y);
81 Py_INCREF(__pyx_v_y);
82 Py_DECREF(__pyx_v_x);
83 __pyx_v_x = __pyx_v_y;
85 __pyx_r = Py_None; Py_INCREF(Py_None);
86 Py_DECREF(__pyx_v_x);
87 Py_DECREF(__pyx_v_y);
88 return __pyx_r;
89 }
91 static void __pyx_f_8simpcall_g(int __pyx_v_i,float __pyx_v_f,char *__pyx_v_p) {
92 __pyx_v_f = __pyx_v_i;
94 }
96 static PyObject *__pyx_f_8simpcall_h(int __pyx_v_i,PyObject *__pyx_v_obj) {
97 PyObject *__pyx_r;
98 int __pyx_1;
99 Py_INCREF(__pyx_v_obj);
100 __pyx_1 = PyInt_AsLong(__pyx_v_obj); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
101 __pyx_v_i = __pyx_1;
103 __pyx_r = Py_None; Py_INCREF(Py_None);
104 goto __pyx_L0;
105 __pyx_L1:;
106 __Pyx_AddTraceback("simpcall.h");
107 __pyx_r = 0;
108 __pyx_L0:;
109 Py_DECREF(__pyx_v_obj);
110 return __pyx_r;
111 }
113 static PyObject *__pyx_f_8simpcall_z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
114 static PyObject *__pyx_f_8simpcall_z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
115 PyObject *__pyx_v_a = 0;
116 PyObject *__pyx_v_b = 0;
117 PyObject *__pyx_v_c = 0;
118 PyObject *__pyx_r;
119 PyObject *__pyx_1 = 0;
120 PyObject *__pyx_2 = 0;
121 PyObject *__pyx_3 = 0;
122 int __pyx_4;
123 float __pyx_5;
124 char *__pyx_6;
125 static char *__pyx_argnames[] = {"a","b","c",0};
126 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_c)) return 0;
127 Py_INCREF(__pyx_v_a);
128 Py_INCREF(__pyx_v_b);
129 Py_INCREF(__pyx_v_c);
131 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":11 */
132 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_f); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
133 __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
134 Py_DECREF(__pyx_1); __pyx_1 = 0;
135 Py_DECREF(__pyx_2); __pyx_2 = 0;
137 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":12 */
138 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_f); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
139 __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
140 Py_INCREF(__pyx_v_a);
141 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_a);
142 __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
143 Py_DECREF(__pyx_1); __pyx_1 = 0;
144 Py_DECREF(__pyx_2); __pyx_2 = 0;
145 Py_DECREF(__pyx_3); __pyx_3 = 0;
147 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":13 */
148 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_f); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
149 __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
150 Py_INCREF(__pyx_v_a);
151 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_a);
152 Py_INCREF(__pyx_v_b);
153 PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_b);
154 __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
155 Py_DECREF(__pyx_1); __pyx_1 = 0;
156 Py_DECREF(__pyx_2); __pyx_2 = 0;
157 Py_DECREF(__pyx_3); __pyx_3 = 0;
159 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":14 */
160 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_f); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
161 __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
162 Py_INCREF(__pyx_v_a);
163 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_a);
164 Py_INCREF(__pyx_v_b);
165 PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_b);
166 __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
167 Py_DECREF(__pyx_1); __pyx_1 = 0;
168 Py_DECREF(__pyx_2); __pyx_2 = 0;
169 Py_DECREF(__pyx_3); __pyx_3 = 0;
171 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":15 */
172 __pyx_f_8simpcall_g(1,2.0,__pyx_k2);
174 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":16 */
175 __pyx_4 = PyInt_AsLong(__pyx_v_a); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
176 __pyx_5 = PyFloat_AsDouble(__pyx_v_b); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
177 __pyx_6 = PyString_AsString(__pyx_v_c); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
178 __pyx_f_8simpcall_g(__pyx_4,__pyx_5,__pyx_6);
180 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":17 */
181 __pyx_1 = __pyx_f_8simpcall_h(42,__pyx_n_eggs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
182 Py_DECREF(__pyx_1); __pyx_1 = 0;
184 __pyx_r = Py_None; Py_INCREF(Py_None);
185 goto __pyx_L0;
186 __pyx_L1:;
187 Py_XDECREF(__pyx_1);
188 Py_XDECREF(__pyx_2);
189 Py_XDECREF(__pyx_3);
190 __Pyx_AddTraceback("simpcall.z");
191 __pyx_r = 0;
192 __pyx_L0:;
193 Py_DECREF(__pyx_v_a);
194 Py_DECREF(__pyx_v_b);
195 Py_DECREF(__pyx_v_c);
196 return __pyx_r;
197 }
199 static struct PyMethodDef __pyx_methods[] = {
200 {"f", (PyCFunction)__pyx_f_8simpcall_f, METH_VARARGS|METH_KEYWORDS, 0},
201 {"z", (PyCFunction)__pyx_f_8simpcall_z, METH_VARARGS|METH_KEYWORDS, 0},
202 {0, 0, 0, 0}
203 };
205 static void __pyx_init_filenames(void); /*proto*/
207 PyMODINIT_FUNC initsimpcall(void); /*proto*/
208 PyMODINIT_FUNC initsimpcall(void) {
209 __pyx_init_filenames();
210 __pyx_m = Py_InitModule4("simpcall", __pyx_methods, 0, 0, PYTHON_API_VERSION);
211 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
212 Py_INCREF(__pyx_m);
213 __pyx_b = PyImport_AddModule("__builtin__");
214 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
215 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
216 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
218 /* "/Local/Projects/D/Pyrex/Source/Tests/3/simpcall.pyx":10 */
219 return;
220 __pyx_L1:;
221 __Pyx_AddTraceback("simpcall");
222 }
224 static char *__pyx_filenames[] = {
225 "simpcall.pyx",
226 };
228 /* Runtime support code */
230 static void __pyx_init_filenames(void) {
231 __pyx_f = __pyx_filenames;
232 }
234 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
235 PyObject *result;
236 result = PyObject_GetAttr(dict, name);
237 if (!result)
238 PyErr_SetObject(PyExc_NameError, name);
239 return result;
240 }
242 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
243 while (t->p) {
244 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
245 if (!*t->p)
246 return -1;
247 if (t->i)
248 PyString_InternInPlace(t->p);
249 ++t;
250 }
251 return 0;
252 }
254 #include "compile.h"
255 #include "frameobject.h"
256 #include "traceback.h"
258 static void __Pyx_AddTraceback(char *funcname) {
259 PyObject *py_srcfile = 0;
260 PyObject *py_funcname = 0;
261 PyObject *py_globals = 0;
262 PyObject *empty_tuple = 0;
263 PyObject *empty_string = 0;
264 PyCodeObject *py_code = 0;
265 PyFrameObject *py_frame = 0;
267 py_srcfile = PyString_FromString(__pyx_filename);
268 if (!py_srcfile) goto bad;
269 py_funcname = PyString_FromString(funcname);
270 if (!py_funcname) goto bad;
271 py_globals = PyModule_GetDict(__pyx_m);
272 if (!py_globals) goto bad;
273 empty_tuple = PyTuple_New(0);
274 if (!empty_tuple) goto bad;
275 empty_string = PyString_FromString("");
276 if (!empty_string) goto bad;
277 py_code = PyCode_New(
278 0, /*int argcount,*/
279 0, /*int nlocals,*/
280 0, /*int stacksize,*/
281 0, /*int flags,*/
282 empty_string, /*PyObject *code,*/
283 empty_tuple, /*PyObject *consts,*/
284 empty_tuple, /*PyObject *names,*/
285 empty_tuple, /*PyObject *varnames,*/
286 empty_tuple, /*PyObject *freevars,*/
287 empty_tuple, /*PyObject *cellvars,*/
288 py_srcfile, /*PyObject *filename,*/
289 py_funcname, /*PyObject *name,*/
290 __pyx_lineno, /*int firstlineno,*/
291 empty_string /*PyObject *lnotab*/
292 );
293 if (!py_code) goto bad;
294 py_frame = PyFrame_New(
295 PyThreadState_Get(), /*PyThreadState *tstate,*/
296 py_code, /*PyCodeObject *code,*/
297 py_globals, /*PyObject *globals,*/
298 0 /*PyObject *locals*/
299 );
300 if (!py_frame) goto bad;
301 py_frame->f_lineno = __pyx_lineno;
302 PyTraceBack_Here(py_frame);
303 bad:
304 Py_XDECREF(py_srcfile);
305 Py_XDECREF(py_funcname);
306 Py_XDECREF(empty_tuple);
307 Py_XDECREF(empty_string);
308 Py_XDECREF(py_code);
309 Py_XDECREF(py_frame);
310 }
