libxslt r1458 - in trunk: . libxslt python
- From: veillard svn gnome org
- To: svn-commits-list gnome org
- Subject: libxslt r1458 - in trunk: . libxslt python
- Date: Thu, 13 Mar 2008 08:39:24 +0000 (GMT)
Author: veillard
Date: Thu Mar 13 08:39:24 2008
New Revision: 1458
URL: http://svn.gnome.org/viewvc/libxslt?rev=1458&view=rev
Log:
* libxslt/win32config.h: patch from Rob Richards for VS 2008
* python/types.c: fix a problem with namespace nodes coming from
XPath nodesets.
Daniel
Modified:
trunk/ChangeLog
trunk/libxslt/win32config.h
trunk/python/types.c
Modified: trunk/libxslt/win32config.h
==============================================================================
--- trunk/libxslt/win32config.h (original)
+++ trunk/libxslt/win32config.h Thu Mar 13 08:39:24 2008
@@ -80,8 +80,10 @@
#if defined(_MSC_VER) || defined(__MINGW32__)
#define mkdir(p,m) _mkdir(p)
#define snprintf _snprintf
+#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#endif
+#endif
#define HAVE_SYS_STAT_H
#define HAVE__STAT
Modified: trunk/python/types.c
==============================================================================
--- trunk/python/types.c (original)
+++ trunk/python/types.c Thu Mar 13 08:39:24 2008
@@ -11,6 +11,7 @@
* daniel veillard com
*/
#include "libxml_wrap.h"
+#include <libxml/xpathInternals.h>
PyObject *
libxml_intWrap(int val)
@@ -333,6 +334,24 @@
return (ret);
}
+/**
+ * libxml_xmlXPathDestructNsNode:
+ * cobj: xmlNsPtr namespace node
+ * desc: ignored string
+ *
+ * This function is called if and when a namespace node returned in
+ * an XPath node set is to be destroyed. That's the only kind of
+ * object returned in node set not directly linked to the original
+ * xmlDoc document, see xmlXPathNodeSetDupNs.
+ */
+static void
+libxml_xmlXPathDestructNsNode(void *cobj, void *desc ATTRIBUTE_UNUSED) {
+#ifdef DEBUG
+ fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cobj);
+#endif
+ xmlXPathNodeSetFreeNs((xmlNsPtr) cobj);
+}
+
PyObject *
libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
{
@@ -383,8 +402,17 @@
ret = PyList_New(obj->nodesetval->nodeNr);
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
node = obj->nodesetval->nodeTab[i];
- /* TODO: try to cast directly to the proper node type */
- PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node));
+ if (node->type == XML_NAMESPACE_DECL) {
+ PyObject *ns =
+ PyCObject_FromVoidPtrAndDesc((void *) node,
+ (char *) "xmlNsPtr",
+ libxml_xmlXPathDestructNsNode);
+ PyList_SetItem(ret, i, ns);
+ /* make sure the xmlNsPtr is not destroyed now */
+ obj->nodesetval->nodeTab[i] = NULL;
+ } else {
+ PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node));
+ }
}
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]