Cython has moved to github.

pyrex

view Tests/9/a_capi.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 int __Pyx_ExportFunction(char *n, void *f, char *s); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from a_capi */
49 /* Declarations from implementation of a_capi */
51 struct Foo {
52 int a;
53 int b;
54 };
56 typedef struct {
57 int c;
58 int d;
59 } __pyx_t_6a_capi_Blarg;
61 typedef struct Foo Zax;
63 struct C_Obj {
64 PyObject_HEAD
65 };
67 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) C_Type;
69 static PyTypeObject *__pyx_ptype_6a_capi_C = 0;
70 Zax *blarg;
71 static float f(struct Foo *); /*proto*/
72 __PYX_EXTERN_C DL_EXPORT(void) g(__pyx_t_6a_capi_Blarg *); /*proto*/
73 __PYX_EXTERN_C DL_EXPORT(void) h(Zax *); /*proto*/
78 static __Pyx_StringTabEntry __pyx_string_tab[] = {
79 {0, 0, 0, 0}
80 };
84 /* Implementation of a_capi */
86 static float f(struct Foo *__pyx_v_x) {
87 float __pyx_r;
89 __pyx_r = 0;
90 return __pyx_r;
91 }
93 __PYX_EXTERN_C DL_EXPORT(void) g(__pyx_t_6a_capi_Blarg *__pyx_v_x) {
95 }
97 __PYX_EXTERN_C DL_EXPORT(void) h(Zax *__pyx_v_x) {
99 }
101 static PyObject *__pyx_tp_new_6a_capi_C(PyTypeObject *t, PyObject *a, PyObject *k) {
102 PyObject *o = (*t->tp_alloc)(t, 0);
103 if (!o) return 0;
104 return o;
105 }
107 static void __pyx_tp_dealloc_6a_capi_C(PyObject *o) {
108 (*o->ob_type->tp_free)(o);
109 }
111 static struct PyMethodDef __pyx_methods_6a_capi_C[] = {
112 {0, 0, 0, 0}
113 };
115 static PyNumberMethods __pyx_tp_as_number_C = {
116 0, /*nb_add*/
117 0, /*nb_subtract*/
118 0, /*nb_multiply*/
119 0, /*nb_divide*/
120 0, /*nb_remainder*/
121 0, /*nb_divmod*/
122 0, /*nb_power*/
123 0, /*nb_negative*/
124 0, /*nb_positive*/
125 0, /*nb_absolute*/
126 0, /*nb_nonzero*/
127 0, /*nb_invert*/
128 0, /*nb_lshift*/
129 0, /*nb_rshift*/
130 0, /*nb_and*/
131 0, /*nb_xor*/
132 0, /*nb_or*/
133 0, /*nb_coerce*/
134 0, /*nb_int*/
135 0, /*nb_long*/
136 0, /*nb_float*/
137 0, /*nb_oct*/
138 0, /*nb_hex*/
139 0, /*nb_inplace_add*/
140 0, /*nb_inplace_subtract*/
141 0, /*nb_inplace_multiply*/
142 0, /*nb_inplace_divide*/
143 0, /*nb_inplace_remainder*/
144 0, /*nb_inplace_power*/
145 0, /*nb_inplace_lshift*/
146 0, /*nb_inplace_rshift*/
147 0, /*nb_inplace_and*/
148 0, /*nb_inplace_xor*/
149 0, /*nb_inplace_or*/
150 0, /*nb_floor_divide*/
151 0, /*nb_true_divide*/
152 0, /*nb_inplace_floor_divide*/
153 0, /*nb_inplace_true_divide*/
154 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
155 0, /*nb_index*/
156 #endif
157 };
159 static PySequenceMethods __pyx_tp_as_sequence_C = {
160 0, /*sq_length*/
161 0, /*sq_concat*/
162 0, /*sq_repeat*/
163 0, /*sq_item*/
164 0, /*sq_slice*/
165 0, /*sq_ass_item*/
166 0, /*sq_ass_slice*/
167 0, /*sq_contains*/
168 0, /*sq_inplace_concat*/
169 0, /*sq_inplace_repeat*/
170 };
172 static PyMappingMethods __pyx_tp_as_mapping_C = {
173 0, /*mp_length*/
174 0, /*mp_subscript*/
175 0, /*mp_ass_subscript*/
176 };
178 static PyBufferProcs __pyx_tp_as_buffer_C = {
179 0, /*bf_getreadbuffer*/
180 0, /*bf_getwritebuffer*/
181 0, /*bf_getsegcount*/
182 0, /*bf_getcharbuffer*/
183 };
185 DL_EXPORT(PyTypeObject) C_Type = {
186 PyObject_HEAD_INIT(0)
187 0, /*ob_size*/
188 "a_capi.C", /*tp_name*/
189 sizeof(struct C_Obj), /*tp_basicsize*/
190 0, /*tp_itemsize*/
191 __pyx_tp_dealloc_6a_capi_C, /*tp_dealloc*/
192 0, /*tp_print*/
193 0, /*tp_getattr*/
194 0, /*tp_setattr*/
195 0, /*tp_compare*/
196 0, /*tp_repr*/
197 &__pyx_tp_as_number_C, /*tp_as_number*/
198 &__pyx_tp_as_sequence_C, /*tp_as_sequence*/
199 &__pyx_tp_as_mapping_C, /*tp_as_mapping*/
200 0, /*tp_hash*/
201 0, /*tp_call*/
202 0, /*tp_str*/
203 0, /*tp_getattro*/
204 0, /*tp_setattro*/
205 &__pyx_tp_as_buffer_C, /*tp_as_buffer*/
206 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
207 0, /*tp_doc*/
208 0, /*tp_traverse*/
209 0, /*tp_clear*/
210 0, /*tp_richcompare*/
211 0, /*tp_weaklistoffset*/
212 0, /*tp_iter*/
213 0, /*tp_iternext*/
214 __pyx_methods_6a_capi_C, /*tp_methods*/
215 0, /*tp_members*/
216 0, /*tp_getset*/
217 0, /*tp_base*/
218 0, /*tp_dict*/
219 0, /*tp_descr_get*/
220 0, /*tp_descr_set*/
221 0, /*tp_dictoffset*/
222 0, /*tp_init*/
223 0, /*tp_alloc*/
224 __pyx_tp_new_6a_capi_C, /*tp_new*/
225 0, /*tp_free*/
226 0, /*tp_is_gc*/
227 0, /*tp_bases*/
228 0, /*tp_mro*/
229 0, /*tp_cache*/
230 0, /*tp_subclasses*/
231 0, /*tp_weaklist*/
232 };
234 static struct PyMethodDef __pyx_methods[] = {
235 {0, 0, 0, 0}
236 };
238 static void __pyx_init_filenames(void); /*proto*/
240 PyMODINIT_FUNC inita_capi(void); /*proto*/
241 PyMODINIT_FUNC inita_capi(void) {
242 __pyx_init_filenames();
243 __pyx_m = Py_InitModule4("a_capi", __pyx_methods, 0, 0, PYTHON_API_VERSION);
244 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
245 Py_INCREF(__pyx_m);
246 __pyx_b = PyImport_AddModule("__builtin__");
247 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
248 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
249 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
250 if (__Pyx_ExportFunction("f", (void*)f, "float (struct Foo *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
251 if (__Pyx_ExportFunction("h", (void*)h, "void (Zax *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
252 if (PyType_Ready(&C_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
253 if (PyObject_SetAttrString(__pyx_m, "C", (PyObject *)&C_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
254 __pyx_ptype_6a_capi_C = &C_Type;
256 /* "/Local/Projects/D/Pyrex/Source/Tests/9/a_capi.pyx":20 */
257 return;
258 __pyx_L1:;
259 __Pyx_AddTraceback("a_capi");
260 }
262 static char *__pyx_filenames[] = {
263 "a_capi.pyx",
264 };
266 /* Runtime support code */
268 static void __pyx_init_filenames(void) {
269 __pyx_f = __pyx_filenames;
270 }
272 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
273 while (t->p) {
274 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
275 if (!*t->p)
276 return -1;
277 if (t->i)
278 PyString_InternInPlace(t->p);
279 ++t;
280 }
281 return 0;
282 }
284 static int __Pyx_ExportFunction(char *n, void *f, char *s) {
285 PyObject *d = 0;
286 PyObject *p = 0;
287 d = PyObject_GetAttrString(__pyx_m, "__pyx_capi__");
288 if (!d) {
289 PyErr_Clear();
290 d = PyDict_New();
291 if (!d)
292 goto bad;
293 Py_INCREF(d);
294 if (PyModule_AddObject(__pyx_m, "__pyx_capi__", d) < 0)
295 goto bad;
296 }
297 p = PyCObject_FromVoidPtrAndDesc(f, s, 0);
298 if (!p)
299 goto bad;
300 if (PyDict_SetItemString(d, n, p) < 0)
301 goto bad;
302 Py_DECREF(d);
303 return 0;
304 bad:
305 Py_XDECREF(p);
306 Py_XDECREF(d);
307 return -1;
308 }
310 #include "compile.h"
311 #include "frameobject.h"
312 #include "traceback.h"
314 static void __Pyx_AddTraceback(char *funcname) {
315 PyObject *py_srcfile = 0;
316 PyObject *py_funcname = 0;
317 PyObject *py_globals = 0;
318 PyObject *empty_tuple = 0;
319 PyObject *empty_string = 0;
320 PyCodeObject *py_code = 0;
321 PyFrameObject *py_frame = 0;
323 py_srcfile = PyString_FromString(__pyx_filename);
324 if (!py_srcfile) goto bad;
325 py_funcname = PyString_FromString(funcname);
326 if (!py_funcname) goto bad;
327 py_globals = PyModule_GetDict(__pyx_m);
328 if (!py_globals) goto bad;
329 empty_tuple = PyTuple_New(0);
330 if (!empty_tuple) goto bad;
331 empty_string = PyString_FromString("");
332 if (!empty_string) goto bad;
333 py_code = PyCode_New(
334 0, /*int argcount,*/
335 0, /*int nlocals,*/
336 0, /*int stacksize,*/
337 0, /*int flags,*/
338 empty_string, /*PyObject *code,*/
339 empty_tuple, /*PyObject *consts,*/
340 empty_tuple, /*PyObject *names,*/
341 empty_tuple, /*PyObject *varnames,*/
342 empty_tuple, /*PyObject *freevars,*/
343 empty_tuple, /*PyObject *cellvars,*/
344 py_srcfile, /*PyObject *filename,*/
345 py_funcname, /*PyObject *name,*/
346 __pyx_lineno, /*int firstlineno,*/
347 empty_string /*PyObject *lnotab*/
348 );
349 if (!py_code) goto bad;
350 py_frame = PyFrame_New(
351 PyThreadState_Get(), /*PyThreadState *tstate,*/
352 py_code, /*PyCodeObject *code,*/
353 py_globals, /*PyObject *globals,*/
354 0 /*PyObject *locals*/
355 );
356 if (!py_frame) goto bad;
357 py_frame->f_lineno = __pyx_lineno;
358 PyTraceBack_Here(py_frame);
359 bad:
360 Py_XDECREF(py_srcfile);
361 Py_XDECREF(py_funcname);
362 Py_XDECREF(empty_tuple);
363 Py_XDECREF(empty_string);
364 Py_XDECREF(py_code);
365 Py_XDECREF(py_frame);
366 }