nokogiri 1.4.7-x86-mingw32 → 1.5.0-x86-mingw32

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 (132) hide show
  1. data/CHANGELOG.ja.rdoc +59 -1
  2. data/CHANGELOG.rdoc +51 -2
  3. data/Manifest.txt +66 -66
  4. data/README.ja.rdoc +4 -0
  5. data/README.rdoc +31 -3
  6. data/Rakefile +111 -135
  7. data/bin/nokogiri +1 -2
  8. data/ext/nokogiri/extconf.rb +9 -3
  9. data/ext/nokogiri/nokogiri.c +21 -3
  10. data/ext/nokogiri/nokogiri.h +0 -2
  11. data/ext/nokogiri/xml_node.c +0 -6
  12. data/ext/nokogiri/xml_relax_ng.c +0 -7
  13. data/ext/nokogiri/xml_sax_parser.c +9 -4
  14. data/ext/nokogiri/xslt_stylesheet.c +5 -1
  15. data/lib/nokogiri.rb +19 -25
  16. data/lib/nokogiri/1.8/nokogiri.so +0 -0
  17. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  18. data/lib/nokogiri/css.rb +0 -1
  19. data/lib/nokogiri/html.rb +1 -0
  20. data/lib/nokogiri/html/document.rb +9 -2
  21. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  22. data/lib/nokogiri/version.rb +76 -31
  23. data/lib/nokogiri/xml/attribute_decl.rb +1 -1
  24. data/lib/nokogiri/xml/builder.rb +7 -0
  25. data/lib/nokogiri/xml/document.rb +17 -1
  26. data/lib/nokogiri/xml/document_fragment.rb +14 -0
  27. data/lib/nokogiri/xml/dtd.rb +1 -1
  28. data/lib/nokogiri/xml/element_decl.rb +1 -1
  29. data/lib/nokogiri/xml/entity_decl.rb +1 -1
  30. data/lib/nokogiri/xml/node.rb +39 -15
  31. data/lib/nokogiri/xml/node/save_options.rb +14 -5
  32. data/lib/nokogiri/xml/node_set.rb +7 -0
  33. data/lib/nokogiri/xml/reader.rb +2 -2
  34. data/lib/nokogiri/xml/sax/document.rb +2 -2
  35. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  36. data/nokogiri_help_responses.md +40 -0
  37. data/tasks/cross_compile.rb +134 -155
  38. data/tasks/nokogiri.org.rb +18 -0
  39. data/tasks/test.rb +2 -2
  40. data/test/files/metacharset.html +10 -0
  41. data/test/files/noencoding.html +47 -0
  42. data/test/helper.rb +2 -1
  43. data/test/html/sax/test_parser.rb +22 -5
  44. data/test/html/test_document.rb +21 -2
  45. data/test/html/test_document_encoding.rb +9 -1
  46. data/test/html/test_document_fragment.rb +5 -3
  47. data/test/html/test_element_description.rb +4 -2
  48. data/test/test_memory_leak.rb +4 -39
  49. data/test/test_nokogiri.rb +14 -20
  50. data/test/test_reader.rb +12 -8
  51. data/test/xml/node/test_save_options.rb +10 -2
  52. data/test/xml/sax/test_parser.rb +14 -7
  53. data/test/xml/test_attribute_decl.rb +7 -3
  54. data/test/xml/test_builder.rb +17 -0
  55. data/test/xml/test_document.rb +31 -4
  56. data/test/xml/test_dtd.rb +13 -3
  57. data/test/xml/test_element_content.rb +1 -1
  58. data/test/xml/test_element_decl.rb +1 -1
  59. data/test/xml/test_entity_decl.rb +12 -10
  60. data/test/xml/test_namespace.rb +7 -5
  61. data/test/xml/test_node.rb +21 -10
  62. data/test/xml/test_node_reparenting.rb +16 -3
  63. data/test/xml/test_node_set.rb +34 -0
  64. data/test/xslt/test_custom_functions.rb +2 -2
  65. data/test/xslt/test_exception_handling.rb +37 -0
  66. metadata +110 -88
  67. data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
  68. data/lib/nokogiri/ffi/html/document.rb +0 -28
  69. data/lib/nokogiri/ffi/html/element_description.rb +0 -81
  70. data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
  71. data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
  72. data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
  73. data/lib/nokogiri/ffi/libxml.rb +0 -420
  74. data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
  75. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
  76. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
  77. data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
  78. data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
  79. data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
  80. data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
  81. data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
  82. data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
  83. data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
  84. data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
  85. data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
  86. data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
  87. data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
  88. data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
  89. data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
  90. data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
  91. data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
  92. data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
  93. data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
  94. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
  95. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
  96. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
  97. data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
  98. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
  99. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
  100. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
  101. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
  102. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
  103. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
  104. data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
  105. data/lib/nokogiri/ffi/xml/attr.rb +0 -41
  106. data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
  107. data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
  108. data/lib/nokogiri/ffi/xml/comment.rb +0 -18
  109. data/lib/nokogiri/ffi/xml/document.rb +0 -174
  110. data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
  111. data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
  112. data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
  113. data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
  114. data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
  115. data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
  116. data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
  117. data/lib/nokogiri/ffi/xml/node.rb +0 -559
  118. data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
  119. data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
  120. data/lib/nokogiri/ffi/xml/reader.rb +0 -236
  121. data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
  122. data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
  123. data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
  124. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
  125. data/lib/nokogiri/ffi/xml/schema.rb +0 -109
  126. data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
  127. data/lib/nokogiri/ffi/xml/text.rb +0 -18
  128. data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
  129. data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
  130. data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
  131. data/lib/nokogiri/version_warning.rb +0 -14
  132. data/test/ffi/test_document.rb +0 -35
