nokogiri 1.16.8 → 1.18.1

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +14 -22
  3. data/LICENSE-DEPENDENCIES.md +6 -6
  4. data/README.md +8 -5
  5. data/dependencies.yml +6 -6
  6. data/ext/nokogiri/extconf.rb +188 -142
  7. data/ext/nokogiri/gumbo.c +69 -53
  8. data/ext/nokogiri/html4_document.c +10 -4
  9. data/ext/nokogiri/html4_element_description.c +18 -18
  10. data/ext/nokogiri/html4_sax_parser.c +40 -0
  11. data/ext/nokogiri/html4_sax_parser_context.c +48 -58
  12. data/ext/nokogiri/html4_sax_push_parser.c +25 -24
  13. data/ext/nokogiri/libxml2_polyfill.c +114 -0
  14. data/ext/nokogiri/nokogiri.c +9 -2
  15. data/ext/nokogiri/nokogiri.h +18 -33
  16. data/ext/nokogiri/xml_attr.c +1 -1
  17. data/ext/nokogiri/xml_cdata.c +2 -10
  18. data/ext/nokogiri/xml_comment.c +3 -8
  19. data/ext/nokogiri/xml_document.c +163 -156
  20. data/ext/nokogiri/xml_document_fragment.c +10 -25
  21. data/ext/nokogiri/xml_dtd.c +1 -1
  22. data/ext/nokogiri/xml_element_content.c +9 -9
  23. data/ext/nokogiri/xml_encoding_handler.c +4 -4
  24. data/ext/nokogiri/xml_namespace.c +6 -6
  25. data/ext/nokogiri/xml_node.c +134 -103
  26. data/ext/nokogiri/xml_node_set.c +46 -44
  27. data/ext/nokogiri/xml_reader.c +54 -58
  28. data/ext/nokogiri/xml_relax_ng.c +35 -56
  29. data/ext/nokogiri/xml_sax_parser.c +156 -88
  30. data/ext/nokogiri/xml_sax_parser_context.c +219 -131
  31. data/ext/nokogiri/xml_sax_push_parser.c +68 -49
  32. data/ext/nokogiri/xml_schema.c +50 -85
  33. data/ext/nokogiri/xml_syntax_error.c +19 -11
  34. data/ext/nokogiri/xml_text.c +2 -4
  35. data/ext/nokogiri/xml_xpath_context.c +103 -100
  36. data/ext/nokogiri/xslt_stylesheet.c +8 -8
  37. data/gumbo-parser/src/ascii.c +2 -2
  38. data/gumbo-parser/src/error.c +76 -48
  39. data/gumbo-parser/src/error.h +5 -1
  40. data/gumbo-parser/src/nokogiri_gumbo.h +11 -2
  41. data/gumbo-parser/src/parser.c +63 -25
  42. data/gumbo-parser/src/tokenizer.c +6 -6
  43. data/lib/nokogiri/class_resolver.rb +1 -1
  44. data/lib/nokogiri/css/node.rb +6 -2
  45. data/lib/nokogiri/css/parser.rb +6 -4
  46. data/lib/nokogiri/css/parser.y +2 -2
  47. data/lib/nokogiri/css/parser_extras.rb +6 -66
  48. data/lib/nokogiri/css/selector_cache.rb +38 -0
  49. data/lib/nokogiri/css/tokenizer.rb +4 -4
  50. data/lib/nokogiri/css/tokenizer.rex +9 -8
  51. data/lib/nokogiri/css/xpath_visitor.rb +42 -6
  52. data/lib/nokogiri/css.rb +86 -20
  53. data/lib/nokogiri/decorators/slop.rb +3 -5
  54. data/lib/nokogiri/encoding_handler.rb +2 -2
  55. data/lib/nokogiri/html4/document.rb +44 -23
  56. data/lib/nokogiri/html4/document_fragment.rb +124 -12
  57. data/lib/nokogiri/html4/encoding_reader.rb +1 -1
  58. data/lib/nokogiri/html4/sax/parser.rb +23 -38
  59. data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
  60. data/lib/nokogiri/html4.rb +9 -14
  61. data/lib/nokogiri/html5/builder.rb +40 -0
  62. data/lib/nokogiri/html5/document.rb +61 -30
  63. data/lib/nokogiri/html5/document_fragment.rb +130 -20
  64. data/lib/nokogiri/html5/node.rb +4 -4
  65. data/lib/nokogiri/html5.rb +114 -72
  66. data/lib/nokogiri/version/constant.rb +1 -1
  67. data/lib/nokogiri/xml/builder.rb +8 -1
  68. data/lib/nokogiri/xml/document.rb +70 -26
  69. data/lib/nokogiri/xml/document_fragment.rb +84 -13
  70. data/lib/nokogiri/xml/node.rb +82 -11
  71. data/lib/nokogiri/xml/node_set.rb +9 -7
  72. data/lib/nokogiri/xml/parse_options.rb +1 -1
  73. data/lib/nokogiri/xml/pp/node.rb +6 -1
  74. data/lib/nokogiri/xml/reader.rb +46 -13
  75. data/lib/nokogiri/xml/relax_ng.rb +57 -20
  76. data/lib/nokogiri/xml/sax/document.rb +174 -83
  77. data/lib/nokogiri/xml/sax/parser.rb +115 -41
  78. data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
  79. data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
  80. data/lib/nokogiri/xml/sax.rb +48 -0
  81. data/lib/nokogiri/xml/schema.rb +112 -45
  82. data/lib/nokogiri/xml/searchable.rb +38 -42
  83. data/lib/nokogiri/xml/syntax_error.rb +22 -0
  84. data/lib/nokogiri/xml/xpath_context.rb +14 -3
  85. data/lib/nokogiri/xml.rb +13 -24
  86. data/lib/nokogiri/xslt.rb +3 -9
  87. data/lib/xsd/xmlparser/nokogiri.rb +3 -4
  88. data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
  89. data/ports/archives/libxml2-2.13.5.tar.xz +0 -0
  90. data/ports/archives/libxslt-1.1.42.tar.xz +0 -0
  91. metadata +13 -12
  92. data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
  93. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +0 -25
  94. data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
  95. data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
