mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
Cleanup of the python Makefiles based on Jacob and James feedback, fixed
* libxml.spec.in python/Makefile.am python/tests/Makefile.am python/generator.py python/libxml.c python/types.c: Cleanup of the python Makefiles based on Jacob and James feedback, fixed the spec file accordingly, fixed the number of warning that passing my pedantic CFLAGS was generating. Conclusion is that Python includes are real crap. Daniel
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
Fri Mar 15 23:21:40 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* libxml.spec.in python/Makefile.am python/tests/Makefile.am
|
||||||
|
python/generator.py python/libxml.c python/types.c: Cleanup
|
||||||
|
of the python Makefiles based on Jacob and James feedback,
|
||||||
|
fixed the spec file accordingly, fixed the number of warning
|
||||||
|
that passing my pedantic CFLAGS was generating. Conclusion
|
||||||
|
is that Python includes are real crap.
|
||||||
|
|
||||||
Fri Mar 15 19:41:25 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Fri Mar 15 19:41:25 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* configure,in: it was reported quite a few times that
|
* configure,in: it was reported quite a few times that
|
||||||
|
@ -98,8 +98,10 @@ do
|
|||||||
echo generating bindings for Python $py_version
|
echo generating bindings for Python $py_version
|
||||||
(cd python ; make clean ; \
|
(cd python ; make clean ; \
|
||||||
make PYTHON="%{prefix}/bin/python$py_version" \
|
make PYTHON="%{prefix}/bin/python$py_version" \
|
||||||
|
PYTHON_INCLUDES="%{prefix}/include/python$py_version" \
|
||||||
PYTHON_VERSION="$py_version"; \
|
PYTHON_VERSION="$py_version"; \
|
||||||
make PYTHON="%{prefix}/bin/python$py_version" \
|
make PYTHON="%{prefix}/bin/python$py_version" \
|
||||||
|
PYTHON_INCLUDES="%{prefix}/include/python$py_version" \
|
||||||
PYTHON_VERSION="$py_version" \
|
PYTHON_VERSION="$py_version" \
|
||||||
prefix=$RPM_BUILD_ROOT%{prefix} \
|
prefix=$RPM_BUILD_ROOT%{prefix} \
|
||||||
mandir=$RPM_BUILD_ROOT%{_mandir} install)
|
mandir=$RPM_BUILD_ROOT%{_mandir} install)
|
||||||
|
@ -4,12 +4,12 @@ AUTOMAKE_OPTIONS = 1.4 foreign
|
|||||||
SUBDIRS= . tests
|
SUBDIRS= . tests
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I/usr/include/python$(PYTHON_VERSION) \
|
|
||||||
-I$(PYTHON_INCLUDES) \
|
-I$(PYTHON_INCLUDES) \
|
||||||
-I$(top_srcdir)/include
|
-I$(top_srcdir)/include
|
||||||
|
|
||||||
DOCS_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)
|
DOCS_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)
|
||||||
DOCS = TODO libxml2class.txt
|
# libxml2class.txt is generated
|
||||||
|
DOCS = TODO
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
libxml.c \
|
libxml.c \
|
||||||
@ -22,24 +22,19 @@ EXTRA_DIST = \
|
|||||||
libxml2-python-api.xml \
|
libxml2-python-api.xml \
|
||||||
$(DOCS)
|
$(DOCS)
|
||||||
|
|
||||||
|
libxml2mod_la_LDFLAGS = -module -avoid-version
|
||||||
|
|
||||||
if WITH_PYTHON
|
if WITH_PYTHON
|
||||||
mylibs = \
|
mylibs = \
|
||||||
$(top_builddir)/libxml2.la
|
$(top_builddir)/libxml2.la
|
||||||
|
|
||||||
all: libxml2mod.so libxml2.py
|
all: libxml2.py # libxml2mod.so
|
||||||
|
|
||||||
pythondir = $(prefix)/lib/python${PYTHON_VERSION}/site-packages
|
pythondir = $(prefix)/lib/python${PYTHON_VERSION}/site-packages
|
||||||
python_PROGRAMS = libxml2mod.so
|
python_LTLIBRARIES = libxml2mod.la
|
||||||
|
|
||||||
libxml2mod_so_SOURCES =
|
|
||||||
libxml2mod_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,libxml2mod.so
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libxmlmodule.la
|
|
||||||
libxmlmodule_la_SOURCES = libxml.c types.c libxml2-py.c
|
|
||||||
|
|
||||||
libxml2mod.so: $(libxmlmodule_la_OBJECTS) $(mylibs)
|
|
||||||
$(LINK) -o $@ $(libxmlmodule_la_OBJECTS) $(libxml2mod_so_LDFLAGS)
|
|
||||||
|
|
||||||
|
libxml2mod_la_SOURCES = libxml.c types.c libxml2-py.c
|
||||||
|
libxml2mod_la_LIBADD = $(mylibs)
|
||||||
|
|
||||||
libxml2.py: $(srcdir)/libxml.py libxml2class.py
|
libxml2.py: $(srcdir)/libxml.py libxml2class.py
|
||||||
cat $(srcdir)/libxml.py libxml2class.py > libxml2.py
|
cat $(srcdir)/libxml.py libxml2class.py > libxml2.py
|
||||||
@ -62,7 +57,6 @@ $(GENERATED): $(srcdir)/$(GENERATE) $(API_DESC)
|
|||||||
cd $(srcdir) && $(PYTHON) $(GENERATE)
|
cd $(srcdir) && $(PYTHON) $(GENERATE)
|
||||||
|
|
||||||
$(libxmlmodule_la_OBJECTS): $(GENERATED)
|
$(libxmlmodule_la_OBJECTS): $(GENERATED)
|
||||||
|
|
||||||
else
|
else
|
||||||
all:
|
all:
|
||||||
endif
|
endif
|
||||||
|
@ -350,7 +350,7 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
if args[1][1] == "char *" or args[1][1] == "xmlChar *":
|
if args[1][1] == "char *" or args[1][1] == "xmlChar *":
|
||||||
c_call = "\n if (%s->%s != NULL) xmlFree(%s->%s);\n" % (
|
c_call = "\n if (%s->%s != NULL) xmlFree(%s->%s);\n" % (
|
||||||
args[0][0], args[1][0], args[0][0], args[1][0])
|
args[0][0], args[1][0], args[0][0], args[1][0])
|
||||||
c_call = c_call + " %s->%s = xmlStrdup(%s);\n" % (args[0][0],
|
c_call = c_call + " %s->%s = xmlStrdup((const xmlChar *)%s);\n" % (args[0][0],
|
||||||
args[1][0], args[1][0])
|
args[1][0], args[1][0])
|
||||||
else:
|
else:
|
||||||
c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0],
|
c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0],
|
||||||
@ -384,9 +384,9 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
include.write("PyObject * ")
|
include.write("PyObject * ")
|
||||||
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name))
|
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name));
|
||||||
|
|
||||||
export.write(" { \"%s\", libxml_%s, METH_VARARGS, NULL },\n" %
|
export.write(" { (char *)\"%s\", libxml_%s, METH_VARARGS, NULL },\n" %
|
||||||
(name, name))
|
(name, name))
|
||||||
|
|
||||||
if file == "python":
|
if file == "python":
|
||||||
@ -397,7 +397,10 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
output.write("PyObject *\n")
|
output.write("PyObject *\n")
|
||||||
output.write("libxml_%s(PyObject *self, PyObject *args) {\n" % (name))
|
output.write("libxml_%s(ATTRIBUTE_UNUSED PyObject *self," % (name))
|
||||||
|
if format == "":
|
||||||
|
output.write("ATTRIBUTE_UNUSED ")
|
||||||
|
output.write(" PyObject *args) {\n")
|
||||||
if ret[0] != 'void':
|
if ret[0] != 'void':
|
||||||
output.write(" PyObject *py_retval;\n")
|
output.write(" PyObject *py_retval;\n")
|
||||||
if c_return != "":
|
if c_return != "":
|
||||||
@ -405,7 +408,7 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
if c_args != "":
|
if c_args != "":
|
||||||
output.write(c_args)
|
output.write(c_args)
|
||||||
if format != "":
|
if format != "":
|
||||||
output.write("\n if (!PyArg_ParseTuple(args, \"%s\"%s))\n" %
|
output.write("\n if (!PyArg_ParseTuple(args, (char *)\"%s\"%s))\n" %
|
||||||
(format, format_args))
|
(format, format_args))
|
||||||
output.write(" return(NULL);\n")
|
output.write(" return(NULL);\n")
|
||||||
if c_convert != "":
|
if c_convert != "":
|
||||||
@ -465,6 +468,8 @@ def buildStubs():
|
|||||||
wrapper = open("libxml2-py.c", "w")
|
wrapper = open("libxml2-py.c", "w")
|
||||||
wrapper.write("/* Generated */\n\n")
|
wrapper.write("/* Generated */\n\n")
|
||||||
wrapper.write("#include <Python.h>\n")
|
wrapper.write("#include <Python.h>\n")
|
||||||
|
wrapper.write("#include \"config.h\"\n")
|
||||||
|
wrapper.write("#include <libxml/xmlversion.h>\n")
|
||||||
wrapper.write("#include <libxml/tree.h>\n")
|
wrapper.write("#include <libxml/tree.h>\n")
|
||||||
wrapper.write("#include \"libxml_wrap.h\"\n")
|
wrapper.write("#include \"libxml_wrap.h\"\n")
|
||||||
wrapper.write("#include \"libxml2-py.h\"\n\n")
|
wrapper.write("#include \"libxml2-py.h\"\n\n")
|
||||||
|
1490
python/libxml.c
1490
python/libxml.c
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ EXTRA_DIST = $(PYTESTS) $(XMLS)
|
|||||||
|
|
||||||
if WITH_PYTHON
|
if WITH_PYTHON
|
||||||
tests: $(PYTESTS)
|
tests: $(PYTESTS)
|
||||||
-@(PYTHONPATH=".." ; export PYTHONPATH; \
|
-@(PYTHONPATH="..:../.libs" ; export PYTHONPATH; \
|
||||||
for test in $(PYTESTS) ; do echo "-- $$test" ; $(PYTHON) $$test ; done)
|
for test in $(PYTESTS) ; do echo "-- $$test" ; $(PYTHON) $$test ; done)
|
||||||
else
|
else
|
||||||
tests:
|
tests:
|
||||||
|
371
python/types.c
371
python/types.c
@ -9,256 +9,288 @@
|
|||||||
#include "libxml_wrap.h"
|
#include "libxml_wrap.h"
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_intWrap(int val) {
|
libxml_intWrap(int val)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_intWrap: val = %d\n", val);
|
printf("libxml_intWrap: val = %d\n", val);
|
||||||
#endif
|
#endif
|
||||||
ret = PyInt_FromLong((long) val);
|
ret = PyInt_FromLong((long) val);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_longWrap(long val) {
|
libxml_longWrap(long val)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_longWrap: val = %ld\n", val);
|
printf("libxml_longWrap: val = %ld\n", val);
|
||||||
#endif
|
#endif
|
||||||
ret = PyInt_FromLong(val);
|
ret = PyInt_FromLong(val);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_doubleWrap(double val) {
|
libxml_doubleWrap(double val)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_doubleWrap: val = %f\n", val);
|
printf("libxml_doubleWrap: val = %f\n", val);
|
||||||
#endif
|
#endif
|
||||||
ret = PyFloat_FromDouble((double) val);
|
ret = PyFloat_FromDouble((double) val);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_charPtrWrap(char *str) {
|
libxml_charPtrWrap(char *str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString(str);
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_charPtrConstWrap(const char *str) {
|
libxml_charPtrConstWrap(const char *str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString(str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlCharPtrWrap(xmlChar *str) {
|
libxml_xmlCharPtrWrap(xmlChar * str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString((char *) str);
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlCharPtrConstWrap(const xmlChar *str) {
|
libxml_xmlCharPtrConstWrap(const xmlChar * str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString((char *) str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_constcharPtrWrap(const char *str) {
|
libxml_constcharPtrWrap(const char *str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString(str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_constxmlCharPtrWrap(const xmlChar *str) {
|
libxml_constxmlCharPtrWrap(const xmlChar * str)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||||
#endif
|
#endif
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyString_FromString(str);
|
ret = PyString_FromString((char *) str);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlDocPtrWrap(xmlDocPtr doc) {
|
libxml_xmlDocPtrWrap(xmlDocPtr doc)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlDocPtrWrap: doc = %p\n", doc);
|
printf("libxml_xmlDocPtrWrap: doc = %p\n", doc);
|
||||||
#endif
|
#endif
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
/* TODO: look at deallocation */
|
/* TODO: look at deallocation */
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) doc, "xmlDocPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) doc, (char *) "xmlDocPtr",
|
||||||
|
NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlNodePtrWrap(xmlNodePtr node) {
|
libxml_xmlNodePtrWrap(xmlNodePtr node)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlNodePtrWrap: node = %p\n", node);
|
printf("libxml_xmlNodePtrWrap: node = %p\n", node);
|
||||||
#endif
|
#endif
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) node, "xmlNodePtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "xmlNodePtr",
|
||||||
|
NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlURIPtrWrap(xmlURIPtr uri) {
|
libxml_xmlURIPtrWrap(xmlURIPtr uri)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlURIPtrWrap: uri = %p\n", uri);
|
printf("libxml_xmlURIPtrWrap: uri = %p\n", uri);
|
||||||
#endif
|
#endif
|
||||||
if (uri == NULL) {
|
if (uri == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) uri, "xmlURIPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) uri, (char *) "xmlURIPtr",
|
||||||
|
NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlNsPtrWrap(xmlNsPtr ns) {
|
libxml_xmlNsPtrWrap(xmlNsPtr ns)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlNsPtrWrap: node = %p\n", ns);
|
printf("libxml_xmlNsPtrWrap: node = %p\n", ns);
|
||||||
#endif
|
#endif
|
||||||
if (ns == NULL) {
|
if (ns == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) ns, "xmlNsPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) ns, (char *) "xmlNsPtr",
|
||||||
|
NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlAttrPtrWrap(xmlAttrPtr attr) {
|
libxml_xmlAttrPtrWrap(xmlAttrPtr attr)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlAttrNodePtrWrap: attr = %p\n", attr);
|
printf("libxml_xmlAttrNodePtrWrap: attr = %p\n", attr);
|
||||||
#endif
|
#endif
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) attr, "xmlAttrPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) attr, (char *) "xmlAttrPtr",
|
||||||
|
NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlAttributePtrWrap(xmlAttributePtr attr) {
|
libxml_xmlAttributePtrWrap(xmlAttributePtr attr)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlAttributePtrWrap: attr = %p\n", attr);
|
printf("libxml_xmlAttributePtrWrap: attr = %p\n", attr);
|
||||||
#endif
|
#endif
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) attr, "xmlAttributePtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) attr,
|
||||||
|
(char *) "xmlAttributePtr", NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlElementPtrWrap(xmlElementPtr elem) {
|
libxml_xmlElementPtrWrap(xmlElementPtr elem)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlElementNodePtrWrap: elem = %p\n", elem);
|
printf("libxml_xmlElementNodePtrWrap: elem = %p\n", elem);
|
||||||
#endif
|
#endif
|
||||||
if (elem == NULL) {
|
if (elem == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) elem, "xmlElementPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) elem,
|
||||||
|
(char *) "xmlElementPtr", NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) {
|
libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlXPathContextPtrWrap: ctxt = %p\n", ctxt);
|
printf("libxml_xmlXPathContextPtrWrap: ctxt = %p\n", ctxt);
|
||||||
#endif
|
#endif
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt, "xmlXPathContextPtr",
|
ret =
|
||||||
NULL);
|
PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
||||||
return(ret);
|
(char *) "xmlXPathContextPtr", NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
@ -274,153 +306,166 @@ libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt)
|
|||||||
return (Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
||||||
"xmlXPathParserContextPtr", NULL);
|
(char *) "xmlXPathParserContextPtr",
|
||||||
|
NULL);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) {
|
libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
printf("libxml_xmlParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
||||||
#endif
|
#endif
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt, "xmlParserCtxtPtr",
|
ret =
|
||||||
NULL);
|
PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
||||||
return(ret);
|
(char *) "xmlParserCtxtPtr", NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj) {
|
libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlXPathObjectPtrWrap: ctxt = %p\n", obj);
|
printf("libxml_xmlXPathObjectPtrWrap: ctxt = %p\n", obj);
|
||||||
#endif
|
#endif
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
switch(obj->type) {
|
switch (obj->type) {
|
||||||
case XPATH_XSLT_TREE:
|
case XPATH_XSLT_TREE:
|
||||||
/* TODO !!!! Allocation problems */
|
/* TODO !!!! Allocation problems */
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0))
|
if ((obj->nodesetval == NULL)
|
||||||
ret = PyList_New(0);
|
|| (obj->nodesetval->nodeNr == 0))
|
||||||
else {
|
ret = PyList_New(0);
|
||||||
int i;
|
else {
|
||||||
xmlNodePtr node;
|
int i;
|
||||||
|
xmlNodePtr node;
|
||||||
|
|
||||||
ret = PyList_New(obj->nodesetval->nodeNr);
|
ret = PyList_New(obj->nodesetval->nodeNr);
|
||||||
for (i = 0;i < obj->nodesetval->nodeNr;i++) {
|
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
|
||||||
node = obj->nodesetval->nodeTab[i];
|
node = obj->nodesetval->nodeTab[i];
|
||||||
/* TODO: try to cast directly to the proper node type */
|
/* TODO: try to cast directly to the proper node type */
|
||||||
PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node));
|
PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XPATH_BOOLEAN:
|
case XPATH_BOOLEAN:
|
||||||
ret = PyInt_FromLong((long) obj->boolval);
|
ret = PyInt_FromLong((long) obj->boolval);
|
||||||
break;
|
break;
|
||||||
case XPATH_NUMBER:
|
case XPATH_NUMBER:
|
||||||
ret = PyFloat_FromDouble(obj->floatval);
|
ret = PyFloat_FromDouble(obj->floatval);
|
||||||
break;
|
break;
|
||||||
case XPATH_STRING:
|
case XPATH_STRING:
|
||||||
ret = PyString_FromString(obj->stringval);
|
ret = PyString_FromString((char *) obj->stringval);
|
||||||
break;
|
break;
|
||||||
case XPATH_POINT:
|
case XPATH_POINT:
|
||||||
case XPATH_RANGE:
|
case XPATH_RANGE:
|
||||||
case XPATH_LOCATIONSET:
|
case XPATH_LOCATIONSET:
|
||||||
default:
|
default:
|
||||||
printf("Unable to convert XPath object type %d\n", obj->type);
|
printf("Unable to convert XPath object type %d\n", obj->type);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
ret = Py_None;
|
ret = Py_None;
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(obj);
|
xmlXPathFreeObject(obj);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlXPathObjectPtr
|
xmlXPathObjectPtr
|
||||||
libxml_xmlXPathObjectPtrConvert(PyObject * obj) {
|
libxml_xmlXPathObjectPtrConvert(PyObject * obj)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr ret = NULL;
|
xmlXPathObjectPtr ret = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
|
printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
|
||||||
#endif
|
#endif
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if PyFloat_Check(obj) {
|
if PyFloat_Check
|
||||||
ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
|
(obj) {
|
||||||
} else if PyString_Check(obj) {
|
ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
|
||||||
xmlChar *str;
|
} else if PyString_Check
|
||||||
|
(obj) {
|
||||||
|
xmlChar *str;
|
||||||
|
|
||||||
str = xmlStrndup((const xmlChar *)PyString_AS_STRING(obj),
|
str = xmlStrndup((const xmlChar *) PyString_AS_STRING(obj),
|
||||||
PyString_GET_SIZE(obj));
|
PyString_GET_SIZE(obj));
|
||||||
ret = xmlXPathWrapString(str);
|
ret = xmlXPathWrapString(str);
|
||||||
} else if PyList_Check(obj) {
|
} else if PyList_Check
|
||||||
int i;
|
(obj) {
|
||||||
PyObject *node;
|
int i;
|
||||||
xmlNodePtr cur;
|
PyObject *node;
|
||||||
xmlNodeSetPtr set;
|
xmlNodePtr cur;
|
||||||
|
xmlNodeSetPtr set;
|
||||||
|
|
||||||
set = xmlXPathNodeSetCreate(NULL);
|
set = xmlXPathNodeSetCreate(NULL);
|
||||||
|
|
||||||
for (i = 0;i < PyList_Size(obj);i++) {
|
for (i = 0; i < PyList_Size(obj); i++) {
|
||||||
node = PyList_GetItem(obj, i);
|
node = PyList_GetItem(obj, i);
|
||||||
if ((node == NULL) || (node->ob_type == NULL))
|
if ((node == NULL) || (node->ob_type == NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cur = NULL;
|
cur = NULL;
|
||||||
if (PyCObject_Check(node)) {
|
if (PyCObject_Check(node)) {
|
||||||
printf("Got a CObject\n");
|
printf("Got a CObject\n");
|
||||||
cur = PyxmlNode_Get(node);
|
cur = PyxmlNode_Get(node);
|
||||||
} else if (PyInstance_Check(node)) {
|
} else if (PyInstance_Check(node)) {
|
||||||
PyInstanceObject *inst = (PyInstanceObject *) node;
|
PyInstanceObject *inst = (PyInstanceObject *) node;
|
||||||
PyObject *name = inst->in_class->cl_name;
|
PyObject *name = inst->in_class->cl_name;
|
||||||
if PyString_Check(name) {
|
|
||||||
char *type = PyString_AS_STRING(name);
|
|
||||||
PyObject *wrapper;
|
|
||||||
|
|
||||||
if (!strcmp(type, "xmlNode")) {
|
if PyString_Check
|
||||||
wrapper = PyObject_GetAttrString(node, "_o");
|
(name) {
|
||||||
if (wrapper != NULL) {
|
char *type = PyString_AS_STRING(name);
|
||||||
cur = PyxmlNode_Get(wrapper);
|
PyObject *wrapper;
|
||||||
}
|
|
||||||
}
|
if (!strcmp(type, "xmlNode")) {
|
||||||
}
|
wrapper =
|
||||||
} else {
|
PyObject_GetAttrString(node, (char *) "_o");
|
||||||
printf("Unknown object in Python return list\n");
|
if (wrapper != NULL) {
|
||||||
}
|
cur = PyxmlNode_Get(wrapper);
|
||||||
if (cur != NULL) {
|
}
|
||||||
xmlXPathNodeSetAdd(set, cur);
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
ret = xmlXPathWrapNodeSet(set);
|
printf("Unknown object in Python return list\n");
|
||||||
|
}
|
||||||
|
if (cur != NULL) {
|
||||||
|
xmlXPathNodeSetAdd(set, cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = xmlXPathWrapNodeSet(set);
|
||||||
} else {
|
} else {
|
||||||
printf("Unable to convert Python Object to XPath");
|
printf("Unable to convert Python Object to XPath");
|
||||||
}
|
}
|
||||||
Py_DECREF(obj);
|
Py_DECREF(obj);
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) {
|
libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal)
|
||||||
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("libxml_xmlNodePtrWrap: catal = %p\n", catal);
|
printf("libxml_xmlNodePtrWrap: catal = %p\n", catal);
|
||||||
#endif
|
#endif
|
||||||
if (catal == NULL) {
|
if (catal == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return (Py_None);
|
||||||
}
|
}
|
||||||
ret = PyCObject_FromVoidPtrAndDesc((void *) catal, "xmlCatalogPtr", NULL);
|
ret =
|
||||||
return(ret);
|
PyCObject_FromVoidPtrAndDesc((void *) catal,
|
||||||
|
(char *) "xmlCatalogPtr", NULL);
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user