libxml-ruby 0.3.6

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.
Files changed (74) hide show
  1. data/CHANGELOG +49 -0
  2. data/LICENSE +22 -0
  3. data/README +129 -0
  4. data/Rakefile +197 -0
  5. data/TODO +84 -0
  6. data/ext/xml/cbg.c +76 -0
  7. data/ext/xml/extconf.rb +95 -0
  8. data/ext/xml/libxml.c +86 -0
  9. data/ext/xml/libxml.h +79 -0
  10. data/ext/xml/ruby_xml_attr.c +372 -0
  11. data/ext/xml/ruby_xml_attr.h +21 -0
  12. data/ext/xml/ruby_xml_attribute.c +224 -0
  13. data/ext/xml/ruby_xml_attribute.h +21 -0
  14. data/ext/xml/ruby_xml_document.c +1159 -0
  15. data/ext/xml/ruby_xml_document.h +27 -0
  16. data/ext/xml/ruby_xml_dtd.c +168 -0
  17. data/ext/xml/ruby_xml_dtd.h +17 -0
  18. data/ext/xml/ruby_xml_input_cbg.c +167 -0
  19. data/ext/xml/ruby_xml_input_cbg.h +21 -0
  20. data/ext/xml/ruby_xml_node.c +2052 -0
  21. data/ext/xml/ruby_xml_node.h +28 -0
  22. data/ext/xml/ruby_xml_node_set.c +197 -0
  23. data/ext/xml/ruby_xml_node_set.h +26 -0
  24. data/ext/xml/ruby_xml_ns.c +153 -0
  25. data/ext/xml/ruby_xml_ns.h +21 -0
  26. data/ext/xml/ruby_xml_parser.c +1363 -0
  27. data/ext/xml/ruby_xml_parser.h +31 -0
  28. data/ext/xml/ruby_xml_parser_context.c +715 -0
  29. data/ext/xml/ruby_xml_parser_context.h +22 -0
  30. data/ext/xml/ruby_xml_sax_parser.c +181 -0
  31. data/ext/xml/ruby_xml_sax_parser.h +21 -0
  32. data/ext/xml/ruby_xml_schema.c +142 -0
  33. data/ext/xml/ruby_xml_schema.h +16 -0
  34. data/ext/xml/ruby_xml_tree.c +43 -0
  35. data/ext/xml/ruby_xml_tree.h +12 -0
  36. data/ext/xml/ruby_xml_xinclude.c +20 -0
  37. data/ext/xml/ruby_xml_xinclude.h +13 -0
  38. data/ext/xml/ruby_xml_xpath.c +357 -0
  39. data/ext/xml/ruby_xml_xpath.h +24 -0
  40. data/ext/xml/ruby_xml_xpath_context.c +124 -0
  41. data/ext/xml/ruby_xml_xpath_context.h +24 -0
  42. data/ext/xml/ruby_xml_xpointer.c +100 -0
  43. data/ext/xml/ruby_xml_xpointer.h +27 -0
  44. data/ext/xml/ruby_xml_xpointer_context.c +22 -0
  45. data/ext/xml/ruby_xml_xpointer_context.h +18 -0
  46. data/tests/copy_bug.rb +21 -0
  47. data/tests/dtd-test.rb +24 -0
  48. data/tests/model/default_validation_bug.rb +0 -0
  49. data/tests/model/rubynet.xml +78 -0
  50. data/tests/model/rubynet_project +13 -0
  51. data/tests/model/xinclude.xml +5 -0
  52. data/tests/runner.rb +13 -0
  53. data/tests/schema-test.rb +74 -0
  54. data/tests/tc_default_validation.rb +0 -0
  55. data/tests/tc_xml_document.rb +51 -0
  56. data/tests/tc_xml_document_write.rb +25 -0
  57. data/tests/tc_xml_document_write2.rb +55 -0
  58. data/tests/tc_xml_document_write3.rb +97 -0
  59. data/tests/tc_xml_node.rb +59 -0
  60. data/tests/tc_xml_node2.rb +26 -0
  61. data/tests/tc_xml_node_set.rb +25 -0
  62. data/tests/tc_xml_node_xlink.rb +28 -0
  63. data/tests/tc_xml_parser.rb +175 -0
  64. data/tests/tc_xml_parser2.rb +17 -0
  65. data/tests/tc_xml_parser3.rb +23 -0
  66. data/tests/tc_xml_parser4.rb +33 -0
  67. data/tests/tc_xml_parser5.rb +27 -0
  68. data/tests/tc_xml_parser6.rb +23 -0
  69. data/tests/tc_xml_parser7.rb +28 -0
  70. data/tests/tc_xml_parser_context.rb +89 -0
  71. data/tests/tc_xml_xinclude.rb +30 -0
  72. data/tests/tc_xml_xpath.rb +23 -0
  73. data/tests/tc_xml_xpointer.rb +78 -0
  74. metadata +144 -0
