nokogiri 1.14.5-aarch64-linux → 1.15.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -8
  3. data/dependencies.yml +6 -6
  4. data/ext/nokogiri/extconf.rb +66 -22
  5. data/ext/nokogiri/html4_document.c +1 -2
  6. data/ext/nokogiri/html4_element_description.c +19 -14
  7. data/ext/nokogiri/html4_sax_parser_context.c +10 -16
  8. data/ext/nokogiri/html4_sax_push_parser.c +2 -2
  9. data/ext/nokogiri/include/libexslt/exsltconfig.h +3 -3
  10. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +52 -38
  11. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +18 -18
  12. data/ext/nokogiri/include/libxml2/libxml/SAX.h +36 -36
  13. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +37 -36
  14. data/ext/nokogiri/include/libxml2/libxml/c14n.h +4 -4
  15. data/ext/nokogiri/include/libxml2/libxml/catalog.h +36 -36
  16. data/ext/nokogiri/include/libxml2/libxml/chvalid.h +9 -9
  17. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +28 -28
  18. data/ext/nokogiri/include/libxml2/libxml/dict.h +13 -13
  19. data/ext/nokogiri/include/libxml2/libxml/encoding.h +20 -19
  20. data/ext/nokogiri/include/libxml2/libxml/entities.h +19 -21
  21. data/ext/nokogiri/include/libxml2/libxml/globals.h +89 -59
  22. data/ext/nokogiri/include/libxml2/libxml/hash.h +25 -25
  23. data/ext/nokogiri/include/libxml2/libxml/list.h +26 -26
  24. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +22 -22
  25. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +17 -17
  26. data/ext/nokogiri/include/libxml2/libxml/parser.h +100 -79
  27. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +149 -143
  28. data/ext/nokogiri/include/libxml2/libxml/pattern.h +15 -15
  29. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +26 -26
  30. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +2 -2
  31. data/ext/nokogiri/include/libxml2/libxml/schematron.h +18 -18
  32. data/ext/nokogiri/include/libxml2/libxml/threads.h +23 -20
  33. data/ext/nokogiri/include/libxml2/libxml/tree.h +166 -164
  34. data/ext/nokogiri/include/libxml2/libxml/uri.h +15 -15
  35. data/ext/nokogiri/include/libxml2/libxml/valid.h +72 -87
  36. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +10 -10
  37. data/ext/nokogiri/include/libxml2/libxml/xlink.h +5 -5
  38. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +60 -59
  39. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +21 -21
  40. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +18 -46
  41. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +14 -41
  42. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +26 -24
  43. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +4 -4
  44. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +87 -87
  45. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +30 -30
  46. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +10 -10
  47. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +30 -30
  48. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +34 -34
  49. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +30 -30
  50. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +166 -166
  51. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +50 -27
  52. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +80 -80
  53. data/ext/nokogiri/include/libxml2/libxml/xpath.h +41 -41
  54. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +117 -117
  55. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +21 -21
  56. data/ext/nokogiri/include/libxslt/attributes.h +1 -0
  57. data/ext/nokogiri/include/libxslt/variables.h +3 -3
  58. data/ext/nokogiri/include/libxslt/xsltInternals.h +14 -4
  59. data/ext/nokogiri/include/libxslt/xsltconfig.h +4 -4
  60. data/ext/nokogiri/include/libxslt/xsltlocale.h +14 -54
  61. data/ext/nokogiri/include/libxslt/xsltutils.h +35 -2
  62. data/ext/nokogiri/nokogiri.c +46 -24
  63. data/ext/nokogiri/nokogiri.h +13 -2
  64. data/ext/nokogiri/xml_attr.c +1 -1
  65. data/ext/nokogiri/xml_cdata.c +10 -2
  66. data/ext/nokogiri/xml_comment.c +1 -1
  67. data/ext/nokogiri/xml_document.c +102 -22
  68. data/ext/nokogiri/xml_document_fragment.c +1 -1
  69. data/ext/nokogiri/xml_dtd.c +1 -1
  70. data/ext/nokogiri/xml_element_content.c +32 -29
  71. data/ext/nokogiri/xml_element_decl.c +5 -5
  72. data/ext/nokogiri/xml_encoding_handler.c +12 -4
  73. data/ext/nokogiri/xml_entity_reference.c +1 -1
  74. data/ext/nokogiri/xml_namespace.c +11 -12
  75. data/ext/nokogiri/xml_node.c +7 -7
  76. data/ext/nokogiri/xml_node_set.c +125 -105
  77. data/ext/nokogiri/xml_processing_instruction.c +1 -1
  78. data/ext/nokogiri/xml_reader.c +37 -28
  79. data/ext/nokogiri/xml_relax_ng.c +65 -78
  80. data/ext/nokogiri/xml_sax_parser.c +24 -5
  81. data/ext/nokogiri/xml_sax_parser_context.c +46 -25
  82. data/ext/nokogiri/xml_sax_push_parser.c +29 -8
  83. data/ext/nokogiri/xml_schema.c +90 -116
  84. data/ext/nokogiri/xml_text.c +10 -2
  85. data/ext/nokogiri/xml_xpath_context.c +156 -83
  86. data/ext/nokogiri/xslt_stylesheet.c +103 -50
  87. data/lib/nokogiri/2.7/nokogiri.so +0 -0
  88. data/lib/nokogiri/3.0/nokogiri.so +0 -0
  89. data/lib/nokogiri/3.1/nokogiri.so +0 -0
  90. data/lib/nokogiri/3.2/nokogiri.so +0 -0
  91. data/lib/nokogiri/css/xpath_visitor.rb +2 -2
  92. data/lib/nokogiri/extension.rb +1 -1
  93. data/lib/nokogiri/html4/document_fragment.rb +1 -1
  94. data/lib/nokogiri/html4/element_description_defaults.rb +1821 -353
  95. data/lib/nokogiri/html5/document_fragment.rb +1 -1
  96. data/lib/nokogiri/html5/node.rb +5 -0
  97. data/lib/nokogiri/html5.rb +5 -2
  98. data/lib/nokogiri/jruby/nokogiri_jars.rb +3 -3
  99. data/lib/nokogiri/version/constant.rb +1 -1
  100. data/lib/nokogiri/xml/attribute_decl.rb +4 -2
  101. data/lib/nokogiri/xml/document_fragment.rb +1 -1
  102. data/lib/nokogiri/xml/element_content.rb +10 -2
  103. data/lib/nokogiri/xml/element_decl.rb +4 -2
  104. data/lib/nokogiri/xml/entity_decl.rb +4 -2
  105. data/lib/nokogiri/xml/node/save_options.rb +8 -0
  106. data/lib/nokogiri/xml/node.rb +22 -13
  107. data/lib/nokogiri/xml/pp/node.rb +23 -12
  108. data/lib/nokogiri/xml/sax/document.rb +1 -1
  109. data/lib/nokogiri/xml/searchable.rb +18 -10
  110. data/lib/nokogiri/xslt.rb +73 -3
  111. data/lib/nokogiri.rb +12 -4
  112. data/lib/xsd/xmlparser/nokogiri.rb +1 -1
  113. metadata +2 -2
