libxml-ruby 0.3.8.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -0
- data/LICENSE +1 -1
- data/README +1 -1
- data/Rakefile +8 -5
- data/TODO +1 -1
- data/ext/xml/extconf.rb +4 -5
- data/ext/xml/libxml.c +5 -2
- data/ext/xml/libxml.h +16 -7
- data/ext/xml/libxml.rb +3 -3
- data/ext/xml/ruby_xml_attr.c +118 -99
- data/ext/xml/ruby_xml_attr.h +4 -7
- data/ext/xml/ruby_xml_document.c +131 -170
- data/ext/xml/ruby_xml_document.h +5 -9
- data/ext/xml/ruby_xml_html_parser.c +453 -0
- data/ext/xml/ruby_xml_html_parser.h +29 -0
- data/ext/xml/ruby_xml_node.c +219 -253
- data/ext/xml/ruby_xml_node.h +4 -7
- data/ext/xml/ruby_xml_node_set.c +6 -6
- data/ext/xml/ruby_xml_node_set.h +1 -1
- data/ext/xml/ruby_xml_ns.c +1 -1
- data/ext/xml/ruby_xml_ns.h +1 -1
- data/ext/xml/ruby_xml_parser.c +5 -8
- data/ext/xml/ruby_xml_parser.h +1 -1
- data/ext/xml/ruby_xml_parser_context.c +3 -4
- data/ext/xml/ruby_xml_parser_context.h +1 -1
- data/ext/xml/ruby_xml_reader.c +893 -0
- data/ext/xml/ruby_xml_reader.h +14 -0
- data/ext/xml/ruby_xml_sax_parser.c +255 -204
- data/ext/xml/ruby_xml_sax_parser.h +6 -2
- data/ext/xml/ruby_xml_tree.c +1 -1
- data/ext/xml/ruby_xml_tree.h +1 -1
- data/ext/xml/ruby_xml_xinclude.c +1 -1
- data/ext/xml/ruby_xml_xinclude.h +1 -1
- data/ext/xml/ruby_xml_xpath.c +3 -2
- data/ext/xml/ruby_xml_xpath.h +1 -1
- data/ext/xml/ruby_xml_xpath_context.c +4 -4
- data/ext/xml/ruby_xml_xpath_context.h +1 -1
- data/ext/xml/ruby_xml_xpointer.c +10 -4
- data/ext/xml/ruby_xml_xpointer.h +1 -1
- data/ext/xml/ruby_xml_xpointer_context.c +1 -1
- data/ext/xml/ruby_xml_xpointer_context.h +1 -1
- data/ext/xml/sax_parser_callbacks.inc +55 -54
- data/tests/model/rubynet_project +1 -1
- data/tests/model/simple.xml +7 -0
- data/tests/tc_xml_document.rb +1 -1
- data/tests/tc_xml_document_write.rb +1 -1
- data/tests/tc_xml_document_write2.rb +1 -1
- data/tests/tc_xml_document_write3.rb +1 -1
- data/tests/tc_xml_html_parser.rb +60 -0
- data/tests/tc_xml_node.rb +1 -1
- data/tests/tc_xml_node2.rb +1 -1
- data/tests/tc_xml_node3.rb +1 -1
- data/tests/tc_xml_node4.rb +8 -5
- data/tests/tc_xml_node5.rb +1 -1
- data/tests/tc_xml_node6.rb +1 -1
- data/tests/tc_xml_node7.rb +1 -1
- data/tests/tc_xml_node_set.rb +1 -1
- data/tests/tc_xml_node_set2.rb +1 -1
- data/tests/tc_xml_node_xlink.rb +1 -1
- data/tests/tc_xml_parser.rb +5 -1
- data/tests/tc_xml_parser2.rb +1 -1
- data/tests/tc_xml_parser3.rb +1 -1
- data/tests/tc_xml_parser4.rb +1 -1
- data/tests/tc_xml_parser5.rb +1 -1
- data/tests/tc_xml_parser6.rb +1 -1
- data/tests/tc_xml_parser7.rb +1 -1
- data/tests/tc_xml_parser8.rb +1 -1
- data/tests/tc_xml_parser_context.rb +1 -1
- data/tests/tc_xml_reader.rb +101 -0
- data/tests/tc_xml_sax_parser.rb +95 -0
- data/tests/tc_xml_xinclude.rb +1 -1
- data/tests/tc_xml_xpath.rb +1 -1
- data/tests/tc_xml_xpointer.rb +1 -1
- metadata +79 -73
- data/ext/xml/ruby_xml_attribute.c +0 -224
- data/ext/xml/ruby_xml_attribute.h +0 -21
- data/tests/test_xml_sax_parser.rb +0 -64
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
===== 14.1.2007 Laurent Sansonetti <lrz at chopine.be>
|
|
2
|
+
* Added some preliminary RDoc comments for XML::Reader.
|
|
3
|
+
|
|
4
|
+
===== 5.12.2006 Laurent Sansonetti <lrz at chopine.be>
|
|
5
|
+
* Added XML::Reader, a set of bindings to the xmlTextReader API.
|
|
6
|
+
|
|
1
7
|
===== 15.4.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
|
2
8
|
* Implemented SAX parser callback handling
|
|
3
9
|
|
data/LICENSE
CHANGED
data/README
CHANGED
data/Rakefile
CHANGED
|
@@ -119,15 +119,18 @@ end
|
|
|
119
119
|
# Used during release packaging if a REL is supplied
|
|
120
120
|
task :update_version do
|
|
121
121
|
unless PKG_VERSION == CURRENT_VERSION
|
|
122
|
+
pkg_vernum = PKG_VERSION.tr('.','').sub(/^0*/,'')
|
|
123
|
+
pkg_vernum << '0' until pkg_vernum.length > 2
|
|
124
|
+
|
|
122
125
|
File.open('ext/xml/libxml.h.new','w+') do |f|
|
|
123
126
|
maj, min, mic, patch = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?/.match(PKG_VERSION).captures
|
|
124
127
|
f << File.read('ext/xml/libxml.h').
|
|
125
128
|
gsub(/RUBY_LIBXML_VERSION\s+"(\d.+)"/) { "RUBY_LIBXML_VERSION \"#{PKG_VERSION}\"" }.
|
|
126
|
-
gsub(/RUBY_LIBXML_VERNUM\s+\d+/) { "RUBY_LIBXML_VERNUM #{
|
|
127
|
-
gsub(/RUBY_LIBXML_VER_MAJ\s+\d+/) { "RUBY_LIBXML_VER_MAJ
|
|
128
|
-
gsub(/RUBY_LIBXML_VER_MIN\s+\d+/) { "RUBY_LIBXML_VER_MIN
|
|
129
|
-
gsub(/RUBY_LIBXML_VER_MIC\s+\d+/) { "RUBY_LIBXML_VER_MIC
|
|
130
|
-
gsub(/RUBY_LIBXML_VER_PATCH\s+\d+/) { "RUBY_LIBXML_VER_PATCH
|
|
129
|
+
gsub(/RUBY_LIBXML_VERNUM\s+\d+/) { "RUBY_LIBXML_VERNUM #{pkg_vernum}" }.
|
|
130
|
+
gsub(/RUBY_LIBXML_VER_MAJ\s+\d+/) { "RUBY_LIBXML_VER_MAJ #{maj}" }.
|
|
131
|
+
gsub(/RUBY_LIBXML_VER_MIN\s+\d+/) { "RUBY_LIBXML_VER_MIN #{min}" }.
|
|
132
|
+
gsub(/RUBY_LIBXML_VER_MIC\s+\d+/) { "RUBY_LIBXML_VER_MIC #{mic || 0}" }.
|
|
133
|
+
gsub(/RUBY_LIBXML_VER_PATCH\s+\d+/) { "RUBY_LIBXML_VER_PATCH #{patch || 0}" }
|
|
131
134
|
end
|
|
132
135
|
mv('ext/xml/libxml.h.new', 'ext/xml/libxml.h')
|
|
133
136
|
end
|
data/TODO
CHANGED
data/ext/xml/extconf.rb
CHANGED
|
@@ -37,6 +37,7 @@ unless have_library('m', 'atan')
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
unless have_library('z', 'inflate') or
|
|
40
|
+
have_library('zlib', 'inflate') or
|
|
40
41
|
have_library('zlib1', 'inflate')
|
|
41
42
|
crash('need zlib')
|
|
42
43
|
else
|
|
@@ -45,6 +46,8 @@ end
|
|
|
45
46
|
|
|
46
47
|
unless have_library('iconv','iconv_open') or
|
|
47
48
|
have_library('iconv','libiconv_open') or
|
|
49
|
+
have_library('libiconv', 'libiconv_open') or
|
|
50
|
+
have_library('libiconv', 'iconv_open') or
|
|
48
51
|
have_library('c','iconv_open') or
|
|
49
52
|
have_library('recode','iconv_open') or
|
|
50
53
|
have_library('iconv')
|
|
@@ -80,7 +83,7 @@ need libxml2.
|
|
|
80
83
|
EOL
|
|
81
84
|
end
|
|
82
85
|
|
|
83
|
-
unless
|
|
86
|
+
unless have_func('xmlDocFormatDump')
|
|
84
87
|
crash('Your version of libxml2 is too old. Please upgrade.')
|
|
85
88
|
end
|
|
86
89
|
|
|
@@ -88,10 +91,6 @@ unless have_func('docbCreateFileParserCtxt')
|
|
|
88
91
|
crash('Need docbCreateFileParserCtxt')
|
|
89
92
|
end
|
|
90
93
|
|
|
91
|
-
if try_compile('int main() { return 0; }','-Wall')
|
|
92
|
-
$CFLAGS << ' -Wall'
|
|
93
|
-
end
|
|
94
|
-
|
|
95
94
|
$CFLAGS << ' ' << $INCFLAGS
|
|
96
95
|
$INSTALLFILES = [["libxml.rb", "$(RUBYLIBDIR)", "../xml"]]
|
|
97
96
|
|
data/ext/xml/libxml.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: libxml.c
|
|
1
|
+
/* $Id: libxml.c 138 2007-08-29 18:00:35Z danj $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -49,6 +49,7 @@ static xmlStrdupFunc strdupFunc = NULL;
|
|
|
49
49
|
void
|
|
50
50
|
Init_libxml_so(void) {
|
|
51
51
|
/* Some libxml memory goo that should be done before anything else */
|
|
52
|
+
#ifdef NONE
|
|
52
53
|
xmlMemGet((xmlFreeFunc *) & freeFunc,
|
|
53
54
|
(xmlMallocFunc *) & mallocFunc,
|
|
54
55
|
(xmlReallocFunc *) & reallocFunc,
|
|
@@ -57,6 +58,7 @@ Init_libxml_so(void) {
|
|
|
57
58
|
if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
|
|
58
59
|
(xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
|
|
59
60
|
rb_fatal("could not install the memory handlers for libxml");
|
|
61
|
+
#endif
|
|
60
62
|
xmlInitParser();
|
|
61
63
|
|
|
62
64
|
mXML = rb_define_module("XML");
|
|
@@ -67,7 +69,6 @@ Init_libxml_so(void) {
|
|
|
67
69
|
ruby_init_parser();
|
|
68
70
|
ruby_init_xml_parser_context();
|
|
69
71
|
ruby_init_xml_attr();
|
|
70
|
-
ruby_init_xml_attribute();
|
|
71
72
|
ruby_init_xml_document();
|
|
72
73
|
ruby_init_xml_node();
|
|
73
74
|
ruby_init_xml_node_set();
|
|
@@ -79,9 +80,11 @@ Init_libxml_so(void) {
|
|
|
79
80
|
ruby_init_xml_xpath_context();
|
|
80
81
|
ruby_init_xml_xpointer();
|
|
81
82
|
ruby_init_xml_xpointer_context();
|
|
83
|
+
ruby_init_html_parser();
|
|
82
84
|
ruby_init_input_callbacks();
|
|
83
85
|
ruby_init_xml_dtd();
|
|
84
86
|
ruby_init_xml_schema();
|
|
87
|
+
ruby_init_xml_reader();
|
|
85
88
|
|
|
86
89
|
ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
|
|
87
90
|
ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
|
data/ext/xml/libxml.h
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
/* Don't nuke this block! It is used for automatically updating the
|
|
7
7
|
* versions below. VERSION = string formatting, VERNUM = numbered
|
|
8
8
|
* version for inline testing: increment both or none at all. */
|
|
9
|
-
#define RUBY_LIBXML_VERSION "0.
|
|
10
|
-
#define RUBY_LIBXML_VERNUM
|
|
11
|
-
#define RUBY_LIBXML_VER_MAJ
|
|
12
|
-
#define RUBY_LIBXML_VER_MIN
|
|
13
|
-
#define RUBY_LIBXML_VER_MIC
|
|
14
|
-
#define RUBY_LIBXML_VER_PATCH
|
|
9
|
+
#define RUBY_LIBXML_VERSION "0.5.0"
|
|
10
|
+
#define RUBY_LIBXML_VERNUM 500
|
|
11
|
+
#define RUBY_LIBXML_VER_MAJ 0
|
|
12
|
+
#define RUBY_LIBXML_VER_MIN 5
|
|
13
|
+
#define RUBY_LIBXML_VER_MIC 0
|
|
14
|
+
#define RUBY_LIBXML_VER_PATCH 0
|
|
15
15
|
|
|
16
16
|
#include <ruby.h>
|
|
17
17
|
#include <rubyio.h>
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
#include <libxml/xpath.h>
|
|
25
25
|
#include <libxml/valid.h>
|
|
26
26
|
#include <libxml/catalog.h>
|
|
27
|
+
#include <libxml/HTMLparser.h>
|
|
28
|
+
#include <libxml/xmlreader.h>
|
|
29
|
+
|
|
30
|
+
// Maybe not yet defined in ruby
|
|
31
|
+
#ifndef RSTRING_LEN
|
|
32
|
+
#define RSTRING_LEN(x) RSTRING(x)->len
|
|
33
|
+
#endif
|
|
34
|
+
|
|
27
35
|
#ifdef LIBXML_DEBUG_ENABLED
|
|
28
36
|
#include <libxml/xpathInternals.h>
|
|
29
37
|
#endif
|
|
@@ -57,7 +65,6 @@ typedef struct rx_xpath_data {
|
|
|
57
65
|
} rx_xpath_data;
|
|
58
66
|
|
|
59
67
|
#include "ruby_xml_attr.h"
|
|
60
|
-
#include "ruby_xml_attribute.h"
|
|
61
68
|
#include "ruby_xml_document.h"
|
|
62
69
|
#include "ruby_xml_node.h"
|
|
63
70
|
#include "ruby_xml_node_set.h"
|
|
@@ -74,6 +81,8 @@ typedef struct rx_xpath_data {
|
|
|
74
81
|
#include "ruby_xml_input_cbg.h"
|
|
75
82
|
#include "ruby_xml_dtd.h"
|
|
76
83
|
#include "ruby_xml_schema.h"
|
|
84
|
+
#include "ruby_xml_html_parser.h"
|
|
85
|
+
#include "ruby_xml_reader.h"
|
|
77
86
|
|
|
78
87
|
extern VALUE mXML;
|
|
79
88
|
extern VALUE eXMLError;
|
data/ext/xml/libxml.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# $Id: libxml.rb
|
|
1
|
+
# $Id: libxml.rb 120 2006-11-26 12:57:56Z roscopeco $
|
|
2
2
|
# Please see the LICENSE file for copyright and distribution information
|
|
3
3
|
require 'xml/libxml_so'
|
|
4
4
|
|
|
@@ -12,8 +12,8 @@ class XML::Document
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
class XML::Node::Set
|
|
15
|
-
include Enumerable
|
|
16
|
-
|
|
15
|
+
include Enumerable
|
|
16
|
+
|
|
17
17
|
# inefficient, but maybe can find a way to cache the
|
|
18
18
|
# ary and dump on change?
|
|
19
19
|
def [](i, count = nil)
|
data/ext/xml/ruby_xml_attr.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_attr.c
|
|
1
|
+
/* $Id: ruby_xml_attr.c 138 2007-08-29 18:00:35Z danj $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -7,25 +7,90 @@
|
|
|
7
7
|
|
|
8
8
|
VALUE cXMLAttr;
|
|
9
9
|
|
|
10
|
+
void ruby_xml_attr_free(ruby_xml_attr_t *rx) {
|
|
11
|
+
if (rx->attr == NULL ) return;
|
|
12
|
+
|
|
13
|
+
if (rx->attr->parent == NULL && rx->attr->doc == NULL ) {
|
|
14
|
+
#ifdef NODE_DEBUG
|
|
15
|
+
fprintf(stderr,"free rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
|
|
16
|
+
#endif
|
|
17
|
+
rx->attr->_private=NULL;
|
|
18
|
+
xmlFreeProp(rx->attr);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
rx->attr=NULL;
|
|
22
|
+
// fprintf(stderr,"%0x ",(long)rxn);
|
|
23
|
+
free(rx);
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
void
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// other pointers remain
|
|
20
|
-
rxa->attr->_private--;
|
|
21
|
-
}
|
|
27
|
+
ruby_xml_attr_mark(ruby_xml_attr_t *rx) {
|
|
28
|
+
xmlNodePtr node;
|
|
29
|
+
if (rx->attr == NULL ) return;
|
|
30
|
+
|
|
31
|
+
if (rx->attr->_private == NULL ) {
|
|
32
|
+
rb_warning("XmlAttr is not bound! (%s:%d)",
|
|
33
|
+
__FILE__,__LINE__);
|
|
34
|
+
return;
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
if (rx->attr->doc != NULL ) {
|
|
38
|
+
if (rx->attr->doc->_private == NULL )
|
|
39
|
+
rb_warning("XmlAttr Doc is not bound! (%s:%d)",
|
|
40
|
+
__FILE__,__LINE__);
|
|
41
|
+
else {
|
|
42
|
+
rb_gc_mark((VALUE)rx->attr->doc->_private);
|
|
43
|
+
#ifdef NODE_DEBUG
|
|
44
|
+
fprintf(stderr,"mark rx=0x%x xn=0x%x o=0x%x\n",(long)rx,(long)rx->attr,(long)rx->attr->_private);
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
} else if (rx->attr->parent != NULL ) {
|
|
48
|
+
if (rx->attr->parent->_private == NULL )
|
|
49
|
+
rb_warning("XmlAttr Parent is not bound! (%s:%d)",
|
|
50
|
+
__FILE__,__LINE__);
|
|
51
|
+
node=rx->attr->parent;
|
|
52
|
+
while (node->parent != NULL )
|
|
53
|
+
node=node->parent;
|
|
54
|
+
if (node->_private != NULL) {
|
|
55
|
+
rb_gc_mark((VALUE)node->_private);
|
|
56
|
+
#ifdef NODE_DEBUG
|
|
57
|
+
fprintf(stderr,"mark rx=0x%x xn=0x%x o=0x%x\n",(long)0,(long)node,(long)node->_private);
|
|
58
|
+
#endif
|
|
59
|
+
}
|
|
60
|
+
}
|
|
26
61
|
}
|
|
27
62
|
|
|
63
|
+
VALUE
|
|
64
|
+
ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode)
|
|
65
|
+
{
|
|
66
|
+
VALUE obj;
|
|
67
|
+
ruby_xml_attr_t *rx;
|
|
68
|
+
|
|
69
|
+
// This node is already wrapped
|
|
70
|
+
if (xnode->_private != NULL)
|
|
71
|
+
return (VALUE)xnode->_private;
|
|
72
|
+
|
|
73
|
+
obj=Data_Make_Struct(class,ruby_xml_attr_t,ruby_xml_attr_mark,
|
|
74
|
+
ruby_xml_attr_free,rx);
|
|
75
|
+
|
|
76
|
+
rx->attr=xnode;
|
|
77
|
+
xnode->_private=(void*)obj;
|
|
78
|
+
#ifdef NODE_DEBUG
|
|
79
|
+
fprintf(stderr,"wrap rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)obj);
|
|
80
|
+
#endif
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
28
83
|
|
|
84
|
+
/*
|
|
85
|
+
* Only use this when a xmlAttr has just been created since
|
|
86
|
+
* oblitterates the _private. Not exposed to ruby interp.
|
|
87
|
+
*/
|
|
88
|
+
VALUE
|
|
89
|
+
ruby_xml_attr_new(VALUE class, xmlAttrPtr xnode)
|
|
90
|
+
{
|
|
91
|
+
xnode->_private=NULL;
|
|
92
|
+
return ruby_xml_attr_wrap(class,xnode);
|
|
93
|
+
}
|
|
29
94
|
/*
|
|
30
95
|
* call-seq:
|
|
31
96
|
* attr.child => node
|
|
@@ -34,12 +99,12 @@ ruby_xml_attr_free(ruby_xml_attr *rxa) {
|
|
|
34
99
|
*/
|
|
35
100
|
VALUE
|
|
36
101
|
ruby_xml_attr_child_get(VALUE self) {
|
|
37
|
-
|
|
38
|
-
Data_Get_Struct(self,
|
|
102
|
+
ruby_xml_attr_t *rxa;
|
|
103
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
39
104
|
if (rxa->attr->children == NULL)
|
|
40
105
|
return(Qnil);
|
|
41
106
|
else
|
|
42
|
-
return(
|
|
107
|
+
return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->children));
|
|
43
108
|
}
|
|
44
109
|
|
|
45
110
|
|
|
@@ -51,8 +116,8 @@ ruby_xml_attr_child_get(VALUE self) {
|
|
|
51
116
|
*/
|
|
52
117
|
VALUE
|
|
53
118
|
ruby_xml_attr_child_q(VALUE self) {
|
|
54
|
-
|
|
55
|
-
Data_Get_Struct(self,
|
|
119
|
+
ruby_xml_attr_t *rxa;
|
|
120
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
56
121
|
if (rxa->attr->children == NULL)
|
|
57
122
|
return(Qfalse);
|
|
58
123
|
else
|
|
@@ -69,15 +134,14 @@ ruby_xml_attr_child_q(VALUE self) {
|
|
|
69
134
|
*/
|
|
70
135
|
VALUE
|
|
71
136
|
ruby_xml_attr_doc_get(VALUE self) {
|
|
72
|
-
|
|
73
|
-
Data_Get_Struct(self,
|
|
137
|
+
ruby_xml_attr_t *rxa;
|
|
138
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
74
139
|
if (rxa->attr->doc == NULL)
|
|
75
140
|
return(Qnil);
|
|
76
141
|
else
|
|
77
|
-
return(
|
|
142
|
+
return(ruby_xml_document_wrap(cXMLDocument, rxa->attr->doc));
|
|
78
143
|
}
|
|
79
144
|
|
|
80
|
-
|
|
81
145
|
/*
|
|
82
146
|
* call-seq:
|
|
83
147
|
* attr.doc? => (true|false)
|
|
@@ -87,8 +151,8 @@ ruby_xml_attr_doc_get(VALUE self) {
|
|
|
87
151
|
*/
|
|
88
152
|
VALUE
|
|
89
153
|
ruby_xml_attr_doc_q(VALUE self) {
|
|
90
|
-
|
|
91
|
-
Data_Get_Struct(self,
|
|
154
|
+
ruby_xml_attr_t *rxa;
|
|
155
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
92
156
|
if (rxa->attr->doc == NULL)
|
|
93
157
|
return(Qfalse);
|
|
94
158
|
else
|
|
@@ -104,12 +168,12 @@ ruby_xml_attr_doc_q(VALUE self) {
|
|
|
104
168
|
*/
|
|
105
169
|
VALUE
|
|
106
170
|
ruby_xml_attr_last_get(VALUE self) {
|
|
107
|
-
|
|
108
|
-
Data_Get_Struct(self,
|
|
171
|
+
ruby_xml_attr_t *rxa;
|
|
172
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
109
173
|
if (rxa->attr->last == NULL)
|
|
110
174
|
return(Qnil);
|
|
111
175
|
else
|
|
112
|
-
return(
|
|
176
|
+
return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->last));
|
|
113
177
|
}
|
|
114
178
|
|
|
115
179
|
|
|
@@ -121,22 +185,14 @@ ruby_xml_attr_last_get(VALUE self) {
|
|
|
121
185
|
*/
|
|
122
186
|
VALUE
|
|
123
187
|
ruby_xml_attr_last_q(VALUE self) {
|
|
124
|
-
|
|
125
|
-
Data_Get_Struct(self,
|
|
188
|
+
ruby_xml_attr_t *rxa;
|
|
189
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
126
190
|
if (rxa->attr->last == NULL)
|
|
127
191
|
return(Qfalse);
|
|
128
192
|
else
|
|
129
193
|
return(Qtrue);
|
|
130
194
|
}
|
|
131
195
|
|
|
132
|
-
|
|
133
|
-
static void
|
|
134
|
-
ruby_xml_attr_mark(ruby_xml_attr *rxa) {
|
|
135
|
-
if (rxa == NULL) return;
|
|
136
|
-
if (!NIL_P(rxa->xd)) rb_gc_mark(rxa->xd);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
196
|
/*
|
|
141
197
|
* call-seq:
|
|
142
198
|
* attr.name => "name"
|
|
@@ -145,8 +201,8 @@ ruby_xml_attr_mark(ruby_xml_attr *rxa) {
|
|
|
145
201
|
*/
|
|
146
202
|
VALUE
|
|
147
203
|
ruby_xml_attr_name_get(VALUE self) {
|
|
148
|
-
|
|
149
|
-
Data_Get_Struct(self,
|
|
204
|
+
ruby_xml_attr_t *rxa;
|
|
205
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
150
206
|
|
|
151
207
|
if (rxa->attr->name == NULL)
|
|
152
208
|
return(Qnil);
|
|
@@ -154,43 +210,6 @@ ruby_xml_attr_name_get(VALUE self) {
|
|
|
154
210
|
return(rb_str_new2((const char*)rxa->attr->name));
|
|
155
211
|
}
|
|
156
212
|
|
|
157
|
-
|
|
158
|
-
VALUE
|
|
159
|
-
ruby_xml_attr_new(VALUE class, VALUE xd, xmlAttrPtr attr) {
|
|
160
|
-
return(ruby_xml_attr_new2(class, xd, attr));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
VALUE
|
|
165
|
-
ruby_xml_attr_new2(VALUE class, VALUE xd, xmlAttrPtr attr) {
|
|
166
|
-
ruby_xml_attr *rxa;
|
|
167
|
-
|
|
168
|
-
rxa = ALLOC(ruby_xml_attr);
|
|
169
|
-
|
|
170
|
-
rxa->attr = attr;
|
|
171
|
-
if (attr->_private) {
|
|
172
|
-
attr->_private++;
|
|
173
|
-
} else {
|
|
174
|
-
attr->_private = (void*)1;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (NIL_P(xd)) {
|
|
178
|
-
rxa->xd = Qnil;
|
|
179
|
-
rxa->attr->doc = NULL;
|
|
180
|
-
} else {
|
|
181
|
-
/* Have to set node->doc too so we don't doublefree this node */
|
|
182
|
-
ruby_xml_document *xdoc;
|
|
183
|
-
Data_Get_Struct(xd, ruby_xml_document, xdoc);
|
|
184
|
-
|
|
185
|
-
rxa->xd = xd;
|
|
186
|
-
rxa->attr->doc = xdoc->doc;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return(Data_Wrap_Struct(class, ruby_xml_attr_mark,
|
|
190
|
-
ruby_xml_attr_free, rxa));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
213
|
/*
|
|
195
214
|
* call-seq:
|
|
196
215
|
* attr.next => node
|
|
@@ -199,12 +218,12 @@ ruby_xml_attr_new2(VALUE class, VALUE xd, xmlAttrPtr attr) {
|
|
|
199
218
|
*/
|
|
200
219
|
VALUE
|
|
201
220
|
ruby_xml_attr_next_get(VALUE self) {
|
|
202
|
-
|
|
203
|
-
Data_Get_Struct(self,
|
|
221
|
+
ruby_xml_attr_t *rxa;
|
|
222
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
204
223
|
if (rxa->attr->next == NULL)
|
|
205
224
|
return(Qnil);
|
|
206
225
|
else
|
|
207
|
-
return(
|
|
226
|
+
return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->next));
|
|
208
227
|
}
|
|
209
228
|
|
|
210
229
|
|
|
@@ -216,8 +235,8 @@ ruby_xml_attr_next_get(VALUE self) {
|
|
|
216
235
|
*/
|
|
217
236
|
VALUE
|
|
218
237
|
ruby_xml_attr_next_q(VALUE self) {
|
|
219
|
-
|
|
220
|
-
Data_Get_Struct(self,
|
|
238
|
+
ruby_xml_attr_t *rxa;
|
|
239
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
221
240
|
if (rxa->attr->next == NULL)
|
|
222
241
|
return(Qfalse);
|
|
223
242
|
else
|
|
@@ -245,12 +264,12 @@ ruby_xml_attr_node_type_name(VALUE self) {
|
|
|
245
264
|
*/
|
|
246
265
|
VALUE
|
|
247
266
|
ruby_xml_attr_ns_get(VALUE self) {
|
|
248
|
-
|
|
249
|
-
Data_Get_Struct(self,
|
|
267
|
+
ruby_xml_attr_t *rxa;
|
|
268
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
250
269
|
if (rxa->attr->ns == NULL)
|
|
251
270
|
return(Qnil);
|
|
252
271
|
else
|
|
253
|
-
return(ruby_xml_ns_new2(cXMLNS,
|
|
272
|
+
return(ruby_xml_ns_new2(cXMLNS, NULL, rxa->attr->ns));
|
|
254
273
|
}
|
|
255
274
|
|
|
256
275
|
|
|
@@ -263,8 +282,8 @@ ruby_xml_attr_ns_get(VALUE self) {
|
|
|
263
282
|
*/
|
|
264
283
|
VALUE
|
|
265
284
|
ruby_xml_attr_ns_q(VALUE self) {
|
|
266
|
-
|
|
267
|
-
Data_Get_Struct(self,
|
|
285
|
+
ruby_xml_attr_t *rxa;
|
|
286
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
268
287
|
if (rxa->attr->ns == NULL)
|
|
269
288
|
return(Qfalse);
|
|
270
289
|
else
|
|
@@ -280,12 +299,12 @@ ruby_xml_attr_ns_q(VALUE self) {
|
|
|
280
299
|
*/
|
|
281
300
|
VALUE
|
|
282
301
|
ruby_xml_attr_parent_get(VALUE self) {
|
|
283
|
-
|
|
284
|
-
Data_Get_Struct(self,
|
|
302
|
+
ruby_xml_attr_t *rxa;
|
|
303
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
285
304
|
if (rxa->attr->parent == NULL)
|
|
286
305
|
return(Qnil);
|
|
287
306
|
else
|
|
288
|
-
return(
|
|
307
|
+
return(ruby_xml_node2_wrap(cXMLNode, rxa->attr->parent));
|
|
289
308
|
}
|
|
290
309
|
|
|
291
310
|
|
|
@@ -297,8 +316,8 @@ ruby_xml_attr_parent_get(VALUE self) {
|
|
|
297
316
|
*/
|
|
298
317
|
VALUE
|
|
299
318
|
ruby_xml_attr_parent_q(VALUE self) {
|
|
300
|
-
|
|
301
|
-
Data_Get_Struct(self,
|
|
319
|
+
ruby_xml_attr_t *rxa;
|
|
320
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
302
321
|
if (rxa->attr->parent == NULL)
|
|
303
322
|
return(Qfalse);
|
|
304
323
|
else
|
|
@@ -314,12 +333,12 @@ ruby_xml_attr_parent_q(VALUE self) {
|
|
|
314
333
|
*/
|
|
315
334
|
VALUE
|
|
316
335
|
ruby_xml_attr_prev_get(VALUE self) {
|
|
317
|
-
|
|
318
|
-
Data_Get_Struct(self,
|
|
336
|
+
ruby_xml_attr_t *rxa;
|
|
337
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
319
338
|
if (rxa->attr->prev == NULL)
|
|
320
339
|
return(Qnil);
|
|
321
340
|
else
|
|
322
|
-
return(
|
|
341
|
+
return(ruby_xml_attr_wrap(cXMLAttr, rxa->attr->prev));
|
|
323
342
|
}
|
|
324
343
|
|
|
325
344
|
|
|
@@ -331,8 +350,8 @@ ruby_xml_attr_prev_get(VALUE self) {
|
|
|
331
350
|
*/
|
|
332
351
|
VALUE
|
|
333
352
|
ruby_xml_attr_prev_q(VALUE self) {
|
|
334
|
-
|
|
335
|
-
Data_Get_Struct(self,
|
|
353
|
+
ruby_xml_attr_t *rxa;
|
|
354
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
336
355
|
if (rxa->attr->prev == NULL)
|
|
337
356
|
return(Qfalse);
|
|
338
357
|
else
|
|
@@ -348,10 +367,10 @@ ruby_xml_attr_prev_q(VALUE self) {
|
|
|
348
367
|
*/
|
|
349
368
|
VALUE
|
|
350
369
|
ruby_xml_attr_value(VALUE self) {
|
|
351
|
-
|
|
370
|
+
ruby_xml_attr_t *rxa;
|
|
352
371
|
xmlChar *value;
|
|
353
372
|
|
|
354
|
-
Data_Get_Struct(self,
|
|
373
|
+
Data_Get_Struct(self, ruby_xml_attr_t, rxa);
|
|
355
374
|
if (ruby_xml_attr_parent_q(self) == Qtrue) {
|
|
356
375
|
value = xmlGetProp(rxa->attr->parent, rxa->attr->name);
|
|
357
376
|
if (value != NULL)
|
data/ext/xml/ruby_xml_attr.h
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_attr.h
|
|
1
|
+
/* $Id: ruby_xml_attr.h 138 2007-08-29 18:00:35Z danj $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -9,13 +9,10 @@ extern VALUE cXMLAttr;
|
|
|
9
9
|
|
|
10
10
|
typedef struct ruby_xml_attr {
|
|
11
11
|
xmlAttrPtr attr;
|
|
12
|
-
|
|
13
|
-
//int is_ptr;
|
|
14
|
-
} ruby_xml_attr;
|
|
12
|
+
} ruby_xml_attr_t;
|
|
15
13
|
|
|
16
|
-
void ruby_xml_attr_free(
|
|
14
|
+
void ruby_xml_attr_free(ruby_xml_attr_t *rxn);
|
|
15
|
+
VALUE ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode);
|
|
17
16
|
void ruby_init_xml_attr(void);
|
|
18
|
-
VALUE ruby_xml_attr_new(VALUE class, VALUE xd, xmlAttrPtr attr);
|
|
19
|
-
VALUE ruby_xml_attr_new2(VALUE class, VALUE xd, xmlAttrPtr attr);
|
|
20
17
|
VALUE ruby_xml_attr_name_get(VALUE self);
|
|
21
18
|
#endif
|