[xml] 2 patches for python type mapping
- From: Nic James Ferrier <nferrier tapsellferrier co uk>
- To: libxml <xml gnome org>
- Subject: [xml] 2 patches for python type mapping
- Date: Thu, 15 Jun 2006 00:10:19 +0100
Python type mapping is not complete (grrr!)
Here is the first patch which sorts out libxml2:
--- ../libxml2-2.6.24.dfsg/python/types.c 2006-05-08 22:03:23.000000000 +0100
+++ libxml2-2.6.24.dfsg/python/types.c 2006-05-11 16:06:28.000000000 +0100
@@ -422,6 +422,20 @@
if PyFloat_Check
(obj) {
ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
+
+ } else if PyInt_Check(obj) {
+
+ ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj));
+
+ } else if PyBool_Check (obj) {
+
+ if (obj == Py_True) {
+ ret = xmlXPathNewBoolean(1);
+ }
+ else {
+ ret = xmlXPathNewBoolean(0);
+ }
+
} else if PyString_Check
(obj) {
xmlChar *str;
The second does libxslt:
--- ../libxslt-1.1.16/python/types.c 2006-02-22 14:59:29.000000000 +0000
+++ libxslt-1.1.16/python/types.c 2006-05-11 16:06:50.000000000 +0100
@@ -425,6 +425,19 @@
if PyFloat_Check
(obj) {
ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
+ } else if PyInt_Check(obj) {
+
+ ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj));
+
+ } else if PyBool_Check (obj) {
+
+ if (obj == Py_True) {
+ ret = xmlXPathNewBoolean(1);
+ }
+ else {
+ ret = xmlXPathNewBoolean(0);
+ }
+
} else if PyString_Check
(obj) {
xmlChar *str;
These patches improve it for my problem domain. I'll submit more
patches as I come to need the mappings /8->
I have a question about this code though: It's a bit wierd that the
method is duplicated. Would it not be sensible for libxslt to simply
call libxml2's implementation?
--
Nic Ferrier
http://www.tapsellferrier.co.uk for all your tapsell ferrier needs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]