mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-17 18:21:05 +03:00
Changed to the MIT Licence updated the doc accordingly preparing 2.4.14
* Copyright Makefile.am README configure.in libxml.spec.in: Changed to the MIT Licence * doc/FAQ.html doc/catalog.html doc/intro.html doc/xml.html doc/xmlio.html: updated the doc accordingly * include/libxml/xmlwin32version.h configure.in: preparing 2.4.14 release * python/generator.py python/libxml.c python/libxml2-python-api.xml python/libxml2class.txt python/libxml_wrap.h python/types.c: fixed the const xmlChar * wrapper and generator, XPath extension functions now use the context as first argument * python/tests/tstxpath.py python/tests/xpath.py python/tests/xpathext.py: Updated the tests accordingly * tree.c: fixed bug #70067 Daniel
This commit is contained in:
@ -214,9 +214,9 @@ py_types = {
|
||||
'xmlChar': ('c', None, "int", "int"),
|
||||
'unsigned char *': ('z', None, "charPtr", "char *"),
|
||||
'char *': ('z', None, "charPtr", "char *"),
|
||||
'const char *': ('z', None, "charPtr", "char *"),
|
||||
'const char *': ('z', None, "charPtrConst", "const char *"),
|
||||
'xmlChar *': ('z', None, "xmlCharPtr", "xmlChar *"),
|
||||
'const xmlChar *': ('z', None, "xmlCharPtr", "xmlChar *"),
|
||||
'const xmlChar *': ('z', None, "xmlCharPtrConst", "const xmlChar *"),
|
||||
'xmlNodePtr': ('O', "xmlNode", "xmlNodePtr", "xmlNodePtr"),
|
||||
'const xmlNodePtr': ('O', "xmlNode", "xmlNodePtr", "xmlNodePtr"),
|
||||
'xmlNode *': ('O', "xmlNode", "xmlNodePtr", "xmlNodePtr"),
|
||||
@ -523,7 +523,6 @@ classes_ancestor = {
|
||||
"xmlAttribute" : "xmlNode",
|
||||
}
|
||||
classes_destructors = {
|
||||
"xpathContext": "xmlXPathFreeContext",
|
||||
"parserCtxt": "xmlFreeParserCtxt",
|
||||
"catalog": "xmlFreeCatalog",
|
||||
}
|
||||
@ -576,6 +575,12 @@ def nameFixup(function, classe, type, file):
|
||||
elif name[0:10] == "xmlNodeGet" and file == "python_accessor":
|
||||
func = name[10:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
elif name[0:17] == "xmlXPathParserGet" and file == "python_accessor":
|
||||
func = name[17:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
elif name[0:11] == "xmlXPathGet" and file == "python_accessor":
|
||||
func = name[11:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
elif name[0:11] == "xmlACatalog":
|
||||
func = name[11:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
|
@ -806,11 +806,12 @@ libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
return;
|
||||
}
|
||||
|
||||
list = PyTuple_New(nargs);
|
||||
list = PyTuple_New(nargs + 1);
|
||||
PyTuple_SetItem(list, 0, libxml_xmlXPathParserContextPtrWrap(ctxt));
|
||||
for (i = 0;i < nargs;i++) {
|
||||
obj = valuePop(ctxt);
|
||||
cur = libxml_xmlXPathObjectPtrWrap(obj);
|
||||
PyTuple_SetItem(list, i, cur);
|
||||
PyTuple_SetItem(list, i + 1, cur);
|
||||
}
|
||||
result = PyEval_CallObject(current_function, list);
|
||||
Py_DECREF(list);
|
||||
|
@ -36,6 +36,7 @@
|
||||
<arg name='size' type='int' info='the size of the initial data'/>
|
||||
<arg name='URI' type='xmlChar *' info='The URI used for base computations'/>
|
||||
</function>
|
||||
<!-- xmlParserCtxtPtr accessors -->
|
||||
<function name='xmlParserGetDoc' file='python_accessor'>
|
||||
<info>Get the document tree from a parser context.</info>
|
||||
<return type='xmlDocPtr' info="the document tree" field="myDoc"/>
|
||||
@ -90,6 +91,7 @@
|
||||
<info>dump the memory allocated in the file .memdump</info>
|
||||
<return type='void'/>
|
||||
</function>
|
||||
<!-- xmlNsPtr accessors -->
|
||||
<function name='xmlNodeGetNs' file='python_accessor'>
|
||||
<info>Get the namespace of a node</info>
|
||||
<return type='xmlNsPtr' info="The namespace or None"/>
|
||||
@ -100,5 +102,41 @@
|
||||
<return type='xmlNsPtr' info="The namespace or None"/>
|
||||
<arg name='node' type='xmlNodePtr' info='the node'/>
|
||||
</function>
|
||||
<!-- xmlXPathParserContextPtr accessors -->
|
||||
<function name='xmlXPathParserGetContext' file='python_accessor'>
|
||||
<info>Get the xpathContext from an xpathParserContext</info>
|
||||
<return type='xmlXPathContextPtr' info="The XPath context" field="context"/>
|
||||
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPath parser context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetContextDoc' file='python_accessor'>
|
||||
<info>Get the doc from an xpathContext</info>
|
||||
<return type='xmlDocPtr' info="The doc context" field="doc"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetContextNode' file='python_accessor'>
|
||||
<info>Get the current node from an xpathContext</info>
|
||||
<return type='xmlNodePtr' info="The node context" field="node"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetContextPosition' file='python_accessor'>
|
||||
<info>Get the current node from an xpathContext</info>
|
||||
<return type='int' info="The node context" field="proximityPosition"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetContextSize' file='python_accessor'>
|
||||
<info>Get the current node from an xpathContext</info>
|
||||
<return type='int' info="The node context" field="contextSize"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetFunction' file='python_accessor'>
|
||||
<info>Get the current function name xpathContext</info>
|
||||
<return type='const xmlChar *' info="The function name" field="function"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
<function name='xmlXPathGetFunctionURI' file='python_accessor'>
|
||||
<info>Get the current function name URI xpathContext</info>
|
||||
<return type='const xmlChar *' info="The function name URI" field="functionURI"/>
|
||||
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
|
||||
</function>
|
||||
</symbols>
|
||||
</api>
|
||||
|
@ -374,6 +374,8 @@ Class catalog()
|
||||
resolveSystem()
|
||||
resolveURI()
|
||||
Class xpathParserContext()
|
||||
# accessors
|
||||
context()
|
||||
|
||||
# functions from module xpathInternals
|
||||
xpathAddValues()
|
||||
@ -507,6 +509,13 @@ Class xmlAttr(xmlNode)
|
||||
freePropList()
|
||||
removeProp()
|
||||
Class xpathContext()
|
||||
# accessors
|
||||
contextDoc()
|
||||
contextNode()
|
||||
contextPosition()
|
||||
contextSize()
|
||||
function()
|
||||
functionURI()
|
||||
|
||||
# functions from module python
|
||||
registerXPathFunction()
|
||||
|
@ -64,6 +64,8 @@ PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
|
||||
PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
|
||||
PyObject * libxml_charPtrWrap(char *str);
|
||||
PyObject * libxml_constcharPtrWrap(const char *str);
|
||||
PyObject * libxml_charPtrConstWrap(const char *str);
|
||||
PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
|
||||
PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
|
||||
PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
|
||||
PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
|
||||
|
@ -5,11 +5,20 @@ import libxml2
|
||||
#memory debug specific
|
||||
libxml2.debugMemory(1)
|
||||
|
||||
called = ""
|
||||
|
||||
def foo(x):
|
||||
def foo(ctx, x):
|
||||
global called
|
||||
|
||||
#
|
||||
# test that access to the XPath evaluation contexts
|
||||
#
|
||||
pctxt = libxml2.xpathParserContext(_obj=ctx)
|
||||
ctxt = pctxt.context()
|
||||
called = ctxt.function()
|
||||
return x + 1
|
||||
|
||||
def bar(x):
|
||||
def bar(ctxt, x):
|
||||
return "%d" % (x + 2)
|
||||
|
||||
doc = libxml2.parseFile("tst.xml")
|
||||
@ -21,7 +30,6 @@ if len(res) != 2:
|
||||
if res[0].name != "doc" or res[1].name != "foo":
|
||||
print "xpath query: wrong node set value"
|
||||
sys.exit(1)
|
||||
|
||||
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
|
||||
libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
|
||||
i = 10000
|
||||
@ -39,7 +47,12 @@ while i > 0:
|
||||
sys.exit(1)
|
||||
i = i - 1
|
||||
doc.freeDoc()
|
||||
del ctxt
|
||||
ctxt.xpathFreeContext()
|
||||
|
||||
if called != "foo":
|
||||
print "xpath function: failed to access the context"
|
||||
print "xpath function: %s" % (called)
|
||||
sys.exit(1)
|
||||
|
||||
#memory debug specific
|
||||
libxml2.cleanupParser()
|
||||
|
@ -23,12 +23,14 @@ if res[0].name != "doc" or res[1].name != "foo":
|
||||
print "xpath query: wrong node set value"
|
||||
sys.exit(1)
|
||||
doc.freeDoc()
|
||||
ctxt.xpathFreeContext()
|
||||
i = 1000
|
||||
while i > 0:
|
||||
doc = libxml2.parseFile("tst.xml")
|
||||
ctxt = doc.xpathNewContext()
|
||||
res = ctxt.xpathEval("//*")
|
||||
doc.freeDoc()
|
||||
ctxt.xpathFreeContext()
|
||||
i = i -1
|
||||
del ctxt
|
||||
|
||||
|
@ -5,10 +5,10 @@ import libxml2
|
||||
# Memory debug specific
|
||||
libxml2.debugMemory(1)
|
||||
|
||||
def foo(x):
|
||||
def foo(ctx, x):
|
||||
return x + 1
|
||||
|
||||
def bar(x):
|
||||
def bar(ctx, x):
|
||||
return "%d" % (x + 2)
|
||||
|
||||
doc = libxml2.parseFile("tst.xml")
|
||||
@ -38,7 +38,7 @@ while i > 0:
|
||||
sys.exit(1)
|
||||
i = i - 1
|
||||
doc.freeDoc()
|
||||
del ctxt
|
||||
ctxt.xpathFreeContext()
|
||||
|
||||
# Memory debug specific
|
||||
libxml2.cleanupParser()
|
||||
|
@ -58,6 +58,22 @@ libxml_charPtrWrap(char *str) {
|
||||
return(ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libxml_charPtrConstWrap(const char *str) {
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlcharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return(Py_None);
|
||||
}
|
||||
/* TODO: look at deallocation */
|
||||
ret = PyString_FromString(str);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libxml_xmlCharPtrWrap(xmlChar *str) {
|
||||
PyObject *ret;
|
||||
@ -75,6 +91,22 @@ libxml_xmlCharPtrWrap(xmlChar *str) {
|
||||
return(ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libxml_xmlCharPtrConstWrap(const xmlChar *str) {
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libxml_xmlCharPtrWrap: str = %s\n", str);
|
||||
#endif
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return(Py_None);
|
||||
}
|
||||
/* TODO: look at deallocation */
|
||||
ret = PyString_FromString(str);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libxml_constcharPtrWrap(const char *str) {
|
||||
PyObject *ret;
|
||||
|
Reference in New Issue
Block a user