libxml-ruby 5.0.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -923
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +77 -98
  6. data/ext/libxml/extconf.rb +34 -20
  7. data/ext/libxml/libxml.c +67 -79
  8. data/ext/libxml/ruby_libxml.h +1 -1
  9. data/ext/libxml/ruby_xml_attr.c +338 -333
  10. data/ext/libxml/ruby_xml_attr.h +13 -12
  11. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  12. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  13. data/ext/libxml/ruby_xml_attributes.c +18 -9
  14. data/ext/libxml/ruby_xml_document.c +111 -98
  15. data/ext/libxml/ruby_xml_document.h +1 -0
  16. data/ext/libxml/ruby_xml_dtd.c +49 -19
  17. data/ext/libxml/ruby_xml_dtd.h +10 -9
  18. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  19. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  20. data/ext/libxml/ruby_xml_html_parser_context.c +19 -6
  21. data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
  22. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  23. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  24. data/ext/libxml/ruby_xml_input_cbg.c +45 -17
  25. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  26. data/ext/libxml/ruby_xml_io.c +49 -47
  27. data/ext/libxml/ruby_xml_io.h +10 -10
  28. data/ext/libxml/ruby_xml_namespace.c +20 -12
  29. data/ext/libxml/ruby_xml_namespace.h +11 -10
  30. data/ext/libxml/ruby_xml_namespaces.c +313 -293
  31. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  32. data/ext/libxml/ruby_xml_node.c +71 -32
  33. data/ext/libxml/ruby_xml_node.h +15 -13
  34. data/ext/libxml/ruby_xml_parser.c +91 -91
  35. data/ext/libxml/ruby_xml_parser_context.c +54 -47
  36. data/ext/libxml/ruby_xml_parser_context.h +11 -10
  37. data/ext/libxml/ruby_xml_reader.c +25 -15
  38. data/ext/libxml/ruby_xml_reader.h +14 -14
  39. data/ext/libxml/ruby_xml_registry.c +31 -0
  40. data/ext/libxml/ruby_xml_registry.h +22 -0
  41. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  42. data/ext/libxml/ruby_xml_relaxng.h +9 -8
  43. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  44. data/ext/libxml/ruby_xml_sax_parser.c +1 -1
  45. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  46. data/ext/libxml/ruby_xml_schema.c +18 -11
  47. data/ext/libxml/ruby_xml_schema.h +26 -25
  48. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  49. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  50. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  51. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  52. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  53. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  54. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  55. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  56. data/ext/libxml/ruby_xml_version.h +4 -4
  57. data/ext/libxml/ruby_xml_writer.c +1136 -1124
  58. data/ext/libxml/ruby_xml_writer.h +6 -6
  59. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  60. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  61. data/ext/libxml/ruby_xml_xpath.c +195 -195
  62. data/ext/libxml/ruby_xml_xpath.h +15 -15
  63. data/ext/libxml/ruby_xml_xpath_context.c +408 -362
  64. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  65. data/ext/libxml/ruby_xml_xpath_expression.c +11 -5
  66. data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
  67. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  68. data/ext/libxml/ruby_xml_xpath_object.h +19 -17
  69. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  70. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  71. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  72. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  73. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  74. data/lib/libxml/document.rb +0 -29
  75. data/lib/libxml/error.rb +30 -3
  76. data/lib/libxml/html_parser.rb +0 -16
  77. data/lib/libxml/node.rb +1 -3
  78. data/lib/libxml/parser.rb +0 -8
  79. data/lib/libxml/schema/attribute.rb +27 -19
  80. data/lib/libxml/schema/element.rb +20 -0
  81. data/lib/libxml/schema/type.rb +44 -21
  82. data/lib/libxml/schema.rb +47 -47
  83. data/lib/libxml-ruby.rb +30 -30
  84. data/libxml-ruby.gemspec +12 -16
  85. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  86. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  87. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  88. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  89. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  90. data/test/c14n/result/with-comments/example-1 +5 -5
  91. data/test/c14n/result/with-comments/example-2 +10 -10
  92. data/test/c14n/result/with-comments/example-3 +13 -13
  93. data/test/c14n/result/with-comments/example-4 +8 -8
  94. data/test/c14n/result/with-comments/example-5 +3 -3
  95. data/test/c14n/result/without-comments/example-1 +3 -3
  96. data/test/c14n/result/without-comments/example-2 +10 -10
  97. data/test/c14n/result/without-comments/example-3 +13 -13
  98. data/test/c14n/result/without-comments/example-4 +8 -8
  99. data/test/c14n/result/without-comments/example-5 +2 -2
  100. data/test/test_attr.rb +179 -180
  101. data/test/test_attr_decl.rb +131 -131
  102. data/test/test_attributes.rb +135 -135
  103. data/test/test_canonicalize.rb +122 -120
  104. data/test/test_document.rb +2 -4
  105. data/test/test_dtd.rb +12 -4
  106. data/test/test_encoding_sax.rb +114 -114
  107. data/test/test_error.rb +6 -3
  108. data/test/test_helper.rb +1 -0
  109. data/test/test_html_parser.rb +6 -2
  110. data/test/test_html_parser_context.rb +22 -22
  111. data/test/test_input_callbacks.rb +36 -0
  112. data/test/test_namespace.rb +1 -1
  113. data/test/test_namespaces.rb +200 -200
  114. data/test/test_node.rb +16 -0
  115. data/test/test_node_cdata.rb +50 -50
  116. data/test/test_node_comment.rb +32 -32
  117. data/test/test_node_copy.rb +40 -40
  118. data/test/test_node_edit.rb +176 -158
  119. data/test/test_node_pi.rb +37 -37
  120. data/test/test_node_text.rb +69 -69
  121. data/test/test_node_xlink.rb +28 -28
  122. data/test/test_parser.rb +5 -41
  123. data/test/test_parser_context.rb +198 -198
  124. data/test/test_properties.rb +38 -38
  125. data/test/test_reader.rb +55 -6
  126. data/test/test_relaxng.rb +59 -53
  127. data/test/test_sax_parser.rb +345 -345
  128. data/test/test_schema.rb +28 -0
  129. data/test/test_traversal.rb +152 -152
  130. data/test/test_writer.rb +469 -468
  131. data/test/test_xinclude.rb +20 -20
  132. data/test/test_xml.rb +3 -7
  133. data/test/test_xpath.rb +244 -244
  134. data/test/test_xpath_context.rb +87 -87
  135. data/test/test_xpath_expression.rb +37 -37
  136. metadata +33 -27
  137. data/README.rdoc +0 -208
  138. data/ext/libxml/extconf.h +0 -3
  139. data/ext/libxml/ruby_xml_cbg.c +0 -85
  140. data/lib/libxml/hpricot.rb +0 -78
  141. data/lib/libxml.rb +0 -5
  142. data/lib/xml/libxml.rb +0 -10
  143. data/lib/xml.rb +0 -14
  144. data/script/benchmark/depixelate +0 -634
  145. data/script/benchmark/hamlet.xml +0 -9055
  146. data/script/benchmark/parsecount +0 -170
  147. data/script/benchmark/sock_entries.xml +0 -507
  148. data/script/benchmark/throughput +0 -41
  149. data/script/test +0 -6
  150. data/test/test.rb +0 -5
  151. data/test/test_deprecated_require.rb +0 -12
