Cython has moved to github.

pyrex

view Tests/8/cimport.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 PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
44 static PyObject *__Pyx_ImportModule(char *name); /*proto*/
46 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
48 static void __Pyx_AddTraceback(char *funcname); /*proto*/
50 /* Declarations from spam */
52 struct __pyx_t_4spam_Spam {
53 int i;
54 char *s;
55 };
57 __PYX_EXTERN_C float tons;
58 __PYX_EXTERN_C DL_EXPORT(void) (*eat)(struct __pyx_t_4spam_Spam); /*proto*/
60 /* Declarations from pkg.eggs */
62 struct __pyx_obj_3pkg_4eggs_Eggs {
63 PyObject_HEAD
64 };
67 static PyTypeObject *__pyx_ptype_3pkg_4eggs_Eggs = 0;
69 /* Declarations from pkg */
72 /* Declarations from cimport */
75 /* Declarations from implementation of cimport */
77 static struct __pyx_t_4spam_Spam __pyx_v_7cimport_yummy;
78 static struct __pyx_obj_3pkg_4eggs_Eggs *__pyx_v_7cimport_fried;
80 static char __pyx_k1[] = "pkg";
81 static char __pyx_k2[] = "eggs";
82 static char __pyx_k3[] = "ova";
84 static PyObject *__pyx_n_eggs;
85 static PyObject *__pyx_n_ova;
86 static PyObject *__pyx_n_pkg;
89 static __Pyx_StringTabEntry __pyx_string_tab[] = {
90 {&__pyx_n_eggs, 1, __pyx_k2, sizeof(__pyx_k2)},
91 {&__pyx_n_ova, 1, __pyx_k3, sizeof(__pyx_k3)},
92 {&__pyx_n_pkg, 1, __pyx_k1, sizeof(__pyx_k1)},
93 {0, 0, 0, 0}
94 };
98 /* Implementation of cimport */
100 static struct PyMethodDef __pyx_methods[] = {
101 {0, 0, 0, 0}
102 };
104 static void __pyx_init_filenames(void); /*proto*/
106 PyMODINIT_FUNC initcimport(void); /*proto*/
107 PyMODINIT_FUNC initcimport(void) {
108 PyObject *__pyx_1 = 0;
109 PyObject *__pyx_2 = 0;
110 __pyx_init_filenames();
111 __pyx_m = Py_InitModule4("cimport", __pyx_methods, 0, 0, PYTHON_API_VERSION);
112 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
113 Py_INCREF(__pyx_m);
114 __pyx_b = PyImport_AddModule("__builtin__");
115 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
116 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
117 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
118 __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)Py_None); Py_INCREF(Py_None);
119 __pyx_ptype_3pkg_4eggs_Eggs = __Pyx_ImportType("pkg.eggs", "Eggs", sizeof(struct __pyx_obj_3pkg_4eggs_Eggs)); if (!__pyx_ptype_3pkg_4eggs_Eggs) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; goto __pyx_L1;}
121 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":7 */
122 eat(__pyx_v_7cimport_yummy);
124 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":8 */
125 tons = 3.14;
127 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":9 */
128 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_pkg); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
129 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_eggs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
130 Py_DECREF(__pyx_1); __pyx_1 = 0;
131 if (PyObject_SetAttr(__pyx_m, __pyx_n_ova, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
132 Py_DECREF(__pyx_2); __pyx_2 = 0;
134 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":10 */
135 __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_3pkg_4eggs_Eggs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
136 Py_DECREF(((PyObject *)__pyx_v_7cimport_fried));
137 __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)__pyx_1);
138 __pyx_1 = 0;
139 return;
140 __pyx_L1:;
141 Py_XDECREF(__pyx_1);
142 Py_XDECREF(__pyx_2);
143 __Pyx_AddTraceback("cimport");
144 }
146 static char *__pyx_filenames[] = {
147 "cimport.pyx",
148 "pkg.eggs.pxd",
149 };
151 /* Runtime support code */
153 static void __pyx_init_filenames(void) {
154 __pyx_f = __pyx_filenames;
155 }
157 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
158 while (t->p) {
159 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
160 if (!*t->p)
161 return -1;
162 if (t->i)
163 PyString_InternInPlace(t->p);
164 ++t;
165 }
166 return 0;
167 }
169 #ifndef __PYX_HAVE_RT_ImportType
170 #define __PYX_HAVE_RT_ImportType
171 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
172 long size)
173 {
174 PyObject *py_module = 0;
175 PyObject *result = 0;
177 py_module = __Pyx_ImportModule(module_name);
178 if (!py_module)
179 goto bad;
180 result = PyObject_GetAttrString(py_module, class_name);
181 if (!result)
182 goto bad;
183 if (!PyType_Check(result)) {
184 PyErr_Format(PyExc_TypeError,
185 "%s.%s is not a type object",
186 module_name, class_name);
187 goto bad;
188 }
189 if (((PyTypeObject *)result)->tp_basicsize != size) {
190 PyErr_Format(PyExc_ValueError,
191 "%s.%s does not appear to be the correct type object",
192 module_name, class_name);
193 goto bad;
194 }
195 return (PyTypeObject *)result;
196 bad:
197 Py_XDECREF(result);
198 return 0;
199 }
200 #endif
202 #ifndef __PYX_HAVE_RT_ImportModule
203 #define __PYX_HAVE_RT_ImportModule
204 static PyObject *__Pyx_ImportModule(char *name) {
205 PyObject *py_name = 0;
207 py_name = PyString_FromString(name);
208 if (!py_name)
209 goto bad;
210 return PyImport_Import(py_name);
211 bad:
212 Py_XDECREF(py_name);
213 return 0;
214 }
215 #endif
217 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
218 PyObject *result;
219 result = PyObject_GetAttr(dict, name);
220 if (!result)
221 PyErr_SetObject(PyExc_NameError, name);
222 return result;
223 }
225 #include "compile.h"
226 #include "frameobject.h"
227 #include "traceback.h"
229 static void __Pyx_AddTraceback(char *funcname) {
230 PyObject *py_srcfile = 0;
231 PyObject *py_funcname = 0;
232 PyObject *py_globals = 0;
233 PyObject *empty_tuple = 0;
234 PyObject *empty_string = 0;
235 PyCodeObject *py_code = 0;
236 PyFrameObject *py_frame = 0;
238 py_srcfile = PyString_FromString(__pyx_filename);
239 if (!py_srcfile) goto bad;
240 py_funcname = PyString_FromString(funcname);
241 if (!py_funcname) goto bad;
242 py_globals = PyModule_GetDict(__pyx_m);
243 if (!py_globals) goto bad;
244 empty_tuple = PyTuple_New(0);
245 if (!empty_tuple) goto bad;
246 empty_string = PyString_FromString("");
247 if (!empty_string) goto bad;
248 py_code = PyCode_New(
249 0, /*int argcount,*/
250 0, /*int nlocals,*/
251 0, /*int stacksize,*/
252 0, /*int flags,*/
253 empty_string, /*PyObject *code,*/
254 empty_tuple, /*PyObject *consts,*/
255 empty_tuple, /*PyObject *names,*/
256 empty_tuple, /*PyObject *varnames,*/
257 empty_tuple, /*PyObject *freevars,*/
258 empty_tuple, /*PyObject *cellvars,*/
259 py_srcfile, /*PyObject *filename,*/
260 py_funcname, /*PyObject *name,*/
261 __pyx_lineno, /*int firstlineno,*/
262 empty_string /*PyObject *lnotab*/
263 );
264 if (!py_code) goto bad;
265 py_frame = PyFrame_New(
266 PyThreadState_Get(), /*PyThreadState *tstate,*/
267 py_code, /*PyCodeObject *code,*/
268 py_globals, /*PyObject *globals,*/
269 0 /*PyObject *locals*/
270 );
271 if (!py_frame) goto bad;
272 py_frame->f_lineno = __pyx_lineno;
273 PyTraceBack_Here(py_frame);
274 bad:
275 Py_XDECREF(py_srcfile);
276 Py_XDECREF(py_funcname);
277 Py_XDECREF(empty_tuple);
278 Py_XDECREF(empty_string);
279 Py_XDECREF(py_code);
280 Py_XDECREF(py_frame);
281 }