@@ -39,8 +39,9 @@ ruby_object_get(xmlNodePtr c_node)
39
39
 
40
40
 
41
41
  static void
42
- mark(xmlNodeSetPtr node_set)
42
+ xml_node_set_mark(void *data)
43
43
  {
44
+ xmlNodeSetPtr node_set = data;
44
45
  VALUE rb_node;
45
46
  int jnode;
46
47
 
@@ -52,6 +53,37 @@ mark(xmlNodeSetPtr node_set)
52
53
  }
53
54
  }
54
55
 
56
+ static void
57
+ xml_node_set_deallocate(void *data)
58
+ {
59
+ xmlNodeSetPtr node_set = data;
60
+ /*
61
+ * For reasons outlined in xml_namespace.c, here we reproduce xmlXPathFreeNodeSet() except for the
62
+ * offending call to xmlXPathNodeSetFreeNs().
63
+ */
64
+ if (node_set->nodeTab != NULL) {
65
+ xmlFree(node_set->nodeTab);
66
+ }
67
+
68
+ xmlFree(node_set);
69
+ }
70
+
71
+
72
+ static VALUE
73
+ xml_node_set_allocate(VALUE klass)
74
+ {
75
+ return noko_xml_node_set_wrap(xmlXPathNodeSetCreate(NULL), Qnil);
76
+ }
77
+
78
+ static const rb_data_type_t xml_node_set_type = {
79
+ .wrap_struct_name = "Nokogiri::XML::NodeSet",
80
+ .function = {
81
+ .dmark = xml_node_set_mark,
82
+ .dfree = xml_node_set_deallocate,
83
+ },
84
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
85
+ };
86
+
55
87
  static void