@@ -2,62 +2,92 @@
2
2
 
3
3
  VALUE cNokogiriXmlSaxParser ;
4
4
 
5
- static ID id_start_document, id_end_document, id_start_element, id_end_element;
6
- static ID id_start_element_namespace, id_end_element_namespace;
7
- static ID id_comment, id_characters, id_xmldecl, id_error, id_warning;
5
+ static ID id_start_document;
6
+ static ID id_end_document;
7
+ static ID id_start_element;
8
+ static ID id_end_element;
9
+ static ID id_start_element_namespace;
10
+ static ID id_end_element_namespace;
11
+ static ID id_comment;
12
+ static ID id_characters;
13
+ static ID id_xmldecl;
14
+ static ID id_error;
15
+ static ID id_warning;
8
16
  static ID id_cdata_block;
9
17
  static ID id_processing_instruction;
18
+ static ID id_reference;
19
+
20
+ static size_t
21
+ xml_sax_parser_memsize(const void *data)
22
+ {
23
+ return sizeof(xmlSAXHandler);
24
+ }
25
+
26
+ /* Used by Nokogiri::XML::SAX::Parser and Nokogiri::HTML::SAX::Parser */
27
+ static const rb_data_type_t xml_sax_parser_type = {
28
+ .wrap_struct_name = "xmlSAXHandler",
29
+ .function = {
30
+ .dfree = RUBY_TYPED_DEFAULT_FREE,
31
+ .dsize = xml_sax_parser_memsize
32
+ },
33
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
34
+ };
10
35
 
11
36
  static void