@@ -1,42 +0,0 @@
1
- module Nokogiri
2
- class EncodingHandler
3
- # :stopdoc:
4
- attr_accessor :cstruct
5
-
6
- class << self
7
- def [](key)
8
- handler = LibXML.xmlFindCharEncodingHandler(key)
9
- handler.null? ? nil : wrap(handler)
10
- end
11
-
12
- def delete(name)
13
- (LibXML.xmlDelEncodingAlias(name) != 0) ? nil : true
14
- end
15
-
16
- def alias(from, to)
17
- LibXML.xmlAddEncodingAlias(from, to)
18
- to
19
- end
20
-
21
- def clear_aliases!
22
- LibXML.xmlCleanupEncodingAliases
23
- self
24
- end
25
-
26
- private
27
-
28
- def wrap(ptr)
29
- cstruct = LibXML::XmlCharEncodingHandler.new(ptr)
30
- eh = Nokogiri::EncodingHandler.allocate
31
- eh.cstruct = cstruct
32
- eh
33
- end
34
-
35
- end
36
-
37
- def name
38
- cstruct[:name]
39
- end
40
- # :startdoc:
41
- end
42
- end
@@ -1,28 +0,0 @@
1
- module Nokogiri
2
- module HTML
3
- class Document < XML::Document
4
-
5
- attr_accessor :cstruct # :nodoc:
6
-
7
- def self.new(*args) # :nodoc:
8
- uri = args[0]
9
- external_id = args[1]
10
- doc = wrap(LibXML.htmlNewDoc(uri, external_id))
11
- doc.send :initialize, *args
12
- doc
13
- end
14
-
15
- def self.read_io(io, url, encoding, options) # :nodoc:
16
- wrap_with_error_handling do
17
- LibXML.htmlReadIO(IoCallbacks.reader(io), nil, nil, url, encoding, options)
18
- end
19
- end
20
-
21
- def self.read_memory(string, url, encoding, options) # :nodoc:
22
- wrap_with_error_handling do
23
- LibXML.htmlReadMemory(string, string.length, url, encoding, options)
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,81 +0,0 @@
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
- ptr = cstruct[sym]
72
- unless ptr.null?
73
- ptr.get_array_of_string(0)
74
- else
75
- []
76
- end
77
- end
78
-
79
- end
80
- end
81
- end
@@ -1,16 +0,0 @@
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
-
@@ -1,38 +0,0 @@
1
- # :stopdoc:
2
- module Nokogiri
3
- module HTML
4
- module SAX
5
- class ParserContext < Nokogiri::XML::SAX::ParserContext
6
- attr_accessor :cstruct
7
-
8
- def self.file filename, encoding
9
- ctx = LibXML.htmlCreateFileParserCtxt filename, encoding
10
- pc = allocate
11
- pc.cstruct = LibXML::XmlParserContext.new ctx
12
- pc
13
- end
14
-
15
- def self.memory data, encoding
16
- raise ArgumentError unless data
17
- raise "data cannot be empty" unless data.length > 0
18
-
19
- ctx = LibXML.htmlCreateMemoryParserCtxt data, data.length
20
- pc = allocate
21
- pc.cstruct = LibXML::XmlParserContext.new ctx
22
- if encoding
23
- enc = LibXML.xmlFindCharEncodingHandler(encoding)
24
- if !enc.null?
25
- LibXML.xmlSwitchToEncoding(ctx, enc)
26
- end
27
- end
28
- pc
29
- end
30
-
31
- def parse_with sax_handler, type = :html
32
- super
33
- end
34
- end
35
- end
36
- end
37
- end
38
- # :startdoc:
@@ -1,42 +0,0 @@
1
- # :stopdoc:
2
- module Nokogiri
3
- module IoCallbacks
4
-
5
- class << self
6
-
7
- def plain_old_reader(io)
8
- lambda do |ctx, buffer, len|
9
- string = io.read(len)
10
- return 0 if string.nil?
11
- buffer.put_bytes(0, string, 0, string.length)
12
- string.length
13
- end
14
- end
15
-
16
- if defined?(FFI::IO.native_read)
17
- def ffi_io_native_reader(io)
18
- if io.is_a?(StringIO)
19
- plain_old_reader(io)
20
- else
21
- lambda do |ctx, buffer, len|
22
- rcode = FFI::IO.native_read(io, buffer, len)
23
- (rcode < 0) ? 0 : rcode
24
- end
25
- end
26
- end
27
- alias :reader :ffi_io_native_reader
28
- else
29
- alias :reader :plain_old_reader
30
- end
31
-
32
- def writer(io)
33
- lambda do |context, buffer, len|
34
- io.write buffer
35
- len
36
- end
37
- end
38
- end
39
-
40
- end
41
- end
42
- # :startdoc:
@@ -1,420 +0,0 @@
1
- # :stopdoc:
2
- module Nokogiri
3
- module LibXML
4
- extend FFI::Library
5
- if RUBY_PLATFORM =~ /java/ && RbConfig::CONFIG['host_os'] =~ /(mswin|mingw)/i
6
- raise(RuntimeError, "Nokogiri requires JRuby 1.4.0 or later on Windows") if JRUBY_VERSION < "1.4.0"
7
- dll_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "ext", "nokogiri"))
8
- libs = ["libxml2.dll", "libxslt.dll", "libexslt.dll"].collect do |lib|
9
- File.join(dll_dir, lib).tr("/","\\") # see http://jira.codehaus.org/browse/JRUBY-2763
10
- end + ["msvcrt"]
11
- ffi_lib(*libs)
12
- else
13
- ffi_lib 'xml2', 'xslt', 'exslt'
14
- end
15
-
16
- # globals.c
17
- attach_function :__xmlParserVersion, [], :pointer
18
- attach_function :__xmlIndentTreeOutput, [], :pointer
19
- attach_function :__xmlTreeIndentString, [], :pointer
20
- attach_function :xmlDeregisterNodeDefault, [:pointer], :pointer
21
- end
22
-
23
- LIBXML_PARSER_VERSION = LibXML.__xmlParserVersion().read_pointer.read_string
24
- LIBXML_VERSION = LIBXML_PARSER_VERSION.scan(/^(.*)(..)(..)$/).first.collect{|j|j.to_i}.join(".")
25
-
26
- LIBXML_ICONV_ENABLED = true # sigh.
27
- end
28
-
29
- require 'nokogiri/version'
30
-
31
- Nokogiri::VERSION_INFO['libxml'] = {}
32
- Nokogiri::VERSION_INFO['libxml']['loaded'] = Nokogiri::LIBXML_VERSION
33
- Nokogiri::VERSION_INFO['libxml']['binding'] = 'ffi'
34
- if RUBY_PLATFORM =~ /java/
35
- Nokogiri::VERSION_INFO['libxml']['platform'] = 'jruby'
36
- raise(RuntimeError, "Nokogiri requires JRuby 1.3.0 or later") if JRUBY_VERSION < "1.3.0"
37
- else
38
- Nokogiri::VERSION_INFO['libxml']['platform'] = 'ruby'
39
- end
40
-
41
- module Nokogiri
42
- module LibXML
43
- XML_CHAR_ENCODING_ERROR = -1
44
-
45
- # useful callback signatures
46
- callback :syntax_error_handler, [:pointer, :pointer], :void
47
- callback :generic_error_handler, [:pointer, :string], :void
48
- callback :io_write_callback, [:pointer, :string, :int], :int
49
- callback :io_read_callback, [:pointer, :pointer, :int], :int
50
- callback :io_close_callback, [:pointer], :int
51
- callback :hash_copier_callback, [:pointer, :pointer, :string], :void
52
- callback :xpath_callback, [:pointer, :int], :void
53
- callback :xpath_lookup_callback, [:pointer, :string, :pointer], :xpath_callback
54
- callback :start_document_sax_func, [:pointer], :void
55
- callback :end_document_sax_func, [:pointer], :void
56
- callback :start_element_sax_func, [:pointer, :string, :pointer], :void
57
- callback :end_element_sax_func, [:pointer, :string], :void
58
- callback :characters_sax_func, [:pointer, :string, :int], :void
59
- callback :comment_sax_func, [:pointer, :string], :void
60
- callback :warning_sax_func, [:pointer, :string], :void
61
- callback :error_sax_func, [:pointer, :string], :void
62
- callback :cdata_block_sax_func, [:pointer, :string, :int], :void
63
- callback :start_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer, :int, :pointer, :int, :int, :pointer], :void
64
- callback :end_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer], :void
65
- callback :xslt_function_init, [:pointer, :string], :pointer
66
- callback :xslt_function_shutdown, [:pointer, :string, :pointer], :void
67
- callback :xslt_function_caller, [:pointer, :int], :void
68
-
69
- # encoding.c
70
- attach_function :xmlFindCharEncodingHandler, [:string], :pointer
71
- attach_function :xmlDelEncodingAlias, [:string], :int
72
- attach_function :xmlAddEncodingAlias, [:string, :string], :int
73
- attach_function :xmlCleanupEncodingAliases, [], :void
74
-
75
- # HTMLparser.c
76
- attach_function :htmlReadMemory, [:string, :int, :string, :string, :int], :pointer
77
- attach_function :htmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
78
- attach_function :htmlNewDoc, [:string, :string], :pointer
79
- attach_function :htmlTagLookup, [:string], :pointer
80
- attach_function :htmlEntityLookup, [:string], :pointer
81
- attach_function :htmlSAXParseFile, [:string, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
82
- attach_function :htmlSAXParseDoc, [:pointer, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
83
- attach_function :htmlCreateMemoryParserCtxt, [:pointer, :int], :pointer
84
- attach_function :htmlCreateFileParserCtxt, [:pointer, :pointer], :pointer
85
- attach_function :htmlParseDocument, [:pointer], :int
86
- attach_function :htmlHandleOmittedElem, [:int], :int
87
-
88
- # HTMLtree.c
89
- attach_function :htmlDocDumpMemory, [:pointer, :pointer, :pointer], :void
90
- attach_function :htmlNodeDump, [:pointer, :pointer, :pointer], :int
91
- attach_function :htmlGetMetaEncoding, [:pointer], :string # returns const char*
92
- attach_function :htmlSetMetaEncoding, [:pointer, :string], :void
93
-
94
- # parser.c
95
- attach_function :xmlReadMemory, [:string, :int, :string, :string, :int], :pointer
96
- attach_function :xmlInitParser, [], :void
97
- attach_function :xmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
98
- attach_function :xmlCreateIOParserCtxt, [:pointer, :pointer, :io_read_callback, :io_close_callback, :pointer, :int], :pointer
99
- attach_function :xmlCreateMemoryParserCtxt, [:pointer, :int], :pointer
100
- attach_function :xmlCreateFileParserCtxt, [:pointer], :pointer
101
- attach_function :xmlSAXUserParseMemory, [:pointer, :pointer, :string, :int], :int
102
- attach_function :xmlSAXUserParseFile, [:pointer, :pointer, :string], :int
103
- attach_function :xmlParseDocument, [:pointer], :int
104
- attach_function :xmlFreeParserCtxt, [:pointer], :void
105
- attach_function :xmlCreatePushParserCtxt, [:pointer, :pointer, :string, :int, :string], :pointer
106
- attach_function :xmlParseChunk, [:pointer, :string, :int, :int], :int
107
- attach_function :xmlCtxtUseOptions, [:pointer, :int], :int
108
- attach_function :xmlParseInNodeContext, [:pointer, :string, :int, :int, :pointer], :pointer
109
-
110
- # tree.c
111
- attach_function :xmlNewDoc, [:string], :pointer
112
- attach_function :xmlNewDocFragment, [:pointer], :pointer
113
- attach_function :xmlDocGetRootElement, [:pointer], :pointer
114
- attach_function :xmlDocSetRootElement, [:pointer, :pointer], :pointer
115
- attach_function :xmlCopyDoc, [:pointer, :int], :pointer
116
- attach_function :xmlFreeDoc, [:pointer], :void
117
- attach_function :xmlSetTreeDoc, [:pointer, :pointer], :void
118
- attach_function :xmlNewReference, [:pointer, :string], :pointer
119
- # attach_function :xmlFirstElementChild, [:pointer], :pointer
120
- # attach_function :xmlLastElementChild, [:pointer], :pointer
121
- # attach_function :xmlNextElementSibling, [:pointer], :pointer
122
- attach_function :xmlNewNode, [:pointer, :string], :pointer
123
- attach_function :xmlCopyNode, [:pointer, :int], :pointer
124
- attach_function :xmlDocCopyNode, [:pointer, :pointer, :int], :pointer
125
- attach_function :xmlReplaceNode, [:pointer, :pointer], :pointer
126
- attach_function :xmlUnlinkNode, [:pointer], :void
127
- attach_function :xmlAddChild, [:pointer, :pointer], :pointer
128
- attach_function :xmlAddNextSibling, [:pointer, :pointer], :pointer
129
- attach_function :xmlAddPrevSibling, [:pointer, :pointer], :pointer
130
- attach_function :xmlIsBlankNode, [:pointer], :int
131
- attach_function :xmlHasProp, [:pointer, :string], :pointer
132
- attach_function :xmlHasNsProp, [:pointer, :string, :string], :pointer
133
- attach_function :xmlGetProp, [:pointer, :string], :pointer # returns char* that must be freed
134
- attach_function :xmlSetProp, [:pointer, :string, :string], :pointer
135
- attach_function :xmlRemoveProp, [:pointer], :int
136
- attach_function :xmlNodeSetContent, [:pointer, :string], :void
137
- attach_function :xmlNodeGetContent, [:pointer], :pointer # returns char* that must be freed
138
- attach_function :xmlNodeSetName, [:pointer, :string], :void
139
- attach_function :xmlGetNodePath, [:pointer], :pointer
140
- attach_function :xmlNewCDataBlock, [:pointer, :string, :int], :pointer
141
- attach_function :xmlNewDocComment, [:pointer, :string], :pointer
142
- attach_function :xmlNewDocPI, [:pointer, :string, :string], :pointer
143
- attach_function :xmlNewText, [:string], :pointer
144
- attach_function :xmlFreeNode, [:pointer], :void
145
- attach_function :xmlFreeNodeList, [:pointer], :void
146
- attach_function :xmlEncodeEntitiesReentrant, [:pointer, :string], :pointer # returns char* that must be freed
147
- attach_function :xmlStringGetNodeList, [:pointer, :pointer], :pointer # second arg should be a :string, but we only ship the results of xmlEncodeEntitiesReentrant, so let's optimize.
148
- attach_function :xmlNewNs, [:pointer, :string, :string], :pointer
149
- attach_function :xmlNewNsProp, [:pointer, :pointer, :string, :string], :pointer
150
- attach_function :xmlSearchNs, [:pointer, :pointer, :string], :pointer
151
- attach_function :xmlSearchNsByHref, [:pointer, :pointer, :string], :pointer
152
- attach_function :xmlGetIntSubset, [:pointer], :pointer
153
- attach_function :xmlBufferCreate, [], :pointer
154
- attach_function :xmlBufferFree, [:pointer], :void
155
- attach_function :xmlSplitQName2, [:string, :buffer_out], :pointer # returns char* that must be freed
156
- attach_function :xmlNewDocProp, [:pointer, :string, :string], :pointer
157
- attach_function :xmlFreePropList, [:pointer], :void
158
- attach_function :xmlCreateIntSubset, [:pointer] * 4, :pointer
159
- attach_function :xmlNewDtd, [:pointer] * 4, :pointer
160
- attach_function :xmlGetNsList, [:pointer, :pointer], :pointer
161
- attach_function :xmlTextMerge, [:pointer, :pointer], :pointer
162
- attach_function :xmlFreeNsList, [:pointer], :void
163
-
164
- # valid.c
165
- attach_function :xmlNewValidCtxt, [], :pointer
166
- attach_function :xmlValidateDtd, [:pointer, :pointer, :pointer], :int
167
- attach_function :xmlFreeValidCtxt, [:pointer], :void
168
-
169
- # xmlsave.c
170
- attach_function :xmlDocDumpMemory, [:pointer, :pointer, :pointer], :void
171
- attach_function :xmlNodeDump, [:pointer, :pointer, :pointer, :int, :int], :int
172
- attach_function :xmlSaveToIO, [:io_write_callback, :io_close_callback, :pointer, :string, :int], :pointer
173
- attach_function :xmlSaveTree, [:pointer, :pointer], :int
174
- attach_function :xmlSaveClose, [:pointer], :int
175
- attach_function :xmlSetNs, [:pointer, :pointer], :void
176
-
177
- # entities.c
178
- attach_function :xmlEncodeSpecialChars, [:pointer, :string], :pointer # returns char* that must be freed
179
- attach_function :xmlAddDocEntity, [:pointer, :string, :int, :string, :string, :string], :pointer
180
-
181
- # xpath.c
182
- attach_function :xmlXPathInit, [], :void
183
- attach_function :xmlXPathNewContext, [:pointer], :pointer
184
- attach_function :xmlXPathFreeContext, [:pointer], :void
185
- attach_function :xmlXPathEvalExpression, [:string, :pointer], :pointer
186
- attach_function :xmlXPathRegisterNs, [:pointer, :string, :string], :int
187
- attach_function :xmlXPathCmpNodes, [:pointer, :pointer], :int
188
- attach_function :xmlXPathNodeSetContains, [:pointer, :pointer], :int
189
- attach_function :xmlXPathNodeSetAdd, [:pointer, :pointer], :void
190
- attach_function :xmlXPathNodeSetAddUnique, [:pointer, :pointer], :void
191
- attach_function :xmlXPathNodeSetRemove, [:pointer, :int], :void
192
- attach_function :xmlXPathNodeSetCreate, [:pointer], :pointer
193
- attach_function :xmlXPathNodeSetDel, [:pointer, :pointer], :void
194
- attach_function :xmlXPathIntersection, [:pointer, :pointer], :pointer
195
- attach_function :xmlXPathFreeNodeSetList, [:pointer], :void
196
- attach_function :xmlXPathRegisterFuncLookup, [:pointer, :xpath_lookup_callback, :pointer], :void
197
- attach_function :valuePop, [:pointer], :pointer
198
- attach_function :valuePush, [:pointer, :pointer], :int
199
- attach_function :xmlXPathCastToString, [:pointer], :pointer # returns char* that must be freed
200
- attach_function :xmlXPathNodeSetMerge, [:pointer, :pointer], :pointer
201
- attach_function :xmlXPathWrapNodeSet, [:pointer], :pointer
202
- attach_function :xmlXPathWrapCString, [:pointer], :pointer # should take a :string, but we optimize
203
- attach_function :xmlXPathWrapString, [:pointer], :pointer # should take a :string, but we optimize
204
- attach_function :xmlXPathNewBoolean, [:int], :pointer
205
- attach_function :xmlXPathNewFloat, [:double], :pointer
206
- attach_function :xmlXPathNewCString, [:string], :pointer
207
- attach_function :xmlXPathRegisterVariable, [:pointer, :string, :pointer], :int
208
-
209
- class << self
210
- # these functions are implemented as C macros
211
- def xmlXPathReturnNodeSet(ctx, ns)
212
- valuePush(ctx, xmlXPathWrapNodeSet(ns))
213
- end
214
- def xmlXPathReturnTrue(ctx)
215
- valuePush(ctx, xmlXPathNewBoolean(1))
216
- end
217
- def xmlXPathReturnFalse(ctx)
218
- valuePush(ctx, xmlXPathNewBoolean(0))
219
- end
220
- def xmlXPathReturnString(ctx, str)
221
- valuePush(ctx, xmlXPathWrapString(str))
222
- end
223
- def xmlXPathReturnNumber(ctx, val)
224
- valuePush(ctx, xmlXPathNewFloat(val))
225
- end
226
- end
227
-
228
- # xmlstring.c
229
- attach_function :xmlStrdup, [:string], :pointer # returns char* that must be freed
230
- def self.xmlFree(pointer)
231
- # xmlFree is a C preprocessor macro, not an actual function
232
- self.free(pointer)
233
- end
234
-
235
- # error.c
236
- attach_function :xmlSetStructuredErrorFunc, [:pointer, :syntax_error_handler], :void
237
- attach_function :xmlSetGenericErrorFunc, [:pointer, :generic_error_handler], :void
238
- attach_function :xmlResetLastError, [], :void
239
- attach_function :xmlCopyError, [:pointer, :pointer], :int
240
- attach_function :xmlGetLastError, [], :pointer
241
- attach_function :xmlCtxtGetLastError, [:pointer], :pointer
242
-
243
- # hash.c
244
- attach_function :xmlHashScan, [:pointer, :hash_copier_callback, :pointer], :void
245
-
246
- # xmlreader.c
247
- attach_function :xmlReaderForMemory, [:pointer, :int, :string, :string, :int], :pointer
248
- attach_function :xmlTextReaderGetAttribute, [:pointer, :string], :pointer # returns char* that must be freed
249
- attach_function :xmlTextReaderGetAttributeNo, [:pointer, :int], :pointer # returns char* that must be freed
250
- attach_function :xmlTextReaderLookupNamespace, [:pointer, :string], :pointer # returns char* that must be freed
251
- attach_function :xmlTextReaderRead, [:pointer], :int
252
- attach_function :xmlTextReaderReadInnerXml, [:pointer], :pointer
253
- attach_function :xmlTextReaderReadOuterXml, [:pointer], :pointer
254
- attach_function :xmlTextReaderAttributeCount, [:pointer], :int
255
- attach_function :xmlTextReaderCurrentNode, [:pointer], :pointer
256
- attach_function :xmlTextReaderExpand, [:pointer], :pointer
257
- attach_function :xmlTextReaderIsDefault, [:pointer], :int
258
- attach_function :xmlTextReaderDepth, [:pointer], :int
259
- attach_function :xmlTextReaderConstXmlLang, [:pointer], :pointer # returns a const char*, but must check for null
260
- attach_function :xmlTextReaderConstLocalName, [:pointer], :pointer # returns a const char* that is deallocated with the reader
261
- attach_function :xmlTextReaderConstName, [:pointer], :pointer # returns a const char* that is deallocated with the reader
262
- attach_function :xmlTextReaderConstNamespaceUri, [:pointer], :pointer # returns a const char* that is deallocated with the reader
263
- attach_function :xmlTextReaderConstPrefix, [:pointer], :pointer # returns a const char* that is deallocated with the reader
264
- attach_function :xmlTextReaderConstValue, [:pointer], :pointer # returns a const char* that is deallocated on the next read()
265
- attach_function :xmlTextReaderConstXmlVersion, [:pointer], :pointer # returns a const char* that is deallocated with the reader
266
- attach_function :xmlTextReaderConstBaseUri, [:pointer], :pointer # returns a const char* that is deallocated with the reader
267
- attach_function :xmlTextReaderReadState, [:pointer], :int
268
- attach_function :xmlTextReaderHasValue, [:pointer], :int
269
- attach_function :xmlFreeTextReader, [:pointer], :void
270
- attach_function :xmlReaderForIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
271
- attach_function :xmlTextReaderNodeType, [:pointer], :int
272
- attach_function :xmlTextReaderIsEmptyElement, [:pointer], :int
273
-
274
- # xslt.c
275
- attach_function :xsltParseStylesheetDoc, [:pointer], :pointer
276
- attach_function :xsltFreeStylesheet, [:pointer], :void
277
- attach_function :xsltApplyStylesheet, [:pointer, :pointer, :pointer], :pointer
278
- attach_function :xsltSaveResultToString, [:buffer_out, :buffer_out, :pointer, :pointer], :int
279
- attach_function :xsltSetGenericErrorFunc, [:pointer, :generic_error_handler], :void
280
- attach_function :xsltRegisterExtModule, [:string, :xslt_function_init, :xslt_function_shutdown], :int
281
- attach_function :xsltRegisterExtFunction, [:pointer, :string, :string, :xslt_function_caller], :int
282
- attach_function :xsltXPathGetTransformContext, [:pointer], :pointer
283
-
284
- # exslt.c
285
- attach_function :exsltRegisterAll, [], :void
286
-
287
- # xmlschemas.c
288
- attach_function :xmlSchemaNewValidCtxt, [:pointer], :pointer
289
- attach_function :xmlSchemaSetValidStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
290
- attach_function :xmlSchemaValidateDoc, [:pointer, :pointer], :void
291
- attach_function :xmlSchemaFreeValidCtxt, [:pointer], :void
292
- attach_function :xmlSchemaNewMemParserCtxt, [:pointer, :int], :pointer # first arg could be string, but we pass length, so let's optimize
293
- attach_function :xmlSchemaSetParserStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
294
- attach_function :xmlSchemaParse, [:pointer], :pointer
295
- attach_function :xmlSchemaFreeParserCtxt, [:pointer], :void
296
- attach_function :xmlSchemaNewDocParserCtxt, [:pointer], :pointer
297
- attach_function :xmlSchemaValidateFile, [:pointer, :string, :int], :int
298
-
299
- # relaxng.c
300
- attach_function :xmlRelaxNGNewValidCtxt, [:pointer], :pointer
301
- attach_function :xmlRelaxNGSetValidStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
302
- attach_function :xmlRelaxNGValidateDoc, [:pointer, :pointer], :int
303
- attach_function :xmlRelaxNGFreeValidCtxt, [:pointer], :void
304
- attach_function :xmlRelaxNGNewMemParserCtxt, [:pointer, :int], :pointer # first arg could be string, but we pass length, so let's optimize
305
- attach_function :xmlRelaxNGSetParserStructuredErrors, [:pointer, :syntax_error_handler, :pointer], :void unless Nokogiri.is_2_6_16?
306
- attach_function :xmlRelaxNGParse, [:pointer], :pointer
307
- attach_function :xmlRelaxNGFreeParserCtxt, [:pointer], :void
308
- attach_function :xmlRelaxNGNewDocParserCtxt, [:pointer], :pointer
309
- attach_function :xmlRelaxNGFree, [:pointer], :void
310
-
311
- # libc
312
- attach_function :calloc, [:int, :int], :pointer
313
- attach_function :free, [:pointer], :void
314
-
315
- attach_function :xmlParseCharEncoding, [:string], :int
316
- attach_function :xmlSwitchToEncoding, [:pointer, :pointer], :void
317
-
318
- # helpers
319
- POINTER_SIZE = FFI.type_size(:pointer)
320
- def self.pointer_offset(n)
321
- n * POINTER_SIZE # byte offset of nth pointer in an array of pointers
322
- end
323
-
324
- # ZOMG hacks. see GH#303
325
- class << self
326
- def xmlFirstElementChildHack(parent)
327
- return nil if parent.nil?
328
- return nil unless [Nokogiri::XML::Node::ELEMENT_NODE, Nokogiri::XML::Node::ENTITY_NODE, Nokogiri::XML::Node::DOCUMENT_NODE, Nokogiri::XML::Node::HTML_DOCUMENT_NODE].include?(parent.type)
329
- parent.children.find { |child| child.element? }
330
- end
331
-
332
- def xmlLastElementChildHack(parent)
333
- return nil if parent.nil?
334
- return nil unless [Nokogiri::XML::Node::ELEMENT_NODE, Nokogiri::XML::Node::ENTITY_NODE, Nokogiri::XML::Node::DOCUMENT_NODE, Nokogiri::XML::Node::HTML_DOCUMENT_NODE].include?(parent.type)
335
- parent.children.reverse.find { |child| child.element? }
336
- end
337
-
338
- def xmlNextElementSiblingHack(sibling)
339
- return nil if sibling.nil?
340
- return nil unless [Nokogiri::XML::Node::ELEMENT_NODE, Nokogiri::XML::Node::ENTITY_NODE, Nokogiri::XML::Node::DOCUMENT_NODE, Nokogiri::XML::Node::HTML_DOCUMENT_NODE].include?(sibling.type)
341
- while (sibling = sibling.next_sibling)
342
- return sibling if sibling.element?
343
- end
344
- nil
345
- end
346
- end
347
- end
348
- end
349
-
350
- # :startdoc:
351
-
352
- require 'nokogiri/syntax_error'
353
- require 'nokogiri/xml/syntax_error'
354
-
355
- [ "io_callbacks",
356
- "encoding_handler",
357
- "weak_bucket",
358
- "structs/common_node",
359
- "structs/xml_alloc",
360
- "structs/xml_char_encoding_handler",
361
- "structs/xml_document",
362
- "structs/xml_node",
363
- "structs/xml_dtd",
364
- "structs/xml_notation",
365
- "structs/xml_node_set",
366
- "structs/xml_xpath_context",
367
- "structs/xml_xpath_object",
368
- "structs/xml_xpath_parser_context",
369
- "structs/xml_buffer",
370
- "structs/xml_syntax_error",
371
- "structs/xml_attr",
372
- "structs/xml_ns",
373
- "structs/xml_schema",
374
- "structs/xml_relax_ng",
375
- "structs/xml_text_reader",
376
- "structs/xml_sax_handler",
377
- "structs/xml_sax_push_parser_context",
378
- "structs/xml_enumeration",
379
- "structs/html_elem_desc",
380
- "structs/html_entity_desc",
381
- "structs/xslt_stylesheet",
382
- "structs/xml_parser_context",
383
- "structs/xml_attribute",
384
- "structs/xml_element",
385
- "structs/xml_entity",
386
- "structs/xml_element_content",
387
- "structs/xml_parser_input",
388
- "xml/node",
389
- "xml/namespace",
390
- "xml/dtd",
391
- "xml/attr",
392
- "xml/attribute_decl",
393
- "xml/element_decl",
394
- "xml/element_content",
395
- "xml/entity_decl",
396
- "xml/document",
397
- "xml/document_fragment",
398
- "xml/schema",
399
- "xml/relax_ng",
400
- "xml/text",
401
- "xml/cdata",
402
- "xml/comment",
403
- "xml/processing_instruction",
404
- "xml/node_set",
405
- "xml/xpath",
406
- "xml/xpath_context",
407
- "xml/syntax_error",
408
- "xml/reader",
409
- "xml/entity_reference",
410
- "xml/sax/parser_context",
411
- "xml/sax/parser",
412
- "xml/sax/push_parser",
413
- "html/document",
414
- "html/element_description",
415
- "html/entity_lookup",
416
- "html/sax/parser_context",
417
- "xslt/stylesheet",
418
- ].each do |file|
419
- require "nokogiri/ffi/#{file}"
420
- end