aboutsummaryrefslogtreecommitdiff
path: root/libxml2-2.9.10/python/libxml_wrap.h
blob: 53a061807e9ddcde35244a5add014f0b7e89a80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#include <Python.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/catalog.h>
#include <libxml/threads.h>
#include <libxml/nanoftp.h>
#include <libxml/nanohttp.h>
#include <libxml/uri.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/xinclude.h>
#include <libxml/xpointer.h>
#include <libxml/xmlunicode.h>
#include <libxml/xmlregexp.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlreader.h>
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
#include <libxml/xmlschemas.h>
#endif

/*
 * for older versions of Python, we don't use PyBytes, but keep PyString
 * and don't use Capsule but CObjects
 */
#if PY_VERSION_HEX < 0x02070000
#ifndef PyBytes_Check
#define PyBytes_Check PyString_Check
#define PyBytes_Size PyString_Size
#define PyBytes_AsString PyString_AsString
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#endif
#ifndef PyCapsule_New
#define PyCapsule_New PyCObject_FromVoidPtrAndDesc
#define PyCapsule_CheckExact PyCObject_Check
#define PyCapsule_GetPointer(o, n) PyCObject_GetDesc((o))
#endif
#endif

/**
 * ATTRIBUTE_UNUSED:
 *
 * Macro used to signal to GCC unused function parameters
 * Repeated here since the definition is not available when
 * compiled outside the libxml2 build tree.
 */
#ifdef __GNUC__
#ifdef ATTRIBUTE_UNUSED
#undef ATTRIBUTE_UNUSED
#endif
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */
#else
#define ATTRIBUTE_UNUSED
#endif

#define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
	(((PyxmlNode_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlNodePtr obj;
} PyxmlNode_Object;

#define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
	(((PyxmlXPathContext_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlXPathContextPtr obj;
} PyxmlXPathContext_Object;

#define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
	(((PyxmlXPathParserContext_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlXPathParserContextPtr obj;
} PyxmlXPathParserContext_Object;

#define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
        (((PyparserCtxt_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlParserCtxtPtr obj;
} PyparserCtxt_Object;

#define PyValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
	(((PyValidCtxt_Object *)(v))->obj))

typedef struct {
	PyObject_HEAD
	xmlValidCtxtPtr obj;
} PyValidCtxt_Object;

#define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
        (((Pycatalog_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlCatalogPtr obj;
} Pycatalog_Object;

#ifdef LIBXML_REGEXP_ENABLED
#define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
        (((PyxmlReg_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlRegexpPtr obj;
} PyxmlReg_Object;
#endif /* LIBXML_REGEXP_ENABLED */

#ifdef LIBXML_READER_ENABLED
#define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
        (((PyxmlTextReader_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlTextReaderPtr obj;
} PyxmlTextReader_Object;

#define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
        (((PyxmlTextReaderLocator_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlTextReaderLocatorPtr obj;
} PyxmlTextReaderLocator_Object;
#endif

#define PyURI_Get(v) (((v) == Py_None) ? NULL : \
	(((PyURI_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlErrorPtr obj;
} PyError_Object;

#define PyError_Get(v) (((v) == Py_None) ? NULL : \
	(((PyError_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlOutputBufferPtr obj;
} PyoutputBuffer_Object;

#define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
	(((PyoutputBuffer_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlParserInputBufferPtr obj;
} PyinputBuffer_Object;

#define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
	(((PyinputBuffer_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlURIPtr obj;
} PyURI_Object;

/* FILE * have their own internal representation */
#if PY_MAJOR_VERSION >= 3
FILE *libxml_PyFileGet(PyObject *f);
void libxml_PyFileRelease(FILE *f);
#define PyFile_Get(v) (((v) == Py_None) ? NULL : libxml_PyFileGet(v))
#define PyFile_Release(f) libxml_PyFileRelease(f)
#else
#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
	(PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
#define PyFile_Release(f)
#endif

#ifdef LIBXML_SCHEMAS_ENABLED
typedef struct {
    PyObject_HEAD
    xmlRelaxNGPtr obj;
} PyrelaxNgSchema_Object;

#define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
	(((PyrelaxNgSchema_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlRelaxNGParserCtxtPtr obj;
} PyrelaxNgParserCtxt_Object;

#define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
	(((PyrelaxNgParserCtxt_Object *)(v))->obj))

typedef struct {
    PyObject_HEAD
    xmlRelaxNGValidCtxtPtr obj;
} PyrelaxNgValidCtxt_Object;

#define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
	(((PyrelaxNgValidCtxt_Object *)(v))->obj))

typedef struct {
	PyObject_HEAD
	xmlSchemaPtr obj;
} PySchema_Object;

#define PySchema_Get(v) (((v) == Py_None) ? NULL : \
	(((PySchema_Object *)(v))->obj))

typedef struct {
	PyObject_HEAD
	xmlSchemaParserCtxtPtr obj;
} PySchemaParserCtxt_Object;

#define PySchemaParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
	(((PySchemaParserCtxt_Object *)(v))->obj))

typedef struct {
	PyObject_HEAD
	xmlSchemaValidCtxtPtr obj;
} PySchemaValidCtxt_Object;

#define PySchemaValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
	(((PySchemaValidCtxt_Object *)(v))->obj))

#endif /* LIBXML_SCHEMAS_ENABLED */

PyObject * libxml_intWrap(int val);
PyObject * libxml_longWrap(long val);
PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
PyObject * libxml_charPtrWrap(char *str);
PyObject * libxml_constcharPtrWrap(const char *str);
PyObject * libxml_charPtrConstWrap(const char *str);
PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
PyObject * libxml_doubleWrap(double val);
PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid);
PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
#ifdef LIBXML_REGEXP_ENABLED
PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
#endif /* LIBXML_REGEXP_ENABLED */
#ifdef LIBXML_READER_ENABLED
PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
#endif

xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
#ifdef LIBXML_SCHEMAS_ENABLED
PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
PyObject * libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt);
PyObject * libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt);
PyObject * libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid);
#endif /* LIBXML_SCHEMAS_ENABLED */
PyObject * libxml_xmlErrorPtrWrap(xmlErrorPtr error);
PyObject * libxml_xmlSchemaSetValidErrors(PyObject * self, PyObject * args);
PyObject * libxml_xmlRegisterInputCallback(PyObject *self, PyObject *args);
PyObject * libxml_xmlUnregisterInputCallback(PyObject *self, PyObject *args);
PyObject * libxml_xmlNodeRemoveNsDef(PyObject * self, PyObject * args);