nokogiri 1.3.0-x86-mswin32

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 (256) hide show
  1. data/.autotest +27 -0
  2. data/CHANGELOG.ja.rdoc +233 -0
  3. data/CHANGELOG.rdoc +222 -0
  4. data/Manifest.txt +247 -0
  5. data/README.ja.rdoc +103 -0
  6. data/README.rdoc +117 -0
  7. data/Rakefile +205 -0
  8. data/bin/nokogiri +47 -0
  9. data/ext/nokogiri/extconf.rb +89 -0
  10. data/ext/nokogiri/html_document.c +183 -0
  11. data/ext/nokogiri/html_document.h +10 -0
  12. data/ext/nokogiri/html_element_description.c +272 -0
  13. data/ext/nokogiri/html_element_description.h +10 -0
  14. data/ext/nokogiri/html_entity_lookup.c +30 -0
  15. data/ext/nokogiri/html_entity_lookup.h +8 -0
  16. data/ext/nokogiri/html_sax_parser.c +57 -0
  17. data/ext/nokogiri/html_sax_parser.h +11 -0
  18. data/ext/nokogiri/iconv.dll +0 -0
  19. data/ext/nokogiri/libexslt.dll +0 -0
  20. data/ext/nokogiri/libxml2.dll +0 -0
  21. data/ext/nokogiri/libxslt.dll +0 -0
  22. data/ext/nokogiri/nokogiri.c +81 -0
  23. data/ext/nokogiri/nokogiri.h +149 -0
  24. data/ext/nokogiri/xml_attr.c +92 -0
  25. data/ext/nokogiri/xml_attr.h +9 -0
  26. data/ext/nokogiri/xml_cdata.c +53 -0
  27. data/ext/nokogiri/xml_cdata.h +9 -0
  28. data/ext/nokogiri/xml_comment.c +51 -0
  29. data/ext/nokogiri/xml_comment.h +9 -0
  30. data/ext/nokogiri/xml_document.c +308 -0
  31. data/ext/nokogiri/xml_document.h +21 -0
  32. data/ext/nokogiri/xml_document_fragment.c +48 -0
  33. data/ext/nokogiri/xml_document_fragment.h +10 -0
  34. data/ext/nokogiri/xml_dtd.c +102 -0
  35. data/ext/nokogiri/xml_dtd.h +8 -0
  36. data/ext/nokogiri/xml_entity_reference.c +50 -0
  37. data/ext/nokogiri/xml_entity_reference.h +9 -0
  38. data/ext/nokogiri/xml_io.c +24 -0
  39. data/ext/nokogiri/xml_io.h +10 -0
  40. data/ext/nokogiri/xml_namespace.c +69 -0
  41. data/ext/nokogiri/xml_namespace.h +12 -0
  42. data/ext/nokogiri/xml_node.c +928 -0
  43. data/ext/nokogiri/xml_node.h +14 -0
  44. data/ext/nokogiri/xml_node_set.c +386 -0
  45. data/ext/nokogiri/xml_node_set.h +9 -0
  46. data/ext/nokogiri/xml_processing_instruction.c +54 -0
  47. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  48. data/ext/nokogiri/xml_reader.c +572 -0
  49. data/ext/nokogiri/xml_reader.h +10 -0
  50. data/ext/nokogiri/xml_relax_ng.c +106 -0
  51. data/ext/nokogiri/xml_relax_ng.h +9 -0
  52. data/ext/nokogiri/xml_sax_parser.c +336 -0
  53. data/ext/nokogiri/xml_sax_parser.h +10 -0
  54. data/ext/nokogiri/xml_sax_push_parser.c +86 -0
  55. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  56. data/ext/nokogiri/xml_schema.c +107 -0
  57. data/ext/nokogiri/xml_schema.h +9 -0
  58. data/ext/nokogiri/xml_syntax_error.c +203 -0
  59. data/ext/nokogiri/xml_syntax_error.h +12 -0
  60. data/ext/nokogiri/xml_text.c +47 -0
  61. data/ext/nokogiri/xml_text.h +9 -0
  62. data/ext/nokogiri/xml_xpath.c +53 -0
  63. data/ext/nokogiri/xml_xpath.h +11 -0
  64. data/ext/nokogiri/xml_xpath_context.c +252 -0
  65. data/ext/nokogiri/xml_xpath_context.h +9 -0
  66. data/ext/nokogiri/xslt_stylesheet.c +131 -0
  67. data/ext/nokogiri/xslt_stylesheet.h +9 -0
  68. data/ext/nokogiri/zlib1.dll +0 -0
  69. data/lib/action-nokogiri.rb +36 -0
  70. data/lib/nokogiri.rb +110 -0
  71. data/lib/nokogiri/1.8/nokogiri.so +0 -0
  72. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  73. data/lib/nokogiri/css.rb +25 -0
  74. data/lib/nokogiri/css/generated_parser.rb +748 -0
  75. data/lib/nokogiri/css/generated_tokenizer.rb +144 -0
  76. data/lib/nokogiri/css/node.rb +107 -0
  77. data/lib/nokogiri/css/parser.rb +82 -0
  78. data/lib/nokogiri/css/parser.y +227 -0
  79. data/lib/nokogiri/css/syntax_error.rb +7 -0
  80. data/lib/nokogiri/css/tokenizer.rb +11 -0
  81. data/lib/nokogiri/css/tokenizer.rex +54 -0
  82. data/lib/nokogiri/css/xpath_visitor.rb +172 -0
  83. data/lib/nokogiri/decorators.rb +2 -0
  84. data/lib/nokogiri/decorators/hpricot.rb +3 -0
  85. data/lib/nokogiri/decorators/hpricot/node.rb +56 -0
  86. data/lib/nokogiri/decorators/hpricot/node_set.rb +54 -0
  87. data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +30 -0
  88. data/lib/nokogiri/decorators/slop.rb +33 -0
  89. data/lib/nokogiri/ffi/html/document.rb +37 -0
  90. data/lib/nokogiri/ffi/html/element_description.rb +85 -0
  91. data/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
  92. data/lib/nokogiri/ffi/html/sax/parser.rb +21 -0
  93. data/lib/nokogiri/ffi/io_callbacks.rb +32 -0
  94. data/lib/nokogiri/ffi/libxml.rb +314 -0
  95. data/lib/nokogiri/ffi/structs/common_node.rb +26 -0
  96. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
  97. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
  98. data/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
  99. data/lib/nokogiri/ffi/structs/xml_attr.rb +19 -0
  100. data/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
  101. data/lib/nokogiri/ffi/structs/xml_document.rb +108 -0
  102. data/lib/nokogiri/ffi/structs/xml_dtd.rb +26 -0
  103. data/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
  104. data/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
  105. data/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
  106. data/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
  107. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
  108. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
  109. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +14 -0
  110. data/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
  111. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
  112. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
  113. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +37 -0
  114. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
  115. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
  116. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
  117. data/lib/nokogiri/ffi/xml/attr.rb +41 -0
  118. data/lib/nokogiri/ffi/xml/cdata.rb +19 -0
  119. data/lib/nokogiri/ffi/xml/comment.rb +18 -0
  120. data/lib/nokogiri/ffi/xml/document.rb +107 -0
  121. data/lib/nokogiri/ffi/xml/document_fragment.rb +26 -0
  122. data/lib/nokogiri/ffi/xml/dtd.rb +42 -0
  123. data/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
  124. data/lib/nokogiri/ffi/xml/namespace.rb +38 -0
  125. data/lib/nokogiri/ffi/xml/node.rb +380 -0
  126. data/lib/nokogiri/ffi/xml/node_set.rb +130 -0
  127. data/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
  128. data/lib/nokogiri/ffi/xml/reader.rb +217 -0
  129. data/lib/nokogiri/ffi/xml/relax_ng.rb +51 -0
  130. data/lib/nokogiri/ffi/xml/sax/parser.rb +148 -0
  131. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +38 -0
  132. data/lib/nokogiri/ffi/xml/schema.rb +55 -0
  133. data/lib/nokogiri/ffi/xml/syntax_error.rb +76 -0
  134. data/lib/nokogiri/ffi/xml/text.rb +18 -0
  135. data/lib/nokogiri/ffi/xml/xpath.rb +19 -0
  136. data/lib/nokogiri/ffi/xml/xpath_context.rb +135 -0
  137. data/lib/nokogiri/ffi/xslt/stylesheet.rb +47 -0
  138. data/lib/nokogiri/hpricot.rb +62 -0
  139. data/lib/nokogiri/html.rb +34 -0
  140. data/lib/nokogiri/html/builder.rb +35 -0
  141. data/lib/nokogiri/html/document.rb +71 -0
  142. data/lib/nokogiri/html/document_fragment.rb +15 -0
  143. data/lib/nokogiri/html/element_description.rb +23 -0
  144. data/lib/nokogiri/html/entity_lookup.rb +13 -0
  145. data/lib/nokogiri/html/sax/parser.rb +47 -0
  146. data/lib/nokogiri/nokogiri.rb +1 -0
  147. data/lib/nokogiri/syntax_error.rb +4 -0
  148. data/lib/nokogiri/version.rb +29 -0
  149. data/lib/nokogiri/version_warning.rb +11 -0
  150. data/lib/nokogiri/xml.rb +62 -0
  151. data/lib/nokogiri/xml/attr.rb +9 -0
  152. data/lib/nokogiri/xml/builder.rb +254 -0
  153. data/lib/nokogiri/xml/cdata.rb +11 -0
  154. data/lib/nokogiri/xml/document.rb +100 -0
  155. data/lib/nokogiri/xml/document_fragment.rb +49 -0
  156. data/lib/nokogiri/xml/dtd.rb +11 -0
  157. data/lib/nokogiri/xml/entity_declaration.rb +11 -0
  158. data/lib/nokogiri/xml/fragment_handler.rb +55 -0
  159. data/lib/nokogiri/xml/namespace.rb +7 -0
  160. data/lib/nokogiri/xml/node.rb +745 -0
  161. data/lib/nokogiri/xml/node/save_options.rb +42 -0
  162. data/lib/nokogiri/xml/node_set.rb +238 -0
  163. data/lib/nokogiri/xml/notation.rb +6 -0
  164. data/lib/nokogiri/xml/parse_options.rb +80 -0
  165. data/lib/nokogiri/xml/processing_instruction.rb +8 -0
  166. data/lib/nokogiri/xml/reader.rb +66 -0
  167. data/lib/nokogiri/xml/relax_ng.rb +32 -0
  168. data/lib/nokogiri/xml/sax.rb +3 -0
  169. data/lib/nokogiri/xml/sax/document.rb +143 -0
  170. data/lib/nokogiri/xml/sax/parser.rb +101 -0
  171. data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
  172. data/lib/nokogiri/xml/schema.rb +65 -0
  173. data/lib/nokogiri/xml/syntax_error.rb +34 -0
  174. data/lib/nokogiri/xml/xpath.rb +10 -0
  175. data/lib/nokogiri/xml/xpath/syntax_error.rb +8 -0
  176. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  177. data/lib/nokogiri/xslt.rb +48 -0
  178. data/lib/nokogiri/xslt/stylesheet.rb +25 -0
  179. data/lib/xsd/xmlparser/nokogiri.rb +64 -0
  180. data/tasks/test.rb +161 -0
  181. data/test/css/test_nthiness.rb +160 -0
  182. data/test/css/test_parser.rb +277 -0
  183. data/test/css/test_tokenizer.rb +176 -0
  184. data/test/css/test_xpath_visitor.rb +76 -0
  185. data/test/ffi/test_document.rb +35 -0
  186. data/test/files/address_book.rlx +12 -0
  187. data/test/files/address_book.xml +10 -0
  188. data/test/files/dont_hurt_em_why.xml +422 -0
  189. data/test/files/exslt.xml +8 -0
  190. data/test/files/exslt.xslt +35 -0
  191. data/test/files/po.xml +32 -0
  192. data/test/files/po.xsd +66 -0
  193. data/test/files/staff.xml +59 -0
  194. data/test/files/staff.xslt +32 -0
  195. data/test/files/tlm.html +850 -0
  196. data/test/helper.rb +123 -0
  197. data/test/hpricot/files/basic.xhtml +17 -0
  198. data/test/hpricot/files/boingboing.html +2266 -0
  199. data/test/hpricot/files/cy0.html +3653 -0
  200. data/test/hpricot/files/immob.html +400 -0
  201. data/test/hpricot/files/pace_application.html +1320 -0
  202. data/test/hpricot/files/tenderlove.html +16 -0
  203. data/test/hpricot/files/uswebgen.html +220 -0
  204. data/test/hpricot/files/utf8.html +1054 -0
  205. data/test/hpricot/files/week9.html +1723 -0
  206. data/test/hpricot/files/why.xml +19 -0
  207. data/test/hpricot/load_files.rb +11 -0
  208. data/test/hpricot/test_alter.rb +68 -0
  209. data/test/hpricot/test_builder.rb +20 -0
  210. data/test/hpricot/test_parser.rb +426 -0
  211. data/test/hpricot/test_paths.rb +15 -0
  212. data/test/hpricot/test_preserved.rb +77 -0
  213. data/test/hpricot/test_xml.rb +30 -0
  214. data/test/html/sax/test_parser.rb +52 -0
  215. data/test/html/test_builder.rb +156 -0
  216. data/test/html/test_document.rb +361 -0
  217. data/test/html/test_document_encoding.rb +46 -0
  218. data/test/html/test_document_fragment.rb +97 -0
  219. data/test/html/test_element_description.rb +95 -0
  220. data/test/html/test_named_characters.rb +14 -0
  221. data/test/html/test_node.rb +165 -0
  222. data/test/test_convert_xpath.rb +186 -0
  223. data/test/test_css_cache.rb +56 -0
  224. data/test/test_gc.rb +15 -0
  225. data/test/test_memory_leak.rb +77 -0
  226. data/test/test_nokogiri.rb +127 -0
  227. data/test/test_reader.rb +316 -0
  228. data/test/test_xslt_transforms.rb +131 -0
  229. data/test/xml/node/test_save_options.rb +20 -0
  230. data/test/xml/node/test_subclass.rb +44 -0
  231. data/test/xml/sax/test_parser.rb +169 -0
  232. data/test/xml/sax/test_push_parser.rb +92 -0
  233. data/test/xml/test_attr.rb +38 -0
  234. data/test/xml/test_builder.rb +73 -0
  235. data/test/xml/test_cdata.rb +38 -0
  236. data/test/xml/test_comment.rb +23 -0
  237. data/test/xml/test_document.rb +397 -0
  238. data/test/xml/test_document_encoding.rb +26 -0
  239. data/test/xml/test_document_fragment.rb +76 -0
  240. data/test/xml/test_dtd.rb +42 -0
  241. data/test/xml/test_dtd_encoding.rb +31 -0
  242. data/test/xml/test_entity_reference.rb +21 -0
  243. data/test/xml/test_namespace.rb +43 -0
  244. data/test/xml/test_node.rb +808 -0
  245. data/test/xml/test_node_attributes.rb +34 -0
  246. data/test/xml/test_node_encoding.rb +84 -0
  247. data/test/xml/test_node_set.rb +368 -0
  248. data/test/xml/test_parse_options.rb +52 -0
  249. data/test/xml/test_processing_instruction.rb +30 -0
  250. data/test/xml/test_reader_encoding.rb +126 -0
  251. data/test/xml/test_relax_ng.rb +60 -0
  252. data/test/xml/test_schema.rb +65 -0
  253. data/test/xml/test_text.rb +18 -0
  254. data/test/xml/test_unparented_node.rb +381 -0
  255. data/test/xml/test_xpath.rb +106 -0
  256. metadata +409 -0