@@ -1,47 +1,49 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "ruby_libxml.h"
4
- #include <ruby/io.h>
5
-
6
- static ID READ_METHOD;
7
- static ID WRITE_METHOD;
8
-
9
- /* This method is called by libxml when it wants to read
10
- more data from a stream. We go with the duck typing
11
- solution to support StringIO objects. */
12
- int rxml_read_callback(void *context, char *buffer, int len)
13
- {
14
- VALUE io = (VALUE) context;
15
- VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
16
- size_t size;
17
-
18
- if (string == Qnil)
19
- return 0;
20
-
21
- size = RSTRING_LEN(string);
22
- memcpy(buffer, StringValuePtr(string), size);
23
-
24
- return (int)size;
25
- }
26
-
27
- int rxml_write_callback(VALUE io, const char *buffer, int len)
28
- {
29
- if (rb_io_check_io(io) == Qnil)
30
- {
31
- // Could be StringIO
32
- VALUE written, string;
33
- string = rb_external_str_new_with_enc(buffer, (long)strlen(buffer), rb_enc_get(io));
34
- written = rb_funcall(io, WRITE_METHOD, 1, string);
35
- return NUM2INT(written);
36
- }
37
- else
38
- {
39
- return (int)rb_io_bufwrite(io, buffer, (size_t)len);
40
- }
41
- }
42
-
43
- void rxml_init_io(void)
44
- {
45
- READ_METHOD = rb_intern("read");
46
- WRITE_METHOD = rb_intern("write");
47
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include <ruby/io.h>
5
+
6
+ static ID READ_METHOD;
7
+ static ID WRITE_METHOD;
8
+
9
+ /* This method is called by libxml when it wants to read
10
+ more data from a stream. We go with the duck typing
11
+ solution to support StringIO objects. */
12
+ int rxml_read_callback(void *context, char *buffer, int len)
13
+ {
14
+ VALUE io = (VALUE) context;
15
+ VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
16
+ size_t size;
17
+
18
+ if (string == Qnil)
19
+ return 0;
20
+
21
+ size = RSTRING_LEN(string);
22
+ if (size > (size_t)len)
23
+ size = (size_t)len;
24
+ memcpy(buffer, StringValuePtr(string), size);
25
+
26
+ return (int)size;
27
+ }
28
+
29
+ int rxml_write_callback(VALUE io, const char *buffer, int len)
30
+ {
31
+ if (rb_io_check_io(io) == Qnil)
32
+ {
33
+ // Could be StringIO
34
+ VALUE written, string;
35
+ string = rb_external_str_new_with_enc(buffer, (long)len, rb_enc_get(io));
36
+ written = rb_funcall(io, WRITE_METHOD, 1, string);
37
+ return NUM2INT(written);
38
+ }
39
+ else
40
+ {
41
+ return (int)rb_io_bufwrite(io, buffer, (size_t)len);
42
+ }
43
+ }
44
+
45
+ void rxml_init_io(void)
46
+ {
47
+ READ_METHOD = rb_intern("read");
48
+ WRITE_METHOD = rb_intern("write");
49
+ }
@@ -1,10 +1,10 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_IO__
4
- #define __RXML_IO__
5
-
6
- int rxml_read_callback(void *context, char *buffer, int len);
7
- int rxml_write_callback(VALUE io, const char *buffer, int len);
8
- void rxml_init_io(void);
9
-
10
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_IO__
4
+ #define __RXML_IO__
5
+
6
+ int rxml_read_callback(void *context, char *buffer, int len);
7
+ int rxml_write_callback(VALUE io, const char *buffer, int len);
8
+ void rxml_init_io(void);
9
+
10
+ #endif
@@ -5,6 +5,11 @@
5
5
 
6
6
  VALUE cXMLNamespace;
7
7
 
8
+ const rb_data_type_t rxml_namespace_type = {
9
+ "libxml/namespace",
10
+ {NULL, NULL, NULL},
11
+ };
12
+
8
13
  /* Document-class: LibXML::XML::Namespace
9
14
  *
10
15
  * The Namespace class represents an XML namespace.
@@ -26,12 +31,12 @@ VALUE cXMLNamespace;
26
31
 
27
32
  static VALUE rxml_namespace_alloc(VALUE klass)
28
33
  {
29
- return Data_Wrap_Struct(klass, NULL, NULL, NULL);
34
+ return TypedData_Wrap_Struct(klass, &rxml_namespace_type, NULL);
30
35
  }
31
36
 
32
37
  VALUE rxml_namespace_wrap(xmlNsPtr xns)
33
38
  {
34
- return Data_Wrap_Struct(cXMLNamespace, NULL, NULL, xns);
39
+ return TypedData_Wrap_Struct(cXMLNamespace, &rxml_namespace_type, xns);
35
40
  }
36
41
 
37
42
 
@@ -50,15 +55,14 @@ static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
50
55
  xmlChar *xmlPrefix;
51
56
  xmlNsPtr xns;
52
57
 
53
- Check_Type(node, T_DATA);
54
- Data_Get_Struct(node, xmlNode, xnode);
58
+ TypedData_Get_Struct(node, xmlNode, &rxml_node_data_type, xnode);
55
59
  xmlResetLastError();
56
60
 
57
61
  /* Prefix can be null - that means its the default namespace */
58
62
  xmlPrefix = NIL_P(prefix) ? NULL : (xmlChar *)StringValuePtr(prefix);
59
63
  xns = xmlNewNs(xnode, (xmlChar*) StringValuePtr(href), xmlPrefix);
60
64
 
61
- DATA_PTR(self) = xns;
65
+ RTYPEDDATA_DATA(self) = xns;
62
66
  return self;
63
67
  }
