Justin Fletcher found some parts of the code needing cleanup Fixed the
* parserInternals.c valid.c: Justin Fletcher found some parts
of the code needing cleanup
* libxml.spec.in python/Makefile.am python/generator.py
python/libxml.c python/libxml.py: Fixed the python Makefiles
corrected a bug showing up on ia64, changed the name of the
python internal module too
Daniel
diff --git a/python/Makefile.am b/python/Makefile.am
index b1e0305..130cc8b 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -1,11 +1,14 @@
+# Makefile for libxml2 python library
+AUTOMAKE_OPTIONS = 1.4 foreign
+
SUBDIRS= . tests
-LIBS=-L../.libs -L.. $(XML_LIBS)
-INCLUDES=-I/usr/include/python$(PYTHON_VERSION) -I$(PYTHON_INCLUDES) -I$(top_srcdir)/include
-SHCFLAGS=$(INCLUDES) -Wall -fPIC -g
-LINK_FLAGS= -shared
-DOCS_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)
+INCLUDES = \
+ -I/usr/include/python$(PYTHON_VERSION) \
+ -I$(PYTHON_INCLUDES) \
+ -I$(top_srcdir)/include
+DOCS_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)
DOCS = TODO libxml2class.txt
EXTRA_DIST = \
@@ -18,31 +21,37 @@
$(DOCS)
if WITH_PYTHON
-all: _libxml.so libxml2.py
+mylibs = \
+ $(top_builddir)/libxml2.la
+
+all: libxml2mod.so libxml2.py
+
+LDADD = -lxml2
+CFLAGS = -Wall -g
+
+pythondir = $(prefix)/lib/python${PYTHON_VERSION}/site-packages
+python_PROGRAMS = libxml2mod.so
+
+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)
+ $(LINK) -o $@ $(libxmlmodule_la_OBJECTS) $(libxml2mod_so_LDFLAGS)
+
libxml2.py: $(srcdir)/libxml.py libxml2class.py
cat $(srcdir)/libxml.py libxml2class.py > libxml2.py
-_libxml.so: libxml.o libxml2-py.o types.o
- $(CC) $(LINK_FLAGS) libxml.o libxml2-py.o types.o $(LIBS) -o _libxml.so
-
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(PYTHON_SITE_PACKAGES)
-@INSTALL@ -m 0644 libxml2.py $(DESTDIR)$(PYTHON_SITE_PACKAGES)
- -@INSTALL@ -m 0755 _libxml.so $(DESTDIR)$(PYTHON_SITE_PACKAGES)
$(mkinstalldirs) $(DESTDIR)$(DOCS_DIR)
-@(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done)
-libxml.o: libxml.c libxml2-export.c libxml_wrap.h
- $(CC) $(SHCFLAGS) -c -o libxml.o $(srcdir)/libxml.c
-
-types.o: types.c libxml_wrap.h
- $(CC) $(SHCFLAGS) -c -o types.o $(srcdir)/types.c
-
-libxml2-py.o: libxml2-py.c libxml2-py.h libxml_wrap.h
- $(CC) $(SHCFLAGS) -c -o libxml2-py.o $(srcdir)/libxml2-py.c
-
GENERATE = generator.py
API_DESC = $(top_srcdir)/doc/libxml2-api.xml $(srcdir)/libxml2-python-api.xml
GENERATED= $(srcdir)/libxml2class.py \
diff --git a/python/generator.py b/python/generator.py
index 13a1011..13e37f4 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -378,7 +378,8 @@
include.write("PyObject * ")
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name))
- export.write(" { \"%s\", libxml_%s, METH_VARARGS },\n" % (name, name))
+ export.write(" { \"%s\", libxml_%s, METH_VARARGS, NULL },\n" %
+ (name, name))
if file == "python":
# Those have been manually generated
@@ -726,7 +727,7 @@
classes.write(" ret = ");
else:
classes.write(" ");
- classes.write("_libxml.%s(" % name)
+ classes.write("libxml2mod.%s(" % name)
n = 0
for arg in args:
if n != 0:
@@ -775,7 +776,7 @@
if classes_destructors.has_key(classname):
classes.write(" def __del__(self):\n")
classes.write(" if self._o != None:\n")
- classes.write(" _libxml.%s(self._o)\n" %
+ classes.write(" libxml2mod.%s(self._o)\n" %
classes_destructors[classname]);
classes.write(" self._o = None\n\n");
flist = function_classes[classname]
@@ -816,7 +817,7 @@
classes.write(" ret = ");
else:
classes.write(" ");
- classes.write("_libxml.%s(" % name)
+ classes.write("libxml2mod.%s(" % name)
n = 0
for arg in args:
if n != 0:
diff --git a/python/libxml.c b/python/libxml.c
index 30dfd58..7fe9319 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -1351,20 +1351,21 @@
************************************************************************/
static PyMethodDef libxmlMethods[] = {
#include "libxml2-export.c"
- { "name", libxml_name, METH_VARARGS },
- { "children", libxml_children, METH_VARARGS },
- { "properties", libxml_properties, METH_VARARGS },
- { "last", libxml_last, METH_VARARGS },
- { "prev", libxml_prev, METH_VARARGS },
- { "next", libxml_next, METH_VARARGS },
- { "parent", libxml_parent, METH_VARARGS },
- { "type", libxml_type, METH_VARARGS },
- { "doc", libxml_doc, METH_VARARGS },
+ { "name", libxml_name, METH_VARARGS, NULL },
+ { "children", libxml_children, METH_VARARGS, NULL },
+ { "properties", libxml_properties, METH_VARARGS, NULL },
+ { "last", libxml_last, METH_VARARGS, NULL },
+ { "prev", libxml_prev, METH_VARARGS, NULL },
+ { "next", libxml_next, METH_VARARGS, NULL },
+ { "parent", libxml_parent, METH_VARARGS, NULL },
+ { "type", libxml_type, METH_VARARGS, NULL },
+ { "doc", libxml_doc, METH_VARARGS, NULL },
+ { NULL, NULL, NULL, NULL}
};
-void init_libxml(void) {
+void initlibxml2mod(void) {
PyObject *m;
- m = Py_InitModule("_libxml", libxmlMethods);
+ m = Py_InitModule("libxml2mod", libxmlMethods);
libxml_xmlErrorInitialize();
}
diff --git a/python/libxml.py b/python/libxml.py
index 22749f8..fdec3e6 100644
--- a/python/libxml.py
+++ b/python/libxml.py
@@ -1,4 +1,4 @@
-import _libxml
+import libxml2mod
#
# This class is the ancestor of all the Node classes. It provides
@@ -15,43 +15,43 @@
def __getattr__(self, attr):
if attr == "parent":
- ret = _libxml.parent(self._o)
+ ret = libxml2mod.parent(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
elif attr == "properties":
- ret = _libxml.properties(self._o)
+ ret = libxml2mod.properties(self._o)
if ret == None:
return None
return xmlAttr(_obj=ret)
elif attr == "children":
- ret = _libxml.children(self._o)
+ ret = libxml2mod.children(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
elif attr == "last":
- ret = _libxml.last(self._o)
+ ret = libxml2mod.last(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
elif attr == "next":
- ret = _libxml.next(self._o)
+ ret = libxml2mod.next(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
elif attr == "prev":
- ret = _libxml.prev(self._o)
+ ret = libxml2mod.prev(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
elif attr == "content":
- return _libxml.xmlNodeGetContent(self._o)
+ return libxml2mod.xmlNodeGetContent(self._o)
elif attr == "name":
- return _libxml.name(self._o)
+ return libxml2mod.name(self._o)
elif attr == "type":
- return _libxml.type(self._o)
+ return libxml2mod.type(self._o)
elif attr == "doc":
- ret = _libxml.doc(self._o)
+ ret = libxml2mod.doc(self._o)
if ret == None:
return None
return xmlDoc(_doc=ret)
@@ -61,62 +61,62 @@
# Those are common attributes to nearly all type of nodes
#
def get_parent(self):
- ret = _libxml.parent(self._o)
+ ret = libxml2mod.parent(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
def get_children(self):
- ret = _libxml.children(self._o)
+ ret = libxml2mod.children(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
def get_last(self):
- ret = _libxml.last(self._o)
+ ret = libxml2mod.last(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
def get_next(self):
- ret = _libxml.next(self._o)
+ ret = libxml2mod.next(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
def get_properties(self):
- ret = _libxml.properties(self._o)
+ ret = libxml2mod.properties(self._o)
if ret == None:
return None
return xmlAttr(_obj=ret)
def get_doc(self):
- ret = _libxml.doc(self._o)
+ ret = libxml2mod.doc(self._o)
if ret == None:
return None
return xmlDoc(_obj=ret)
def get_prev(self):
- ret = _libxml.prev(self._o)
+ ret = libxml2mod.prev(self._o)
if ret == None:
return None
return xmlNode(_obj=ret)
def get_content(self):
- return _libxml.xmlNodeGetContent(self._o)
+ return libxml2mod.xmlNodeGetContent(self._o)
def getContent(self):
- return _libxml.xmlNodeGetContent(self._o)
+ return libxml2mod.xmlNodeGetContent(self._o)
def get_name(self):
- return _libxml.name(self._o)
+ return libxml2mod.name(self._o)
def get_type(self):
- return _libxml.type(self._o)
+ return libxml2mod.type(self._o)
def get_doc(self):
- ret = _libxml.doc(self._o)
+ ret = libxml2mod.doc(self._o)
if ret == None:
return None
return xmlDoc(_doc=ret)
def free(self):
- _libxml.freeDoc(self._o)
+ libxml2mod.freeDoc(self._o)
#
# converters to present a nicer view of the XPath returns
#
def nodeWrap(o):
# TODO try to cast to the most appropriate node class
- name = _libxml.name(o)
+ name = libxml2mod.name(o)
if name == "element" or name == "text":
return xmlNode(_obj=o)
if name == "attribute":
@@ -145,7 +145,7 @@
# register an XPath function
#
def registerXPathFunction(ctxt, name, ns_uri, f):
- ret = _libxml.xmlRegisterXPathFunction(ctxt, name, ns_uri, f)
+ ret = libxml2mod.xmlRegisterXPathFunction(ctxt, name, ns_uri, f)
#
# Everything below this point is automatically generated