12
- start_document(void *ctx)
37
+ noko_xml_sax_parser_start_document_callback(void *ctx)
13
38
  {
14
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
39
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
40
+ VALUE self = (VALUE)ctxt->_private;
15
41
  VALUE doc = rb_iv_get(self, "@document");
16
42
 
17
- xmlParserCtxtPtr ctxt = NOKOGIRI_SAX_CTXT(ctx);
18
-
19
- if (NULL != ctxt && ctxt->html != 1) {
20
- if (ctxt->standalone != -1) { /* -1 means there was no declaration */
21
- VALUE encoding = Qnil ;
22
- VALUE standalone = Qnil;
23
- VALUE version;
24
- if (ctxt->encoding) {
25
- encoding = NOKOGIRI_STR_NEW2(ctxt->encoding) ;
26
- } else if (ctxt->input && ctxt->input->encoding) {
27
- encoding = NOKOGIRI_STR_NEW2(ctxt->input->encoding) ;
28
- }
29
-
30
- version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
31
-
32
- switch (ctxt->standalone) {
33
- case 0:
34
- standalone = NOKOGIRI_STR_NEW2("no");
35
- break;
36
- case 1:
37
- standalone = NOKOGIRI_STR_NEW2("yes");
38
- break;
39
- }
40
-
41
- rb_funcall(doc, id_xmldecl, 3, version, encoding, standalone);
43
+ xmlSAX2StartDocument(ctx);
44
+
45
+ if (ctxt->standalone != -1) { /* -1 means there was no declaration */
46
+ VALUE encoding = Qnil ;
47
+ VALUE standalone = Qnil;
48
+ VALUE version;
49
+
50
+ if (ctxt->encoding) {
51
+ encoding = NOKOGIRI_STR_NEW2(ctxt->encoding) ;
52
+ } else if (ctxt->input && ctxt->input->encoding) { // unnecessary after v2.12.0 / gnome/libxml2@ec7be506
53
+ encoding = NOKOGIRI_STR_NEW2(ctxt->input->encoding) ;
54
+ }
55
+
56
+ version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
57
+
58
+ /* TODO try using xmlSAX2IsStandalone */
59
+ switch (ctxt->standalone) {
60
+ case 0:
61
+ standalone = NOKOGIRI_STR_NEW2("no");
62
+ break;
63
+ case 1:
64
+ standalone = NOKOGIRI_STR_NEW2("yes");
65
+ break;
42
66
  }
67
+
68
+ rb_funcall(doc, id_xmldecl, 3, version, encoding, standalone);
43
69
  }
44
70
 
45
71
  rb_funcall(doc, id_start_document, 0);
46
72
  }
47
73
 
48
74
  static void
49
- end_document(void *ctx)
75
+ noko_xml_sax_parser_end_document_callback(void *ctx)
50
76
  {
51
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
77
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
78
+ VALUE self = (VALUE)ctxt->_private;
52
79
  VALUE doc = rb_iv_get(self, "@document");
80
+
53
81
  rb_funcall(doc, id_end_document, 0);
54
82
  }
55
83
 
56
84
  static void
57
- start_element(void *ctx, const xmlChar *name, const xmlChar **atts)
85
+ noko_xml_sax_parser_start_element_callback(void *ctx, const xmlChar *name, const xmlChar **atts)
58
86
  {
59
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
87
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
88
+ VALUE self = (VALUE)ctxt->_private;
60
89
  VALUE doc = rb_iv_get(self, "@document");
90
+
61
91
  VALUE attributes = rb_ary_new();
62
92
  const xmlChar *attr;
63
93
  int i = 0;
@@ -79,15 +109,17 @@ start_element(void *ctx, const xmlChar *name, const xmlChar **atts)
79
109
  }
80
110
 
81
111
  static void
82
- end_element(void *ctx, const xmlChar *name)
112
+ noko_xml_sax_parser_end_element_callback(void *ctx, const xmlChar *name)
83
113
  {
84
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
114
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
115
+ VALUE self = (VALUE)ctxt->_private;
85
116
  VALUE doc = rb_iv_get(self, "@document");
117
+
86
118
  rb_funcall(doc, id_end_element, 1, NOKOGIRI_STR_NEW2(name));
87
119
  }
88
120
 
89
121
  static VALUE
90
- attributes_as_array(int attributes_len, const xmlChar **c_attributes)
122
+ xml_sax_parser_marshal_attributes(int attributes_len, const xmlChar **c_attributes)
91
123
  {
92
124
  VALUE rb_array = rb_ary_new2((long)attributes_len);
93
125
  VALUE cNokogiriXmlSaxParserAttribute;
@@ -116,7 +148,7 @@ attributes_as_array(int attributes_len, const xmlChar **c_attributes)
116
148
  }
117
149
 
118
150
  static void
119
- start_element_ns(
151
+ noko_xml_sax_parser_start_element_ns_callback(
120
152
  void *ctx,
121
153
  const xmlChar *localname,
122
154
  const xmlChar *prefix,
@@ -127,10 +159,11 @@ start_element_ns(
127
159
  int nb_defaulted,
128
160
  const xmlChar **attributes)
129
161
  {
130
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
162
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
163
+ VALUE self = (VALUE)ctxt->_private;
131
164
  VALUE doc = rb_iv_get(self, "@document");
132
165
 
133
- VALUE attribute_ary = attributes_as_array(nb_attributes, attributes);
166
+ VALUE attribute_ary = xml_sax_parser_marshal_attributes(nb_attributes, attributes);
134
167
 
135
168
  VALUE ns_list = rb_ary_new2((long)nb_namespaces);
136
169
 
@@ -161,13 +194,14 @@ start_element_ns(
161
194
  * end_element_ns was borrowed heavily from libxml-ruby.
162
195
  */
163
196
  static void
164
- end_element_ns(
197
+ noko_xml_sax_parser_end_element_ns_callback(
165
198
  void *ctx,
166
199
  const xmlChar *localname,
167
200
  const xmlChar *prefix,
168
201
  const xmlChar *uri)
169
202
  {
170
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
203
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
204
+ VALUE self = (VALUE)ctxt->_private;
171
205
  VALUE doc = rb_iv_get(self, "@document");
172
206
 
173
207
  rb_funcall(doc, id_end_element_namespace, 3,
@@ -178,29 +212,35 @@ end_element_ns(
178
212
  }
179
213
 
180
214
  static void
181
- characters_func(void *ctx, const xmlChar *ch, int len)
215
+ noko_xml_sax_parser_characters_callback(void *ctx, const xmlChar *ch, int len)
182
216
  {
183
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
217
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
218
+ VALUE self = (VALUE)ctxt->_private;
184
219
  VALUE doc = rb_iv_get(self, "@document");
220
+
185
221
  VALUE str = NOKOGIRI_STR_NEW(ch, len);
186
222
  rb_funcall(doc, id_characters, 1, str);
187
223
  }
188
224
 
189
225
  static void
190
- comment_func(void *ctx, const xmlChar *value)
226
+ noko_xml_sax_parser_comment_callback(void *ctx, const xmlChar *value)
191
227
  {
192
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
228
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
229
+ VALUE self = (VALUE)ctxt->_private;
193
230
  VALUE doc = rb_iv_get(self, "@document");
231
+
194
232
  VALUE str = NOKOGIRI_STR_NEW2(value);
195
233
  rb_funcall(doc, id_comment, 1, str);
196
234
  }
197
235
 
198
236
  PRINTFLIKE_DECL(2, 3)
199
237
  static void
200
- warning_func(void *ctx, const char *msg, ...)
238
+ noko_xml_sax_parser_warning_callback(void *ctx, const char *msg, ...)
201
239
  {
202
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
240
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
241
+ VALUE self = (VALUE)ctxt->_private;
203
242
  VALUE doc = rb_iv_get(self, "@document");
243
+
204
244
  VALUE rb_message;
205
245
 
206
246
  #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
@@ -219,10 +259,12 @@ warning_func(void *ctx, const char *msg, ...)
219
259
 
220
260
  PRINTFLIKE_DECL(2, 3)
221
261
  static void
222
- error_func(void *ctx, const char *msg, ...)
262
+ noko_xml_sax_parser_error_callback(void *ctx, const char *msg, ...)
223
263
  {
224
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
264
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
265
+ VALUE self = (VALUE)ctxt->_private;
225
266
  VALUE doc = rb_iv_get(self, "@document");
267
+
226
268
  VALUE rb_message;
227
269
 
228
270
  #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
@@ -240,22 +282,24 @@ error_func(void *ctx, const char *msg, ...)
240
282
  }
241
283
 
242
284
  static void
243
- cdata_block(void *ctx, const xmlChar *value, int len)
285
+ noko_xml_sax_parser_cdata_block_callback(void *ctx, const xmlChar *value, int len)
244
286
  {
245
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
287
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
288
+ VALUE self = (VALUE)ctxt->_private;
246
289
  VALUE doc = rb_iv_get(self, "@document");
290
+
247
291
  VALUE string = NOKOGIRI_STR_NEW(value, len);
248
292
  rb_funcall(doc, id_cdata_block, 1, string);
249
293
  }
250
294
 
251
295
  static void
252
- processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
296
+ noko_xml_sax_parser_processing_instruction_callback(void *ctx, const xmlChar *name, const xmlChar *content)
253
297
  {
254
- VALUE rb_content;
255
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
298
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
299
+ VALUE self = (VALUE)ctxt->_private;
256
300
  VALUE doc = rb_iv_get(self, "@document");
257
301
 
258
- rb_content = content ? NOKOGIRI_STR_NEW2(content) : Qnil;
302
+ VALUE rb_content = content ? NOKOGIRI_STR_NEW2(content) : Qnil;
259
303
 
260
304
  rb_funcall(doc,
261
305
  id_processing_instruction,
@@ -265,50 +309,70 @@ processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
265
309
  );
266
310
  }
267
311
 
268
- static size_t
269
- memsize(const void *data)
312
+ static void
313
+ noko_xml_sax_parser_reference_callback(void *ctx, const xmlChar *name)
270
314
  {
271
- return sizeof(xmlSAXHandler);
272
- }
315
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
316
+ xmlEntityPtr entity = xmlSAX2GetEntity(ctxt, name);
273
317
 
274
- /* Used by Nokogiri::XML::SAX::Parser and Nokogiri::HTML::SAX::Parser */
275
- static const rb_data_type_t noko_sax_handler_type = {
276
- .wrap_struct_name = "Nokogiri::SAXHandler",
277
- .function = {
278
- .dfree = RUBY_TYPED_DEFAULT_FREE,
279
- .dsize = memsize
280
- },
281
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
282
- };
318
+ VALUE self = (VALUE)ctxt->_private;
319
+ VALUE doc = rb_iv_get(self, "@document");
320
+
321
+ if (entity && entity->content) {
322
+ rb_funcall(doc, id_reference, 2, NOKOGIRI_STR_NEW2(entity->name), NOKOGIRI_STR_NEW2(entity->content));
323
+ } else {
324
+ rb_funcall(doc, id_reference, 2, NOKOGIRI_STR_NEW2(name), Qnil);
325
+ }
326
+ }
283
327
 
284
328
  static VALUE
285
- allocate(VALUE klass)
329
+ noko_xml_sax_parser__initialize_native(VALUE self)
286
330
  {
287
- xmlSAXHandlerPtr handler;
288
- VALUE self = TypedData_Make_Struct(klass, xmlSAXHandler, &noko_sax_handler_type, handler);
289
-
290
- handler->startDocument = start_document;
291
- handler->endDocument = end_document;
292
- handler->startElement = start_element;
293
- handler->endElement = end_element;
294
- handler->startElementNs = start_element_ns;
295
- handler->endElementNs = end_element_ns;
296
- handler->characters = characters_func;
297
- handler->comment = comment_func;
298
- handler->warning = warning_func;
299
- handler->error = error_func;
300
- handler->cdataBlock = cdata_block;
301
- handler->processingInstruction = processing_instruction;
331
+ xmlSAXHandlerPtr handler = noko_xml_sax_parser_unwrap(self);
332
+
333
+ handler->startDocument = noko_xml_sax_parser_start_document_callback;
334
+ handler->endDocument = noko_xml_sax_parser_end_document_callback;
335
+ handler->startElement = noko_xml_sax_parser_start_element_callback;
336
+ handler->endElement = noko_xml_sax_parser_end_element_callback;
337
+ handler->startElementNs = noko_xml_sax_parser_start_element_ns_callback;
338
+ handler->endElementNs = noko_xml_sax_parser_end_element_ns_callback;
339
+ handler->characters = noko_xml_sax_parser_characters_callback;
340
+ handler->comment = noko_xml_sax_parser_comment_callback;
341
+ handler->warning = noko_xml_sax_parser_warning_callback;
342
+ handler->error = noko_xml_sax_parser_error_callback;
343
+ handler->cdataBlock = noko_xml_sax_parser_cdata_block_callback;
344
+ handler->processingInstruction = noko_xml_sax_parser_processing_instruction_callback;
345
+ handler->reference = noko_xml_sax_parser_reference_callback;
346
+
347
+ /* use some of libxml2's default callbacks to managed DTDs and entities */
348
+ handler->getEntity = xmlSAX2GetEntity;
349
+ handler->internalSubset = xmlSAX2InternalSubset;
350
+ handler->externalSubset = xmlSAX2ExternalSubset;
351
+ handler->isStandalone = xmlSAX2IsStandalone;
352
+ handler->hasInternalSubset = xmlSAX2HasInternalSubset;
353
+ handler->hasExternalSubset = xmlSAX2HasExternalSubset;
354
+ handler->resolveEntity = xmlSAX2ResolveEntity;
355
+ handler->getParameterEntity = xmlSAX2GetParameterEntity;
356
+ handler->entityDecl = xmlSAX2EntityDecl;
357
+ handler->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
358
+
302
359
  handler->initialized = XML_SAX2_MAGIC;
303
360
 
304
361
  return self;
305
362
  }
306
363
 
364
+ static VALUE
365
+ noko_xml_sax_parser_allocate(VALUE klass)
366
+ {
367
+ xmlSAXHandlerPtr handler;
368
+ return TypedData_Make_Struct(klass, xmlSAXHandler, &xml_sax_parser_type, handler);
369
+ }
370
+
307
371
  xmlSAXHandlerPtr
308
- noko_sax_handler_unwrap(VALUE rb_sax_handler)
372
+ noko_xml_sax_parser_unwrap(VALUE rb_sax_handler)
309
373
  {
310
374
  xmlSAXHandlerPtr c_sax_handler;
311
- TypedData_Get_Struct(rb_sax_handler, xmlSAXHandler, &noko_sax_handler_type, c_sax_handler);
375
+ TypedData_Get_Struct(rb_sax_handler, xmlSAXHandler, &xml_sax_parser_type, c_sax_handler);
312
376
  return c_sax_handler;
313
377
  }
314
378
 
@@ -317,7 +381,10 @@ noko_init_xml_sax_parser(void)
317
381
  {
318
382
  cNokogiriXmlSaxParser = rb_define_class_under(mNokogiriXmlSax, "Parser", rb_cObject);
319
383
 
320
- rb_define_alloc_func(cNokogiriXmlSaxParser, allocate);
384
+ rb_define_alloc_func(cNokogiriXmlSaxParser, noko_xml_sax_parser_allocate);
385
+
386
+ rb_define_private_method(cNokogiriXmlSaxParser, "initialize_native",
387
+ noko_xml_sax_parser__initialize_native, 0);
321
388
 
322
389
  id_start_document = rb_intern("start_document");
323
390
  id_end_document = rb_intern("end_document");
@@ -332,4 +399,5 @@ noko_init_xml_sax_parser(void)
332
399
  id_start_element_namespace = rb_intern("start_element_namespace");
333
400
  id_end_element_namespace = rb_intern("end_element_namespace");
334
401
  id_processing_instruction = rb_intern("processing_instruction");
402
+ id_reference = rb_intern("reference");
335
403
  }