nokogiri 1.4.7-java → 1.5.0.beta.1-java
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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.ja.rdoc +8 -83
- data/CHANGELOG.rdoc +6 -80
- data/Manifest.txt +4 -74
- data/README.ja.rdoc +5 -1
- data/README.rdoc +8 -22
- data/Rakefile +79 -60
- data/bin/nokogiri +1 -6
- data/deps.rip +5 -0
- data/ext/nokogiri/extconf.rb +32 -53
- data/ext/nokogiri/nokogiri.c +0 -2
- data/ext/nokogiri/nokogiri.h +0 -9
- data/ext/nokogiri/xml_document.c +0 -14
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_io.c +7 -32
- data/ext/nokogiri/xml_node.c +31 -103
- data/ext/nokogiri/xml_node_set.c +8 -8
- data/ext/nokogiri/xml_reader.c +1 -20
- data/ext/nokogiri/xml_sax_parser.c +3 -5
- data/ext/nokogiri/xml_sax_parser_context.c +0 -40
- data/ext/nokogiri/xml_xpath_context.c +2 -35
- data/ext/nokogiri/xslt_stylesheet.c +6 -124
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri.rb +7 -3
- data/lib/nokogiri/css.rb +3 -6
- data/lib/nokogiri/css/generated_parser.rb +669 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +145 -0
- data/lib/nokogiri/css/parser.rb +70 -665
- data/lib/nokogiri/css/parser.y +1 -6
- data/lib/nokogiri/css/tokenizer.rb +3 -148
- data/lib/nokogiri/css/tokenizer.rex +1 -1
- data/lib/nokogiri/css/xpath_visitor.rb +14 -16
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/html.rb +3 -2
- data/lib/nokogiri/html/document.rb +18 -134
- data/lib/nokogiri/html/document_fragment.rb +21 -26
- data/lib/nokogiri/html/element_description_defaults.rb +671 -0
- data/lib/nokogiri/html/sax/parser.rb +2 -6
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +4 -9
- data/lib/nokogiri/xml/attribute_decl.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +3 -27
- data/lib/nokogiri/xml/document_fragment.rb +2 -9
- data/lib/nokogiri/xml/dtd.rb +1 -12
- data/lib/nokogiri/xml/element_decl.rb +1 -1
- data/lib/nokogiri/xml/entity_decl.rb +1 -1
- data/lib/nokogiri/xml/node.rb +75 -172
- data/lib/nokogiri/xml/node/save_options.rb +0 -10
- data/lib/nokogiri/xml/node_set.rb +3 -28
- data/lib/nokogiri/xml/parse_options.rb +0 -8
- data/lib/nokogiri/xml/reader.rb +6 -44
- data/lib/nokogiri/xml/sax/document.rb +5 -9
- data/lib/nokogiri/xml/schema.rb +1 -7
- data/lib/nokogiri/xslt.rb +5 -9
- data/lib/xercesImpl.jar +0 -0
- data/tasks/cross_compile.rb +12 -27
- data/tasks/test.rb +0 -0
- data/test/css/test_parser.rb +19 -40
- data/test/css/test_tokenizer.rb +0 -8
- data/test/helper.rb +1 -4
- data/test/html/sax/test_parser.rb +21 -47
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +3 -58
- data/test/html/test_document_encoding.rb +0 -53
- data/test/html/test_document_fragment.rb +13 -82
- data/test/html/test_element_description.rb +4 -2
- data/test/html/test_node.rb +0 -9
- data/test/test_memory_leak.rb +2 -57
- data/test/test_nokogiri.rb +14 -20
- data/test/test_reader.rb +7 -47
- data/test/test_xslt_transforms.rb +5 -8
- data/test/xml/sax/test_parser.rb +17 -34
- data/test/xml/sax/test_parser_context.rb +0 -50
- data/test/xml/sax/test_push_parser.rb +1 -18
- data/test/xml/test_attr.rb +4 -31
- data/test/xml/test_attribute_decl.rb +7 -3
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +18 -15
- data/test/xml/test_document_fragment.rb +20 -19
- data/test/xml/test_dtd.rb +13 -18
- data/test/xml/test_element_content.rb +1 -1
- data/test/xml/test_element_decl.rb +1 -1
- data/test/xml/test_entity_decl.rb +12 -10
- data/test/xml/test_namespace.rb +7 -5
- data/test/xml/test_node.rb +15 -54
- data/test/xml/test_node_reparenting.rb +42 -85
- data/test/xml/test_node_set.rb +2 -61
- data/test/xml/test_schema.rb +0 -5
- data/test/xml/test_text.rb +2 -11
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +7 -43
- metadata +442 -473
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ext/nokogiri/depend +0 -358
- data/ext/nokogiri/libcharset-1.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libiconv-2.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri/css/parser_extras.rb +0 -91
- data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
- data/lib/nokogiri/ffi/html/document.rb +0 -28
- data/lib/nokogiri/ffi/html/element_description.rb +0 -81
- data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
- data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
- data/lib/nokogiri/ffi/libxml.rb +0 -420
- data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
- data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
- data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
- data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
- data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
- data/lib/nokogiri/ffi/xml/attr.rb +0 -41
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
- data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
- data/lib/nokogiri/ffi/xml/comment.rb +0 -18
- data/lib/nokogiri/ffi/xml/document.rb +0 -174
- data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
- data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
- data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
- data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
- data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
- data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
- data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
- data/lib/nokogiri/ffi/xml/node.rb +0 -559
- data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
- data/lib/nokogiri/ffi/xml/reader.rb +0 -236
- data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
- data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
- data/lib/nokogiri/ffi/xml/schema.rb +0 -109
- data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
- data/lib/nokogiri/ffi/xml/text.rb +0 -18
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
- data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
- data/test/decorators/test_slop.rb +0 -16
- data/test/ffi/test_document.rb +0 -35
- data/test/files/encoding.html +0 -82
- data/test/files/encoding.xhtml +0 -84
- data/test/xslt/test_custom_functions.rb +0 -94
@@ -1,12 +0,0 @@
|
|
1
|
-
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
2
|
-
|
3
|
-
#ifndef XML_LIBXML2_HACKS
|
4
|
-
#define XML_LIBXML2_HACKS
|
5
|
-
|
6
|
-
xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
|
7
|
-
xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
|
8
|
-
xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
|
9
|
-
|
10
|
-
#endif
|
11
|
-
|
12
|
-
#endif
|
data/ext/nokogiri/zlib1.dll
DELETED
Binary file
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
|
3
|
-
module Nokogiri
|
4
|
-
module CSS
|
5
|
-
class Parser < Racc::Parser
|
6
|
-
@cache_on = true
|
7
|
-
@cache = {}
|
8
|
-
@mutex = Mutex.new
|
9
|
-
|
10
|
-
class << self
|
11
|
-
# Turn on CSS parse caching
|
12
|
-
attr_accessor :cache_on
|
13
|
-
alias :cache_on? :cache_on
|
14
|
-
alias :set_cache :cache_on=
|
15
|
-
|
16
|
-
# Get the css selector in +string+ from the cache
|
17
|
-
def [] string
|
18
|
-
return unless @cache_on
|
19
|
-
@mutex.synchronize { @cache[string] }
|
20
|
-
end
|
21
|
-
|
22
|
-
# Set the css selector in +string+ in the cache to +value+
|
23
|
-
def []= string, value
|
24
|
-
return value unless @cache_on
|
25
|
-
@mutex.synchronize { @cache[string] = value }
|
26
|
-
end
|
27
|
-
|
28
|
-
# Clear the cache
|
29
|
-
def clear_cache
|
30
|
-
@mutex.synchronize { @cache = {} }
|
31
|
-
end
|
32
|
-
|
33
|
-
# Execute +block+ without cache
|
34
|
-
def without_cache &block
|
35
|
-
tmp = @cache_on
|
36
|
-
@cache_on = false
|
37
|
-
block.call
|
38
|
-
@cache_on = tmp
|
39
|
-
end
|
40
|
-
|
41
|
-
###
|
42
|
-
# Parse this CSS selector in +selector+. Returns an AST.
|
43
|
-
def parse selector
|
44
|
-
@warned ||= false
|
45
|
-
unless @warned
|
46
|
-
$stderr.puts('Nokogiri::CSS::Parser.parse is deprecated, call Nokogiri::CSS.parse(), this will be removed August 1st or version 1.4.0 (whichever is first)')
|
47
|
-
@warned = true
|
48
|
-
end
|
49
|
-
new.parse selector
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Create a new CSS parser with respect to +namespaces+
|
54
|
-
def initialize namespaces = {}
|
55
|
-
@tokenizer = Tokenizer.new
|
56
|
-
@namespaces = namespaces
|
57
|
-
super()
|
58
|
-
end
|
59
|
-
|
60
|
-
def parse string
|
61
|
-
@tokenizer.scan_setup string
|
62
|
-
do_parse
|
63
|
-
end
|
64
|
-
|
65
|
-
def next_token
|
66
|
-
@tokenizer.next_token
|
67
|
-
end
|
68
|
-
|
69
|
-
# Get the xpath for +string+ using +options+
|
70
|
-
def xpath_for string, options={}
|
71
|
-
key = "#{string}#{options[:ns]}#{options[:prefix]}"
|
72
|
-
v = self.class[key]
|
73
|
-
return v if v
|
74
|
-
|
75
|
-
args = [
|
76
|
-
options[:prefix] || '//',
|
77
|
-
options[:visitor] || XPathVisitor.new
|
78
|
-
]
|
79
|
-
self.class[key] = parse(string).map { |ast|
|
80
|
-
ast.to_xpath(*args)
|
81
|
-
}
|
82
|
-
end
|
83
|
-
|
84
|
-
# On CSS parser error, raise an exception
|
85
|
-
def on_error error_token_id, error_value, value_stack
|
86
|
-
after = value_stack.compact.last
|
87
|
-
raise SyntaxError.new("unexpected '#{error_value}' after '#{after}'")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -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:
|
data/lib/nokogiri/ffi/libxml.rb
DELETED
@@ -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
|