Commit 70cab35a authored by Daniel Veillard's avatar Daniel Veillard
Browse files

cleanup the extension function lookup always compile the list Daniel

* python/TODO python/libxml.c: cleanup the extension function lookup
* xmlmemory.c include/libxml/xmlmemory.h: always compile the list
Daniel
parent 7a96efc0
Wed Feb 6 17:04:51 CET 2002 Daniel Veillard <daniel@veillard.com>
* python/TODO python/libxml.c: cleanup the extension function lookup
* xmlmemory.c include/libxml/xmlmemory.h: always compile the list
Tue Feb 5 17:33:30 CET 2002 Daniel Veillard <daniel@veillard.com>
* configure.in python/Makefile.am: do not install outside
......
......@@ -39,13 +39,6 @@
* libxml i.e. if libxml has been configured with --with-debug-mem too
*/
#ifdef DEBUG_MEMORY_LOCATION
/**
* MEM_LIST:
*
* keep track of all allocated blocks for error reporting
*/
#define MEM_LIST /* keep a list of all the allocated memory blocks */
#endif
#ifdef __cplusplus
......
......@@ -13,6 +13,8 @@ Things to do:
- access to XPath variables
- xmlBuffer exposure
- xpathContext, being able to set/get info and clean it up
- more work needed on context handling for function lookup
and use of an hash table.
- add regression tests
- SAX flow
- DTD element and attributes content accesses
......
......@@ -769,19 +769,43 @@ static libxml_xpathCallback libxml_xpathCallbacks[10];
static int libxml_xpathCallbacksNb = 0;
static int libxml_xpathCallbacksMax = 10;
/* TODO: this is not reentrant !!! MUST FIX with a per context hash */
static PyObject *current_function = NULL;
static void
libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs) {
PyObject *list, *cur, *result;
xmlXPathObjectPtr obj;
xmlXPathContextPtr rctxt;
PyObject *current_function = NULL;
const xmlChar *name;
const xmlChar *ns_uri;
int i;
if (ctxt == NULL)
return;
rctxt = ctxt->context;
if (rctxt == NULL)
return;
name = rctxt->function;
ns_uri = rctxt->functionURI;
#ifdef DEBUG_XPATH
printf("libxml_xmlXPathFuncCallback called\n");
printf("libxml_xmlXPathFuncCallback called name %s URI %s\n", name, ns_uri);
#endif
/*
* Find the function, it should be there it was there at lookup
*/
for (i = 0;i < libxml_xpathCallbacksNb;i++) {
if (/* TODO (ctxt == libxml_xpathCallbacks[i].ctx) && */
(xmlStrEqual(name, libxml_xpathCallbacks[i].name)) &&
(xmlStrEqual(ns_uri, libxml_xpathCallbacks[i].ns_uri))) {
current_function = libxml_xpathCallbacks[i].function;
}
}
if (current_function == NULL) {
printf("libxml_xmlXPathFuncCallback: internal error %s not found !\n",
name);
return;
}
list = PyTuple_New(nargs);
for (i = 0;i < nargs;i++) {
obj = valuePop(ctxt);
......@@ -803,15 +827,19 @@ libxml_xmlXPathFuncLookupFunc(void *ctxt, const xmlChar *name,
printf("libxml_xmlXPathFuncLookupFunc(%p, %s, %s) called\n",
ctxt, name, ns_uri);
#endif
/*
* This is called once only. The address is then stored in the
* XPath expression evaluation, the proper object to call can
* then still be found using the execution context function
* and functionURI fields.
*/
for (i = 0;i < libxml_xpathCallbacksNb;i++) {
if ((ctxt == libxml_xpathCallbacks[i].ctx) &&
(xmlStrEqual(name, libxml_xpathCallbacks[i].name)) &&
(xmlStrEqual(ns_uri, libxml_xpathCallbacks[i].ns_uri))) {
current_function = libxml_xpathCallbacks[i].function;
return(libxml_xmlXPathFuncCallback);
}
}
current_function = NULL;
return(NULL);
}
......@@ -832,7 +860,6 @@ libxml_xpathCallbacksInitialize(void) {
libxml_xpathCallbacks[i].ns_uri = NULL;
libxml_xpathCallbacks[i].function = NULL;
}
current_function = NULL;
libxml_xpathCallbacksInitialized = 1;
}
......
......@@ -24,6 +24,15 @@
#include <ctype.h>
#endif
/**
* MEM_LIST:
*
* keep track of all allocated blocks for error reporting
* Always build the memory list !
*/
#ifndef MEM_LIST
#define MEM_LIST /* keep a list of all the allocated memory blocks */
#endif
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
......@@ -638,7 +647,6 @@ static FILE *xmlMemoryDumpFile = NULL;
void
xmlMemoryDump(void)
{
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
FILE *dump;
dump = fopen(".memdump", "w");
......@@ -649,7 +657,6 @@ xmlMemoryDump(void)
xmlMemDisplay(xmlMemoryDumpFile);
if (dump != NULL) fclose(dump);
#endif
}
......
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