56
88
  xpath_node_set_del(xmlNodeSetPtr cur, xmlNodePtr val)
57
89
  {
@@ -81,28 +113,6 @@ xpath_node_set_del(xmlNodeSetPtr cur, xmlNodePtr val)
81
113
  }
82
114
 
83
115
 
84
- static void
85
- deallocate(xmlNodeSetPtr node_set)
86
- {
87
- /*
88
- * For reasons outlined in xml_namespace.c, here we reproduce xmlXPathFreeNodeSet() except for the
89
- * offending call to xmlXPathNodeSetFreeNs().
90
- */
91
- if (node_set->nodeTab != NULL) {
92
- xmlFree(node_set->nodeTab);
93
- }
94
-
95
- xmlFree(node_set);
96
- }
97
-
98
-
99
- static VALUE
100
- allocate(VALUE klass)
101
- {
102
- return noko_xml_node_set_wrap(xmlXPathNodeSetCreate(NULL), Qnil);
103
- }
104
-
105
-
106
116
  /*
107
117
  * call-seq:
108
118
  * dup
@@ -111,16 +121,16 @@ allocate(VALUE klass)
111
121
  * duplicated (similar to how Array and other Enumerable classes work).
112
122
  */
113
123
  static VALUE
114
- duplicate(VALUE self)
124
+ duplicate(VALUE rb_self)
115
125
  {
116
- xmlNodeSetPtr node_set;
126
+ xmlNodeSetPtr c_self;
117
127
  xmlNodeSetPtr dupl;
118
128
 
119
- Data_Get_Struct(self, xmlNodeSet, node_set);
129
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
120
130
 
121
- dupl = xmlXPathNodeSetMerge(NULL, node_set);
131
+ dupl = xmlXPathNodeSetMerge(NULL, c_self);
122
132
 
123
- return noko_xml_node_set_wrap(dupl, rb_iv_get(self, "@document"));
133
+ return noko_xml_node_set_wrap(dupl, rb_iv_get(rb_self, "@document"));
124
134
  }
125
135
 
126
136
  /*
@@ -130,13 +140,13 @@ duplicate(VALUE self)
130
140
  * Get the length of the node set
131
141
  */
132
142
  static VALUE
133
- length(VALUE self)
143
+ length(VALUE rb_self)
134
144
  {
135
- xmlNodeSetPtr node_set;
145
+ xmlNodeSetPtr c_self;
136
146
 
137
- Data_Get_Struct(self, xmlNodeSet, node_set);
147
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
138
148
 
139
- return node_set ? INT2NUM(node_set->nodeNr) : INT2NUM(0);
149
+ return c_self ? INT2NUM(c_self->nodeNr) : INT2NUM(0);
140
150
  }
141
151
 
142
152
  /*
@@ -146,19 +156,19 @@ length(VALUE self)
146
156
  * Append +node+ to the NodeSet.
147
157
  */
148
158
  static VALUE
149
- push(VALUE self, VALUE rb_node)
159
+ push(VALUE rb_self, VALUE rb_node)
150
160
  {
151
- xmlNodeSetPtr node_set;
161
+ xmlNodeSetPtr c_self;
152
162
  xmlNodePtr node;
153
163
 
154
164
  Check_Node_Set_Node_Type(rb_node);
155
165
 
156
- Data_Get_Struct(self, xmlNodeSet, node_set);
166
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
157
167
  Noko_Node_Get_Struct(rb_node, xmlNode, node);
158
168
 
159
- xmlXPathNodeSetAdd(node_set, node);
169
+ xmlXPathNodeSetAdd(c_self, node);
160
170
 
161
- return self;
171
+ return rb_self;
162
172
  }
163
173
 
164
174
  /*
@@ -169,18 +179,18 @@ push(VALUE self, VALUE rb_node)
169
179
  * if found, otherwise returns nil.
170
180
  */
