libxml-ruby 4.0.0-x64-mingw-ucrt → 4.1.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,81 +1,81 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "ruby_libxml.h"
4
- #include "ruby_xml_xpath.h"
5
- #include "ruby_xml_xpath_expression.h"
6
-
7
- /*
8
- * Document-class: LibXML::XML::XPath::Expression
9
- *
10
- * The XML::XPath::Expression class is used to compile
11
- * XPath expressions so they can be parsed only once
12
- * but reused multiple times.
13
- *
14
- * doc = XML::Document.string(IO.read('some xml file'))
15
- * expr = XPath::Expression.new('//first')
16
- * doc.root.each do |node|
17
- * result = node.find(expr) # many, many, many times
18
- * # ...
19
- * end
20
- */
21
-
22
- VALUE cXMLXPathExpression;
23
-
24
- static void rxml_xpath_expression_free(xmlXPathCompExprPtr expr)
25
- {
26
- xmlXPathFreeCompExpr(expr);
27
- }
28
-
29
- static VALUE rxml_xpath_expression_alloc(VALUE klass)
30
- {
31
- return Data_Wrap_Struct(cXMLXPathExpression, NULL,
32
- rxml_xpath_expression_free, NULL);
33
- }
34
-
35
- /* call-seq:
36
- * XPath::Expression.compile(expression) -> XPath::Expression
37
- *
38
- * Compiles an XPatch expression. This improves performance
39
- * when an XPath expression is called multiple times.
40
- *
41
- * doc = XML::Document.string('<header><first>hi</first></header>')
42
- * expr = XPath::Expression.new('//first')
43
- * nodes = doc.find(expr)
44
- */
45
- static VALUE rxml_xpath_expression_compile(VALUE klass, VALUE expression)
46
- {
47
- VALUE args[] = {expression};
48
- return rb_class_new_instance(1, args, cXMLXPathExpression);
49
- }
50
-
51
- /* call-seq:
52
- * XPath::Expression.new(expression) -> XPath::Expression
53
- *
54
- * Compiles an XPatch expression. This improves performance
55
- * when an XPath expression is called multiple times.
56
- *
57
- * doc = XML::Document.string('<header><first>hi</first></header>')
58
- * expr = XPath::Expression.new('//first')
59
- * nodes = doc.find(expr)
60
- */
61
- static VALUE rxml_xpath_expression_initialize(VALUE self, VALUE expression)
62
- {
63
- xmlXPathCompExprPtr compexpr = xmlXPathCompile((const xmlChar*)StringValueCStr(expression));
64
-
65
- if (compexpr == NULL)
66
- {
67
- xmlErrorPtr xerror = xmlGetLastError();
68
- rxml_raise(xerror);
69
- }
70
-
71
- DATA_PTR( self) = compexpr;
72
- return self;
73
- }
74
-
75
- void rxml_init_xpath_expression(void)
76
- {
77
- cXMLXPathExpression = rb_define_class_under(mXPath, "Expression", rb_cObject);
78
- rb_define_alloc_func(cXMLXPathExpression, rxml_xpath_expression_alloc);
79
- rb_define_singleton_method(cXMLXPathExpression, "compile", rxml_xpath_expression_compile, 1);
80
- rb_define_method(cXMLXPathExpression, "initialize", rxml_xpath_expression_initialize, 1);
81
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_xpath.h"
5
+ #include "ruby_xml_xpath_expression.h"
6
+
7
+ /*
8
+ * Document-class: LibXML::XML::XPath::Expression
9
+ *
10
+ * The XML::XPath::Expression class is used to compile
11
+ * XPath expressions so they can be parsed only once
12
+ * but reused multiple times.
13
+ *
14
+ * doc = XML::Document.string(IO.read('some xml file'))
15
+ * expr = XPath::Expression.new('//first')
16
+ * doc.root.each do |node|
17
+ * result = node.find(expr) # many, many, many times
18
+ * # ...
19
+ * end
20
+ */
21
+
22
+ VALUE cXMLXPathExpression;
23
+
24
+ static void rxml_xpath_expression_free(xmlXPathCompExprPtr expr)
25
+ {
26
+ xmlXPathFreeCompExpr(expr);
27
+ }
28
+
29
+ static VALUE rxml_xpath_expression_alloc(VALUE klass)
30
+ {
31
+ return Data_Wrap_Struct(cXMLXPathExpression, NULL,
32
+ rxml_xpath_expression_free, NULL);
33
+ }
34
+
35
+ /* call-seq:
36
+ * XPath::Expression.compile(expression) -> XPath::Expression
37
+ *
38
+ * Compiles an XPath expression. This improves performance
39
+ * when an XPath expression is called multiple times.
40
+ *
41
+ * doc = XML::Document.string('<header><first>hi</first></header>')
42
+ * expr = XPath::Expression.new('//first')
43
+ * nodes = doc.find(expr)
44
+ */
45
+ static VALUE rxml_xpath_expression_compile(VALUE klass, VALUE expression)
46
+ {
47
+ VALUE args[] = {expression};
48
+ return rb_class_new_instance(1, args, cXMLXPathExpression);
49
+ }
50
+
51
+ /* call-seq:
52
+ * XPath::Expression.new(expression) -> XPath::Expression
53
+ *
54
+ * Compiles an XPath expression. This improves performance
55
+ * when an XPath expression is called multiple times.
56
+ *
57
+ * doc = XML::Document.string('<header><first>hi</first></header>')
58
+ * expr = XPath::Expression.new('//first')
59
+ * nodes = doc.find(expr)
60
+ */
61
+ static VALUE rxml_xpath_expression_initialize(VALUE self, VALUE expression)
62
+ {
63
+ xmlXPathCompExprPtr compexpr = xmlXPathCompile((const xmlChar*)StringValueCStr(expression));
64
+
65
+ if (compexpr == NULL)
66
+ {
67
+ xmlErrorPtr xerror = xmlGetLastError();
68
+ rxml_raise(xerror);
69
+ }
70
+
71
+ DATA_PTR( self) = compexpr;
72
+ return self;
73
+ }
74
+
75
+ void rxml_init_xpath_expression(void)
76
+ {
77
+ cXMLXPathExpression = rb_define_class_under(mXPath, "Expression", rb_cObject);
78
+ rb_define_alloc_func(cXMLXPathExpression, rxml_xpath_expression_alloc);
79
+ rb_define_singleton_method(cXMLXPathExpression, "compile", rxml_xpath_expression_compile, 1);
80
+ rb_define_method(cXMLXPathExpression, "initialize", rxml_xpath_expression_initialize, 1);
81
+ }