Cython has moved to github.
pyrex
view Tests/3/fromimport.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_Import(PyObject *name, PyObject *from_list); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from fromimport */
49 /* Declarations from implementation of fromimport */
52 static char __pyx_k1[] = "spam";
53 static char __pyx_k2[] = "eggs";
54 static char __pyx_k3[] = "spam.morespam";
55 static char __pyx_k4[] = "bacon";
56 static char __pyx_k5[] = "ham";
58 static PyObject *__pyx_n_bacon;
59 static PyObject *__pyx_n_eggs;
60 static PyObject *__pyx_n_ham;
61 static PyObject *__pyx_n_spam;
63 static PyObject *__pyx_k3p;
65 static __Pyx_StringTabEntry __pyx_string_tab[] = {
66 {&__pyx_n_bacon, 1, __pyx_k4, sizeof(__pyx_k4)},
67 {&__pyx_n_eggs, 1, __pyx_k2, sizeof(__pyx_k2)},
68 {&__pyx_n_ham, 1, __pyx_k5, sizeof(__pyx_k5)},
69 {&__pyx_n_spam, 1, __pyx_k1, sizeof(__pyx_k1)},
70 {&__pyx_k3p, 0, __pyx_k3, sizeof(__pyx_k3)},
71 {0, 0, 0, 0}
72 };
76 /* Implementation of fromimport */
78 static PyObject *__pyx_f_10fromimport_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
79 static PyObject *__pyx_f_10fromimport_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
80 PyObject *__pyx_v_eggs;
81 PyObject *__pyx_v_bacon;
82 PyObject *__pyx_v_ham;
83 PyObject *__pyx_v_ova;
84 PyObject *__pyx_r;
85 PyObject *__pyx_1 = 0;
86 PyObject *__pyx_2 = 0;
87 static char *__pyx_argnames[] = {0};
88 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
89 __pyx_v_eggs = Py_None; Py_INCREF(Py_None);
90 __pyx_v_bacon = Py_None; Py_INCREF(Py_None);
91 __pyx_v_ham = Py_None; Py_INCREF(Py_None);
92 __pyx_v_ova = Py_None; Py_INCREF(Py_None);
94 /* "/Local/Projects/D/Pyrex/Source/Tests/3/fromimport.pyx":2 */
95 __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
96 Py_INCREF(__pyx_n_eggs);
97 PyList_SET_ITEM(__pyx_1, 0, __pyx_n_eggs);
98 __pyx_2 = __Pyx_Import(__pyx_n_spam, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
99 Py_DECREF(__pyx_1); __pyx_1 = 0;
100 __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_eggs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
101 Py_DECREF(__pyx_v_eggs);
102 __pyx_v_eggs = __pyx_1;
103 __pyx_1 = 0;
104 Py_DECREF(__pyx_2); __pyx_2 = 0;
106 /* "/Local/Projects/D/Pyrex/Source/Tests/3/fromimport.pyx":3 */
107 __pyx_2 = PyList_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
108 Py_INCREF(__pyx_n_bacon);
109 PyList_SET_ITEM(__pyx_2, 0, __pyx_n_bacon);
110 Py_INCREF(__pyx_n_eggs);
111 PyList_SET_ITEM(__pyx_2, 1, __pyx_n_eggs);
112 Py_INCREF(__pyx_n_ham);
113 PyList_SET_ITEM(__pyx_2, 2, __pyx_n_ham);
114 __pyx_1 = __Pyx_Import(__pyx_k3p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
115 Py_DECREF(__pyx_2); __pyx_2 = 0;
116 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bacon); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
117 Py_DECREF(__pyx_v_bacon);
118 __pyx_v_bacon = __pyx_2;
119 __pyx_2 = 0;
120 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_eggs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
121 Py_DECREF(__pyx_v_eggs);
122 __pyx_v_eggs = __pyx_2;
123 __pyx_2 = 0;
124 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_ham); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
125 Py_DECREF(__pyx_v_ham);
126 __pyx_v_ham = __pyx_2;
127 __pyx_2 = 0;
128 Py_DECREF(__pyx_1); __pyx_1 = 0;
130 /* "/Local/Projects/D/Pyrex/Source/Tests/3/fromimport.pyx":4 */
131 __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
132 Py_INCREF(__pyx_n_eggs);
133 PyList_SET_ITEM(__pyx_1, 0, __pyx_n_eggs);
134 __pyx_2 = __Pyx_Import(__pyx_n_spam, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
135 Py_DECREF(__pyx_1); __pyx_1 = 0;
136 __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_eggs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
137 Py_DECREF(__pyx_v_ova);
138 __pyx_v_ova = __pyx_1;
139 __pyx_1 = 0;
140 Py_DECREF(__pyx_2); __pyx_2 = 0;
142 __pyx_r = Py_None; Py_INCREF(Py_None);
143 goto __pyx_L0;
144 __pyx_L1:;
145 Py_XDECREF(__pyx_1);
146 Py_XDECREF(__pyx_2);
147 __Pyx_AddTraceback("fromimport.f");
148 __pyx_r = 0;
149 __pyx_L0:;
150 Py_DECREF(__pyx_v_eggs);
151 Py_DECREF(__pyx_v_bacon);
152 Py_DECREF(__pyx_v_ham);
153 Py_DECREF(__pyx_v_ova);
154 return __pyx_r;
155 }
157 static struct PyMethodDef __pyx_methods[] = {
158 {"f", (PyCFunction)__pyx_f_10fromimport_f, METH_VARARGS|METH_KEYWORDS, 0},
159 {0, 0, 0, 0}
160 };
162 static void __pyx_init_filenames(void); /*proto*/
164 PyMODINIT_FUNC initfromimport(void); /*proto*/
165 PyMODINIT_FUNC initfromimport(void) {
166 __pyx_init_filenames();
167 __pyx_m = Py_InitModule4("fromimport", __pyx_methods, 0, 0, PYTHON_API_VERSION);
168 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
169 Py_INCREF(__pyx_m);
170 __pyx_b = PyImport_AddModule("__builtin__");
171 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
172 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
173 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
174 return;
175 __pyx_L1:;
176 __Pyx_AddTraceback("fromimport");
177 }
179 static char *__pyx_filenames[] = {
180 "fromimport.pyx",
181 };
183 /* Runtime support code */
185 static void __pyx_init_filenames(void) {
186 __pyx_f = __pyx_filenames;
187 }
189 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
190 PyObject *__import__ = 0;
191 PyObject *empty_list = 0;
192 PyObject *module = 0;
193 PyObject *global_dict = 0;
194 PyObject *empty_dict = 0;
195 PyObject *list;
196 __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
197 if (!__import__)
198 goto bad;
199 if (from_list)
200 list = from_list;
201 else {
202 empty_list = PyList_New(0);
203 if (!empty_list)
204 goto bad;
205 list = empty_list;
206 }
207 global_dict = PyModule_GetDict(__pyx_m);
208 if (!global_dict)
209 goto bad;
210 empty_dict = PyDict_New();
211 if (!empty_dict)
212 goto bad;
213 module = PyObject_CallFunction(__import__, "OOOO",
214 name, global_dict, empty_dict, list);
215 bad:
216 Py_XDECREF(empty_list);
217 Py_XDECREF(__import__);
218 Py_XDECREF(empty_dict);
219 return module;
220 }
222 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
223 while (t->p) {
224 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
225 if (!*t->p)
226 return -1;
227 if (t->i)
228 PyString_InternInPlace(t->p);
229 ++t;
230 }
231 return 0;
232 }
234 #include "compile.h"
235 #include "frameobject.h"
236 #include "traceback.h"
238 static void __Pyx_AddTraceback(char *funcname) {
239 PyObject *py_srcfile = 0;
240 PyObject *py_funcname = 0;
241 PyObject *py_globals = 0;
242 PyObject *empty_tuple = 0;
243 PyObject *empty_string = 0;
244 PyCodeObject *py_code = 0;
245 PyFrameObject *py_frame = 0;
247 py_srcfile = PyString_FromString(__pyx_filename);
248 if (!py_srcfile) goto bad;
249 py_funcname = PyString_FromString(funcname);
250 if (!py_funcname) goto bad;
251 py_globals = PyModule_GetDict(__pyx_m);
252 if (!py_globals) goto bad;
253 empty_tuple = PyTuple_New(0);
254 if (!empty_tuple) goto bad;
255 empty_string = PyString_FromString("");
256 if (!empty_string) goto bad;
257 py_code = PyCode_New(
258 0, /*int argcount,*/
259 0, /*int nlocals,*/
260 0, /*int stacksize,*/
261 0, /*int flags,*/
262 empty_string, /*PyObject *code,*/
263 empty_tuple, /*PyObject *consts,*/
264 empty_tuple, /*PyObject *names,*/
265 empty_tuple, /*PyObject *varnames,*/
266 empty_tuple, /*PyObject *freevars,*/
267 empty_tuple, /*PyObject *cellvars,*/
268 py_srcfile, /*PyObject *filename,*/
269 py_funcname, /*PyObject *name,*/
270 __pyx_lineno, /*int firstlineno,*/
271 empty_string /*PyObject *lnotab*/
272 );
273 if (!py_code) goto bad;
274 py_frame = PyFrame_New(
275 PyThreadState_Get(), /*PyThreadState *tstate,*/
276 py_code, /*PyCodeObject *code,*/
277 py_globals, /*PyObject *globals,*/
278 0 /*PyObject *locals*/
279 );
280 if (!py_frame) goto bad;
281 py_frame->f_lineno = __pyx_lineno;
282 PyTraceBack_Here(py_frame);
283 bad:
284 Py_XDECREF(py_srcfile);
285 Py_XDECREF(py_funcname);
286 Py_XDECREF(empty_tuple);
287 Py_XDECREF(empty_string);
288 Py_XDECREF(py_code);
289 Py_XDECREF(py_frame);
290 }