@@ -0,0 +1,28 @@
1
+ /* $Id: ruby_xml_node.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_NODE__
6
+ #define __RUBY_XML_NODE__
7
+
8
+ extern VALUE cXMLNode;
9
+ extern VALUE eXMLNodeSetNamespace;
10
+ extern VALUE eXMLNodeFailedModify;
11
+ extern VALUE eXMLNodeUnknownType;
12
+
13
+ typedef struct ruby_xml_node {
14
+ xmlNodePtr node;
15
+ VALUE xd;
16
+ int is_ptr;
17
+ } ruby_xml_node;
18
+
19
+ void ruby_xml_node_free(ruby_xml_node *rxn);
20
+ void ruby_init_xml_node(void);
21
+ VALUE ruby_xml_node_child_set(VALUE self, VALUE obj);
22
+ VALUE ruby_xml_node_new(VALUE class, xmlNodePtr node);
23
+ VALUE ruby_xml_node_new2(VALUE class, VALUE xd, xmlNodePtr node);
24
+ VALUE ruby_xml_node_name_get(VALUE self);
25
+ VALUE ruby_xml_node_property_get(VALUE self, VALUE key);
26
+ VALUE ruby_xml_node_property_set(VALUE self, VALUE key, VALUE val);
27
+ VALUE ruby_xml_node_set_ptr(VALUE node, int is_ptr);
28
+ #endif
@@ -0,0 +1,197 @@
1
+ /* $Id: ruby_xml_node_set.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "libxml.h"
6
+ #include "ruby_xml_node_set.h"
7
+
8
+ VALUE cXMLNodeSet;
9
+
10
+ // TODO maybe we should support [] on nodeset?
11
+ // Would also give us on xpath too...
12
+
13
+ /*
14
+ * call-seq:
15
+ * nodeset.to_a => [node, ..., node]
16
+ *
17
+ * Obtain an array of the nodes in this set.
18
+ */
19
+ VALUE
20
+ ruby_xml_node_set_to_a(VALUE self) {
21
+ int i;
22
+ ruby_xml_node_set *rxnset;
23
+ VALUE nodeobj, set_ary;
24
+
25
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
26
+
27
+ if ((rxnset->node_set == NULL) || (rxnset->node_set->nodeNr == 0))
28
+ return(Qnil);
29
+
30
+ set_ary = rb_ary_new();
31
+ for (i = 0; i < rxnset->node_set->nodeNr; i++) {
32
+ nodeobj = ruby_xml_node_new2(cXMLNode, rxnset->xd, rxnset->node_set->nodeTab[i]);
33
+ rb_ary_push(set_ary, nodeobj);
34
+ }
35
+ return(set_ary);
36
+ }
37
+
38
+
39
+ /*
40
+ * call-seq:
41
+ * nodeset.each { |node| ... } => self
42
+ *
43
+ * Call the supplied block for each node in this set.
44
+ */
45
+ VALUE
46
+ ruby_xml_node_set_each(VALUE self) {
47
+ int i;
48
+ ruby_xml_node_set *rxnset;
49
+ VALUE nodeobj;
50
+
51
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
52
+
53
+ if (rxnset->node_set == NULL)
54
+ return(Qnil);
55
+
56
+ for (i = 0; i < rxnset->node_set->nodeNr; i++) {
57
+ switch(rxnset->node_set->nodeTab[i]->type) {
58
+ case XML_ATTRIBUTE_NODE:
59
+ nodeobj = ruby_xml_attr_new2(cXMLAttr, rxnset->xd, (xmlAttrPtr)rxnset->node_set->nodeTab[i]);
60
+ break;
61
+ default:
62
+ nodeobj = ruby_xml_node_new2(cXMLNode, rxnset->xd, rxnset->node_set->nodeTab[i]);
63
+ }
64
+
65
+ rb_yield(nodeobj);
66
+ }
67
+ return(self);
68
+ }
69
+
70
+
71
+ void
72
+ ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
73
+ void *data;
74
+
75
+ switch(rxnset->data_type) {
76
+ case RUBY_LIBXML_SRC_TYPE_NULL:
77
+ break;
78
+ case RUBY_LIBXML_SRC_TYPE_XPATH:
79
+ data = (void*)(rx_xpath_data *)rxnset->data;
80
+ free((rx_xpath_data *)data);
81
+ default:
82
+ rb_fatal("Unknown data type, %d", rxnset->data_type);
83
+ }
84
+
85
+ /* Don't need to free the node set because the nodeset is a child of
86
+ the XPath object that created the set.
87
+ if (rxnset->node_set != NULL)
88
+ xmlXPathFreeNodeSet(rxnset->node_set);
89
+ */
90
+
91
+ free(rxnset);
92
+ }
93
+
94
+
95
+ /*
96
+ * call-seq:
97
+ * nodeset.length => num
98
+ *
99
+ * Obtain the length of this nodeset.
100
+ */
101
+ VALUE
102
+ ruby_xml_node_set_length(VALUE self) {
103
+ ruby_xml_node_set *rxnset;
104
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
105
+ if (rxnset->node_set == NULL)
106
+ return(Qnil);
107
+ else
108
+ return(INT2NUM(rxnset->node_set->nodeNr));
109
+ }
110
+
111
+ // TODO Check this for doublefree (should we mark nodes?)
112
+ static void
113
+ ruby_xml_node_set_mark(ruby_xml_node_set *rxnset) {
114
+ if (rxnset == NULL) return;
115
+ if (!NIL_P(rxnset->xd)) rb_gc_mark(rxnset->xd);
116
+ if (!NIL_P(rxnset->xpath)) rb_gc_mark(rxnset->xpath);
117
+ }
118
+
119
+
120
+ VALUE
121
+ ruby_xml_node_set_new(VALUE class, VALUE xd, VALUE xpath,
122
+ xmlNodeSetPtr node_set) {
123
+ ruby_xml_node_set *rxnset;
124
+
125
+ rxnset = ALLOC(ruby_xml_node_set);
126
+ rxnset->node_set = node_set;
127
+ rxnset->data = NULL;
128
+ rxnset->data_type = RUBY_LIBXML_SRC_TYPE_NULL;
129
+ rxnset->xd = xd;
130
+ rxnset->xpath = xpath;
131
+ return(Data_Wrap_Struct(class, ruby_xml_node_set_mark,
132
+ ruby_xml_node_set_free, rxnset));
133
+ }
134
+
135
+
136
+ VALUE
137
+ ruby_xml_node_set_new2(VALUE xd, VALUE xpath,
138
+ xmlNodeSetPtr node_set) {
139
+ return(ruby_xml_node_set_new(cXMLNodeSet, xd, xpath, node_set));
140
+ }
141
+
142
+
143
+ /*
144
+ * call-seq:
145
+ * nodeset.xpath => xpath
146
+ *
147
+ * Obtain the xpath corresponding to this nodeset, if any.
148
+ */
149
+ VALUE
150
+ ruby_xml_node_set_xpath_get(VALUE self) {
151
+ ruby_xml_node_set *rxnset;
152
+
153
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
154
+ if (NIL_P(rxnset->xpath))
155
+ return(Qnil);
156
+ else
157
+ return(rxnset->xpath);
158
+ }
159
+
160
+
161
+ /*
162
+ * call-seq:
163
+ * nodeset.xpath_ctxt => context
164
+ *
165
+ * Return the xpath context corresponding to this nodeset,
166
+ * if any.
167
+ */
168
+ VALUE
169
+ ruby_xml_node_set_xpath_data_get(VALUE self) {
170
+ ruby_xml_node_set *rxnset;
171
+ rx_xpath_data *rxxpd;
172
+
173
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
174
+ if (rxnset->data_type != RUBY_LIBXML_SRC_TYPE_XPATH)
175
+ return(Qnil);
176
+
177
+ rxxpd = (rx_xpath_data *)rxnset->data;
178
+ return(rxxpd->ctxt);
179
+ }
180
+
181
+ // Rdoc needs to know
182
+ #ifdef RDOC_NEVER_DEFINED
183
+ mXML = rb_define_module("XML");
184
+ cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
185
+ #endif
186
+
187
+ void
188
+ ruby_init_xml_node_set(void) {
189
+ cXMLNodeSet = rb_define_class_under(cXMLNode, "Set", rb_cObject);
190
+
191
+ rb_define_method(cXMLNodeSet, "to_a", ruby_xml_node_set_to_a, 0);
192
+ rb_define_method(cXMLNodeSet, "each", ruby_xml_node_set_each, 0);
193
+ rb_define_method(cXMLNodeSet, "length", ruby_xml_node_set_length, 0);
194
+ rb_define_method(cXMLNodeSet, "xpath", ruby_xml_node_set_xpath_get, 0);
195
+ rb_define_method(cXMLNodeSet, "xpath_ctxt",
196
+ ruby_xml_node_set_xpath_data_get, 0);
197
+ }
@@ -0,0 +1,26 @@
1
+ /* $Id: ruby_xml_node_set.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_NODE_SET__
6
+ #define __RUBY_XML_NODE_SET__
7
+
8
+ extern VALUE cXMLNodeSet;
9
+
10
+ typedef struct ruby_xml_node_set {
11
+ xmlNodeSetPtr node_set;
12
+ VALUE xd;
13
+ VALUE xpath;
14
+ int data_type;
15
+ void *data;
16
+ } ruby_xml_node_set;
17
+
18
+ void ruby_xml_node_set_free(ruby_xml_node_set *rxnset);
19
+ void ruby_init_xml_node_set(void);
20
+ VALUE ruby_xml_node_set_new(VALUE class, VALUE xd, VALUE xpath,
21
+ xmlNodeSetPtr node_set);
22
+ VALUE ruby_xml_node_set_new2(VALUE xd, VALUE xpath,
23
+ xmlNodeSetPtr node_set);
24
+ VALUE ruby_xml_node_set_each(VALUE self);
25
+
26
+ #endif
@@ -0,0 +1,153 @@
1
+ /* $Id: ruby_xml_ns.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "libxml.h"
6
+ #include "ruby_xml_ns.h"
7
+
8
+ VALUE cXMLNS;
9
+
10
+ /*
11
+ * call-seq:
12
+ * ns.href => "href"
13
+ *
14
+ * Obtain the namespace's href.
15
+ */
16
+ VALUE
17
+ ruby_xml_ns_href_get(VALUE self) {
18
+ ruby_xml_ns *rxns;
19
+ Data_Get_Struct(self, ruby_xml_ns, rxns);
20
+ if (rxns->ns == NULL || rxns->ns->href == NULL)
21
+ return(Qnil);
22
+ else
23
+ return(rb_str_new2((const char*)rxns->ns->href));
24
+ }
25
+
26
+
27
+ /*
28
+ * call-seq:
29
+ * ns.href? => (true|false)
30
+ *
31
+ * Determine whether this namespace has an href.
32
+ */
33
+ VALUE
34
+ ruby_xml_ns_href_q(VALUE self) {
35
+ ruby_xml_ns *rxns;
36
+ Data_Get_Struct(self, ruby_xml_ns, rxns);
37
+ if (rxns->ns == NULL || rxns->ns->href == NULL)
38
+ return(Qfalse);
39
+ else
40
+ return(Qtrue);
41
+ }
42
+
43
+
44
+ void
45
+ ruby_xml_ns_free(ruby_xml_ns *rxns) {
46
+ if (rxns->ns != NULL && !rxns->is_ptr) {
47
+ xmlFreeNs(rxns->ns);
48
+ rxns->ns = NULL;
49
+ }
50
+
51
+ free(rxns);
52
+ }
53
+
54
+
55
+ static void
56
+ ruby_xml_ns_mark(ruby_xml_ns *rxns) {
57
+ if (rxns == NULL) return;
58
+ if (!NIL_P(rxns->xd)) rb_gc_mark(rxns->xd);
59
+ }
60
+
61
+
62
+ VALUE
63
+ ruby_xml_ns_new(VALUE class, VALUE xd, xmlNsPtr ns) {
64
+ ruby_xml_ns *rxns;
65
+
66
+ rxns = ALLOC(ruby_xml_ns);
67
+ rxns->is_ptr = 0;
68
+ rxns->ns = ns;
69
+ rxns->xd = xd;
70
+ return(Data_Wrap_Struct(class, ruby_xml_ns_mark,
71
+ ruby_xml_ns_free, rxns));
72
+ }
73
+
74
+
75
+ VALUE
76
+ ruby_xml_ns_new2(VALUE class, VALUE xd, xmlNsPtr ns) {
77
+ ruby_xml_ns *rxns;
78
+
79
+ rxns = ALLOC(ruby_xml_ns);
80
+ rxns->is_ptr = 1;
81
+ rxns->ns = ns;
82
+ rxns->xd = xd;
83
+ return(Data_Wrap_Struct(class, ruby_xml_ns_mark,
84
+ ruby_xml_ns_free, rxns));
85
+ }
86
+
87
+
88
+ /*
89
+ * call-seq:
90
+ * ns.next => ns
91
+ *
92
+ * Obtain the next namespace.
93
+ */
94
+ VALUE
95
+ ruby_xml_ns_next(VALUE self) {
96
+ ruby_xml_ns *rxns;
97
+ Data_Get_Struct(self, ruby_xml_ns, rxns);
98
+ if (rxns->ns == NULL || rxns->ns->next == NULL)
99
+ return(Qnil);
100
+ else
101
+ return(ruby_xml_ns_new2(cXMLNS, rxns->xd, rxns->ns->next));
102
+ }
103
+
104
+
105
+ /*
106
+ * call-seq:
107
+ * ns.prefix => "prefix"
108
+ * ns.to_s => "prefix"
109
+ *
110
+ * Obtain the namespace's prefix.
111
+ */
112
+ VALUE
113
+ ruby_xml_ns_prefix_get(VALUE self) {
114
+ ruby_xml_ns *rxns;
115
+ Data_Get_Struct(self, ruby_xml_ns, rxns);
116
+ if (rxns->ns == NULL || rxns->ns->prefix == NULL)
117
+ return(Qnil);
118
+ else
119
+ return(rb_str_new2((const char*)rxns->ns->prefix));
120
+ }
121
+
122
+
123
+ /*
124
+ * call-seq:
125
+ * ns.prefix? => (true|false)
126
+ *
127
+ * Determine whether this namespace has a prefix.
128
+ */
129
+ VALUE
130
+ ruby_xml_ns_prefix_q(VALUE self) {
131
+ ruby_xml_ns *rxns;
132
+ Data_Get_Struct(self, ruby_xml_ns, rxns);
133
+ if (rxns->ns == NULL || rxns->ns->prefix == NULL)
134
+ return(Qfalse);
135
+ else
136
+ return(Qtrue);
137
+ }
138
+
139
+ // Rdoc needs to know
140
+ #ifdef RDOC_NEVER_DEFINED
141
+ mXML = rb_define_module("XML");
142
+ #endif
143
+
144
+ void
145
+ ruby_init_xml_ns(void) {
146
+ cXMLNS = rb_define_class_under(mXML, "NS", rb_cObject);
147
+ rb_define_method(cXMLNS, "href", ruby_xml_ns_href_get, 0);
148
+ rb_define_method(cXMLNS, "href?", ruby_xml_ns_href_q, 0);
149
+ rb_define_method(cXMLNS, "next", ruby_xml_ns_next, 0);
150
+ rb_define_method(cXMLNS, "prefix", ruby_xml_ns_prefix_get, 0);
151
+ rb_define_method(cXMLNS, "prefix?", ruby_xml_ns_prefix_q, 0);
152
+ rb_define_method(cXMLNS, "to_s", ruby_xml_ns_prefix_get, 0);
153
+ }
@@ -0,0 +1,21 @@
1
+ /* $Id: ruby_xml_ns.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_NS__
6
+ #define __RUBY_XML_NS__
7
+
8
+ extern VALUE cXMLNS;
9
+
10
+ typedef struct ruby_xml_ns {
11
+ xmlNsPtr ns;
12
+ int is_ptr;
13
+ VALUE xd;
14
+ } ruby_xml_ns;
15
+
16
+ void ruby_xml_ns_free(ruby_xml_ns *rxn);
17
+ void ruby_init_xml_ns(void);
18
+ VALUE ruby_xml_ns_new(VALUE class, VALUE xd, xmlNsPtr ns);
19
+ VALUE ruby_xml_ns_new2(VALUE class, VALUE xd, xmlNsPtr ns);
20
+ VALUE ruby_xml_ns_name_get(VALUE self);
21
+ #endif
@@ -0,0 +1,1363 @@
1
+ /* $Id: ruby_xml_parser.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "libxml.h"
6
+
7
+ int ruby_xml_parser_count = 0;
8
+ VALUE cXMLParser;
9
+ VALUE eXMLParserParseError;
10
+
11
+ static int
12
+ ctxtRead(FILE *f, char * buf, int len) {
13
+ return(fread(buf, 1, len, f));
14
+ }
15
+
16
+ /*
17
+ * call-seq:
18
+ * XML::Parser.catalog_dump => true
19
+ *
20
+ * Dump the parser resource catalogs to stdout.
21
+ */
22
+ VALUE
23
+ ruby_xml_parser_catalog_dump(VALUE self) {
24
+ xmlCatalogDump(stdout);
25
+ return(Qtrue);
26
+ }
27
+
28
+
29
+ /*
30
+ * call-seq:
31
+ * XML::Parser.catalog_remove(catalog) => true
32
+ *
33
+ * Remove the specified resource catalog.
34
+ */
35
+ VALUE
36
+ ruby_xml_parser_catalog_remove(VALUE self, VALUE cat) {
37
+ Check_Type(cat, T_STRING);
38
+ xmlCatalogRemove((xmlChar *)StringValuePtr(cat));
39
+ return(Qtrue);
40
+ }
41
+
42
+
43
+ /*
44
+ * call-seq:
45
+ * XML::Parser.check_lib_versions => true
46
+ *
47
+ * Check LIBXML version matches version the bindings
48
+ * were compiled to. Throws an exception if not.
49
+ */
50
+ VALUE
51
+ ruby_xml_parser_check_lib_versions(VALUE class) {
52
+ xmlCheckVersion(LIBXML_VERSION);
53
+ return(Qtrue);
54
+ }
55
+
56
+
57
+ /*
58
+ * call-seq:
59
+ * XML::Parser.enabled_automata? => (true|false)
60
+ *
61
+ * Determine whether libxml regexp automata support is enabled.
62
+ */
63
+ VALUE
64
+ ruby_xml_parser_enabled_automata_q(VALUE class) {
65
+ #ifdef LIBXML_AUTOMATA_ENABLED
66
+ return(Qtrue);
67
+ #else
68
+ return(Qfalse);
69
+ #endif
70
+ }
71
+
72
+
73
+ /*
74
+ * call-seq:
75
+ * XML::Parser.enabled_c14n? => (true|false)
76
+ *
77
+ * Determine whether libxml 'canonical XML' support is enabled.
78
+ * See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
79
+ */
80
+ VALUE
81
+ ruby_xml_parser_enabled_c14n_q(VALUE class) {
82
+ #ifdef LIBXML_C14N_ENABLED
83
+ return(Qtrue);
84
+ #else
85
+ return(Qfalse);
86
+ #endif
87
+ }
88
+
89
+
90
+ /*
91
+ * call-seq:
92
+ * XML::Parser.enabled_catalog? => (true|false)
93
+ *
94
+ * Determine whether libxml resource catalog support is enabled.
95
+ */
96
+ VALUE
97
+ ruby_xml_parser_enabled_catalog_q(VALUE class) {
98
+ #ifdef LIBXML_CATALOG_ENABLED
99
+ return(Qtrue);
100
+ #else
101
+ return(Qfalse);
102
+ #endif
103
+ }
104
+
105
+
106
+ /*
107
+ * call-seq:
108
+ * XML::Parser.enabled_debug? => (true|false)
109
+ *
110
+ * Determine whether libxml debugging support is enabled.
111
+ */
112
+ VALUE
113
+ ruby_xml_parser_enabled_debug_q(VALUE class) {
114
+ #ifdef LIBXML_DEBUG_ENABLED
115
+ return(Qtrue);
116
+ #else
117
+ return(Qfalse);
118
+ #endif
119
+ }
120
+
121
+
122
+ /*
123
+ * call-seq:
124
+ * XML::Parser.enabled_docbook? => (true|false)
125
+ *
126
+ * Determine whether libxml docbook support is enabled.
127
+ */
128
+ VALUE
129
+ ruby_xml_parser_enabled_docbook_q(VALUE class) {
130
+ #ifdef LIBXML_DOCB_ENABLED
131
+ return(Qtrue);
132
+ #else
133
+ return(Qfalse);
134
+ #endif
135
+ }
136
+
137
+
138
+ /*
139
+ * call-seq:
140
+ * XML::Parser.enabled_ftp? => (true|false)
141
+ *
142
+ * Determine whether libxml ftp client support is enabled.
143
+ */
144
+ VALUE
145
+ ruby_xml_parser_enabled_ftp_q(VALUE class) {
146
+ #ifdef LIBXML_FTP_ENABLED
147
+ return(Qtrue);
148
+ #else
149
+ return(Qfalse);
150
+ #endif
151
+ }
152
+
153
+
154
+ /*
155
+ * call-seq:
156
+ * XML::Parser.enabled_http? => (true|false)
157
+ *
158
+ * Determine whether libxml http client support is enabled.
159
+ */
160
+ VALUE
161
+ ruby_xml_parser_enabled_http_q(VALUE class) {
162
+ #ifdef LIBXML_HTTP_ENABLED
163
+ return(Qtrue);
164
+ #else
165
+ return(Qfalse);
166
+ #endif
167
+ }
168
+
169
+
170
+ /*
171
+ * call-seq:
172
+ * XML::Parser.enabled_html? => (true|false)
173
+ *
174
+ * Determine whether libxml html support is enabled.
175
+ */
176
+ VALUE
177
+ ruby_xml_parser_enabled_html_q(VALUE class) {
178
+ #ifdef LIBXML_HTML_ENABLED
179
+ return(Qtrue);
180
+ #else
181
+ return(Qfalse);
182
+ #endif
183
+ }
184
+
185
+
186
+ /*
187
+ * call-seq:
188
+ * XML::Parser.enabled_iconv? => (true|false)
189
+ *
190
+ * Determine whether libxml iconv support is enabled.
191
+ */
192
+ VALUE
193
+ ruby_xml_parser_enabled_iconv_q(VALUE class) {
194
+ #ifdef LIBXML_ICONV_ENABLED
195
+ return(Qtrue);
196
+ #else
197
+ return(Qfalse);
198
+ #endif
199
+ }
200
+
201
+
202
+ /*
203
+ * call-seq:
204
+ * XML::Parser.enabled_memory_debug? => (true|false)
205
+ *
206
+ * Determine whether libxml memory location debugging support
207
+ * is enabled.
208
+ */
209
+ VALUE
210
+ ruby_xml_parser_enabled_memory_debug_location_q(VALUE class) {
211
+ #ifdef DEBUG_MEMORY_LOCATION
212
+ return(Qtrue);
213
+ #else
214
+ return(Qfalse);
215
+ #endif
216
+ }
217
+
218
+
219
+ /*
220
+ * call-seq:
221
+ * XML::Parser.enabled_catalog? => (true|false)
222
+ *
223
+ * Determine whether libxml regular expression support is enabled.
224
+ */
225
+ VALUE
226
+ ruby_xml_parser_enabled_regexp_q(VALUE class) {
227
+ #ifdef LIBXML_REGEXP_ENABLED
228
+ return(Qtrue);
229
+ #else
230
+ return(Qfalse);
231
+ #endif
232
+ }
233
+
234
+
235
+ /*
236
+ * call-seq:
237
+ * XML::Parser.enabled_schemas? => (true|false)
238
+ *
239
+ * Determine whether libxml schema support is enabled.
240
+ */
241
+ VALUE
242
+ ruby_xml_parser_enabled_schemas_q(VALUE class) {
243
+ #ifdef LIBXML_SCHEMAS_ENABLED
244
+ return(Qtrue);
245
+ #else
246
+ return(Qfalse);
247
+ #endif
248
+ }
249
+
250
+
251
+ /*
252
+ * call-seq:
253
+ * XML::Parser.enabled_thread? => (true|false)
254
+ *
255
+ * Determine whether libxml thread-safe semantics support
256
+ * is enabled (I think?).
257
+ */
258
+ VALUE
259
+ ruby_xml_parser_enabled_thread_q(VALUE class) {
260
+ #ifdef LIBXML_THREAD_ENABLED
261
+ return(Qtrue);
262
+ #else
263
+ return(Qfalse);
264
+ #endif
265
+ }
266
+
267
+
268
+ /*
269
+ * call-seq:
270
+ * XML::Parser.enabled_catalog? => (true|false)
271
+ *
272
+ * Determine whether libxml unicode support is enabled.
273
+ */
274
+ VALUE
275
+ ruby_xml_parser_enabled_unicode_q(VALUE class) {
276
+ #ifdef LIBXML_UNICODE_ENABLED
277
+ return(Qtrue);
278
+ #else
279
+ return(Qfalse);
280
+ #endif
281
+ }
282
+
283
+
284
+ /*
285
+ * call-seq:
286
+ * XML::Parser.enabled_catalog? => (true|false)
287
+ *
288
+ * Determine whether libxml xinclude support is enabled.
289
+ */
290
+ VALUE
291
+ ruby_xml_parser_enabled_xinclude_q(VALUE class) {
292
+ #ifdef LIBXML_XINCLUDE_ENABLED
293
+ return(Qtrue);
294
+ #else
295
+ return(Qfalse);
296
+ #endif
297
+ }
298
+
299
+
300
+ /*
301
+ * call-seq:
302
+ * XML::Parser.enabled_catalog? => (true|false)
303
+ *
304
+ * Determine whether libxml xpath support is enabled.
305
+ */
306
+ VALUE
307
+ ruby_xml_parser_enabled_xpath_q(VALUE class) {
308
+ #ifdef LIBXML_XPATH_ENABLED
309
+ return(Qtrue);
310
+ #else
311
+ return(Qfalse);
312
+ #endif
313
+ }
314
+
315
+
316
+ /*
317
+ * call-seq:
318
+ * XML::Parser.enabled_catalog? => (true|false)
319
+ *
320
+ * Determine whether libxml xpointer support is enabled.
321
+ */
322
+ VALUE
323
+ ruby_xml_parser_enabled_xpointer_q(VALUE class) {
324
+ #ifdef LIBXML_XPTR_ENABLED
325
+ return(Qtrue);
326
+ #else
327
+ return(Qfalse);
328
+ #endif
329
+ }
330
+
331
+
332
+ /*
333
+ * call-seq:
334
+ * XML::Parser.enabled_catalog? => (true|false)
335
+ *
336
+ * Determine whether libxml zlib support is enabled.
337
+ */
338
+ VALUE
339
+ ruby_xml_parser_enabled_zlib_q(VALUE class) {
340
+ #ifdef HAVE_ZLIB_H
341
+ return(Qtrue);
342
+ #else
343
+ return(Qfalse);
344
+ #endif
345
+ }
346
+
347
+
348
+ /*
349
+ * call-seq:
350
+ * XML::Parser.debug_entities => (true|false)
351
+ *
352
+ * Determine whether included-entity debugging is enabled.
353
+ * (Requires Libxml to be compiled with debugging support)
354
+ */
355
+ VALUE
356
+ ruby_xml_parser_debug_entities_get(VALUE class) {
357
+ #ifdef LIBXML_DEBUG_ENABLED
358
+ if (xmlParserDebugEntities)
359
+ return(Qtrue);
360
+ else
361
+ return(Qfalse);
362
+ #else
363
+ rb_warn("libxml was compiled with debugging turned off");
364
+ return(Qfalse);
365
+ #endif
366
+ }
367
+
368
+
369
+ /*
370
+ * call-seq:
371
+ * XML::Parser.debug_entities = true|false
372
+ *
373
+ * Enable or disable included-entity debugging.
374
+ * (Requires Libxml to be compiled with debugging support)
375
+ */
376
+ VALUE
377
+ ruby_xml_parser_debug_entities_set(VALUE class, VALUE bool) {
378
+ #ifdef LIBXML_DEBUG_ENABLED
379
+ if (TYPE(bool) == T_FALSE) {
380
+ xmlParserDebugEntities = 0;
381
+ return(Qfalse);
382
+ } else {
383
+ xmlParserDebugEntities = 1;
384
+ return(Qtrue);
385
+ }
386
+ #else
387
+ rb_warn("libxml was compiled with debugging turned off");
388
+ #endif
389
+ }
390
+
391
+
392
+ /*
393
+ * call-seq:
394
+ * XML::Parser.default_keep_blanks => (true|false)
395
+ *
396
+ * Determine whether parsers retain whitespace by default.
397
+ */
398
+ VALUE
399
+ ruby_xml_parser_default_keep_blanks_get(VALUE class) {
400
+ if (xmlKeepBlanksDefaultValue)
401
+ return(Qtrue);
402
+ else
403
+ return(Qfalse);
404
+ }
405
+
406
+
407
+ /*
408
+ * call-seq:
409
+ * XML::Parser.default_keep_blanks = true|false
410
+ *
411
+ * Controls whether parsers retain whitespace by default.
412
+ */
413
+ VALUE
414
+ ruby_xml_parser_default_keep_blanks_set(VALUE class, VALUE bool) {
415
+ if (TYPE(bool) == T_FALSE) {
416
+ xmlKeepBlanksDefaultValue = 0;
417
+ return(Qfalse);
418
+ } else if (TYPE(bool) == T_TRUE) {
419
+ xmlKeepBlanksDefaultValue = 1;
420
+ return(Qtrue);
421
+ } else {
422
+ rb_raise(rb_eArgError, "invalid argument, must be a boolean");
423
+ }
424
+ }
425
+
426
+
427
+ /*
428
+ * call-seq:
429
+ * XML::Parser.default_load_external_dtd => (true|false)
430
+ *
431
+ * Determine whether parsers load external DTDs by default.
432
+ */
433
+ VALUE
434
+ ruby_xml_parser_default_load_external_dtd_get(VALUE class) {
435
+ if (xmlSubstituteEntitiesDefaultValue)
436
+ return(Qtrue);
437
+ else
438
+ return(Qfalse);
439
+ }
440
+
441
+
442
+ /*
443
+ * call-seq:
444
+ * XML::Parser.default_load_external_dtd = true|false
445
+ *
446
+ * Controls whether parsers load external DTDs by default.
447
+ */
448
+ VALUE
449
+ ruby_xml_parser_default_load_external_dtd_set(VALUE class, VALUE bool) {
450
+ if (TYPE(bool) == T_FALSE) {
451
+ xmlLoadExtDtdDefaultValue = 0;
452
+ return(Qfalse);
453
+ } else {
454
+ xmlLoadExtDtdDefaultValue = 1;
455
+ return(Qtrue);
456
+ }
457
+ }
458
+
459
+
460
+ /*
461
+ * call-seq:
462
+ * XML::Parser.default_line_numbers => (true|false)
463
+ *
464
+ * Determine whether parsers retain line-numbers by default.
465
+ */
466
+ VALUE
467
+ ruby_xml_parser_default_line_numbers_get(VALUE class) {
468
+ if (xmlLineNumbersDefaultValue)
469
+ return(Qtrue);
470
+ else
471
+ return(Qfalse);
472
+ }
473
+
474
+
475
+ /*
476
+ * call-seq:
477
+ * XML::Parser.default_line_numbers = true|false
478
+ *
479
+ * Controls whether parsers retain line-numbers by default.
480
+ */
481
+ VALUE
482
+ ruby_xml_parser_default_line_numbers_set(VALUE class, VALUE bool) {
483
+ if (TYPE(bool) == T_FALSE) {
484
+ xmlLineNumbersDefault(0);
485
+ return(Qfalse);
486
+ } else {
487
+ xmlLineNumbersDefault(1);
488
+ return(Qtrue);
489
+ }
490
+ }
491
+
492
+
493
+ /*
494
+ * call-seq:
495
+ * XML::Parser.default_pedantic_parser => (true|false)
496
+ *
497
+ * Determine whether parsers are pedantic by default.
498
+ */
499
+ VALUE
500
+ ruby_xml_parser_default_pedantic_parser_get(VALUE class) {
501
+ if (xmlPedanticParserDefaultValue)
502
+ return(Qtrue);
503
+ else
504
+ return(Qfalse);
505
+ }
506
+
507
+
508
+ /*
509
+ * call-seq:
510
+ * XML::Parser.default_pedantic_parser = true|false
511
+ *
512
+ * Controls whether parsers are pedantic by default.
513
+ */
514
+ VALUE
515
+ ruby_xml_parser_default_pedantic_parser_set(VALUE class, VALUE bool) {
516
+ if (TYPE(bool) == T_FALSE) {
517
+ xmlPedanticParserDefault(0);
518
+ return(Qfalse);
519
+ } else {
520
+ xmlPedanticParserDefault(1);
521
+ return(Qtrue);
522
+ }
523
+ }
524
+
525
+
526
+ /*
527
+ * call-seq:
528
+ * XML::Parser.default_substitute_entities => (true|false)
529
+ *
530
+ * Determine whether parsers perform inline entity substitution
531
+ * (for external entities) by default.
532
+ */
533
+ VALUE
534
+ ruby_xml_parser_default_substitute_entities_get(VALUE class) {
535
+ if (xmlSubstituteEntitiesDefaultValue)
536
+ return(Qtrue);
537
+ else
538
+ return(Qfalse);
539
+ }
540
+
541
+
542
+ /*
543
+ * call-seq:
544
+ * XML::Parser.default_substitute_entities = true|false
545
+ *
546
+ * Controls whether parsers perform inline entity substitution
547
+ * (for external entities) by default.
548
+ */
549
+ VALUE
550
+ ruby_xml_parser_default_substitute_entities_set(VALUE class, VALUE bool) {
551
+ if (TYPE(bool) == T_FALSE) {
552
+ xmlSubstituteEntitiesDefault(0);
553
+ return(Qfalse);
554
+ } else {
555
+ xmlSubstituteEntitiesDefault(1);
556
+ return(Qtrue);
557
+ }
558
+ }
559
+
560
+
561
+ /*
562
+ * call-seq:
563
+ * XML::Parser.default_tree_indent_string => "string"
564
+ *
565
+ * Obtain the default string used by parsers to indent the XML tree
566
+ * for output.
567
+ */
568
+ VALUE
569
+ ruby_xml_parser_default_tree_indent_string_get(VALUE class) {
570
+ if (xmlTreeIndentString == NULL)
571
+ return(Qnil);
572
+ else
573
+ return(rb_str_new2(xmlTreeIndentString));
574
+ }
575
+
576
+
577
+ /*
578
+ * call-seq:
579
+ * XML::Parser.default_tree_indent_string = "string"
580
+ *
581
+ * Set the default string used by parsers to indent the XML tree
582
+ * for output.
583
+ */
584
+ VALUE
585
+ ruby_xml_parser_default_tree_indent_string_set(VALUE class, VALUE string) {
586
+ Check_Type(string, T_STRING);
587
+ xmlTreeIndentString = ruby_strdup(StringValuePtr(string));
588
+ return(string);
589
+ }
590
+
591
+
592
+ /*
593
+ * call-seq:
594
+ * XML::Parser.default_validity_checking => (true|false)
595
+ *
596
+ * Determine whether parsers perform XML validation by default.
597
+ */
598
+ VALUE
599
+ ruby_xml_parser_default_validity_checking_get(VALUE class) {
600
+ if (xmlDoValidityCheckingDefaultValue)
601
+ return(Qtrue);
602
+ else
603
+ return(Qfalse);
604
+ }
605
+
606
+
607
+ /*
608
+ * call-seq:
609
+ * XML::Parser.default_validity_checking = true|false
610
+ *
611
+ * Controls whether parsers perform XML validation by default.
612
+ */
613
+ VALUE
614
+ ruby_xml_parser_default_validity_checking_set(VALUE class, VALUE bool) {
615
+ if (TYPE(bool) == T_FALSE) {
616
+ xmlDoValidityCheckingDefaultValue = 0;
617
+ return(Qfalse);
618
+ } else {
619
+ xmlDoValidityCheckingDefaultValue = 1;
620
+ return(Qtrue);
621
+ }
622
+ }
623
+
624
+
625
+ /*
626
+ * call-seq:
627
+ * XML::Parser.default_warnings => (true|false)
628
+ *
629
+ * Determine whether parsers output warnings by default.
630
+ */
631
+ VALUE
632
+ ruby_xml_parser_default_warnings_get(VALUE class) {
633
+ if (xmlGetWarningsDefaultValue)
634
+ return(Qtrue);
635
+ else
636
+ return(Qfalse);
637
+ }
638
+
639
+
640
+ /*
641
+ * call-seq:
642
+ * XML::Parser.default_warnings = true|false
643
+ *
644
+ * Controls whether parsers output warnings by default.
645
+ */
646
+ VALUE
647
+ ruby_xml_parser_default_warnings_set(VALUE class, VALUE bool) {
648
+ if (TYPE(bool) == T_FALSE) {
649
+ xmlGetWarningsDefaultValue = 0;
650
+ return(Qfalse);
651
+ } else {
652
+ xmlGetWarningsDefaultValue = 1;
653
+ return(Qtrue);
654
+ }
655
+ }
656
+
657
+
658
+ /*
659
+ * call-seq:
660
+ * XML::Parser.default_compression => (true|false)
661
+ *
662
+ * Determine whether parsers use Zlib compression by default
663
+ * (requires libxml to be compiled with Zlib support).
664
+ */
665
+ VALUE
666
+ ruby_xml_parser_default_compression_get(VALUE class) {
667
+ #ifdef HAVE_ZLIB_H
668
+ return(INT2FIX(xmlGetCompressMode()));
669
+ #else
670
+ rb_warn("libxml was compiled without zlib support");
671
+ return(Qfalse);
672
+ #endif
673
+ }
674
+
675
+
676
+ /*
677
+ * call-seq:
678
+ * XML::Parser.default_compression = true|false
679
+ *
680
+ * Controls whether parsers use Zlib compression by default
681
+ * (requires libxml to be compiled with Zlib support).
682
+ */
683
+ VALUE
684
+ ruby_xml_parser_default_compression_set(VALUE class, VALUE num) {
685
+ #ifdef HAVE_ZLIB_H
686
+ Check_Type(num, T_FIXNUM);
687
+ xmlSetCompressMode(FIX2INT(num));
688
+ return(num);
689
+ #else
690
+ rb_warn("libxml was compiled without zlib support");
691
+ return(Qfalse);
692
+ #endif
693
+ }
694
+
695
+
696
+ /*
697
+ * call-seq:
698
+ * XML::Parser.features => ["feature", ..., "feature"]
699
+ *
700
+ * Obtains an array of strings representing features supported
701
+ * (and enabled) by the installed libxml.
702
+ */
703
+ VALUE
704
+ ruby_xml_parser_features(VALUE class) {
705
+ VALUE arr, str;
706
+ int i, len = MAX_LIBXML_FEATURES_LEN;
707
+ char **list = NULL;
708
+
709
+ list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
710
+ MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
711
+
712
+ arr = rb_ary_new();
713
+ if (xmlGetFeaturesList(&len, (const char **)list) == -1)
714
+ return Qnil;
715
+
716
+ for (i = 0; i < len; i++) {
717
+ str = rb_str_new2((const char *)list[i]);
718
+ rb_gc_unregister_address(&str);
719
+ rb_ary_push(arr, str);
720
+ }
721
+
722
+ if (len == MAX_LIBXML_FEATURES_LEN)
723
+ rb_warn("Please contact libxml-devel@rubyforge.org and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
724
+
725
+ ruby_xfree(list);
726
+ return(arr);
727
+ }
728
+
729
+
730
+ /*
731
+ * call-seq:
732
+ * parser.filename => "filename"
733
+ *
734
+ * Obtain the filename this parser will read from.
735
+ */
736
+ VALUE
737
+ ruby_xml_parser_filename_get(VALUE self) {
738
+ ruby_xml_parser *rxp;
739
+ rx_file_data *data;
740
+
741
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
742
+ if (rxp->data == NULL)
743
+ return(Qnil);
744
+
745
+ if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_FILE)
746
+ return(Qnil);
747
+
748
+ data = (rx_file_data *)rxp->data;
749
+ return(data->filename);
750
+ }
751
+
752
+
753
+ /*
754
+ * call-seq:
755
+ * parser.filename = "filename"
756
+ *
757
+ * Set the filename this parser will read from.
758
+ */
759
+ VALUE
760
+ ruby_xml_parser_filename_set(VALUE self, VALUE filename) {
761
+ ruby_xml_parser *rxp;
762
+ ruby_xml_parser_context *rxpc;
763
+ rx_file_data *data;
764
+
765
+ Check_Type(filename, T_STRING);
766
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
767
+
768
+ if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
769
+ if (rxp->data != NULL)
770
+ rb_fatal("crap, this should be null");
771
+
772
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_FILE;
773
+ data = ALLOC(rx_file_data);
774
+ rxp->data = data;
775
+ } else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_FILE) {
776
+ return(Qnil);
777
+ }
778
+
779
+ rxp->ctxt = ruby_xml_parser_context_new3();
780
+ data = (rx_file_data *)rxp->data;
781
+ data->filename = filename;
782
+
783
+ Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
784
+ rxpc->ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
785
+ if (rxpc->ctxt == NULL)
786
+ rb_sys_fail(StringValuePtr(filename));
787
+
788
+ return(data->filename);
789
+ }
790
+
791
+
792
+ void
793
+ ruby_xml_parser_free(ruby_xml_parser *rxp) {
794
+ void *data;
795
+
796
+ ruby_xml_parser_count--;
797
+ if (ruby_xml_parser_count == 0)
798
+ xmlCleanupParser();
799
+
800
+ switch(rxp->data_type) {
801
+ case RUBY_LIBXML_SRC_TYPE_NULL:
802
+ break;
803
+ case RUBY_LIBXML_SRC_TYPE_FILE:
804
+ data = (void *)(rx_file_data *)rxp->data;
805
+ free((rx_file_data *)data);
806
+ break;
807
+ case RUBY_LIBXML_SRC_TYPE_STRING:
808
+ data = (void *)(rx_string_data *)rxp->data;
809
+ free((rx_string_data *)data);
810
+ break;
811
+ case RUBY_LIBXML_SRC_TYPE_IO:
812
+ data = (void *)(rx_io_data *)rxp->data;
813
+ free((rx_io_data *)data);
814
+ break;
815
+ default:
816
+ rb_fatal("Unknown data type, %d", rxp->data_type);
817
+ }
818
+
819
+ free(rxp);
820
+ }
821
+
822
+
823
+ /*
824
+ * call-seq:
825
+ * XML::Parser.indent_tree_output => (true|false)
826
+ *
827
+ * Determines whether XML output will be indented
828
+ * (using the string supplied to +default_indent_tree_string+)
829
+ */
830
+ VALUE
831
+ ruby_xml_parser_indent_tree_output_get(VALUE class) {
832
+ if (xmlIndentTreeOutput)
833
+ return(Qtrue);
834
+ else
835
+ return(Qfalse);
836
+ }
837
+
838
+
839
+ /*
840
+ * call-seq:
841
+ * XML::Parser.indent_tree_output = true|false
842
+ *
843
+ * Controls whether XML output will be indented
844
+ * (using the string supplied to +default_indent_tree_string+)
845
+ */
846
+ VALUE
847
+ ruby_xml_parser_indent_tree_output_set(VALUE class, VALUE bool) {
848
+ if (TYPE(bool) == T_TRUE) {
849
+ xmlIndentTreeOutput = 1;
850
+ return(Qtrue);
851
+ } else if (TYPE(bool) == T_FALSE) {
852
+ xmlIndentTreeOutput = 0;
853
+ return(Qfalse);
854
+ } else {
855
+ rb_raise(rb_eArgError, "invalid argument, must be boolean");
856
+ }
857
+ }
858
+
859
+
860
+ /*
861
+ * call-seq:
862
+ * parser.io => IO
863
+ *
864
+ * Obtain the IO instance this parser works with.
865
+ */
866
+ VALUE
867
+ ruby_xml_parser_io_get(VALUE self, VALUE io) {
868
+ ruby_xml_parser *rxp;
869
+ rx_io_data *data;
870
+
871
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
872
+
873
+ if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL ||
874
+ rxp->data_type != RUBY_LIBXML_SRC_TYPE_IO ||
875
+ rxp->data == NULL)
876
+ return(Qnil);
877
+
878
+ data = (rx_io_data *)rxp->data;
879
+
880
+ return(data->io);
881
+ }
882
+
883
+
884
+ /*
885
+ * call-seq:
886
+ * parser.io = IO
887
+ *
888
+ * Set the IO instance this parser works with.
889
+ */
890
+ VALUE
891
+ ruby_xml_parser_io_set(VALUE self, VALUE io) {
892
+ ruby_xml_parser *rxp;
893
+ ruby_xml_parser_context *rxpc;
894
+ rx_io_data *data;
895
+ OpenFile *fptr;
896
+ FILE *f;
897
+
898
+ if (!rb_obj_is_kind_of(io, rb_cIO))
899
+ rb_raise(rb_eTypeError, "need an IO object");
900
+
901
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
902
+
903
+ if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
904
+ if (rxp->data != NULL)
905
+ rb_fatal("crap, this should be null");
906
+
907
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_IO;
908
+ data = ALLOC(rx_io_data);
909
+ rxp->data = data;
910
+ } else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_IO) {
911
+ return(Qnil);
912
+ }
913
+
914
+ rxp->ctxt = ruby_xml_parser_context_new3();
915
+ data = (rx_io_data *)rxp->data;
916
+ data->io = io;
917
+
918
+ GetOpenFile(io, fptr);
919
+ rb_io_check_readable(fptr);
920
+ f = GetWriteFile(fptr);
921
+
922
+ Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
923
+ rxpc->ctxt = xmlCreateIOParserCtxt(NULL, NULL,
924
+ (xmlInputReadCallback) ctxtRead,
925
+ NULL, f, XML_CHAR_ENCODING_NONE);
926
+ if (NIL_P(rxpc->ctxt))
927
+ rb_sys_fail(0);
928
+
929
+ return(data->io);
930
+ }
931
+
932
+
933
+ void
934
+ ruby_xml_parser_mark(ruby_xml_parser *rxp) {
935
+ if (rxp == NULL) return;
936
+ if (!NIL_P(rxp->ctxt)) rb_gc_mark(rxp->ctxt);
937
+
938
+ switch(rxp->data_type) {
939
+ case RUBY_LIBXML_SRC_TYPE_NULL:
940
+ break;
941
+ case RUBY_LIBXML_SRC_TYPE_FILE:
942
+ if (!NIL_P(((rx_file_data *)rxp->data)->filename))
943
+ rb_gc_mark(((rx_file_data *)rxp->data)->filename);
944
+ break;
945
+ case RUBY_LIBXML_SRC_TYPE_STRING:
946
+ if (!NIL_P(((rx_string_data *)rxp->data)->str))
947
+ rb_gc_mark(((rx_string_data *)rxp->data)->str);
948
+ break;
949
+ case RUBY_LIBXML_SRC_TYPE_IO:
950
+ if (!NIL_P(((rx_io_data *)rxp->data)->io))
951
+ rb_gc_mark(((rx_io_data *)rxp->data)->io);
952
+ break;
953
+ default:
954
+ rb_fatal("unknown datatype: %d", rxp->data_type);
955
+ }
956
+ }
957
+
958
+
959
+ /*
960
+ * call-seq:
961
+ * XML::Parser.memory_dump => (true|false)
962
+ *
963
+ * Perform a parser memory dump (requires memory debugging
964
+ * support in libxml).
965
+ */
966
+ VALUE
967
+ ruby_xml_parser_memory_dump(VALUE self) {
968
+ #ifdef DEBUG_MEMORY_LOCATION
969
+ xmlMemoryDump();
970
+ return(Qtrue);
971
+ #else
972
+ rb_warn("libxml was compiled without memory debugging support");
973
+ return(Qfalse);
974
+ #endif
975
+ }
976
+
977
+
978
+ /*
979
+ * call-seq:
980
+ * XML::Parser.memory_used => num_bytes
981
+ *
982
+ * Perform a parser memory dump (requires memory debugging
983
+ * support in libxml).
984
+ */
985
+ VALUE
986
+ ruby_xml_parser_memory_used(VALUE self) {
987
+ #ifdef DEBUG_MEMORY_LOCATION
988
+ return(INT2NUM(xmlMemUsed()));
989
+ #else
990
+ rb_warn("libxml was compiled without memory debugging support");
991
+ return(Qfalse);
992
+ #endif
993
+ }
994
+
995
+
996
+ /*
997
+ * call-seq:
998
+ * XML::Parser.new => parser
999
+ *
1000
+ * Create a new parser instance with no pre-determined source.
1001
+ */
1002
+ VALUE
1003
+ ruby_xml_parser_new(VALUE class) {
1004
+ ruby_xml_parser *rxp;
1005
+
1006
+ ruby_xml_parser_count++;
1007
+ rxp = ALLOC(ruby_xml_parser);
1008
+ rxp->ctxt = Qnil;
1009
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_NULL;
1010
+ rxp->data = NULL;
1011
+ rxp->parsed = 0;
1012
+
1013
+ return(Data_Wrap_Struct(class, ruby_xml_parser_mark,
1014
+ ruby_xml_parser_free, rxp));
1015
+ }
1016
+
1017
+
1018
+ /*
1019
+ * call-seq:
1020
+ * XML::Parser.file => parser
1021
+ *
1022
+ * Create a new parser instance that will read the specified file.
1023
+ */
1024
+ VALUE
1025
+ ruby_xml_parser_new_file(VALUE class, VALUE filename) {
1026
+ VALUE obj;
1027
+ ruby_xml_parser *rxp;
1028
+ rx_file_data *data;
1029
+
1030
+ obj = ruby_xml_parser_new(class);
1031
+ Data_Get_Struct(obj, ruby_xml_parser, rxp);
1032
+
1033
+ data = ALLOC(rx_file_data);
1034
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_FILE;
1035
+ rxp->data = data;
1036
+
1037
+ ruby_xml_parser_filename_set(obj, filename);
1038
+
1039
+ return(obj);
1040
+ }
1041
+
1042
+
1043
+ /*
1044
+ * call-seq:
1045
+ * XML::Parser.io => parser
1046
+ *
1047
+ * Create a new parser instance that will read from the
1048
+ * specified IO object.
1049
+ */
1050
+ VALUE
1051
+ ruby_xml_parser_new_io(VALUE class, VALUE io) {
1052
+ VALUE obj;
1053
+ ruby_xml_parser *rxp;
1054
+ rx_io_data *data;
1055
+
1056
+ obj = ruby_xml_parser_new(class);
1057
+ Data_Get_Struct(obj, ruby_xml_parser, rxp);
1058
+
1059
+ data = ALLOC(rx_io_data);
1060
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_IO;
1061
+ rxp->data = data;
1062
+
1063
+ ruby_xml_parser_io_set(obj, io);
1064
+
1065
+ return(obj);
1066
+ }
1067
+
1068
+
1069
+ /*
1070
+ * call-seq:
1071
+ * XML::Parser.string => parser
1072
+ *
1073
+ * Create a new parser instance that will parse the given
1074
+ * string.
1075
+ */
1076
+ VALUE
1077
+ ruby_xml_parser_new_string(VALUE class, VALUE str) {
1078
+ VALUE obj;
1079
+ ruby_xml_parser *rxp;
1080
+ rx_string_data *data;
1081
+
1082
+ obj = ruby_xml_parser_new(class);
1083
+ Data_Get_Struct(obj, ruby_xml_parser, rxp);
1084
+
1085
+ data = ALLOC(rx_string_data);
1086
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_STRING;
1087
+ rxp->data = data;
1088
+
1089
+ ruby_xml_parser_str_set(obj, str);
1090
+
1091
+ return(obj);
1092
+ }
1093
+
1094
+
1095
+ /*
1096
+ * call-seq:
1097
+ * parser.parse => document
1098
+ *
1099
+ * Parse the input XML and create an XML::Document with
1100
+ * it's content. If an error occurs, XML::Parser::ParseError
1101
+ * is thrown.
1102
+ */
1103
+ VALUE
1104
+ ruby_xml_parser_parse(VALUE self) {
1105
+ ruby_xml_document *rxd;
1106
+ ruby_xml_parser *rxp;
1107
+ ruby_xml_parser_context *rxpc;
1108
+ xmlDocPtr xdp;
1109
+ VALUE doc;
1110
+
1111
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
1112
+
1113
+ switch (rxp->data_type) {
1114
+ case RUBY_LIBXML_SRC_TYPE_NULL:
1115
+ return(Qnil);
1116
+ case RUBY_LIBXML_SRC_TYPE_STRING:
1117
+ case RUBY_LIBXML_SRC_TYPE_FILE:
1118
+ case RUBY_LIBXML_SRC_TYPE_IO:
1119
+ Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
1120
+ if (xmlParseDocument(rxpc->ctxt) == -1) {
1121
+ xmlFreeDoc(rxpc->ctxt->myDoc);
1122
+ rb_raise(eXMLParserParseError, "Document didn't parse");
1123
+ }
1124
+
1125
+ xdp = rxpc->ctxt->myDoc;
1126
+ if (!rxpc->ctxt->wellFormed) {
1127
+ xmlFreeDoc(xdp);
1128
+ xdp = NULL;
1129
+ rb_raise(eXMLParserParseError, "Document did not contain well-formed XML");
1130
+ } else {
1131
+ rxp->parsed = 1;
1132
+ }
1133
+
1134
+ doc = ruby_xml_document_new(cXMLDocument, xdp);
1135
+ Data_Get_Struct(doc, ruby_xml_document, rxd);
1136
+ rxd->is_ptr = 0;
1137
+ rxd->doc = xdp;
1138
+ break;
1139
+ default:
1140
+ rb_fatal("Unknown data type, %d", rxp->data_type);
1141
+ }
1142
+
1143
+ return(doc);
1144
+ }
1145
+
1146
+
1147
+ /*
1148
+ * call-seq:
1149
+ * parser.context => context
1150
+ *
1151
+ * Obtain the XML::Parser::Context associated with this
1152
+ * parser.
1153
+ */
1154
+ VALUE
1155
+ ruby_xml_parser_parser_context_get(VALUE self) {
1156
+ ruby_xml_parser *rxp;
1157
+
1158
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
1159
+ if (rxp->ctxt == Qnil)
1160
+ return(Qnil);
1161
+ else
1162
+ return(rxp->ctxt);
1163
+ }
1164
+
1165
+
1166
+ /*
1167
+ * call-seq:
1168
+ * parser.string => "string"
1169
+ *
1170
+ * Obtain the string this parser works with.
1171
+ */
1172
+ VALUE
1173
+ ruby_xml_parser_str_get(VALUE self) {
1174
+ ruby_xml_parser *rxp;
1175
+ rx_string_data *data;
1176
+
1177
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
1178
+ if (rxp->data == NULL || rxp->data_type != RUBY_LIBXML_SRC_TYPE_STRING)
1179
+ return(Qnil);
1180
+
1181
+ data = (rx_string_data *)rxp->data;
1182
+ return(data->str);
1183
+ }
1184
+
1185
+
1186
+ /*
1187
+ * call-seq:
1188
+ * parser.string = "string"
1189
+ *
1190
+ * Set the string this parser works with.
1191
+ */
1192
+ VALUE
1193
+ ruby_xml_parser_str_set(VALUE self, VALUE str) {
1194
+ ruby_xml_parser *rxp;
1195
+ ruby_xml_parser_context *rxpc;
1196
+ rx_string_data *data;
1197
+
1198
+ Check_Type(str, T_STRING);
1199
+ Data_Get_Struct(self, ruby_xml_parser, rxp);
1200
+
1201
+ if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
1202
+ rxp->data_type = RUBY_LIBXML_SRC_TYPE_STRING;
1203
+ data = ALLOC(rx_string_data);
1204
+ rxp->data = data;
1205
+ } else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_STRING) {
1206
+ return(Qnil);
1207
+ }
1208
+
1209
+ rxp->ctxt = ruby_xml_parser_context_new3();
1210
+ data = (rx_string_data *)rxp->data;
1211
+ data->str = str;
1212
+
1213
+ Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
1214
+ rxpc->ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(data->str), RSTRING(data->str)->len);
1215
+
1216
+ return(data->str);
1217
+ }
1218
+
1219
+
1220
+ /* #define RUBY_XML_PARSER_ENABLED_INIT(func, method) \
1221
+ rb_define_singleton_method(cXMLParser, method, \
1222
+ ruby_xml_parser_enabled_##func##_q, 0); */
1223
+
1224
+ ///#include "cbg.c"
1225
+ ///
1226
+ ///VALUE ruby_register_deb(VALUE self) {
1227
+ /// deb_register_cbg();
1228
+ /// return(Qtrue);
1229
+ ///}
1230
+
1231
+ // Rdoc needs to know
1232
+ #ifdef RDOC_NEVER_DEFINED
1233
+ mXML = rb_define_module("XML");
1234
+ #endif
1235
+
1236
+ void
1237
+ ruby_init_parser(void) {
1238
+
1239
+ cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
1240
+ eXMLParserParseError = rb_define_class_under(cXMLParser, "ParseError",
1241
+ rb_eRuntimeError);
1242
+
1243
+ /* Constants */
1244
+ rb_define_const(cXMLParser, "LIBXML_VERSION",
1245
+ rb_str_new2(LIBXML_DOTTED_VERSION));
1246
+ rb_define_const(cXMLParser, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
1247
+ rb_define_const(cXMLParser, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
1248
+
1249
+ /* Question-esqe Class Methods */
1250
+ /* RDoc won't have them defined by a macro... */
1251
+ rb_define_singleton_method(cXMLParser, "enabled_automata?",
1252
+ ruby_xml_parser_enabled_automata_q, 0);
1253
+ rb_define_singleton_method(cXMLParser, "enabled_c14n?",
1254
+ ruby_xml_parser_enabled_c14n_q, 0);
1255
+ rb_define_singleton_method(cXMLParser, "enabled_catalog?",
1256
+ ruby_xml_parser_enabled_catalog_q, 0);
1257
+ rb_define_singleton_method(cXMLParser, "enabled_debug?",
1258
+ ruby_xml_parser_enabled_debug_q, 0);
1259
+ rb_define_singleton_method(cXMLParser, "enabled_docbook?",
1260
+ ruby_xml_parser_enabled_docbook_q, 0);
1261
+ rb_define_singleton_method(cXMLParser, "enabled_ftp?",
1262
+ ruby_xml_parser_enabled_ftp_q, 0);
1263
+ rb_define_singleton_method(cXMLParser, "enabled_http?",
1264
+ ruby_xml_parser_enabled_http_q, 0);
1265
+ rb_define_singleton_method(cXMLParser, "enabled_html?",
1266
+ ruby_xml_parser_enabled_html_q, 0);
1267
+ rb_define_singleton_method(cXMLParser, "enabled_iconv?",
1268
+ ruby_xml_parser_enabled_iconv_q, 0);
1269
+ rb_define_singleton_method(cXMLParser, "enabled_memory_debug?",
1270
+ ruby_xml_parser_enabled_memory_debug_location_q, 0);
1271
+ rb_define_singleton_method(cXMLParser, "enabled_regexp?",
1272
+ ruby_xml_parser_enabled_regexp_q, 0);
1273
+ rb_define_singleton_method(cXMLParser, "enabled_schemas?",
1274
+ ruby_xml_parser_enabled_schemas_q, 0);
1275
+ rb_define_singleton_method(cXMLParser, "enabled_thread?",
1276
+ ruby_xml_parser_enabled_thread_q, 0);
1277
+ rb_define_singleton_method(cXMLParser, "enabled_unicode?",
1278
+ ruby_xml_parser_enabled_unicode_q, 0);
1279
+ rb_define_singleton_method(cXMLParser, "enabled_xinclude?",
1280
+ ruby_xml_parser_enabled_xinclude_q, 0);
1281
+ rb_define_singleton_method(cXMLParser, "enabled_xpath?",
1282
+ ruby_xml_parser_enabled_xpath_q, 0);
1283
+ rb_define_singleton_method(cXMLParser, "enabled_xpointer?",
1284
+ ruby_xml_parser_enabled_xpointer_q, 0);
1285
+ rb_define_singleton_method(cXMLParser, "enabled_zlib?",
1286
+ ruby_xml_parser_enabled_zlib_q, 0);
1287
+
1288
+ /* Other Class Methods */
1289
+ /// rb_define_singleton_method(cXMLParser, "register_deb",
1290
+ /// ruby_register_deb, 0);
1291
+
1292
+ // TODO Maybe a set of 'xxxx_catalog' aliases might be more Ruby?
1293
+ rb_define_singleton_method(cXMLParser, "catalog_dump",
1294
+ ruby_xml_parser_catalog_dump, 0);
1295
+ rb_define_singleton_method(cXMLParser, "catalog_remove",
1296
+ ruby_xml_parser_catalog_remove, 1);
1297
+ rb_define_singleton_method(cXMLParser, "check_lib_versions",
1298
+ ruby_xml_parser_check_lib_versions, 0);
1299
+
1300
+ // TODO should this be debug_entities_q / debug_entities_set?
1301
+ // should all these default attribute pairs work that way?
1302
+ rb_define_singleton_method(cXMLParser, "debug_entities",
1303
+ ruby_xml_parser_debug_entities_get, 0);
1304
+ rb_define_singleton_method(cXMLParser, "debug_entities=",
1305
+ ruby_xml_parser_debug_entities_set, 1);
1306
+ rb_define_singleton_method(cXMLParser, "default_compression",
1307
+ ruby_xml_parser_default_compression_get, 0);
1308
+ rb_define_singleton_method(cXMLParser, "default_compression=",
1309
+ ruby_xml_parser_default_compression_set, 1);
1310
+ rb_define_singleton_method(cXMLParser, "default_keep_blanks",
1311
+ ruby_xml_parser_default_keep_blanks_get, 0);
1312
+ rb_define_singleton_method(cXMLParser, "default_keep_blanks=",
1313
+ ruby_xml_parser_default_keep_blanks_set, 1);
1314
+ rb_define_singleton_method(cXMLParser, "default_load_external_dtd",
1315
+ ruby_xml_parser_default_load_external_dtd_set, 0);
1316
+ rb_define_singleton_method(cXMLParser, "default_load_external_dtd=",
1317
+ ruby_xml_parser_default_load_external_dtd_get, 1);
1318
+ rb_define_singleton_method(cXMLParser, "default_line_numbers",
1319
+ ruby_xml_parser_default_line_numbers_get, 0);
1320
+ rb_define_singleton_method(cXMLParser, "default_line_numbers=",
1321
+ ruby_xml_parser_default_line_numbers_set, 1);
1322
+ rb_define_singleton_method(cXMLParser, "default_pedantic_parser",
1323
+ ruby_xml_parser_default_pedantic_parser_get, 0);
1324
+ rb_define_singleton_method(cXMLParser, "default_pedantic_parser=",
1325
+ ruby_xml_parser_default_pedantic_parser_set, 1);
1326
+ rb_define_singleton_method(cXMLParser, "default_substitute_entities",
1327
+ ruby_xml_parser_default_substitute_entities_get, 0);
1328
+ rb_define_singleton_method(cXMLParser, "default_substitute_entities=",
1329
+ ruby_xml_parser_default_substitute_entities_set, 1);
1330
+ rb_define_singleton_method(cXMLParser, "default_tree_indent_string",
1331
+ ruby_xml_parser_default_tree_indent_string_get, 0);
1332
+ rb_define_singleton_method(cXMLParser, "default_tree_indent_string=",
1333
+ ruby_xml_parser_default_tree_indent_string_set, 1);
1334
+ rb_define_singleton_method(cXMLParser, "default_validity_checking",
1335
+ ruby_xml_parser_default_validity_checking_get, 0);
1336
+ rb_define_singleton_method(cXMLParser, "default_validity_checking=",
1337
+ ruby_xml_parser_default_validity_checking_set, 1);
1338
+ rb_define_singleton_method(cXMLParser, "default_warnings",
1339
+ ruby_xml_parser_default_warnings_get, 0);
1340
+ rb_define_singleton_method(cXMLParser, "default_warnings=",
1341
+ ruby_xml_parser_default_warnings_set, 1);
1342
+
1343
+ rb_define_singleton_method(cXMLParser, "features", ruby_xml_parser_features, 0);
1344
+ rb_define_singleton_method(cXMLParser, "file", ruby_xml_parser_new_file, 1);
1345
+ rb_define_singleton_method(cXMLParser, "indent_tree_output", ruby_xml_parser_indent_tree_output_get, 0);
1346
+ rb_define_singleton_method(cXMLParser, "indent_tree_output=", ruby_xml_parser_indent_tree_output_set, 1);
1347
+ rb_define_singleton_method(cXMLParser, "io", ruby_xml_parser_new_io, 1);
1348
+ rb_define_singleton_method(cXMLParser, "memory_dump",
1349
+ ruby_xml_parser_memory_dump, 0);
1350
+ rb_define_singleton_method(cXMLParser, "memory_used",
1351
+ ruby_xml_parser_memory_used, 0);
1352
+ rb_define_singleton_method(cXMLParser, "new", ruby_xml_parser_new, 0);
1353
+ rb_define_singleton_method(cXMLParser, "string", ruby_xml_parser_new_string, 1);
1354
+
1355
+ rb_define_method(cXMLParser, "filename", ruby_xml_parser_filename_get, 0);
1356
+ rb_define_method(cXMLParser, "filename=", ruby_xml_parser_filename_set, 1);
1357
+ rb_define_method(cXMLParser, "io", ruby_xml_parser_io_get, 0);
1358
+ rb_define_method(cXMLParser, "io=", ruby_xml_parser_io_set, 1);
1359
+ rb_define_method(cXMLParser, "parse", ruby_xml_parser_parse, 0);
1360
+ rb_define_method(cXMLParser, "parser_context", ruby_xml_parser_parser_context_get, 0);
1361
+ rb_define_method(cXMLParser, "string", ruby_xml_parser_str_get, 0);
1362
+ rb_define_method(cXMLParser, "string=", ruby_xml_parser_str_set, 1);
1363
+ }