mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-01 10:06:59 +03:00
added a function lookup framework
* xpath.c include/libxml/xpath{,Internals}.h: added a function lookup framework
This commit is contained in:
43
xpath.c
43
xpath.c
@ -2309,6 +2309,24 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
||||
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXPathRegisterFuncLookup:
|
||||
* @ctxt: the XPath context
|
||||
* @f: the lookup function
|
||||
* @data: the lookup data
|
||||
*
|
||||
* Registers an external mecanism to do function lookup.
|
||||
*/
|
||||
void
|
||||
xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
|
||||
xmlXPathFuncLookupFunc f,
|
||||
void *funcCtxt) {
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
ctxt->funcLookupFunc = (void *) f;
|
||||
ctxt->funcLookupData = funcCtxt;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXPathFunctionLookup:
|
||||
* @ctxt: the XPath context
|
||||
@ -2321,6 +2339,17 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
||||
*/
|
||||
xmlXPathFunction
|
||||
xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
|
||||
if (ctxt == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (ctxt->funcLookupFunc != NULL) {
|
||||
xmlXPathFunction ret;
|
||||
|
||||
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
|
||||
(ctxt->funcLookupData, name, NULL);
|
||||
if (ret != NULL)
|
||||
return(ret);
|
||||
}
|
||||
return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
|
||||
}
|
||||
|
||||
@ -2340,11 +2369,21 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
||||
const xmlChar *ns_uri) {
|
||||
if (ctxt == NULL)
|
||||
return(NULL);
|
||||
if (ctxt->funcHash == NULL)
|
||||
return(NULL);
|
||||
if (name == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (ctxt->funcLookupFunc != NULL) {
|
||||
xmlXPathFunction ret;
|
||||
|
||||
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
|
||||
(ctxt->funcLookupData, name, ns_uri);
|
||||
if (ret != NULL)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
if (ctxt->funcHash == NULL)
|
||||
return(NULL);
|
||||
|
||||
return((xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user