[seed] xml: Bind xpath.rxpathRegisterNs
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] xml: Bind xpath.rxpathRegisterNs
- Date: Wed, 13 May 2009 20:09:11 -0400 (EDT)
commit 8b8630cfa6501d1d689b6921779725805a4dbdd9
Author: Robert Carr <racarr svn gnome org>
Date: Wed May 13 20:09:03 2009 -0400
xml: Bind xpath.rxpathRegisterNs
---
modules/libxml/libxml.c | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/modules/libxml/libxml.c b/modules/libxml/libxml.c
index dd45005..0327151 100644
--- a/modules/libxml/libxml.c
+++ b/modules/libxml/libxml.c
@@ -308,8 +308,6 @@ seed_xml_xpath_eval (SeedContext ctx,
xmlXPathContextPtr xpath_ctx;
gchar *xpath;
- xpath_ctx = XML_XPATH_PRIV (this_object);
-
if (argument_count != 1)
{
seed_make_exception (ctx, exception,
@@ -318,6 +316,8 @@ seed_xml_xpath_eval (SeedContext ctx,
argument_count);
return seed_make_null (ctx);
}
+ xpath_ctx = XML_XPATH_PRIV (this_object);
+
xpath = seed_value_to_string (ctx, arguments[0], exception);
xpath_obj = xmlXPathEval (xpath, xpath_ctx);
g_free (xpath);
@@ -326,6 +326,35 @@ seed_xml_xpath_eval (SeedContext ctx,
}
static SeedValue
+seed_xml_xpath_register_ns (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ xmlXPathContextPtr xpath;
+ gchar *prefix;
+ gchar *ns_uri;
+ if (argument_count != 2)
+ {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "xpathRegisterNs expects 2 arguments, got %zd",
+ argument_count);
+ return seed_make_undefined (ctx);
+ }
+ ctx = XML_XPATH_PRIV (this_object);
+ prefix = seed_value_to_string (ctx, arguments[0], exception);
+ ns_uri = seed_value_to_string (ctx, arguments[1], exception);
+
+ xmlXPathRegisterNs (xpath, prefix, ns_uri);
+ g_free (prefix);
+ g_free (ns_uri);
+
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
seed_xml_construct_xpath_context (SeedContext ctx,
SeedObject function,
SeedObject this_object,
@@ -452,6 +481,7 @@ seed_static_value attr_values[] = {
seed_static_function xpath_funcs[] = {
{"xpathEval", seed_xml_xpath_eval, 0},
+ {"xpathRegisterNs", seed_xml_xpath_register_ns, 0},
{0, 0, 0}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]