summaryrefslogtreecommitdiff
path: root/python/libxml_wrap.h
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2014-10-26 07:02:25 +0800
committerAron Xu <aron@debian.org>2014-10-26 07:02:25 +0800
commit3871a83a5f0aebd8c00879eab14fe901c93dbfcf (patch)
treeb022967f880b7fb1e56c8cc4c3f200d6ffbc9efd /python/libxml_wrap.h
parent7042e17490515a990a45aa7237d11bc49ab0eaf0 (diff)
downloadlibxml2-3871a83a5f0aebd8c00879eab14fe901c93dbfcf.tar.gz
Imported Upstream version 2.9.2+dfsg1
Diffstat (limited to 'python/libxml_wrap.h')
-rw-r--r--python/libxml_wrap.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h
index eaa5e96..53a0618 100644
--- a/python/libxml_wrap.h
+++ b/python/libxml_wrap.h
@@ -23,6 +23,25 @@
#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:
*
@@ -150,8 +169,16 @@ typedef struct {
} 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 {
@@ -247,3 +274,6 @@ 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);