171
181
  static VALUE
172
- delete (VALUE self, VALUE rb_node)
182
+ delete (VALUE rb_self, VALUE rb_node)
173
183
  {
174
- xmlNodeSetPtr node_set;
184
+ xmlNodeSetPtr c_self;
175
185
  xmlNodePtr node;
176
186
 
177
187
  Check_Node_Set_Node_Type(rb_node);
178
188
 
179
- Data_Get_Struct(self, xmlNodeSet, node_set);
189
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
180
190
  Noko_Node_Get_Struct(rb_node, xmlNode, node);
181
191
 
182
- if (xmlXPathNodeSetContains(node_set, node)) {
183
- xpath_node_set_del(node_set, node);
192
+ if (xmlXPathNodeSetContains(c_self, node)) {
193
+ xpath_node_set_del(c_self, node);
184
194
  return rb_node;
185
195
  }
186
196
  return Qnil ;
@@ -194,20 +204,20 @@ delete (VALUE self, VALUE rb_node)
194
204
  * Set Intersection — Returns a new NodeSet containing nodes common to the two NodeSets.
195
205
  */
196
206
  static VALUE
197
- intersection(VALUE self, VALUE rb_other)
207
+ intersection(VALUE rb_self, VALUE rb_other)
198
208
  {
199
- xmlNodeSetPtr node_set, other ;
209
+ xmlNodeSetPtr c_self, c_other ;
200
210
  xmlNodeSetPtr intersection;
201
211
 
202
212
  if (!rb_obj_is_kind_of(rb_other, cNokogiriXmlNodeSet)) {
203
213
  rb_raise(rb_eArgError, "node_set must be a Nokogiri::XML::NodeSet");
204
214
  }
205
215
 
206
- Data_Get_Struct(self, xmlNodeSet, node_set);
207
- Data_Get_Struct(rb_other, xmlNodeSet, other);
216
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
217
+ TypedData_Get_Struct(rb_other, xmlNodeSet, &xml_node_set_type, c_other);
208
218
 
209
- intersection = xmlXPathIntersection(node_set, other);
210
- return noko_xml_node_set_wrap(intersection, rb_iv_get(self, "@document"));
219
+ intersection = xmlXPathIntersection(c_self, c_other);
220
+ return noko_xml_node_set_wrap(intersection, rb_iv_get(rb_self, "@document"));
211
221
  }
212
222
 
213
223
 
@@ -218,17 +228,17 @@ intersection(VALUE self, VALUE rb_other)
218
228
  * Returns true if any member of node set equals +node+.
219
229
  */
220
230
  static VALUE
221
- include_eh(VALUE self, VALUE rb_node)
231
+ include_eh(VALUE rb_self, VALUE rb_node)
222
232
  {
223
- xmlNodeSetPtr node_set;
233
+ xmlNodeSetPtr c_self;
224
234
  xmlNodePtr node;
225
235
 
226
236
  Check_Node_Set_Node_Type(rb_node);
227
237
 
228
- Data_Get_Struct(self, xmlNodeSet, node_set);
238
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
229
239
  Noko_Node_Get_Struct(rb_node, xmlNode, node);
230
240
 
231
- return (xmlXPathNodeSetContains(node_set, node) ? Qtrue : Qfalse);
241
+ return (xmlXPathNodeSetContains(c_self, node) ? Qtrue : Qfalse);
232
242
  }
233
243
 
234
244
 
@@ -240,22 +250,22 @@ include_eh(VALUE self, VALUE rb_node)
240
250
  * set.
241
251
  */
242
252
  static VALUE
243
- rb_xml_node_set_union(VALUE rb_node_set, VALUE rb_other)
253
+ rb_xml_node_set_union(VALUE rb_self, VALUE rb_other)
244
254
  {
245
- xmlNodeSetPtr c_node_set, c_other;
255
+ xmlNodeSetPtr c_self, c_other;
246
256
  xmlNodeSetPtr c_new_node_set;
247
257
 
248
258
  if (!rb_obj_is_kind_of(rb_other, cNokogiriXmlNodeSet)) {
249
259
  rb_raise(rb_eArgError, "node_set must be a Nokogiri::XML::NodeSet");
250
260
  }
251
261
 
252
- Data_Get_Struct(rb_node_set, xmlNodeSet, c_node_set);
253
- Data_Get_Struct(rb_other, xmlNodeSet, c_other);
262
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
263
+ TypedData_Get_Struct(rb_other, xmlNodeSet, &xml_node_set_type, c_other);
254
264
 
255
- c_new_node_set = xmlXPathNodeSetMerge(NULL, c_node_set);
265
+ c_new_node_set = xmlXPathNodeSetMerge(NULL, c_self);
256
266
  c_new_node_set = xmlXPathNodeSetMerge(c_new_node_set, c_other);
257
267
 
258
- return noko_xml_node_set_wrap(c_new_node_set, rb_iv_get(rb_node_set, "@document"));
268
+ return noko_xml_node_set_wrap(c_new_node_set, rb_iv_get(rb_self, "@document"));
259
269
  }
260
270
 
261
271
  /*
@@ -266,9 +276,9 @@ rb_xml_node_set_union(VALUE rb_node_set, VALUE rb_other)
266
276
  * each item that also appears in +node_set+
267
277
  */
268
278
  static VALUE
269
- minus(VALUE self, VALUE rb_other)
279
+ minus(VALUE rb_self, VALUE rb_other)
270
280
  {
271
- xmlNodeSetPtr node_set, other;
281
+ xmlNodeSetPtr c_self, c_other;
272
282
  xmlNodeSetPtr new;
273
283
  int j ;
274
284
 
@@ -276,55 +286,55 @@ minus(VALUE self, VALUE rb_other)
276
286
  rb_raise(rb_eArgError, "node_set must be a Nokogiri::XML::NodeSet");
277
287
  }
278
288
 
279
- Data_Get_Struct(self, xmlNodeSet, node_set);
280
- Data_Get_Struct(rb_other, xmlNodeSet, other);
289
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
290
+ TypedData_Get_Struct(rb_other, xmlNodeSet, &xml_node_set_type, c_other);
281
291
 
282
- new = xmlXPathNodeSetMerge(NULL, node_set);
283
- for (j = 0 ; j < other->nodeNr ; ++j) {
284
- xpath_node_set_del(new, other->nodeTab[j]);
292
+ new = xmlXPathNodeSetMerge(NULL, c_self);
293
+ for (j = 0 ; j < c_other->nodeNr ; ++j) {
294
+ xpath_node_set_del(new, c_other->nodeTab[j]);
285
295
  }
286
296
 
287
- return noko_xml_node_set_wrap(new, rb_iv_get(self, "@document"));
297
+ return noko_xml_node_set_wrap(new, rb_iv_get(rb_self, "@document"));
288
298
  }
289
299
 
290
300
 
291
301
  static VALUE
292
- index_at(VALUE self, long offset)
302
+ index_at(VALUE rb_self, long offset)
293
303
  {
294
- xmlNodeSetPtr node_set;
304
+ xmlNodeSetPtr c_self;
295
305
 
296
- Data_Get_Struct(self, xmlNodeSet, node_set);
306
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
297
307
 
298
- if (offset >= node_set->nodeNr || abs((int)offset) > node_set->nodeNr) {
308
+ if (offset >= c_self->nodeNr || abs((int)offset) > c_self->nodeNr) {
299
309
  return Qnil;
300
310
  }
301
311
 
302
- if (offset < 0) { offset += node_set->nodeNr ; }
312
+ if (offset < 0) { offset += c_self->nodeNr ; }
303
313
 
304
- return noko_xml_node_wrap_node_set_result(node_set->nodeTab[offset], self);
314
+ return noko_xml_node_wrap_node_set_result(c_self->nodeTab[offset], rb_self);
305
315
  }
306
316
 
307
317
  static VALUE
308
- subseq(VALUE self, long beg, long len)
318
+ subseq(VALUE rb_self, long beg, long len)
309
319
  {
310
320
  long j;
311
- xmlNodeSetPtr node_set;
321
+ xmlNodeSetPtr c_self;
312
322
  xmlNodeSetPtr new_set ;
313
323
 
314
- Data_Get_Struct(self, xmlNodeSet, node_set);
324
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
315
325
 
316
- if (beg > node_set->nodeNr) { return Qnil ; }
326
+ if (beg > c_self->nodeNr) { return Qnil ; }
317
327
  if (beg < 0 || len < 0) { return Qnil ; }
318
328
 
319
- if ((beg + len) > node_set->nodeNr) {
320
- len = node_set->nodeNr - beg ;
329
+ if ((beg + len) > c_self->nodeNr) {
330
+ len = c_self->nodeNr - beg ;
321
331
  }
322
332
 
323
333
  new_set = xmlXPathNodeSetCreate(NULL);
324
334
  for (j = beg ; j < beg + len ; ++j) {
325
- xmlXPathNodeSetAddUnique(new_set, node_set->nodeTab[j]);
335
+ xmlXPathNodeSetAddUnique(new_set, c_self->nodeTab[j]);
326
336
  }
327
- return noko_xml_node_set_wrap(new_set, rb_iv_get(self, "@document"));
337
+ return noko_xml_node_set_wrap(new_set, rb_iv_get(rb_self, "@document"));
328
338
  }
329
339
 
330
340
  /*
@@ -343,21 +353,21 @@ subseq(VALUE self, long beg, long len)
343
353
  * nil if the +index+ (or +start+) are out of range.
344
354
  */
345
355
  static VALUE
346
- slice(int argc, VALUE *argv, VALUE self)
356
+ slice(int argc, VALUE *argv, VALUE rb_self)
347
357
  {
348
358
  VALUE arg ;
349
359
  long beg, len ;
350
- xmlNodeSetPtr node_set;
360
+ xmlNodeSetPtr c_self;
351
361
 
352
- Data_Get_Struct(self, xmlNodeSet, node_set);
362
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
353
363
 
354
364
  if (argc == 2) {
355
365
  beg = NUM2LONG(argv[0]);
356
366
  len = NUM2LONG(argv[1]);
357
367
  if (beg < 0) {
358
- beg += node_set->nodeNr ;
368
+ beg += c_self->nodeNr ;
359
369
  }
360
- return subseq(self, beg, len);
370
+ return subseq(rb_self, beg, len);
361
371
  }
362
372
 
363
373
  if (argc != 1) {
@@ -366,20 +376,20 @@ slice(int argc, VALUE *argv, VALUE self)
366
376
  arg = argv[0];
367
377
 
368
378
  if (FIXNUM_P(arg)) {
369
- return index_at(self, FIX2LONG(arg));
379
+ return index_at(rb_self, FIX2LONG(arg));
370
380
  }
371
381
 
372
382
  /* if arg is Range */
373
- switch (rb_range_beg_len(arg, &beg, &len, (long)node_set->nodeNr, 0)) {
383
+ switch (rb_range_beg_len(arg, &beg, &len, (long)c_self->nodeNr, 0)) {
374
384
  case Qfalse:
375
385
  break;
376
386
  case Qnil:
377
387
  return Qnil;
378
388
  default:
379
- return subseq(self, beg, len);
389
+ return subseq(rb_self, beg, len);
380
390
  }
381
391
 
382
- return index_at(self, NUM2LONG(arg));
392
+ return index_at(rb_self, NUM2LONG(arg));
383
393
  }
384
394
 
385
395
 
@@ -390,17 +400,17 @@ slice(int argc, VALUE *argv, VALUE self)
390
400
  * Return this list as an Array
391
401
  */
392
402
  static VALUE
393
- to_array(VALUE self)
403
+ to_array(VALUE rb_self)
394
404
  {
395
- xmlNodeSetPtr node_set ;
405
+ xmlNodeSetPtr c_self ;
396
406
  VALUE list;
397
407
  int i;
398
408
 
399
- Data_Get_Struct(self, xmlNodeSet, node_set);
409
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
400
410
 
401
- list = rb_ary_new2(node_set->nodeNr);
402
- for (i = 0; i < node_set->nodeNr; i++) {
403
- VALUE elt = noko_xml_node_wrap_node_set_result(node_set->nodeTab[i], self);
411
+ list = rb_ary_new2(c_self->nodeNr);
412
+ for (i = 0; i < c_self->nodeNr; i++) {
413
+ VALUE elt = noko_xml_node_wrap_node_set_result(c_self->nodeTab[i], rb_self);
404
414
  rb_ary_push(list, elt);
405
415
  }
406
416
 
@@ -414,25 +424,25 @@ to_array(VALUE self)
414
424
  * Unlink this NodeSet and all Node objects it contains from their current context.
415
425
  */
416
426
  static VALUE
417
- unlink_nodeset(VALUE self)
427
+ unlink_nodeset(VALUE rb_self)
418
428
  {
419
- xmlNodeSetPtr node_set;
429
+ xmlNodeSetPtr c_self;
420
430
  int j, nodeNr ;
421
431
 
422
- Data_Get_Struct(self, xmlNodeSet, node_set);
432
+ TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
423
433
 
424
- nodeNr = node_set->nodeNr ;
434
+ nodeNr = c_self->nodeNr ;
425
435
  for (j = 0 ; j < nodeNr ; j++) {
426
- if (! NOKOGIRI_NAMESPACE_EH(node_set->nodeTab[j])) {
436
+ if (! NOKOGIRI_NAMESPACE_EH(c_self->nodeTab[j])) {
427
437
  VALUE node ;
428
438
  xmlNodePtr node_ptr;
429
- node = noko_xml_node_wrap(Qnil, node_set->nodeTab[j]);
439
+ node = noko_xml_node_wrap(Qnil, c_self->nodeTab[j]);
430
440
  rb_funcall(node, rb_intern("unlink"), 0); /* modifies the C struct out from under the object */
431
441
  Noko_Node_Get_Struct(node, xmlNode, node_ptr);
432
- node_set->nodeTab[j] = node_ptr ;
442
+ c_self->nodeTab[j] = node_ptr ;
433
443
  }
434
444
  }
435
- return self ;
445
+ return rb_self ;
436
446
  }
437
447
 
438
448
 
@@ -446,7 +456,7 @@ noko_xml_node_set_wrap(xmlNodeSetPtr c_node_set, VALUE document)
446
456
  c_node_set = xmlXPathNodeSetCreate(NULL);
447
457
  }
448
458
 
449
- rb_node_set = Data_Wrap_Struct(cNokogiriXmlNodeSet, mark, deallocate, c_node_set);
459
+ rb_node_set = TypedData_Wrap_Struct(cNokogiriXmlNodeSet, &xml_node_set_type, c_node_set);
450
460
 
451
461
  if (!NIL_P(document)) {
452
462
  rb_iv_set(rb_node_set, "@document", document);
@@ -461,6 +471,7 @@ noko_xml_node_set_wrap(xmlNodeSetPtr c_node_set, VALUE document)
461
471
  return rb_node_set ;
462
472
  }
463
473
 
474
+
464
475
  VALUE
465
476
  noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set)
466
477
  {
@@ -472,12 +483,21 @@ noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set)
472
483
  }
473
484
 
474
485
 
486
+ xmlNodeSetPtr
487
+ noko_xml_node_set_unwrap(VALUE rb_node_set)
488
+ {
489
+ xmlNodeSetPtr c_node_set;
490
+ TypedData_Get_Struct(rb_node_set, xmlNodeSet, &xml_node_set_type, c_node_set);
491
+ return c_node_set;
492
+ }
493
+
494
+
475
495
  void
476
496
  noko_init_xml_node_set(void)
477
497
  {
478
498
  cNokogiriXmlNodeSet = rb_define_class_under(mNokogiriXml, "NodeSet", rb_cObject);
479
499
 
480
- rb_define_alloc_func(cNokogiriXmlNodeSet, allocate);
500
+ rb_define_alloc_func(cNokogiriXmlNodeSet, xml_node_set_allocate);
481
501
 
482
502
  rb_define_method(cNokogiriXmlNodeSet, "length", length, 0);
483
503
  rb_define_method(cNokogiriXmlNodeSet, "[]", slice, -1);
@@ -22,7 +22,7 @@ new (int argc, VALUE *argv, VALUE klass)
22
22
 
23
23
  rb_scan_args(argc, argv, "3*", &document, &name, &content, &rest);
24
24
 
25
- Data_Get_Struct(document, xmlDoc, xml_doc);
25
+ xml_doc = noko_xml_document_unwrap(document);
26
26
 
27
27
  node = xmlNewDocPI(
28
28
  xml_doc,