Cython has moved to github.

pyrex

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