Daniel Veillard | 3ce5257 | 2002-02-03 15:08:05 +0000 | [diff] [blame] | 1 | #include <Python.h> |
Daniel Veillard | d2897fd | 2002-01-30 16:37:32 +0000 | [diff] [blame] | 2 | #include <libxml/tree.h> |
| 3 | #include <libxml/parser.h> |
| 4 | #include <libxml/parserInternals.h> |
| 5 | #include <libxml/catalog.h> |
| 6 | #include <libxml/threads.h> |
| 7 | #include <libxml/nanoftp.h> |
| 8 | #include <libxml/nanohttp.h> |
| 9 | #include <libxml/uri.h> |
| 10 | #include <libxml/xpath.h> |
| 11 | #include <libxml/xpathInternals.h> |
| 12 | #include <libxml/debugXML.h> |
Daniel Veillard | 96fe095 | 2002-01-30 20:52:23 +0000 | [diff] [blame] | 13 | #include <libxml/HTMLparser.h> |
| 14 | #include <libxml/HTMLtree.h> |
| 15 | #include <libxml/xinclude.h> |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 16 | #include <libxml/xpointer.h> |
Daniel Veillard | bd9afb5 | 2002-09-25 22:25:35 +0000 | [diff] [blame] | 17 | #include <libxml/xmlunicode.h> |
| 18 | #include <libxml/xmlregexp.h> |
| 19 | #include <libxml/xmlautomata.h> |
Daniel Veillard | 0eb38c7 | 2002-12-14 23:00:35 +0000 | [diff] [blame] | 20 | #include <libxml/xmlreader.h> |
| 21 | |
| 22 | /** |
| 23 | * ATTRIBUTE_UNUSED: |
| 24 | * |
| 25 | * Macro used to signal to GCC unused function parameters |
| 26 | * Repeated here since the definition is not available when |
| 27 | * compiled outside the libxml2 build tree. |
| 28 | */ |
| 29 | #ifdef __GNUC__ |
| 30 | #ifdef ATTRIBUTE_UNUSED |
| 31 | #undef ATTRIBUTE_UNUSED |
| 32 | #endif |
Daniel Veillard | 0eb38c7 | 2002-12-14 23:00:35 +0000 | [diff] [blame] | 33 | #ifndef ATTRIBUTE_UNUSED |
Daniel Veillard | 0e9dafa | 2002-12-27 11:58:25 +0000 | [diff] [blame] | 34 | #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) |
| 35 | #endif /* ATTRIBUTE_UNUSED */ |
Daniel Veillard | 0eb38c7 | 2002-12-14 23:00:35 +0000 | [diff] [blame] | 36 | #else |
| 37 | #define ATTRIBUTE_UNUSED |
| 38 | #endif |
Daniel Veillard | 96fe095 | 2002-01-30 20:52:23 +0000 | [diff] [blame] | 39 | |
Daniel Veillard | 36eea2d | 2002-02-04 00:17:01 +0000 | [diff] [blame] | 40 | #define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \ |
| 41 | (((PyxmlNode_Object *)(v))->obj)) |
Daniel Veillard | 96fe095 | 2002-01-30 20:52:23 +0000 | [diff] [blame] | 42 | |
| 43 | typedef struct { |
| 44 | PyObject_HEAD |
| 45 | xmlNodePtr obj; |
| 46 | } PyxmlNode_Object; |
Daniel Veillard | d2897fd | 2002-01-30 16:37:32 +0000 | [diff] [blame] | 47 | |
Daniel Veillard | 36eea2d | 2002-02-04 00:17:01 +0000 | [diff] [blame] | 48 | #define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \ |
| 49 | (((PyxmlXPathContext_Object *)(v))->obj)) |
| 50 | |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 51 | typedef struct { |
| 52 | PyObject_HEAD |
| 53 | xmlXPathContextPtr obj; |
| 54 | } PyxmlXPathContext_Object; |
| 55 | |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 56 | #define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \ |
| 57 | (((PyxmlXPathParserContext_Object *)(v))->obj)) |
| 58 | |
| 59 | typedef struct { |
| 60 | PyObject_HEAD |
| 61 | xmlXPathParserContextPtr obj; |
| 62 | } PyxmlXPathParserContext_Object; |
| 63 | |
Daniel Veillard | 36eea2d | 2002-02-04 00:17:01 +0000 | [diff] [blame] | 64 | #define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \ |
| 65 | (((PyparserCtxt_Object *)(v))->obj)) |
| 66 | |
Daniel Veillard | 3ce5257 | 2002-02-03 15:08:05 +0000 | [diff] [blame] | 67 | typedef struct { |
| 68 | PyObject_HEAD |
| 69 | xmlParserCtxtPtr obj; |
| 70 | } PyparserCtxt_Object; |
| 71 | |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 72 | #define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \ |
| 73 | (((Pycatalog_Object *)(v))->obj)) |
| 74 | |
| 75 | typedef struct { |
| 76 | PyObject_HEAD |
| 77 | xmlCatalogPtr obj; |
| 78 | } Pycatalog_Object; |
| 79 | |
Daniel Veillard | bd9afb5 | 2002-09-25 22:25:35 +0000 | [diff] [blame] | 80 | #define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \ |
| 81 | (((PyxmlReg_Object *)(v))->obj)) |
| 82 | |
| 83 | typedef struct { |
| 84 | PyObject_HEAD |
| 85 | xmlRegexpPtr obj; |
| 86 | } PyxmlReg_Object; |
| 87 | |
Daniel Veillard | 0eb38c7 | 2002-12-14 23:00:35 +0000 | [diff] [blame] | 88 | #define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \ |
| 89 | (((PyxmlTextReader_Object *)(v))->obj)) |
| 90 | |
| 91 | typedef struct { |
| 92 | PyObject_HEAD |
| 93 | xmlTextReaderPtr obj; |
| 94 | } PyxmlTextReader_Object; |
| 95 | |
Daniel Veillard | 6361da0 | 2002-02-23 10:10:33 +0000 | [diff] [blame] | 96 | #define PyURI_Get(v) (((v) == Py_None) ? NULL : \ |
| 97 | (((PyURI_Object *)(v))->obj)) |
| 98 | |
| 99 | typedef struct { |
| 100 | PyObject_HEAD |
Daniel Veillard | c6d4a93 | 2002-09-12 15:00:57 +0000 | [diff] [blame] | 101 | xmlOutputBufferPtr obj; |
| 102 | } PyoutputBuffer_Object; |
| 103 | |
| 104 | #define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \ |
| 105 | (((PyURI_Object *)(v))->obj)) |
| 106 | |
| 107 | typedef struct { |
| 108 | PyObject_HEAD |
| 109 | xmlParserInputBufferPtr obj; |
| 110 | } PyinputBuffer_Object; |
| 111 | |
| 112 | #define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \ |
| 113 | (((PyURI_Object *)(v))->obj)) |
| 114 | |
| 115 | typedef struct { |
| 116 | PyObject_HEAD |
Daniel Veillard | 6361da0 | 2002-02-23 10:10:33 +0000 | [diff] [blame] | 117 | xmlURIPtr obj; |
| 118 | } PyURI_Object; |
| 119 | |
| 120 | /* FILE * have their own internal representation */ |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 121 | #define PyFile_Get(v) (((v) == Py_None) ? NULL : \ |
Daniel Veillard | bd9afb5 | 2002-09-25 22:25:35 +0000 | [diff] [blame] | 122 | (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout)) |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 123 | |
Daniel Veillard | 6361da0 | 2002-02-23 10:10:33 +0000 | [diff] [blame] | 124 | |
Daniel Veillard | d2897fd | 2002-01-30 16:37:32 +0000 | [diff] [blame] | 125 | PyObject * libxml_intWrap(int val); |
Daniel Veillard | 4e1b26c | 2002-02-03 20:13:06 +0000 | [diff] [blame] | 126 | PyObject * libxml_longWrap(long val); |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 127 | PyObject * libxml_xmlCharPtrWrap(xmlChar *str); |
| 128 | PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str); |
| 129 | PyObject * libxml_charPtrWrap(char *str); |
| 130 | PyObject * libxml_constcharPtrWrap(const char *str); |
Daniel Veillard | c575b99 | 2002-02-08 13:28:40 +0000 | [diff] [blame] | 131 | PyObject * libxml_charPtrConstWrap(const char *str); |
| 132 | PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str); |
Daniel Veillard | d2897fd | 2002-01-30 16:37:32 +0000 | [diff] [blame] | 133 | PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc); |
| 134 | PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node); |
| 135 | PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr); |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 136 | PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns); |
| 137 | PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns); |
| 138 | PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns); |
Daniel Veillard | 96fe095 | 2002-01-30 20:52:23 +0000 | [diff] [blame] | 139 | PyObject * libxml_doubleWrap(double val); |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 140 | PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt); |
Daniel Veillard | 3ce5257 | 2002-02-03 15:08:05 +0000 | [diff] [blame] | 141 | PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt); |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 142 | PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt); |
Daniel Veillard | 1971ee2 | 2002-01-31 20:29:19 +0000 | [diff] [blame] | 143 | PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj); |
Daniel Veillard | 7db3871 | 2002-02-07 16:39:11 +0000 | [diff] [blame] | 144 | PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj); |
Daniel Veillard | 6361da0 | 2002-02-23 10:10:33 +0000 | [diff] [blame] | 145 | PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri); |
Daniel Veillard | c6d4a93 | 2002-09-12 15:00:57 +0000 | [diff] [blame] | 146 | PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer); |
| 147 | PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer); |
Daniel Veillard | bd9afb5 | 2002-09-25 22:25:35 +0000 | [diff] [blame] | 148 | PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp); |
Daniel Veillard | 0eb38c7 | 2002-12-14 23:00:35 +0000 | [diff] [blame] | 149 | PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader); |
Daniel Veillard | 96fe095 | 2002-01-30 20:52:23 +0000 | [diff] [blame] | 150 | |
Daniel Veillard | 3ce5257 | 2002-02-03 15:08:05 +0000 | [diff] [blame] | 151 | xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj); |
Daniel Veillard | e6227e0 | 2003-01-14 11:42:39 +0000 | [diff] [blame^] | 152 | |
| 153 | /* |
| 154 | * Data structure that makes the link from the parser context |
| 155 | * to the python wrapper. |
| 156 | */ |
| 157 | typedef struct |
| 158 | { |
| 159 | PyObject *errorFunc; |
| 160 | PyObject *errorFuncArg; |
| 161 | PyObject *warningFunc; |
| 162 | PyObject *warningFuncArg; |
| 163 | } xmlParserCtxtPyCtxt; |
| 164 | typedef xmlParserCtxtPyCtxt *xmlParserCtxtPyCtxtPtr; |
| 165 | |