aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2012-09-19 13:41:56 -0400
committerDaniel Veillard <veillard@redhat.com>2013-03-27 15:55:36 +0800
commit519bc6a3ab82445a8719f548d0450efe02cc9c82 (patch)
treeeb9ecba7af479f1fbbf5eeabe0a1108bc677da09 /python
parent483272f3f004f8538239ff8707b8c6ea02e397c9 (diff)
downloadandroid_external_libxml2-519bc6a3ab82445a8719f548d0450efe02cc9c82.tar.gz
android_external_libxml2-519bc6a3ab82445a8719f548d0450efe02cc9c82.tar.bz2
android_external_libxml2-519bc6a3ab82445a8719f548d0450efe02cc9c82.zip
Add support for xpathRegisterVariable in Python
Diffstat (limited to 'python')
-rw-r--r--python/libxml.c26
-rw-r--r--python/libxml2-python-api.xml9
-rw-r--r--python/types.c1
3 files changed, 35 insertions, 1 deletions
diff --git a/python/libxml.c b/python/libxml.c
index 8c66fed6..8bb3db27 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -2329,6 +2329,32 @@ libxml_xmlRegisterXPathFunction(ATTRIBUTE_UNUSED PyObject * self,
return (py_retval);
}
+PyObject *
+libxml_xmlXPathRegisterVariable(ATTRIBUTE_UNUSED PyObject * self,
+ PyObject * args)
+{
+ PyObject *py_retval;
+ int c_retval = 0;
+ xmlChar *name;
+ xmlChar *ns_uri;
+ xmlXPathContextPtr ctx;
+ xmlXPathObjectPtr val;
+ PyObject *pyobj_ctx;
+ PyObject *pyobj_value;
+
+ if (!PyArg_ParseTuple
+ (args, (char *) "OszO:xpathRegisterVariable", &pyobj_ctx, &name,
+ &ns_uri, &pyobj_value))
+ return (NULL);
+
+ ctx = (xmlXPathContextPtr) PyxmlXPathContext_Get(pyobj_ctx);
+ val = libxml_xmlXPathObjectPtrConvert(pyobj_value);
+
+ c_retval = xmlXPathRegisterVariableNS(ctx, name, ns_uri, val);
+ py_retval = libxml_intWrap(c_retval);
+ return (py_retval);
+}
+
/************************************************************************
* *
* Global properties access *
diff --git a/python/libxml2-python-api.xml b/python/libxml2-python-api.xml
index 42f661d5..032b44ba 100644
--- a/python/libxml2-python-api.xml
+++ b/python/libxml2-python-api.xml
@@ -10,6 +10,15 @@
<arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
<arg name='f' type='pythonObject' info='the python function'/>
</function>
+ <function name='xmlXPathRegisterVariable' file='python'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
+ <info>Register a variable with the XPath context</info>
+ <return type='int' info="1 in case of success, 0 or -1 in case of error"/>
+ <arg name='ctx' type='xmlXPathContextPtr' info='the xpathContext'/>
+ <arg name='name' type='xmlChar *' info='the variable name'/>
+ <arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
+ <arg name='value' type='pythonObject' info='the value'/>
+ </function>
<function name='xmlNewNode' file='python'>
<info>Create a new Node</info>
<return type='xmlNodePtr' info="A new element node"/>
diff --git a/python/types.c b/python/types.c
index 54b50de2..2c9ab228 100644
--- a/python/types.c
+++ b/python/types.c
@@ -622,7 +622,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject * obj)
printf("Unable to convert Python Object to XPath");
#endif
}
- Py_DECREF(obj);
return (ret);
}