nokogiri 1.3.3-x86-mingw32 → 1.4.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.
- data/CHANGELOG.ja.rdoc +48 -3
- data/CHANGELOG.rdoc +42 -0
- data/Manifest.txt +44 -29
- data/README.ja.rdoc +0 -2
- data/README.rdoc +4 -7
- data/Rakefile +14 -22
- data/bin/nokogiri +7 -5
- data/ext/nokogiri/extconf.rb +5 -21
- data/ext/nokogiri/html_document.c +14 -50
- data/ext/nokogiri/html_element_description.c +7 -7
- data/ext/nokogiri/html_entity_lookup.c +6 -4
- data/ext/nokogiri/html_sax_parser_context.c +92 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/nokogiri.c +9 -3
- data/ext/nokogiri/nokogiri.h +16 -20
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_attribute_decl.c +67 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +6 -5
- data/ext/nokogiri/xml_comment.c +3 -2
- data/ext/nokogiri/xml_document.c +93 -23
- data/ext/nokogiri/xml_document_fragment.c +1 -3
- data/ext/nokogiri/xml_dtd.c +63 -6
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_entity_decl.c +97 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_io.c +10 -3
- data/ext/nokogiri/xml_io.h +1 -0
- data/ext/nokogiri/xml_namespace.c +2 -2
- data/ext/nokogiri/xml_node.c +139 -34
- data/ext/nokogiri/xml_node.h +0 -1
- data/ext/nokogiri/xml_node_set.c +23 -16
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_reader.c +78 -50
- data/ext/nokogiri/xml_sax_parser.c +109 -168
- data/ext/nokogiri/xml_sax_parser.h +33 -0
- data/ext/nokogiri/xml_sax_parser_context.c +155 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +11 -6
- data/ext/nokogiri/xml_syntax_error.c +63 -12
- data/ext/nokogiri/xml_text.c +4 -3
- data/ext/nokogiri/xml_xpath.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +12 -25
- data/ext/nokogiri/xslt_stylesheet.c +3 -3
- data/lib/nokogiri.rb +4 -4
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css/node.rb +1 -9
- data/lib/nokogiri/css/xpath_visitor.rb +11 -21
- data/lib/nokogiri/ffi/html/document.rb +0 -9
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +38 -0
- data/lib/nokogiri/ffi/io_callbacks.rb +4 -2
- data/lib/nokogiri/ffi/libxml.rb +44 -10
- data/lib/nokogiri/ffi/structs/common_node.rb +1 -1
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +27 -0
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +3 -1
- data/lib/nokogiri/ffi/structs/xml_element.rb +26 -0
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +17 -0
- data/lib/nokogiri/ffi/structs/xml_entity.rb +32 -0
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +4 -3
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +1 -1
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/comment.rb +2 -2
- data/lib/nokogiri/ffi/xml/document.rb +29 -12
- data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -5
- data/lib/nokogiri/ffi/xml/dtd.rb +14 -3
- data/lib/nokogiri/ffi/xml/element_content.rb +43 -0
- data/lib/nokogiri/ffi/xml/element_decl.rb +19 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/node.rb +45 -5
- data/lib/nokogiri/ffi/xml/node_set.rb +1 -1
- data/lib/nokogiri/ffi/xml/reader.rb +45 -24
- data/lib/nokogiri/ffi/xml/sax/parser.rb +27 -34
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +67 -0
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +5 -4
- data/lib/nokogiri/ffi/xml/syntax_error.rb +31 -16
- data/lib/nokogiri/ffi/xml/text.rb +2 -2
- data/lib/nokogiri/html.rb +1 -0
- data/lib/nokogiri/html/document.rb +39 -24
- data/lib/nokogiri/html/sax/parser.rb +2 -2
- data/lib/nokogiri/html/sax/parser_context.rb +16 -0
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml.rb +6 -1
- data/lib/nokogiri/xml/attr.rb +5 -0
- data/lib/nokogiri/xml/attribute_decl.rb +18 -0
- data/lib/nokogiri/xml/builder.rb +121 -13
- data/lib/nokogiri/xml/character_data.rb +7 -0
- data/lib/nokogiri/xml/document.rb +43 -29
- data/lib/nokogiri/xml/document_fragment.rb +26 -6
- data/lib/nokogiri/xml/dtd.rb +5 -5
- data/lib/nokogiri/xml/element_content.rb +36 -0
- data/lib/nokogiri/xml/element_decl.rb +13 -0
- data/lib/nokogiri/xml/entity_decl.rb +15 -0
- data/lib/nokogiri/xml/fragment_handler.rb +22 -11
- data/lib/nokogiri/xml/namespace.rb +6 -0
- data/lib/nokogiri/xml/node.rb +33 -15
- data/lib/nokogiri/xml/node_set.rb +66 -44
- data/lib/nokogiri/xml/pp.rb +2 -0
- data/lib/nokogiri/xml/pp/character_data.rb +18 -0
- data/lib/nokogiri/xml/pp/node.rb +56 -0
- data/lib/nokogiri/xml/reader.rb +8 -0
- data/lib/nokogiri/xml/sax.rb +1 -1
- data/lib/nokogiri/xml/sax/document.rb +18 -1
- data/lib/nokogiri/xml/sax/parser.rb +15 -8
- data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +0 -3
- data/lib/nokogiri/xml/syntax_error.rb +4 -0
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/test/css/test_nthiness.rb +1 -1
- data/test/css/test_parser.rb +1 -1
- data/test/css/test_tokenizer.rb +1 -1
- data/test/css/test_xpath_visitor.rb +1 -1
- data/test/ffi/test_document.rb +1 -1
- data/test/files/shift_jis.html +10 -0
- data/test/files/staff.dtd +10 -0
- data/test/helper.rb +12 -3
- data/test/html/sax/test_parser.rb +1 -1
- data/test/html/sax/test_parser_context.rb +48 -0
- data/test/html/test_builder.rb +8 -2
- data/test/html/test_document.rb +23 -1
- data/test/html/test_document_encoding.rb +15 -1
- data/test/html/test_document_fragment.rb +10 -1
- data/test/html/test_element_description.rb +1 -2
- data/test/html/test_named_characters.rb +1 -1
- data/test/html/test_node.rb +61 -1
- data/test/html/test_node_encoding.rb +27 -0
- data/test/test_convert_xpath.rb +1 -3
- data/test/test_css_cache.rb +1 -1
- data/test/test_gc.rb +1 -1
- data/test/test_memory_leak.rb +1 -1
- data/test/test_nokogiri.rb +3 -3
- data/test/test_reader.rb +29 -1
- data/test/test_xslt_transforms.rb +1 -1
- data/test/xml/node/test_save_options.rb +1 -1
- data/test/xml/node/test_subclass.rb +1 -1
- data/test/xml/sax/test_parser.rb +64 -3
- data/test/xml/sax/test_parser_context.rb +56 -0
- data/test/xml/sax/test_push_parser.rb +11 -1
- data/test/xml/test_attr.rb +1 -1
- data/test/xml/test_attribute_decl.rb +82 -0
- data/test/xml/test_builder.rb +95 -1
- data/test/xml/test_cdata.rb +1 -1
- data/test/xml/test_comment.rb +7 -1
- data/test/xml/test_document.rb +147 -6
- data/test/xml/test_document_encoding.rb +1 -1
- data/test/xml/test_document_fragment.rb +55 -5
- data/test/xml/test_dtd.rb +40 -5
- data/test/xml/test_dtd_encoding.rb +3 -1
- data/test/xml/test_element_content.rb +56 -0
- data/test/xml/test_element_decl.rb +73 -0
- data/test/xml/test_entity_decl.rb +83 -0
- data/test/xml/test_entity_reference.rb +1 -1
- data/test/xml/test_namespace.rb +21 -1
- data/test/xml/test_node.rb +70 -4
- data/test/xml/test_node_attributes.rb +1 -1
- data/test/xml/test_node_encoding.rb +1 -1
- data/test/xml/test_node_set.rb +136 -2
- data/test/xml/test_parse_options.rb +1 -1
- data/test/xml/test_processing_instruction.rb +1 -1
- data/test/xml/test_reader_encoding.rb +1 -1
- data/test/xml/test_relax_ng.rb +1 -1
- data/test/xml/test_schema.rb +1 -1
- data/test/xml/test_syntax_error.rb +27 -0
- data/test/xml/test_text.rb +13 -1
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +1 -1
- metadata +55 -38
- data/ext/nokogiri/html_sax_parser.c +0 -57
- data/ext/nokogiri/html_sax_parser.h +0 -11
- data/lib/action-nokogiri.rb +0 -38
- data/lib/nokogiri/decorators.rb +0 -2
- data/lib/nokogiri/decorators/hpricot.rb +0 -3
- data/lib/nokogiri/decorators/hpricot/node.rb +0 -56
- data/lib/nokogiri/decorators/hpricot/node_set.rb +0 -54
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +0 -30
- data/lib/nokogiri/ffi/html/sax/parser.rb +0 -21
- data/lib/nokogiri/hpricot.rb +0 -92
- data/lib/nokogiri/xml/entity_declaration.rb +0 -11
- data/lib/nokogiri/xml/sax/legacy_handlers.rb +0 -65
- data/test/hpricot/files/basic.xhtml +0 -17
- data/test/hpricot/files/boingboing.html +0 -2266
- data/test/hpricot/files/cy0.html +0 -3653
- data/test/hpricot/files/immob.html +0 -400
- data/test/hpricot/files/pace_application.html +0 -1320
- data/test/hpricot/files/tenderlove.html +0 -16
- data/test/hpricot/files/uswebgen.html +0 -220
- data/test/hpricot/files/utf8.html +0 -1054
- data/test/hpricot/files/week9.html +0 -1723
- data/test/hpricot/files/why.xml +0 -19
- data/test/hpricot/load_files.rb +0 -11
- data/test/hpricot/test_alter.rb +0 -68
- data/test/hpricot/test_builder.rb +0 -20
- data/test/hpricot/test_parser.rb +0 -350
- data/test/hpricot/test_paths.rb +0 -15
- data/test/hpricot/test_preserved.rb +0 -77
- data/test/hpricot/test_xml.rb +0 -30
@@ -64,7 +64,7 @@ static VALUE serialize(VALUE self, VALUE xmlobj)
|
|
64
64
|
Data_Get_Struct(xmlobj, xmlDoc, xml);
|
65
65
|
Data_Get_Struct(self, xsltStylesheet, ss);
|
66
66
|
xsltSaveResultToString(&doc_ptr, &doc_len, xml, ss);
|
67
|
-
rval = NOKOGIRI_STR_NEW(doc_ptr, doc_len
|
67
|
+
rval = NOKOGIRI_STR_NEW(doc_ptr, doc_len);
|
68
68
|
xmlFree(doc_ptr);
|
69
69
|
return rval ;
|
70
70
|
}
|
@@ -94,12 +94,12 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
|
|
94
94
|
int param_len, j ;
|
95
95
|
|
96
96
|
rb_scan_args(argc, argv, "11", &xmldoc, ¶mobj);
|
97
|
-
if (paramobj
|
97
|
+
if (NIL_P(paramobj)) { paramobj = rb_ary_new2(0) ; }
|
98
98
|
|
99
99
|
Data_Get_Struct(xmldoc, xmlDoc, xml);
|
100
100
|
Data_Get_Struct(self, xsltStylesheet, ss);
|
101
101
|
|
102
|
-
param_len =
|
102
|
+
param_len = RARRAY_LEN(paramobj);
|
103
103
|
params = calloc((size_t)param_len+1, sizeof(char*));
|
104
104
|
for (j = 0 ; j < param_len ; j++) {
|
105
105
|
VALUE entry = rb_ary_entry(paramobj, j);
|
data/lib/nokogiri.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Modify the PATH on windows so that the external DLLs will get loaded.
|
3
|
+
|
4
|
+
require 'rbconfig'
|
3
5
|
ENV['PATH'] = [File.expand_path(
|
4
6
|
File.join(File.dirname(__FILE__), "..", "ext", "nokogiri")
|
5
|
-
), ENV['PATH']].compact.join(';') if
|
7
|
+
), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw)/i
|
6
8
|
|
7
9
|
if ENV['NOKOGIRI_FFI'] || RUBY_PLATFORM =~ /java/
|
8
|
-
gem 'ffi', '>=0.4.0' unless RUBY_PLATFORM =~ /java/
|
9
10
|
require 'ffi'
|
10
11
|
require 'nokogiri/ffi/libxml'
|
11
12
|
else
|
@@ -18,10 +19,9 @@ require 'nokogiri/syntax_error'
|
|
18
19
|
require 'nokogiri/xml'
|
19
20
|
require 'nokogiri/xslt'
|
20
21
|
require 'nokogiri/html'
|
21
|
-
require 'nokogiri/decorators'
|
22
|
+
require 'nokogiri/decorators/slop'
|
22
23
|
require 'nokogiri/css'
|
23
24
|
require 'nokogiri/html/builder'
|
24
|
-
require 'nokogiri/hpricot'
|
25
25
|
|
26
26
|
# Nokogiri parses and searches XML/HTML very quickly, and also has
|
27
27
|
# correctly implemented CSS3 selector support as well as XPath support.
|
Binary file
|
Binary file
|
data/lib/nokogiri/css/node.rb
CHANGED
@@ -36,15 +36,7 @@ module Nokogiri
|
|
36
36
|
]
|
37
37
|
)
|
38
38
|
matches.each do |match|
|
39
|
-
if match.value[1].value[0].value[0] =~ /^nth-child/
|
40
|
-
tag_name = match.value[0].value.first
|
41
|
-
match.value[0].value = ['*']
|
42
|
-
match.value[1] = Node.new(:COMBINATOR, [
|
43
|
-
match.value[1].value[0],
|
44
|
-
Node.new(:FUNCTION, ['self(', tag_name])
|
45
|
-
])
|
46
|
-
end
|
47
|
-
if match.value[1].value[0].value[0] =~ /^nth-last-child/
|
39
|
+
if match.value[1].value[0].value[0] =~ /^nth-(last-)?child/
|
48
40
|
tag_name = match.value[0].value.first
|
49
41
|
match.value[0].value = ['*']
|
50
42
|
match.value[1] = Node.new(:COMBINATOR, [
|
@@ -48,12 +48,6 @@ module Nokogiri
|
|
48
48
|
']'
|
49
49
|
end
|
50
50
|
|
51
|
-
def visit_direct_adjacent_selector node
|
52
|
-
node.value.first.accept(self) +
|
53
|
-
"/following-sibling::*[1]/self::" +
|
54
|
-
node.value.last.accept(self)
|
55
|
-
end
|
56
|
-
|
57
51
|
def visit_id node
|
58
52
|
node.value.first =~ /^#(.*)$/
|
59
53
|
"@id = '#{$1}'"
|
@@ -122,9 +116,17 @@ module Nokogiri
|
|
122
116
|
"contains(concat(' ', @class, ' '), ' #{node.value.first} ')"
|
123
117
|
end
|
124
118
|
|
125
|
-
|
126
|
-
|
127
|
-
|
119
|
+
{
|
120
|
+
'combinator' => ' and ',
|
121
|
+
'direct_adjacent_selector' => "/following-sibling::*[1]/self::",
|
122
|
+
'descendant_selector' => '//',
|
123
|
+
'child_selector' => '/',
|
124
|
+
}.each do |k,v|
|
125
|
+
class_eval %{
|
126
|
+
def visit_#{k} node
|
127
|
+
"\#{node.value.first.accept(self)}#{v}\#{node.value.last.accept(self)}"
|
128
|
+
end
|
129
|
+
}
|
128
130
|
end
|
129
131
|
|
130
132
|
def visit_conditional_selector node
|
@@ -132,18 +134,6 @@ module Nokogiri
|
|
132
134
|
node.value.last.accept(self) + ']'
|
133
135
|
end
|
134
136
|
|
135
|
-
def visit_descendant_selector node
|
136
|
-
node.value.first.accept(self) +
|
137
|
-
'//' +
|
138
|
-
node.value.last.accept(self)
|
139
|
-
end
|
140
|
-
|
141
|
-
def visit_child_selector node
|
142
|
-
node.value.first.accept(self) +
|
143
|
-
'/' +
|
144
|
-
node.value.last.accept(self)
|
145
|
-
end
|
146
|
-
|
147
137
|
def visit_element_name node
|
148
138
|
node.value.first
|
149
139
|
end
|
@@ -23,15 +23,6 @@ module Nokogiri
|
|
23
23
|
LibXML.htmlReadMemory(string, string.length, url, encoding, options)
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def meta_encoding=(encoding) # :nodoc:
|
28
|
-
LibXML.htmlSetMetaEncoding(cstruct, encoding)
|
29
|
-
encoding
|
30
|
-
end
|
31
|
-
|
32
|
-
def meta_encoding # :nodoc:
|
33
|
-
LibXML.htmlGetMetaEncoding(cstruct)
|
34
|
-
end
|
35
26
|
end
|
36
27
|
end
|
37
28
|
end
|
@@ -0,0 +1,38 @@
|
|
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.xmlParseCharEncoding(encoding)
|
24
|
+
if enc != LibXML::XML_CHAR_ENCODING_ERROR
|
25
|
+
LibXML.xmlSwitchEncoding(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:
|
data/lib/nokogiri/ffi/libxml.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
|
1
|
+
# :stopdoc:
|
2
2
|
module Nokogiri
|
3
|
-
module LibXML
|
3
|
+
module LibXML
|
4
4
|
extend FFI::Library
|
5
|
-
|
5
|
+
if RUBY_PLATFORM =~ /java/ && java.lang.System.getProperty('os.name') =~ /windows/i
|
6
|
+
raise(RuntimeError, "Nokogiri requires JRuby 1.4.0RC1 or later on Windows") if JRUBY_VERSION < "1.4.0RC1"
|
7
|
+
ffi_lib 'libxml2', 'libxslt', 'libexslt', 'msvcrt'
|
8
|
+
else
|
9
|
+
ffi_lib 'xml2', 'xslt', 'exslt'
|
10
|
+
end
|
6
11
|
|
7
12
|
# globals.c
|
8
13
|
attach_function :__xmlParserVersion, [], :pointer
|
@@ -28,7 +33,9 @@ else
|
|
28
33
|
end
|
29
34
|
|
30
35
|
module Nokogiri
|
31
|
-
module LibXML
|
36
|
+
module LibXML
|
37
|
+
XML_CHAR_ENCODING_ERROR = -1
|
38
|
+
|
32
39
|
# useful callback signatures
|
33
40
|
callback :syntax_error_handler, [:pointer, :pointer], :void
|
34
41
|
callback :generic_error_handler, [:pointer, :string], :void
|
@@ -50,10 +57,6 @@ module Nokogiri
|
|
50
57
|
callback :start_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer, :int, :pointer, :int, :int, :pointer], :void
|
51
58
|
callback :end_element_ns_sax2_func, [:pointer, :pointer, :pointer, :pointer], :void
|
52
59
|
|
53
|
-
# libc
|
54
|
-
attach_function :calloc, [:int, :int], :pointer
|
55
|
-
attach_function :free, [:pointer], :void
|
56
|
-
|
57
60
|
# HTMLparser.c
|
58
61
|
attach_function :htmlReadMemory, [:string, :int, :string, :string, :int], :pointer
|
59
62
|
attach_function :htmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
|
@@ -62,6 +65,9 @@ module Nokogiri
|
|
62
65
|
attach_function :htmlEntityLookup, [:string], :pointer
|
63
66
|
attach_function :htmlSAXParseFile, [:string, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
|
64
67
|
attach_function :htmlSAXParseDoc, [:pointer, :pointer, :pointer, :pointer], :pointer # second arg 'encoding' should be a string, but we assign it as a pointer elsewhere
|
68
|
+
attach_function :htmlCreateMemoryParserCtxt, [:pointer, :int], :pointer
|
69
|
+
attach_function :htmlCreateFileParserCtxt, [:pointer, :pointer], :pointer
|
70
|
+
attach_function :htmlParseDocument, [:pointer], :int
|
65
71
|
|
66
72
|
# HTMLtree.c
|
67
73
|
attach_function :htmlDocDumpMemory, [:pointer, :pointer, :pointer], :void
|
@@ -74,6 +80,8 @@ module Nokogiri
|
|
74
80
|
attach_function :xmlInitParser, [], :void
|
75
81
|
attach_function :xmlReadIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
|
76
82
|
attach_function :xmlCreateIOParserCtxt, [:pointer, :pointer, :io_read_callback, :io_close_callback, :pointer, :int], :pointer
|
83
|
+
attach_function :xmlCreateMemoryParserCtxt, [:pointer, :int], :pointer
|
84
|
+
attach_function :xmlCreateFileParserCtxt, [:pointer], :pointer
|
77
85
|
attach_function :xmlSAXUserParseMemory, [:pointer, :pointer, :string, :int], :int
|
78
86
|
attach_function :xmlSAXUserParseFile, [:pointer, :pointer, :string], :int
|
79
87
|
attach_function :xmlParseDocument, [:pointer], :int
|
@@ -126,6 +134,8 @@ module Nokogiri
|
|
126
134
|
attach_function :xmlSplitQName2, [:string, :pointer], :pointer # returns char* that must be freed
|
127
135
|
attach_function :xmlNewDocProp, [:pointer, :string, :string], :pointer
|
128
136
|
attach_function :xmlFreePropList, [:pointer], :void
|
137
|
+
attach_function :xmlCreateIntSubset, [:pointer] * 4, :pointer
|
138
|
+
attach_function :xmlNewDtd, [:pointer] * 4, :pointer
|
129
139
|
|
130
140
|
# valid.c
|
131
141
|
attach_function :xmlNewValidCtxt, [], :pointer
|
@@ -200,6 +210,7 @@ module Nokogiri
|
|
200
210
|
attach_function :xmlResetLastError, [], :void
|
201
211
|
attach_function :xmlCopyError, [:pointer, :pointer], :int
|
202
212
|
attach_function :xmlGetLastError, [], :pointer
|
213
|
+
attach_function :xmlCtxtGetLastError, [:pointer], :pointer
|
203
214
|
|
204
215
|
# hash.c
|
205
216
|
attach_function :xmlHashScan, [:pointer, :hash_copier_callback, :pointer], :void
|
@@ -210,6 +221,8 @@ module Nokogiri
|
|
210
221
|
attach_function :xmlTextReaderGetAttributeNo, [:pointer, :int], :pointer # returns char* that must be freed
|
211
222
|
attach_function :xmlTextReaderLookupNamespace, [:pointer, :string], :pointer # returns char* that must be freed
|
212
223
|
attach_function :xmlTextReaderRead, [:pointer], :int
|
224
|
+
attach_function :xmlTextReaderReadInnerXml, [:pointer], :pointer
|
225
|
+
attach_function :xmlTextReaderReadOuterXml, [:pointer], :pointer
|
213
226
|
attach_function :xmlTextReaderAttributeCount, [:pointer], :int
|
214
227
|
attach_function :xmlTextReaderCurrentNode, [:pointer], :pointer
|
215
228
|
attach_function :xmlTextReaderExpand, [:pointer], :pointer
|
@@ -226,6 +239,7 @@ module Nokogiri
|
|
226
239
|
attach_function :xmlTextReaderHasValue, [:pointer], :int
|
227
240
|
attach_function :xmlFreeTextReader, [:pointer], :void
|
228
241
|
attach_function :xmlReaderForIO, [:io_read_callback, :io_close_callback, :pointer, :string, :string, :int], :pointer
|
242
|
+
attach_function :xmlTextReaderNodeType, [:pointer], :int
|
229
243
|
|
230
244
|
# xslt.c
|
231
245
|
attach_function :xsltParseStylesheetDoc, [:pointer], :pointer
|
@@ -259,6 +273,13 @@ module Nokogiri
|
|
259
273
|
attach_function :xmlRelaxNGFreeParserCtxt, [:pointer], :void
|
260
274
|
attach_function :xmlRelaxNGNewDocParserCtxt, [:pointer], :pointer
|
261
275
|
|
276
|
+
# libc
|
277
|
+
attach_function :calloc, [:int, :int], :pointer
|
278
|
+
attach_function :free, [:pointer], :void
|
279
|
+
|
280
|
+
attach_function :xmlParseCharEncoding, [:string], :int
|
281
|
+
attach_function :xmlSwitchEncoding, [:pointer, :int], :void
|
282
|
+
|
262
283
|
# helpers
|
263
284
|
def self.pointer_offset(n)
|
264
285
|
n * FFI.type_size(:pointer) # byte offset of nth pointer in an array of pointers
|
@@ -266,6 +287,8 @@ module Nokogiri
|
|
266
287
|
end
|
267
288
|
end
|
268
289
|
|
290
|
+
# :startdoc:
|
291
|
+
|
269
292
|
require 'nokogiri/syntax_error'
|
270
293
|
require 'nokogiri/xml/syntax_error'
|
271
294
|
|
@@ -289,13 +312,23 @@ require 'nokogiri/xml/syntax_error'
|
|
289
312
|
"structs/xml_text_reader",
|
290
313
|
"structs/xml_sax_handler",
|
291
314
|
"structs/xml_sax_push_parser_context",
|
315
|
+
"structs/xml_enumeration",
|
292
316
|
"structs/html_elem_desc",
|
293
317
|
"structs/html_entity_desc",
|
294
318
|
"structs/xslt_stylesheet",
|
319
|
+
"structs/xml_parser_context",
|
320
|
+
"structs/xml_attribute",
|
321
|
+
"structs/xml_element",
|
322
|
+
"structs/xml_entity",
|
323
|
+
"structs/xml_element_content",
|
295
324
|
"xml/node",
|
296
325
|
"xml/namespace",
|
297
326
|
"xml/dtd",
|
298
327
|
"xml/attr",
|
328
|
+
"xml/attribute_decl",
|
329
|
+
"xml/element_decl",
|
330
|
+
"xml/element_content",
|
331
|
+
"xml/entity_decl",
|
299
332
|
"xml/document",
|
300
333
|
"xml/document_fragment",
|
301
334
|
"xml/schema",
|
@@ -310,13 +343,14 @@ require 'nokogiri/xml/syntax_error'
|
|
310
343
|
"xml/syntax_error",
|
311
344
|
"xml/reader",
|
312
345
|
"xml/entity_reference",
|
346
|
+
"xml/sax/parser_context",
|
313
347
|
"xml/sax/parser",
|
314
348
|
"xml/sax/push_parser",
|
315
349
|
"html/document",
|
316
350
|
"html/element_description",
|
317
351
|
"html/entity_lookup",
|
318
|
-
"html/sax/
|
352
|
+
"html/sax/parser_context",
|
319
353
|
"xslt/stylesheet",
|
320
354
|
].each do |file|
|
321
|
-
require
|
355
|
+
require "nokogiri/ffi/#{file}"
|
322
356
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Nokogiri
|
2
|
+
module LibXML # :nodoc:
|
3
|
+
class XmlAttribute < FFI::Struct # :nodoc:
|
4
|
+
include CommonNode
|
5
|
+
|
6
|
+
layout(
|
7
|
+
:_private, :long,
|
8
|
+
:type, :int,
|
9
|
+
:name, :string,
|
10
|
+
:children, :pointer,
|
11
|
+
:last, :pointer,
|
12
|
+
:parent, :pointer,
|
13
|
+
:next, :pointer,
|
14
|
+
:prev, :pointer,
|
15
|
+
:doc, :pointer,
|
16
|
+
|
17
|
+
:nexth, :pointer,
|
18
|
+
:atype, :int,
|
19
|
+
:def, :int,
|
20
|
+
:default_value, :string,
|
21
|
+
:tree, :pointer,
|
22
|
+
:prefix, :string,
|
23
|
+
:elem, :string
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nokogiri
|
2
|
+
# :stopdoc:
|
3
|
+
module LibXML
|
4
|
+
class XmlElement < FFI::Struct
|
5
|
+
include CommonNode
|
6
|
+
|
7
|
+
layout(
|
8
|
+
:_private, :long,
|
9
|
+
:type, :int,
|
10
|
+
:name, :string,
|
11
|
+
:children, :pointer,
|
12
|
+
:last, :pointer,
|
13
|
+
:parent, :pointer,
|
14
|
+
:next, :pointer,
|
15
|
+
:prev, :pointer,
|
16
|
+
:doc, :pointer,
|
17
|
+
|
18
|
+
:etype, :int,
|
19
|
+
:content, :pointer,
|
20
|
+
:properties, :pointer,
|
21
|
+
:prefix, :string
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# :startdoc:
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
module Nokogiri
|
3
|
+
module LibXML
|
4
|
+
class XmlElementContent < FFI::Struct
|
5
|
+
layout(
|
6
|
+
:type, :int,
|
7
|
+
:ocur, :int, # This is misspelled in the header file
|
8
|
+
:name, :string,
|
9
|
+
:c1, :pointer,
|
10
|
+
:c2, :pointer,
|
11
|
+
:parent,:pointer,
|
12
|
+
:prefix,:string
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# :startdoc:
|