Cython has moved to github.

pyrex

view Tests/Bugs/behnel/behnel5/Reference/use_etree.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_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
45 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
47 static PyObject *__Pyx_ImportModule(char *name); /*proto*/
49 static int __Pyx_ImportFunction(PyObject *module, char *funcname, void **f, char *sig); /*proto*/
51 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
53 static void __Pyx_AddTraceback(char *funcname); /*proto*/
55 /* Declarations from tree */
58 /* Declarations from ia_etree */
60 struct LxmlDocument {
61 PyObject_HEAD
62 struct __pyx_t_4tree_xmlDoc *_c_doc;
63 struct __pyx_obj_8ia_etree__BaseParser *_parser;
64 };
66 struct LxmlElement {
67 PyObject_HEAD
68 struct LxmlDocument *_doc;
69 struct __pyx_t_4tree_xmlNode *_c_node;
70 };
73 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlDocumentType;
75 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlElementType;
77 static PyTypeObject *__pyx_ptype_8ia_etree__Document = 0;
78 static PyTypeObject *__pyx_ptype_8ia_etree__Element = 0;
79 static PyObject *(*__pyx_f_8ia_etree_getAttributeValue)(struct LxmlElement *,PyObject *,PyObject *); /*proto*/
81 /* Declarations from use_etree */
85 static __Pyx_StringTabEntry __pyx_string_tab[] = {
86 {&__pyx_n_doc, 1, __pyx_k1, sizeof(__pyx_k1)},
87 {&__pyx_n_elem, 1, __pyx_k2, sizeof(__pyx_k2)},
88 {&__pyx_n_ftang, 1, __pyx_k3, sizeof(__pyx_k3)},
89 {&__pyx_n_zax, 1, __pyx_k4, sizeof(__pyx_k4)},
90 {0, 0, 0, 0}
91 };
93 /* Implementation of use_etree */
98 static struct PyMethodDef __pyx_methods[] = {
99 {0, 0, 0, 0}
100 };
102 static void __pyx_init_filenames(void); /*proto*/
104 PyMODINIT_FUNC inituse_etree(void); /*proto*/
105 PyMODINIT_FUNC inituse_etree(void) {
106 PyObject *__pyx_1 = 0;
107 PyObject *__pyx_2 = 0;
108 __pyx_init_filenames();
109 __pyx_m = Py_InitModule4("use_etree", __pyx_methods, 0, 0, PYTHON_API_VERSION);
110 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
111 Py_INCREF(__pyx_m);
112 __pyx_b = PyImport_AddModule("__builtin__");
113 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
114 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
115 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
116 __pyx_1 = __Pyx_ImportModule("ia_etree"); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
117 if (__Pyx_ImportFunction(__pyx_1, "getAttributeValue", (void**)&__pyx_f_8ia_etree_getAttributeValue, "PyObject *(struct LxmlElement *,PyObject *,PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
118 Py_DECREF(__pyx_1); __pyx_1 = 0;
119 __pyx_ptype_8ia_etree__Document = __Pyx_ImportType("ia_etree", "_Document", sizeof(struct LxmlDocument)); if (!__pyx_ptype_8ia_etree__Document) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; goto __pyx_L1;}
120 __pyx_ptype_8ia_etree__Element = __Pyx_ImportType("ia_etree", "_Element", sizeof(struct LxmlElement)); if (!__pyx_ptype_8ia_etree__Element) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; goto __pyx_L1;}
122 /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/behnel/behnel5/use_etree.pyx":3 */
123 __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_8ia_etree__Document), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
124 if (PyObject_SetAttr(__pyx_m, __pyx_n_doc, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
125 Py_DECREF(__pyx_1); __pyx_1 = 0;
127 /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/behnel/behnel5/use_etree.pyx":4 */
128 __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_8ia_etree__Element), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
129 if (PyObject_SetAttr(__pyx_m, __pyx_n_elem, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
130 Py_DECREF(__pyx_1); __pyx_1 = 0;
132 /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/behnel/behnel5/use_etree.pyx":5 */
133 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_elem); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
134 if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_8ia_etree__Element)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
135 __pyx_2 = __pyx_f_8ia_etree_getAttributeValue(((struct LxmlElement *)__pyx_1),__pyx_n_zax,__pyx_n_ftang); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
136 Py_DECREF(__pyx_1); __pyx_1 = 0;
137 Py_DECREF(__pyx_2); __pyx_2 = 0;
138 return;
139 __pyx_L1:;
140 Py_XDECREF(__pyx_1);
141 Py_XDECREF(__pyx_2);
142 __Pyx_AddTraceback("use_etree");
143 }
145 static char *__pyx_filenames[] = {
146 "use_etree.pyx",
147 "ia_etree.pxd",
148 };
150 /* Runtime support code */
152 static void __pyx_init_filenames(void) {
153 __pyx_f = __pyx_filenames;
154 }
156 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
157 PyObject *result;
158 result = PyObject_GetAttr(dict, name);
159 if (!result)
160 PyErr_SetObject(PyExc_NameError, name);
161 return result;
162 }
164 static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
165 if (!type) {
166 PyErr_Format(PyExc_SystemError, "Missing type object");
167 return 0;
168 }
169 if (obj == Py_None || PyObject_TypeCheck(obj, type))
170 return 1;
171 PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
172 obj->ob_type->tp_name, type->tp_name);
173 return 0;
174 }
176 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
177 while (t->p) {
178 *t->p = PyString_InternFromString(t->s);
179 if (!*t->p)
180 return -1;
181 ++t;
182 }
183 return 0;
184 }
186 #ifndef __PYX_HAVE_RT_ImportModule
187 #define __PYX_HAVE_RT_ImportModule
188 static PyObject *__Pyx_ImportModule(char *name) {
189 PyObject *py_name = 0;
191 py_name = PyString_FromString(name);
192 if (!py_name)
193 goto bad;
194 return PyImport_Import(py_name);
195 bad:
196 Py_XDECREF(py_name);
197 return 0;
198 }
199 #endif
201 #ifndef __PYX_HAVE_RT_ImportFunction
202 #define __PYX_HAVE_RT_ImportFunction
203 static int __Pyx_ImportFunction(PyObject *module, char *funcname, void **f, char *sig) {
204 PyObject *d = 0;
205 PyObject *cobj = 0;
206 char *desc;
208 d = PyObject_GetAttrString(module, "__pyx_capi__");
209 if (!d)
210 goto bad;
211 cobj = PyDict_GetItemString(d, funcname);
212 if (!cobj) {
213 PyErr_Format(PyExc_ImportError,
214 "%s does not export expected C function %s",
215 PyModule_GetName(module), funcname);
216 goto bad;
217 }
218 desc = (char *)PyCObject_GetDesc(cobj);
219 if (!desc)
220 goto bad;
221 if (strcmp(desc, sig) != 0) {
222 PyErr_Format(PyExc_TypeError,
223 "C function %s.%s has wrong signature (expected %s, got %s)",
224 PyModule_GetName(module), funcname, sig, desc);
225 goto bad;
226 }
227 *f = PyCObject_AsVoidPtr(cobj);
228 Py_DECREF(d);
229 return 0;
230 bad:
231 Py_XDECREF(d);
232 return -1;
233 }
234 #endif
236 #ifndef __PYX_HAVE_RT_ImportType
237 #define __PYX_HAVE_RT_ImportType
238 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
239 long size)
240 {
241 PyObject *py_module = 0;
242 PyObject *result = 0;
244 py_module = __Pyx_ImportModule(module_name);
245 if (!py_module)
246 goto bad;
247 result = PyObject_GetAttrString(py_module, class_name);
248 if (!result)
249 goto bad;
250 if (!PyType_Check(result)) {
251 PyErr_Format(PyExc_TypeError,
252 "%s.%s is not a type object",
253 module_name, class_name);
254 goto bad;
255 }
256 if (((PyTypeObject *)result)->tp_basicsize != size) {
257 PyErr_Format(PyExc_ValueError,
258 "%s.%s does not appear to be the correct type object",
259 module_name, class_name);
260 goto bad;
261 }
262 return (PyTypeObject *)result;
263 bad:
264 Py_XDECREF(result);
265 return 0;
266 }
267 #endif
269 #include "compile.h"
270 #include "frameobject.h"
271 #include "traceback.h"
273 static void __Pyx_AddTraceback(char *funcname) {
274 PyObject *py_srcfile = 0;
275 PyObject *py_funcname = 0;
276 PyObject *py_globals = 0;
277 PyObject *empty_tuple = 0;
278 PyObject *empty_string = 0;
279 PyCodeObject *py_code = 0;
280 PyFrameObject *py_frame = 0;
282 py_srcfile = PyString_FromString(__pyx_filename);
283 if (!py_srcfile) goto bad;
284 py_funcname = PyString_FromString(funcname);
285 if (!py_funcname) goto bad;
286 py_globals = PyModule_GetDict(__pyx_m);
287 if (!py_globals) goto bad;
288 empty_tuple = PyTuple_New(0);
289 if (!empty_tuple) goto bad;
290 empty_string = PyString_FromString("");
291 if (!empty_string) goto bad;
292 py_code = PyCode_New(
293 0, /*int argcount,*/
294 0, /*int nlocals,*/
295 0, /*int stacksize,*/
296 0, /*int flags,*/
297 empty_string, /*PyObject *code,*/
298 empty_tuple, /*PyObject *consts,*/
299 empty_tuple, /*PyObject *names,*/
300 empty_tuple, /*PyObject *varnames,*/
301 empty_tuple, /*PyObject *freevars,*/
302 empty_tuple, /*PyObject *cellvars,*/
303 py_srcfile, /*PyObject *filename,*/
304 py_funcname, /*PyObject *name,*/
305 __pyx_lineno, /*int firstlineno,*/
306 empty_string /*PyObject *lnotab*/
307 );
308 if (!py_code) goto bad;
309 py_frame = PyFrame_New(
310 PyThreadState_Get(), /*PyThreadState *tstate,*/
311 py_code, /*PyCodeObject *code,*/
312 py_globals, /*PyObject *globals,*/
313 0 /*PyObject *locals*/
314 );
315 if (!py_frame) goto bad;
316 py_frame->f_lineno = __pyx_lineno;
317 PyTraceBack_Here(py_frame);
318 bad:
319 Py_XDECREF(py_srcfile);
320 Py_XDECREF(py_funcname);
321 Py_XDECREF(empty_tuple);
322 Py_XDECREF(empty_string);
323 Py_XDECREF(py_code);
324 Py_XDECREF(py_frame);
325 }