1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-31 02:43:06 +03:00

fixed bugs when passing result value tree to Python functions. Daniel

* python/types.c: fixed bugs when passing result value tree
  to Python functions.
Daniel
This commit is contained in:
Daniel Veillard
2002-10-20 21:21:26 +00:00
parent 1cebc6af3c
commit 2f28716537
2 changed files with 87 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Sun Oct 20 23:20:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
* python/types.c: fixed bugs when passing result value tree
to Python functions.
Sun Oct 20 15:23:28 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de> Sun Oct 20 15:23:28 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
* libxslt/win32config.h: mapped vsnprintf to _vsnprintf for the * libxslt/win32config.h: mapped vsnprintf to _vsnprintf for the

View File

@ -342,13 +342,37 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
return (Py_None); return (Py_None);
} }
switch (obj->type) { switch (obj->type) {
case XPATH_XSLT_TREE: case XPATH_XSLT_TREE: {
/* TODO !!!! Allocation problems */ if ((obj->nodesetval == NULL) ||
(obj->nodesetval->nodeNr == 0) ||
(obj->nodesetval->nodeTab == NULL)) {
ret = PyList_New(0);
} else {
int i, len = 0;
xmlNodePtr node;
node = obj->nodesetval->nodeTab[0]->children;
while (node != NULL) {
len++;
node = node->next;
}
ret = PyList_New(len);
node = obj->nodesetval->nodeTab[0]->children;
for (i = 0;i < len;i++) {
PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node));
node = node->next;
}
}
/*
* Return now, do not free the object passed down
*/
return (ret);
}
case XPATH_NODESET: case XPATH_NODESET:
if ((obj->nodesetval == NULL) if ((obj->nodesetval == NULL)
|| (obj->nodesetval->nodeNr == 0)) || (obj->nodesetval->nodeNr == 0)) {
ret = PyList_New(0); ret = PyList_New(0);
else { } else {
int i; int i;
xmlNodePtr node; xmlNodePtr node;
@ -469,3 +493,57 @@ libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal)
(char *) "xmlCatalogPtr", NULL); (char *) "xmlCatalogPtr", NULL);
return (ret); return (ret);
} }
PyObject *
libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer)
{
PyObject *ret;
#ifdef DEBUG
printf("libxml_xmlOutputBufferPtrWrap: buffer = %p\n", buffer);
#endif
if (buffer == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret =
PyCObject_FromVoidPtrAndDesc((void *) buffer,
(char *) "xmlOutputBufferPtr", NULL);
return (ret);
}
PyObject *
libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer)
{
PyObject *ret;
#ifdef DEBUG
printf("libxml_xmlParserInputBufferPtrWrap: buffer = %p\n", buffer);
#endif
if (buffer == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret =
PyCObject_FromVoidPtrAndDesc((void *) buffer,
(char *) "xmlParserInputBufferPtr", NULL);
return (ret);
}
PyObject *
libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp)
{
PyObject *ret;
#ifdef DEBUG
printf("libxml_xmlRegexpPtrWrap: regexp = %p\n", regexp);
#endif
if (regexp == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret =
PyCObject_FromVoidPtrAndDesc((void *) regexp,
(char *) "xmlRegexpPtr", NULL);
return (ret);
}