@@ -0,0 +1,85 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class ElementDescription
4
+
5
+ attr_accessor :cstruct # :nodoc:
6
+
7
+ def required_attributes # :nodoc:
8
+ get_string_array_from :attrs_req
9
+ end
10
+
11
+ def deprecated_attributes # :nodoc:
12
+ get_string_array_from :attrs_depr
13
+ end
14
+
15
+ def optional_attributes # :nodoc:
16
+ get_string_array_from :attrs_opt
17
+ end
18
+
19
+ def default_sub_element # :nodoc:
20
+ cstruct[:defaultsubelt]
21
+ end
22
+
23
+ def sub_elements # :nodoc:
24
+ get_string_array_from :subelts
25
+ end
26
+
27
+ def description # :nodoc:
28
+ cstruct[:desc]
29
+ end
30
+
31
+ def inline? # :nodoc:
32
+ cstruct[:isinline] != 0
33
+ end
34
+
35
+ def deprecated? # :nodoc:
36
+ cstruct[:depr] != 0
37
+ end
38
+
39
+ def empty? # :nodoc:
40
+ cstruct[:empty] != 0
41
+ end
42
+
43
+ def save_end_tag? # :nodoc:
44
+ cstruct[:saveEndTag] != 0
45
+ end
46
+
47
+ def implied_end_tag? # :nodoc:
48
+ cstruct[:endTag] != 0
49
+ end
50
+
51
+ def implied_start_tag? # :nodoc:
52
+ cstruct[:startTag] != 0
53
+ end
54
+
55
+ def name # :nodoc:
56
+ cstruct[:name]
57
+ end
58
+
59
+ def self.[](tag_name) # :nodoc:
60
+ ptr = LibXML.htmlTagLookup(tag_name)
61
+ return nil if ptr.null?
62
+
63
+ desc = allocate
64
+ desc.cstruct = LibXML::HtmlElemDesc.new(ptr)
65
+ desc
66
+ end
67
+
68
+ private
69
+
70
+ def get_string_array_from(sym) # :nodoc:
71
+ list = []
72
+ return list if cstruct[sym].null?
73
+
74
+ j = 0
75
+ while (ptr = cstruct[sym].get_pointer(j * FFI.type_size(:pointer))) && ! ptr.null?
76
+ list << ptr.read_string
77
+ j += 1
78
+ end
79
+
80
+ list
81
+ end
82
+
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,16 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class EntityLookup
4
+
5
+ def get(key) # :nodoc:
6
+ ptr = LibXML.htmlEntityLookup(key.to_s)
7
+ return nil if ptr.null?
8
+
9
+ cstruct = LibXML::HtmlEntityDesc.new(ptr)
10
+ EntityDescription.new cstruct[:value], cstruct[:name], cstruct[:desc]
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,21 @@
1
+ module Nokogiri
2
+ module HTML
3
+ module SAX
4
+ class Parser < XML::SAX::Parser
5
+
6
+ def native_parse_file(data, encoding) # :nodoc:
7
+ docptr = LibXML.htmlSAXParseFile(data, encoding, cstruct, nil)
8
+ LibXML.xmlFreeDoc docptr
9
+ data
10
+ end
11
+
12
+ def native_parse_memory(data, encoding) # :nodoc:
13
+ docptr = LibXML.htmlSAXParseDoc(data, encoding, cstruct, nil)
14
+ LibXML.xmlFreeDoc docptr
15
+ data
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module Nokogiri
2
+ module IoCallbacks # :nodoc:
3
+
4
+ class << self
5
+ if defined?(FFI::IO.native_read)
6
+ def reader(io)
7
+ lambda do |ctx, buffer, len|
8
+ rcode = FFI::IO.native_read(io, buffer, len)
9
+ (rcode < 0) ? 0 : rcode
10
+ end
11
+ end
12
+ else
13
+ def reader(io) # TODO: this can be removed once JRuby 1.3.0RC2 and ruby-ffi 0.4.0 are both released
14
+ lambda do |ctx, buffer, len|
15
+ string = io.read(len)
16
+ return 0 if string.nil?
17
+ buffer.put_bytes(0, string, 0, string.length)
18
+ string.length
19
+ end
20
+ end
21
+ end
22
+
23
+ def writer(io)
24
+ lambda do |context, buffer, len|
25
+ io.write buffer
26
+ len
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,314 @@
1
+
2
+ module Nokogiri
3
+ module LibXML # :nodoc: all
4
+ extend FFI::Library
5
+ ffi_lib 'xml2', 'xslt', 'exslt'
6
+
7
+ # globals.c
8
+ attach_function :__xmlParserVersion, [], :pointer
9
+ attach_function :__xmlIndentTreeOutput, [], :pointer
10
+ attach_function :__xmlTreeIndentString, [], :pointer
11
+ attach_function :xmlDeregisterNodeDefault, [:pointer], :pointer
12
+ end
13
+
14
+ LIBXML_PARSER_VERSION = LibXML.__xmlParserVersion().read_pointer.read_string
15
+ LIBXML_VERSION = LIBXML_PARSER_VERSION.scan(/^(.*)(..)(..)$/).first.collect{|j|j.to_i}.join(".")
16
+ end
17
+
18
+ require 'nokogiri/version'
19
+
20
+ Nokogiri::VERSION_INFO['libxml'] = {}
21
+ Nokogiri::VERSION_INFO['libxml']['loaded'] = Nokogiri::LIBXML_VERSION
22
+ Nokogiri::VERSION_INFO['libxml']['binding'] = 'ffi'
23
+ if RUBY_PLATFORM =~ /java/
24
+ Nokogiri::VERSION_INFO['libxml']['platform'] = 'jruby'
25
+ raise(RuntimeError, "Nokogiri requires JRuby 1.3.0 or later") if JRUBY_VERSION < "1.3.0"
26
+ else
27
+ Nokogiri::VERSION_INFO['libxml']['platform'] = 'ruby'
28
+ end
29
+
30
+ module Nokogiri
31
+ module LibXML # :nodoc:
32
+ # useful callback signatures
33
+ callback :syntax_error_handler, [:pointer, :pointer], :void
34
+ callback :generic_error_handler, [:pointer, :string], :void
35
+ callback :io_write_callback, [:pointer, :string, :int], :int
36
+ callback :io_read_callback, [:pointer, :pointer, :int], :int
37
+ callback :io_close_callback, [:pointer], :int
38
+ callback :hash_copier_callback, [:pointer, :pointer, :string], :void
39
+ callback :xpath_callback, [:pointer, :int], :void
40
+ callback :xpath_lookup_callback, [:pointer, :string, :pointer], :xpath_callback
41
+ callback :start_document_sax_func, [:pointer], :void
42
+ callback :end_document_sax_func, [:pointer], :void
43
+ callback :start_element_sax_func, [:pointer, :string, :pointer], :void
44
+ callback :end_element_sax_func, [:pointer, :string], :void
45
+ callback :characters_sax_func, [:pointer, :string, :int], :void
46
+ callback :comment_sax_func, [:pointer, :string], :void
47
+ callback :warning_sax_func, [:pointer, :string], :void
48
+ callback :error_sax_func, [:pointer, :string], :void
49
+ callback :cdata_block_sax_func, [:pointer, :string, :int], :void
50
+ callback :start_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer, :int, :pointer, :int, :int, :pointer], :void
51
+ callback :end_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer], :void
52
+
53
+ # libc
54
+ attach_function :calloc, [:int, :int], :pointer
55
+ attach_function :free, [:pointer], :void
56
+
57
+ # HTMLparser.c
58
+ attach_function :htmlReadMemory, [:string, :int, :string, :string, :int], :pointer
59
+ attach_function :htmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
60
+ attach_function :htmlNewDoc, [:string, :string], :pointer
61
+ attach_function :htmlTagLookup, [:string], :pointer
62
+ attach_function :htmlEntityLookup, [:string], :pointer
63
+ attach_function :htmlSAXParseFile, [:string, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
64
+ attach_function :htmlSAXParseDoc, [:pointer, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
65
+
66
+ # HTMLtree.c
67
+ attach_function :htmlDocDumpMemory, [:pointer, :pointer, :pointer], :void
68
+ attach_function :htmlNodeDump, [:pointer, :pointer, :pointer], :int
69
+ attach_function :htmlGetMetaEncoding, [:pointer], :string # returns const char*
70
+ attach_function :htmlSetMetaEncoding, [:pointer, :string], :void
71
+
72
+ # parser.c
73
+ attach_function :xmlReadMemory, [:string, :int, :string, :string, :int], :pointer
74
+ attach_function :xmlInitParser, [], :void
75
+ attach_function :xmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
76
+ attach_function :xmlCreateIOParserCtxt, [:pointer, :pointer, :io_read_callback, :io_close_callback, :pointer, :int], :pointer
77
+ attach_function :xmlSAXUserParseMemory, [:pointer, :pointer, :string, :int], :int
78
+ attach_function :xmlSAXUserParseFile, [:pointer, :pointer, :string], :int
79
+ attach_function :xmlParseDocument, [:pointer], :int
80
+ attach_function :xmlFreeParserCtxt, [:pointer], :void
81
+ attach_function :xmlCreatePushParserCtxt, [:pointer, :pointer, :string, :int, :string], :pointer
82
+ attach_function :xmlParseChunk, [:pointer, :string, :int, :int], :int
83
+
84
+ # tree.c
85
+ attach_function :xmlNewDoc, [:string], :pointer
86
+ attach_function :xmlNewDocFragment, [:pointer], :pointer
87
+ attach_function :xmlDocGetRootElement, [:pointer], :pointer
88
+ attach_function :xmlDocSetRootElement, [:pointer, :pointer], :pointer
89
+ attach_function :xmlCopyDoc, [:pointer, :int], :pointer
90
+ attach_function :xmlFreeDoc, [:pointer], :void
91
+ attach_function :xmlSetTreeDoc, [:pointer, :pointer], :void
92
+ attach_function :xmlNewReference, [:pointer, :string], :pointer
93
+ attach_function :xmlNewNode, [:pointer, :string], :pointer
94
+ attach_function :xmlCopyNode, [:pointer, :int], :pointer
95
+ attach_function :xmlDocCopyNode, [:pointer, :pointer, :int], :pointer
96
+ attach_function :xmlReplaceNode, [:pointer, :pointer], :pointer
97
+ attach_function :xmlUnlinkNode, [:pointer], :void
98
+ attach_function :xmlAddChild, [:pointer, :pointer], :pointer
99
+ attach_function :xmlAddNextSibling, [:pointer, :pointer], :pointer
100
+ attach_function :xmlAddPrevSibling, [:pointer, :pointer], :pointer
101
+ attach_function :xmlIsBlankNode, [:pointer], :int
102
+ attach_function :xmlHasProp, [:pointer, :string], :pointer
103
+ attach_function :xmlHasNsProp, [:pointer, :string, :string], :pointer
104
+ attach_function :xmlGetProp, [:pointer, :string], :pointer # returns char* that must be freed
105
+ attach_function :xmlSetProp, [:pointer, :string, :string], :pointer
106
+ attach_function :xmlRemoveProp, [:pointer], :int
107
+ attach_function :xmlNodeSetContent, [:pointer, :string], :void
108
+ attach_function :xmlNodeGetContent, [:pointer], :pointer # returns char* that must be freed
109
+ attach_function :xmlNodeSetName, [:pointer, :string], :void
110
+ attach_function :xmlGetNodePath, [:pointer], :pointer
111
+ attach_function :xmlNewCDataBlock, [:pointer, :string, :int], :pointer
112
+ attach_function :xmlNewDocComment, [:pointer, :string], :pointer
113
+ attach_function :xmlNewDocPI, [:pointer, :string, :string], :pointer
114
+ attach_function :xmlNewText, [:string], :pointer
115
+ attach_function :xmlFreeNode, [:pointer], :void
116
+ attach_function :xmlFreeNodeList, [:pointer], :void
117
+ attach_function :xmlEncodeEntitiesReentrant, [:pointer, :string], :pointer # returns char* that must be freed
118
+ attach_function :xmlStringGetNodeList, [:pointer, :pointer], :pointer # second arg should be a :string, but we only ship the results of xmlEncodeEntitiesReentrant, so let's optimize.
119
+ attach_function :xmlNewNs, [:pointer, :string, :string], :pointer
120
+ attach_function :xmlNewNsProp, [:pointer, :pointer, :string, :string], :pointer
121
+ attach_function :xmlSearchNsByHref, [:pointer, :pointer, :string], :pointer
122
+ attach_function :xmlGetIntSubset, [:pointer], :pointer
123
+ attach_function :xmlBufferCreate, [], :pointer
124
+ attach_function :xmlBufferFree, [:pointer], :void
125
+ attach_function :xmlSplitQName2, [:string, :pointer], :pointer # returns char* that must be freed
126
+ attach_function :xmlNewDocProp, [:pointer, :string, :string], :pointer
127
+ attach_function :xmlFreePropList, [:pointer], :void
128
+
129
+ # xmlsave.c
130
+ attach_function :xmlDocDumpMemory, [:pointer, :pointer, :pointer], :void
131
+ attach_function :xmlNodeDump, [:pointer, :pointer, :pointer, :int, :int], :int
132
+ attach_function :xmlSaveToIO, [:io_write_callback, :io_close_callback, :pointer, :string, :int], :pointer
133
+ attach_function :xmlSaveTree, [:pointer, :pointer], :int
134
+ attach_function :xmlSaveClose, [:pointer], :int
135
+ attach_function :xmlSetNs, [:pointer, :pointer], :void
136
+
137
+ # entities.c
138
+ attach_function :xmlEncodeSpecialChars, [:pointer, :string], :pointer # returns char* that must be freed
139
+
140
+ # xpath.c
141
+ attach_function :xmlXPathInit, [], :void
142
+ attach_function :xmlXPathNewContext, [:pointer], :pointer
143
+ attach_function :xmlXPathFreeContext, [:pointer], :void
144
+ attach_function :xmlXPathEvalExpression, [:string, :pointer], :pointer
145
+ attach_function :xmlXPathRegisterNs, [:pointer, :string, :string], :int
146
+ attach_function :xmlXPathCmpNodes, [:pointer, :pointer], :int
147
+ attach_function :xmlXPathNodeSetContains, [:pointer, :pointer], :int
148
+ attach_function :xmlXPathNodeSetAdd, [:pointer, :pointer], :void
149
+ attach_function :xmlXPathNodeSetRemove, [:pointer, :int], :void
150
+ attach_function :xmlXPathNodeSetCreate, [:pointer], :pointer
151
+ attach_function :xmlXPathNodeSetDel, [:pointer, :pointer], :void
152
+ attach_function :xmlXPathIntersection, [:pointer, :pointer], :pointer
153
+ attach_function :xmlXPathFreeNodeSetList, [:pointer], :void
154
+ attach_function :xmlXPathRegisterFuncLookup, [:pointer, :xpath_lookup_callback, :pointer], :void
155
+ attach_function :valuePop, [:pointer], :pointer
156
+ attach_function :valuePush, [:pointer, :pointer], :int
157
+ attach_function :xmlXPathCastToString, [:pointer], :pointer # returns char* that must be freed
158
+ attach_function :xmlXPathNodeSetMerge, [:pointer, :pointer], :pointer
159
+ attach_function :xmlXPathWrapNodeSet, [:pointer], :pointer
160
+ attach_function :xmlXPathWrapCString, [:pointer], :pointer # should take a :string, but we optimize
161
+ attach_function :xmlXPathWrapString, [:pointer], :pointer # should take a :string, but we optimize
162
+ attach_function :xmlXPathNewBoolean, [:int], :pointer
163
+ attach_function :xmlXPathNewFloat, [:double], :pointer
164
+
165
+ class << self
166
+ # these functions are implemented as C macros
167
+ def xmlXPathReturnNodeSet(ctx, ns)
168
+ valuePush(ctx, xmlXPathWrapNodeSet(ns))
169
+ end
170
+ def xmlXPathReturnTrue(ctx)
171
+ valuePush(ctx, xmlXPathNewBoolean(1))
172
+ end
173
+ def xmlXPathReturnFalse(ctx)
174
+ valuePush(ctx, xmlXPathNewBoolean(0))
175
+ end
176
+ def xmlXPathReturnString(ctx, str)
177
+ valuePush(ctx, xmlXPathWrapString(str))
178
+ end
179
+ def xmlXPathReturnNumber(ctx, val)
180
+ valuePush(ctx, xmlXPathNewFloat(val))
181
+ end
182
+ end
183
+
184
+ # xmlstring.c
185
+ attach_function :xmlStrdup, [:string], :pointer # returns char* that must be freed
186
+ def self.xmlFree(pointer)
187
+ # xmlFree is a C preprocessor macro, not an actual function
188
+ self.free(pointer)
189
+ end
190
+
191
+ # error.c
192
+ attach_function :xmlSetStructuredErrorFunc, [:pointer, :syntax_error_handler], :void
193
+ attach_function :xmlSetGenericErrorFunc, [:pointer, :generic_error_handler], :void
194
+ attach_function :xmlResetLastError, [], :void
195
+ attach_function :xmlCopyError, [:pointer, :pointer], :int
196
+ attach_function :xmlGetLastError, [], :pointer
197
+
198
+ # hash.c
199
+ attach_function :xmlHashScan, [:pointer, :hash_copier_callback, :pointer], :void
200
+
201
+ # xmlreader.c
202
+ attach_function :xmlReaderForMemory, [:pointer, :int, :string, :string, :int], :pointer
203
+ attach_function :xmlTextReaderGetAttribute, [:pointer, :string], :pointer # returns char* that must be freed
204
+ attach_function :xmlTextReaderGetAttributeNo, [:pointer, :int], :pointer # returns char* that must be freed
205
+ attach_function :xmlTextReaderLookupNamespace, [:pointer, :string], :pointer # returns char* that must be freed
206
+ attach_function :xmlTextReaderRead, [:pointer], :int
207
+ attach_function :xmlTextReaderAttributeCount, [:pointer], :int
208
+ attach_function :xmlTextReaderCurrentNode, [:pointer], :pointer
209
+ attach_function :xmlTextReaderExpand, [:pointer], :pointer
210
+ attach_function :xmlTextReaderIsDefault, [:pointer], :int
211
+ attach_function :xmlTextReaderDepth, [:pointer], :int
212
+ attach_function :xmlTextReaderConstXmlLang, [:pointer], :pointer # returns a const char*, but must check for null
213
+ attach_function :xmlTextReaderConstLocalName, [:pointer], :pointer # returns a const char* that is deallocated with the reader
214
+ attach_function :xmlTextReaderConstName, [:pointer], :pointer # returns a const char* that is deallocated with the reader
215
+ attach_function :xmlTextReaderConstNamespaceUri, [:pointer], :pointer # returns a const char* that is deallocated with the reader
216
+ attach_function :xmlTextReaderConstPrefix, [:pointer], :pointer # returns a const char* that is deallocated with the reader
217
+ attach_function :xmlTextReaderConstValue, [:pointer], :pointer # returns a const char* that is deallocated on the next read()
218
+ attach_function :xmlTextReaderConstXmlVersion, [:pointer], :pointer # returns a const char* that is deallocated with the reader
219
+ attach_function :xmlTextReaderReadState, [:pointer], :int
220
+ attach_function :xmlTextReaderHasValue, [:pointer], :int
221
+ attach_function :xmlFreeTextReader, [:pointer], :void
222
+ attach_function :xmlReaderForIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
223
+
224
+ # xslt.c
225
+ attach_function :xsltParseStylesheetDoc, [:pointer], :pointer
226
+ attach_function :xsltFreeStylesheet, [:pointer], :void
227
+ attach_function :xsltApplyStylesheet, [:pointer, :pointer, :pointer], :pointer
228
+ attach_function :xsltSaveResultToString, [:pointer, :pointer, :pointer, :pointer], :int
229
+ attach_function :xsltSetGenericErrorFunc, [:pointer, :generic_error_handler], :void
230
+
231
+ # exslt.c
232
+ attach_function :exsltRegisterAll, [], :void
233
+
234
+ # xmlschemas.c
235
+ attach_function :xmlSchemaNewValidCtxt, [:pointer], :pointer
236
+ attach_function :xmlSchemaSetValidStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
237
+ attach_function :xmlSchemaValidateDoc, [:pointer, :pointer], :void
238
+ attach_function :xmlSchemaFreeValidCtxt, [:pointer], :void
239
+ attach_function :xmlSchemaNewMemParserCtxt, [:pointer, :int], :pointer # first arg could be string, but we pass length, so let's optimize
240
+ attach_function :xmlSchemaSetParserStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
241
+ attach_function :xmlSchemaParse, [:pointer], :pointer
242
+ attach_function :xmlSchemaFreeParserCtxt, [:pointer], :void
243
+
244
+ # relaxng.c
245
+ attach_function :xmlRelaxNGNewValidCtxt, [:pointer], :pointer
246
+ attach_function :xmlRelaxNGSetValidStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
247
+ attach_function :xmlRelaxNGValidateDoc, [:pointer, :pointer], :int
248
+ attach_function :xmlRelaxNGFreeValidCtxt, [:pointer], :void
249
+ attach_function :xmlRelaxNGNewMemParserCtxt, [:pointer, :int], :pointer # first arg could be string, but we pass length, so let's optimize
250
+ attach_function :xmlRelaxNGSetParserStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
251
+ attach_function :xmlRelaxNGParse, [:pointer], :pointer
252
+ attach_function :xmlRelaxNGFreeParserCtxt, [:pointer], :void
253
+
254
+ # helpers
255
+ def self.pointer_offset(n)
256
+ n * FFI.type_size(:pointer) # byte offset of nth pointer in an array of pointers
257
+ end
258
+ end
259
+ end
260
+
261
+ require 'nokogiri/syntax_error'
262
+ require 'nokogiri/xml/syntax_error'
263
+
264
+ [ "io_callbacks",
265
+ "structs/common_node",
266
+ "structs/xml_alloc",
267
+ "structs/xml_document",
268
+ "structs/xml_node",
269
+ "structs/xml_dtd",
270
+ "structs/xml_notation",
271
+ "structs/xml_node_set",
272
+ "structs/xml_xpath_context",
273
+ "structs/xml_xpath_object",
274
+ "structs/xml_xpath_parser_context",
275
+ "structs/xml_buffer",
276
+ "structs/xml_syntax_error",
277
+ "structs/xml_attr",
278
+ "structs/xml_ns",
279
+ "structs/xml_schema",
280
+ "structs/xml_relax_ng",
281
+ "structs/xml_text_reader",
282
+ "structs/xml_sax_handler",
283
+ "structs/xml_sax_push_parser_context",
284
+ "structs/html_elem_desc",
285
+ "structs/html_entity_desc",
286
+ "structs/xslt_stylesheet",
287
+ "xml/node",
288
+ "xml/namespace",
289
+ "xml/dtd",
290
+ "xml/attr",
291
+ "xml/document",
292
+ "xml/document_fragment",
293
+ "xml/schema",
294
+ "xml/relax_ng",
295
+ "xml/text",
296
+ "xml/cdata",
297
+ "xml/comment",
298
+ "xml/processing_instruction",
299
+ "xml/node_set",
300
+ "xml/xpath",
301
+ "xml/xpath_context",
302
+ "xml/syntax_error",
303
+ "xml/reader",
304
+ "xml/entity_reference",
305
+ "xml/sax/parser",
306
+ "xml/sax/push_parser",
307
+ "html/document",
308
+ "html/element_description",
309
+ "html/entity_lookup",
310
+ "html/sax/parser",
311
+ "xslt/stylesheet",
312
+ ].each do |file|
313
+ require File.join(File.dirname(__FILE__), file)
314
+ end