mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-28 00:21:53 +03:00
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
This commit is contained in:
@ -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 \
|
||||
|
16
python/TODO
16
python/TODO
@ -1,6 +1,6 @@
|
||||
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);
|
||||
|
18
python/libxml2-python-api.xml
Normal file
18
python/libxml2-python-api.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?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,6 +211,90 @@ Class xmlNode(xmlCore)
|
||||
xpathNewValueTree()
|
||||
|
||||
|
||||
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 xmlEntity(xmlNode)
|
||||
|
||||
|
||||
Class xmlNs(xmlNode)
|
||||
|
||||
# functions from module tree
|
||||
copyNamespace()
|
||||
copyNamespaceList()
|
||||
freeNs()
|
||||
freeNsList()
|
||||
newNode()
|
||||
|
||||
|
||||
Class xmlAttr(xmlNode)
|
||||
|
||||
# functions from module tree
|
||||
freeProp()
|
||||
freePropList()
|
||||
removeProp()
|
||||
|
||||
|
||||
Class xmlAttribute(xmlNode)
|
||||
|
||||
|
||||
@ -306,25 +311,23 @@ Class xmlDtd(xmlNode)
|
||||
dtdQElementDesc()
|
||||
|
||||
|
||||
Class xmlAttr(xmlNode)
|
||||
|
||||
# functions from module tree
|
||||
freeProp()
|
||||
freePropList()
|
||||
removeProp()
|
||||
|
||||
|
||||
Class xmlEntity(xmlNode)
|
||||
|
||||
|
||||
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()
|
||||
|
Reference in New Issue
Block a user