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