Cython has moved to github.

pyrex

view Tests/9/cimportfunc.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 PyObject *__Pyx_ImportModule(char *name); /*proto*/
44 static int __Pyx_ImportFunction(PyObject *module, char *funcname, void **f, char *sig); /*proto*/
46 static void __Pyx_AddTraceback(char *funcname); /*proto*/
48 /* Declarations from cexportfunc */
50 static int (*__pyx_f_11cexportfunc_f)(void); /*proto*/
51 static char *(*__pyx_f_11cexportfunc_g)(int,float); /*proto*/
53 /* Declarations from cimportfunc */
56 /* Declarations from implementation of cimportfunc */
62 static __Pyx_StringTabEntry __pyx_string_tab[] = {
63 {0, 0, 0, 0}
64 };
68 /* Implementation of cimportfunc */
70 static struct PyMethodDef __pyx_methods[] = {
71 {0, 0, 0, 0}
72 };
74 static void __pyx_init_filenames(void); /*proto*/
76 PyMODINIT_FUNC initcimportfunc(void); /*proto*/
77 PyMODINIT_FUNC initcimportfunc(void) {
78 PyObject *__pyx_1 = 0;
79 __pyx_init_filenames();
80 __pyx_m = Py_InitModule4("cimportfunc", __pyx_methods, 0, 0, PYTHON_API_VERSION);
81 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
82 Py_INCREF(__pyx_m);
83 __pyx_b = PyImport_AddModule("__builtin__");
84 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
85 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
86 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
87 __pyx_1 = __Pyx_ImportModule("cexportfunc"); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
88 if (__Pyx_ImportFunction(__pyx_1, "f", (void**)&__pyx_f_11cexportfunc_f, "int (void)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
89 if (__Pyx_ImportFunction(__pyx_1, "g", (void**)&__pyx_f_11cexportfunc_g, "char *(int,float)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
90 Py_DECREF(__pyx_1); __pyx_1 = 0;
91 return;
92 __pyx_L1:;
93 Py_XDECREF(__pyx_1);
94 __Pyx_AddTraceback("cimportfunc");
95 }
97 static char *__pyx_filenames[] = {
98 "cimportfunc.pyx",
99 };
101 /* Runtime support code */
103 static void __pyx_init_filenames(void) {
104 __pyx_f = __pyx_filenames;
105 }
107 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
108 while (t->p) {
109 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
110 if (!*t->p)
111 return -1;
112 if (t->i)
113 PyString_InternInPlace(t->p);
114 ++t;
115 }
116 return 0;
117 }
119 #ifndef __PYX_HAVE_RT_ImportModule
120 #define __PYX_HAVE_RT_ImportModule
121 static PyObject *__Pyx_ImportModule(char *name) {
122 PyObject *py_name = 0;
124 py_name = PyString_FromString(name);
125 if (!py_name)
126 goto bad;
127 return PyImport_Import(py_name);
128 bad:
129 Py_XDECREF(py_name);
130 return 0;
131 }
132 #endif
134 #ifndef __PYX_HAVE_RT_ImportFunction
135 #define __PYX_HAVE_RT_ImportFunction
136 static int __Pyx_ImportFunction(PyObject *module, char *funcname, void **f, char *sig) {
137 PyObject *d = 0;
138 PyObject *cobj = 0;
139 char *desc;
141 d = PyObject_GetAttrString(module, "__pyx_capi__");
142 if (!d)
143 goto bad;
144 cobj = PyDict_GetItemString(d, funcname);
145 if (!cobj) {
146 PyErr_Format(PyExc_ImportError,
147 "%s does not export expected C function %s",
148 PyModule_GetName(module), funcname);
149 goto bad;
150 }
151 desc = (char *)PyCObject_GetDesc(cobj);
152 if (!desc)
153 goto bad;
154 if (strcmp(desc, sig) != 0) {
155 PyErr_Format(PyExc_TypeError,
156 "C function %s.%s has wrong signature (expected %s, got %s)",
157 PyModule_GetName(module), funcname, sig, desc);
158 goto bad;
159 }
160 *f = PyCObject_AsVoidPtr(cobj);
161 Py_DECREF(d);
162 return 0;
163 bad:
164 Py_XDECREF(d);
165 return -1;
166 }
167 #endif
169 #include "compile.h"
170 #include "frameobject.h"
171 #include "traceback.h"
173 static void __Pyx_AddTraceback(char *funcname) {
174 PyObject *py_srcfile = 0;
175 PyObject *py_funcname = 0;
176 PyObject *py_globals = 0;
177 PyObject *empty_tuple = 0;
178 PyObject *empty_string = 0;
179 PyCodeObject *py_code = 0;
180 PyFrameObject *py_frame = 0;
182 py_srcfile = PyString_FromString(__pyx_filename);
183 if (!py_srcfile) goto bad;
184 py_funcname = PyString_FromString(funcname);
185 if (!py_funcname) goto bad;
186 py_globals = PyModule_GetDict(__pyx_m);
187 if (!py_globals) goto bad;
188 empty_tuple = PyTuple_New(0);
189 if (!empty_tuple) goto bad;
190 empty_string = PyString_FromString("");
191 if (!empty_string) goto bad;
192 py_code = PyCode_New(
193 0, /*int argcount,*/
194 0, /*int nlocals,*/
195 0, /*int stacksize,*/
196 0, /*int flags,*/
197 empty_string, /*PyObject *code,*/
198 empty_tuple, /*PyObject *consts,*/
199 empty_tuple, /*PyObject *names,*/
200 empty_tuple, /*PyObject *varnames,*/
201 empty_tuple, /*PyObject *freevars,*/
202 empty_tuple, /*PyObject *cellvars,*/
203 py_srcfile, /*PyObject *filename,*/
204 py_funcname, /*PyObject *name,*/
205 __pyx_lineno, /*int firstlineno,*/
206 empty_string /*PyObject *lnotab*/
207 );
208 if (!py_code) goto bad;
209 py_frame = PyFrame_New(
210 PyThreadState_Get(), /*PyThreadState *tstate,*/
211 py_code, /*PyCodeObject *code,*/
212 py_globals, /*PyObject *globals,*/
213 0 /*PyObject *locals*/
214 );
215 if (!py_frame) goto bad;
216 py_frame->f_lineno = __pyx_lineno;
217 PyTraceBack_Here(py_frame);
218 bad:
219 Py_XDECREF(py_srcfile);
220 Py_XDECREF(py_funcname);
221 Py_XDECREF(empty_tuple);
222 Py_XDECREF(empty_string);
223 Py_XDECREF(py_code);
224 Py_XDECREF(py_frame);
225 }