64
68
 
@@ -75,7 +79,7 @@ static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
75
79
  static VALUE rxml_namespace_href_get(VALUE self)
76
80
  {
77
81
  xmlNsPtr xns;
78
- Data_Get_Struct(self, xmlNs, xns);
82
+ TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
79
83
  if (xns->href == NULL)
80
84
  return Qnil;
81
85
  else
@@ -91,7 +95,7 @@ static VALUE rxml_namespace_href_get(VALUE self)
91
95
  static VALUE rxml_namespace_node_type(VALUE self)
92
96
  {
93
97
  xmlNsPtr xns;
94
- Data_Get_Struct(self, xmlNs, xns);
98
+ TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
95
99
  return INT2NUM(xns->type);
96
100
  }
97
101
 
@@ -110,7 +114,7 @@ static VALUE rxml_namespace_node_type(VALUE self)
110
114
  static VALUE rxml_namespace_prefix_get(VALUE self)
111
115
  {
112
116
  xmlNsPtr xns;
113
- Data_Get_Struct(self, xmlNs, xns);
117
+ TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
114
118
  if (xns->prefix == NULL)
115
119
  return Qnil;
116
120
  else
@@ -132,11 +136,15 @@ static VALUE rxml_namespace_prefix_get(VALUE self)
132
136
  static VALUE rxml_namespace_next(VALUE self)
133
137
  {
134
138
  xmlNsPtr xns;
135
- Data_Get_Struct(self, xmlNs, xns);
136
- if (xns == NULL || xns->next == NULL)
139
+ TypedData_Get_Struct(self, xmlNs, &rxml_namespace_type, xns);
140
+ /* Guard against libxml2's XPath hack where xns->next stores a parent
141
+ element pointer instead of the next namespace (see xmlXPathNodeSetAddNs
142
+ in xpath.c). xmlNs.type and xmlNode.type share the same struct offset,
143
+ so checking the type is safe even when next points to an xmlNode. */
144
+ if (xns == NULL || xns->next == NULL || xns->next->type != XML_LOCAL_NAMESPACE)
137
145
  return (Qnil);
138
- else
139
- return rxml_namespace_wrap(xns->next);
146
+
147
+ return rxml_namespace_wrap(xns->next);
140
148
  }
141
149
 
142
150
  void rxml_init_namespace(void)
@@ -1,10 +1,11 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_NAMESPACE__
4
- #define __RXML_NAMESPACE__
5
-
6
- extern VALUE cXMLNamespace;
7
-
8
- void rxml_init_namespace(void);
9
- VALUE rxml_namespace_wrap(xmlNsPtr xns);
10
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_NAMESPACE__
4
+ #define __RXML_NAMESPACE__
5
+
6
+ extern VALUE cXMLNamespace;
7
+ extern const rb_data_type_t rxml_namespace_type;
8
+
9
+ void rxml_init_namespace(void);
10
+ VALUE rxml_namespace_wrap(xmlNsPtr xns);
11
+ #endif