Cython has moved to github.
pyrex
view Tests/8/Reference/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 | 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 PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
43 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
45 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
47 static PyObject *__Pyx_ImportModule(char *name); /*proto*/
49 static void __Pyx_AddTraceback(char *funcname); /*proto*/
51 /* Declarations from spam */
53 struct __pyx_t_4spam_Spam {
54 int i;
55 char *s;
56 };
58 __PYX_EXTERN_C float tons;
59 __PYX_EXTERN_C DL_EXPORT(void) eat(struct __pyx_t_4spam_Spam); /*proto*/
61 /* Declarations from pkg.eggs */
63 struct __pyx_obj_3pkg_4eggs_Eggs {
64 PyObject_HEAD
65 };
68 static PyTypeObject *__pyx_ptype_3pkg_4eggs_Eggs = 0;
70 /* Declarations from pkg */
73 /* Declarations from cimport */
75 static struct __pyx_t_4spam_Spam __pyx_v_7cimport_yummy;
76 static struct __pyx_obj_3pkg_4eggs_Eggs *__pyx_v_7cimport_fried;
79 static __Pyx_StringTabEntry __pyx_string_tab[] = {
80 {&__pyx_n_eggs, 1, __pyx_k1, sizeof(__pyx_k1)},
81 {&__pyx_n_ova, 1, __pyx_k2, sizeof(__pyx_k2)},
82 {&__pyx_n_pkg, 1, __pyx_k3, sizeof(__pyx_k3)},
83 {0, 0, 0, 0}
84 };
86 /* Implementation of cimport */
90 static struct PyMethodDef __pyx_methods[] = {
91 {0, 0, 0, 0}
92 };
94 static void __pyx_init_filenames(void); /*proto*/
96 PyMODINIT_FUNC initcimport(void); /*proto*/
97 PyMODINIT_FUNC initcimport(void) {
98 PyObject *__pyx_1 = 0;
99 PyObject *__pyx_2 = 0;
100 __pyx_init_filenames();
101 __pyx_m = Py_InitModule4("cimport", __pyx_methods, 0, 0, PYTHON_API_VERSION);
102 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
103 Py_INCREF(__pyx_m);
104 __pyx_b = PyImport_AddModule("__builtin__");
105 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
106 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
107 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
108 __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)Py_None); Py_INCREF(Py_None);
109 __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;}
111 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":7 */
112 eat(__pyx_v_7cimport_yummy);
114 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":8 */
115 tons = 3.14;
117 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":9 */
118 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_pkg); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
119 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_eggs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
120 Py_DECREF(__pyx_1); __pyx_1 = 0;
121 if (PyObject_SetAttr(__pyx_m, __pyx_n_ova, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
122 Py_DECREF(__pyx_2); __pyx_2 = 0;
124 /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":10 */
125 __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;}
126 Py_DECREF(((PyObject *)__pyx_v_7cimport_fried));
127 __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)__pyx_1);
128 __pyx_1 = 0;
129 return;
130 __pyx_L1:;
131 Py_XDECREF(__pyx_1);
132 Py_XDECREF(__pyx_2);
133 __Pyx_AddTraceback("cimport");
134 }
136 static char *__pyx_filenames[] = {
137 "cimport.pyx",
138 "pkg.eggs.pxd",
139 };
141 /* Runtime support code */
143 static void __pyx_init_filenames(void) {
144 __pyx_f = __pyx_filenames;
145 }
147 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
148 PyObject *result;
149 result = PyObject_GetAttr(dict, name);
150 if (!result)
151 PyErr_SetObject(PyExc_NameError, name);
152 return result;
153 }
155 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
156 while (t->p) {
157 *t->p = PyString_InternFromString(t->s);
158 if (!*t->p)
159 return -1;
160 ++t;
161 }
162 return 0;
163 }
165 #ifndef __PYX_HAVE_RT_ImportType
166 #define __PYX_HAVE_RT_ImportType
167 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
168 long size)
169 {
170 PyObject *py_module = 0;
171 PyObject *result = 0;
173 py_module = __Pyx_ImportModule(module_name);
174 if (!py_module)
175 goto bad;
176 result = PyObject_GetAttrString(py_module, class_name);
177 if (!result)
178 goto bad;
179 if (!PyType_Check(result)) {
180 PyErr_Format(PyExc_TypeError,
181 "%s.%s is not a type object",
182 module_name, class_name);
183 goto bad;
184 }
185 if (((PyTypeObject *)result)->tp_basicsize != size) {
186 PyErr_Format(PyExc_ValueError,
187 "%s.%s does not appear to be the correct type object",
188 module_name, class_name);
189 goto bad;
190 }
191 return (PyTypeObject *)result;
192 bad:
193 Py_XDECREF(result);
194 return 0;
195 }
196 #endif
198 #ifndef __PYX_HAVE_RT_ImportModule
199 #define __PYX_HAVE_RT_ImportModule
200 static PyObject *__Pyx_ImportModule(char *name) {
201 PyObject *py_name = 0;
203 py_name = PyString_FromString(name);
204 if (!py_name)
205 goto bad;
206 return PyImport_Import(py_name);
207 bad:
208 Py_XDECREF(py_name);
209 return 0;
210 }
211 #endif
213 #include "compile.h"
214 #include "frameobject.h"
215 #include "traceback.h"
217 static void __Pyx_AddTraceback(char *funcname) {
218 PyObject *py_srcfile = 0;
219 PyObject *py_funcname = 0;
220 PyObject *py_globals = 0;
221 PyObject *empty_tuple = 0;
222 PyObject *empty_string = 0;
223 PyCodeObject *py_code = 0;
224 PyFrameObject *py_frame = 0;
226 py_srcfile = PyString_FromString(__pyx_filename);
227 if (!py_srcfile) goto bad;
228 py_funcname = PyString_FromString(funcname);
229 if (!py_funcname) goto bad;
230 py_globals = PyModule_GetDict(__pyx_m);
231 if (!py_globals) goto bad;
232 empty_tuple = PyTuple_New(0);
233 if (!empty_tuple) goto bad;
234 empty_string = PyString_FromString("");
235 if (!empty_string) goto bad;
236 py_code = PyCode_New(
237 0, /*int argcount,*/
238 0, /*int nlocals,*/
239 0, /*int stacksize,*/
240 0, /*int flags,*/
241 empty_string, /*PyObject *code,*/
242 empty_tuple, /*PyObject *consts,*/
243 empty_tuple, /*PyObject *names,*/
244 empty_tuple, /*PyObject *varnames,*/
245 empty_tuple, /*PyObject *freevars,*/
246 empty_tuple, /*PyObject *cellvars,*/
247 py_srcfile, /*PyObject *filename,*/
248 py_funcname, /*PyObject *name,*/
249 __pyx_lineno, /*int firstlineno,*/
250 empty_string /*PyObject *lnotab*/
251 );
252 if (!py_code) goto bad;
253 py_frame = PyFrame_New(
254 PyThreadState_Get(), /*PyThreadState *tstate,*/
255 py_code, /*PyCodeObject *code,*/
256 py_globals, /*PyObject *globals,*/
257 0 /*PyObject *locals*/
258 );
259 if (!py_frame) goto bad;
260 py_frame->f_lineno = __pyx_lineno;
261 PyTraceBack_Here(py_frame);
262 bad:
263 Py_XDECREF(py_srcfile);
264 Py_XDECREF(py_funcname);
265 Py_XDECREF(empty_tuple);
266 Py_XDECREF(empty_string);
267 Py_XDECREF(py_code);
268 Py_XDECREF(py_frame);
269 }
