Commit 9589d455 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

Progressing through the TODOs, class description output, extra XML API,

* libxml.spec.in python/Makefile.am python/TODO python/generator.py
  python/libxml.c python/libxml2-python-api.xml
  python/libxml2class.txt: Progressing through the TODOs, class
  description output, extra XML API, RPM now builds the wrappers
  for all python installed versions
Daniel
parent 253aa2c3
Sat Feb 2 11:25:51 CET 2002 Daniel Veillard <daniel@veillard.com>
* libxml.spec.in python/Makefile.am python/TODO python/generator.py
python/libxml.c python/libxml2-python-api.xml
python/libxml2class.txt: Progressing through the TODOs, class
description output, extra XML API, RPM now builds the wrappers
for all python installed versions
Sat Feb 2 10:13:52 CET 2002 Daniel Veillard <daniel@veillard.com>
* configure.in libxml.spec.in python/Makefile.am python/TODO
......
......@@ -87,6 +87,24 @@ install -d $RPM_BUILD_ROOT%{_mandir}/man1
install -d $RPM_BUILD_ROOT%{_mandir}/man4
make prefix=$RPM_BUILD_ROOT%{prefix} mandir=$RPM_BUILD_ROOT%{_mandir} install
#
# this is a bit ugly but tries to generate the bindings for all versions
# of python installed
for i in %{prefix}/include/python*
do
py_version=`echo $i | sed "s+%{prefix}/include/python++"`
if test -x %{prefix}/bin/python$py_version
then
echo generating bindings for Python $py_version
(cd python ; make clean ; \
make PYTHON="%{prefix}/bin/python$py_version" \
PYTHON_VERSION="$py_version"; \
make PYTHON="%{prefix}/bin/python$py_version" \
PYTHON_VERSION="$py_version" \
prefix=$RPM_BUILD_ROOT%{prefix} \
mandir=$RPM_BUILD_ROOT%{_mandir} install)
fi
done
%clean
rm -rf $RPM_BUILD_ROOT
......
......@@ -34,7 +34,7 @@ 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
API_DESC = $(top_srcdir)/doc/libxml2-api.xml $(srcdir)/libxml2-python-api.xml
GENERATED= $(srcdir)/libxml2class.py \
$(srcdir)/libxml2-export.c \
$(srcdir)/libxml2-py.c \
......
TODO for the libxml2 Python wrappers
$Id$
$Id$
Things to do:
-------------
......@@ -8,13 +8,8 @@ Things to do:
- handling of node.content
- SAX interfaces
- error redirections and preformat
- class hierarchy:
+ get the generator to output a classes.txt description
- extensions based on a python.xml description of the new specific
interfaces
- memory debug interfaces
- enums -> libxml.py
- spec file: automatically generate for pythonX.Y if found
- access to XPath variables
- parserCtxt exposure:
- entry points
......@@ -33,9 +28,18 @@ Done:
-----
- class hierarchy:
+ make specific node type inherit from xmlNode
done, had to sort the classes in the output
+ get the generator to output a classes.txt description
done libxml2class.txt
- add regression tests
- tests/Makefile.am: export the Python class path
- xpath queries
- xpath extension
- extensions based on a python.xml description of the new specific
interfaces
file libxml2-python-api.xml , first entry is xmlRegisterXPathFunction
- spec file: automatically generate for pythonX.Y if found
Done, a bit ugly by running new makes in %install for each level
found.
Daniel Veillard
......@@ -361,7 +361,13 @@ def print_function_wrapper(name, output, export, include):
include.write("PyObject * ")
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name))
export.write(" { \"%s\", libxml_%s, METH_VARARGS },\n" % (name, name))
if file == "python":
# Those have been manually generated
return 1
output.write("PyObject *\n")
output.write("libxml_%s(PyObject *self, PyObject *args) {\n" % (name))
if ret[0] != 'void':
......@@ -391,7 +397,22 @@ try:
except IOError, msg:
print file, ":", msg
print "Found %d functions in libxml2-api.xml" % (len(functions.keys()))
n = len(functions.keys())
print "Found %d functions in libxml2-api.xml" % (n)
py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
try:
f = open("libxml2-python-api.xml")
data = f.read()
(parser, target) = getparser()
parser.feed(data)
parser.close()
except IOError, msg:
print file, ":", msg
print "Found %d functions in libxml2-python-api.xml" % (
len(functions.keys()) - n)
nb_wrap = 0
failed = 0
skipped = 0
......@@ -487,8 +508,12 @@ for type in classes_type.keys():
# Build the list of C types to look for ordered to start with primary classes
#
ctypes = []
classes_list = []
ctypes_processed = {}
classes_processed = {}
for classe in primary_classes:
classes_list.append(classe)
classes_processed[classe] = ()
for type in classes_type.keys():
tinfo = classes_type[type]
if tinfo[2] == classe:
......@@ -498,6 +523,10 @@ for type in classes_type.keys():
if ctypes_processed.has_key(type):
continue
tinfo = classes_type[type]
if not classes_processed.has_key(tinfo[2]):
classes_list.append(tinfo[2])
classes_processed[tinfo[2]] = ()
ctypes.append(type)
ctypes_processed[type] = ()
......@@ -511,6 +540,9 @@ def nameFixup(function, classe, type):
elif name[0:l] == classe:
func = name[l:]
func = string.lower(func[0:1]) + func[1:]
elif name[0:7] == "libxml_":
func = name[7:]
func = string.lower(func[0:1]) + func[1:]
elif name[0:6] == "xmlGet":
func = name[6:]
func = string.lower(func[0:1]) + func[1:]
......@@ -656,7 +688,7 @@ if function_classes.has_key("None"):
classes.write("\n");
txt.write("\n\n#\n# Set of classes of the module\n#\n\n")
for classname in function_classes.keys():
for classname in classes_list:
if classname == "None":
pass
else:
......
......@@ -419,6 +419,7 @@ libxml_registerXPathFunction(PyObject *self, PyObject *args) {
libxml_xpathCallbacks[i].name = xmlStrdup(name);
libxml_xpathCallbacks[i].ns_uri = xmlStrdup(ns_uri);
libxml_xpathCallbacks[i].function = pyobj_f;
c_retval = 1;
}
done:
py_retval = libxml_intWrap((int) c_retval);
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<api name='libxml2-python'>
<files>
<file name='python'>
<exports symbol='libxml_registerXPathFunction'/>
</file>
</files>
<symbols>
<function name='xmlRegisterXPathFunction' file='python'>
<info>Register a Python written function to the XPath interpreter</info>
<return type='int' info="1 in case of success, 0 or -1 in case of error"/>
<arg name='ctx' type='xmlXPathContextPtr' info='the xpathContext'/>
<arg name='name' type='xmlChar *' info='the function name'/>
<arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
<arg name='f' type='pythonObject' info='the python function'/>
</function>
</symbols>
</api>
......@@ -131,85 +131,6 @@ checkVersion()
# Set of classes of the module
#
Class xpathContext()
# functions from module xpath
xpathEval()
xpathEvalExpression()
# functions from module xpathInternals
xpathFreeContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
Class xmlDoc(xmlNode)
# functions from module HTMLparser
htmlAutoCloseTag()
htmlIsAutoClosed()
# functions from module HTMLtree
htmlGetMetaEncoding()
htmlSaveFile()
htmlSaveFileEnc()
htmlSaveFileFormat()
htmlSetMetaEncoding()
# functions from module entities
addDocEntity()
addDtdEntity()
docEntity()
dtdEntity()
encodeEntities()
encodeEntitiesReentrant()
encodeSpecialChars()
parameterEntity()
# functions from module tree
copyDoc()
createIntSubset()
docCompressMode()
freeDoc()
getRootElement()
intSubset()
newCDataBlock()
newCharRef()
newDocComment()
newDocFragment()
newDocNode()
newDocProp()
newDocRawNode()
newDocText()
newDocTextLen()
newDtd()
newGlobalNs()
newReference()
saveFile()
saveFileEnc()
saveFormatFile()
saveFormatFileEnc()
setDocCompressMode()
stringGetNodeList()
stringLenGetNodeList()
# functions from module valid
ID()
isMixedElement()
removeID()
removeRef()
# functions from module xinclude
xincludeProcess()
# functions from module xpathInternals
xpathNewContext()
Class xmlNode(xmlCore)
......@@ -290,20 +211,80 @@ Class xmlNode(xmlCore)
xpathNewValueTree()
Class xmlAttribute(xmlNode)
Class xmlDoc(xmlNode)
# functions from module HTMLparser
htmlAutoCloseTag()
htmlIsAutoClosed()
Class xmlDtd(xmlNode)
# functions from module HTMLtree
htmlGetMetaEncoding()
htmlSaveFile()
htmlSaveFileEnc()
htmlSaveFileFormat()
htmlSetMetaEncoding()
# functions from module entities
addDocEntity()
addDtdEntity()
docEntity()
dtdEntity()
encodeEntities()
encodeEntitiesReentrant()
encodeSpecialChars()
parameterEntity()
# functions from module tree
copyDtd()
freeDtd()
copyDoc()
createIntSubset()
docCompressMode()
freeDoc()
getRootElement()
intSubset()
newCDataBlock()
newCharRef()
newDocComment()
newDocFragment()
newDocNode()
newDocProp()
newDocRawNode()
newDocText()
newDocTextLen()
newDtd()
newGlobalNs()
newReference()
saveFile()
saveFileEnc()
saveFormatFile()
saveFormatFileEnc()
setDocCompressMode()
stringGetNodeList()
stringLenGetNodeList()
# functions from module valid
dtdAttrDesc()
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
ID()
isMixedElement()
removeID()
removeRef()
# functions from module xinclude
xincludeProcess()
# functions from module xpathInternals
xpathNewContext()
Class xmlEntity(xmlNode)
Class xmlNs(xmlNode)
# functions from module tree
copyNamespace()
copyNamespaceList()
freeNs()
freeNsList()
newNode()
Class xmlAttr(xmlNode)
......@@ -314,17 +295,39 @@ Class xmlAttr(xmlNode)
removeProp()
Class xmlEntity(xmlNode)
Class xmlAttribute(xmlNode)
Class xmlDtd(xmlNode)
# functions from module tree
copyDtd()
freeDtd()
# functions from module valid
dtdAttrDesc()
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
Class xmlElement(xmlNode)
Class xpathContext()
# functions from module python
registerXPathFunction()
Class xmlNs(xmlNode)
# functions from module xpath
xpathEval()
xpathEvalExpression()
# functions from module tree
copyNamespace()
copyNamespaceList()
freeNs()
freeNsList()
newNode()
# functions from module xpathInternals
xpathFreeContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment