1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-16 07:21:58 +03:00

added the possibility of returning nodesets from XPath extension functions

* python/types.c python/tests/Makefile.am python/tests/xpathret.py:
  added the possibility of returning nodesets from XPath extension
  functions written in Python
Daniel
This commit is contained in:
Daniel Veillard
2002-03-01 16:14:17 +00:00
parent a94ec6ff13
commit 79426f2b46
4 changed files with 87 additions and 3 deletions

View File

@ -372,10 +372,30 @@ libxml_xmlXPathObjectPtrConvert(PyObject * obj) {
for (i = 0;i < PyList_Size(obj);i++) {
node = PyList_GetItem(obj, i);
if ((node == NULL) || (node->ob_type == NULL) ||
(!PyCObject_Check(node)))
if ((node == NULL) || (node->ob_type == NULL))
continue;
cur = PyxmlNode_Get(node);
cur = NULL;
if (PyCObject_Check(node)) {
printf("Got a CObject\n");
cur = PyxmlNode_Get(node);
} else if (PyInstance_Check(node)) {
PyInstanceObject *inst = (PyInstanceObject *) node;
PyObject *name = inst->in_class->cl_name;
if PyString_Check(name) {
char *type = PyString_AS_STRING(name);
PyObject *wrapper;
if (!strcmp(type, "xmlNode")) {
wrapper = PyObject_GetAttrString(node, "_o");
if (wrapper != NULL) {
cur = PyxmlNode_Get(wrapper);
}
}
}
} else {
printf("Unknown object in Python return list\n");
}
if (cur != NULL) {
xmlXPathNodeSetAdd(set, cur);
}