libxml-ruby 0.5.1.0 → 0.5.2.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.
Files changed (45) hide show
  1. data/ext/xml/libxml.c +2 -1
  2. data/ext/xml/libxml.h +5 -3
  3. data/ext/xml/libxml.rb +1 -1
  4. data/ext/xml/ruby_xml_attr.c +13 -33
  5. data/ext/xml/ruby_xml_document.c +11 -22
  6. data/ext/xml/ruby_xml_document.h +2 -1
  7. data/ext/xml/ruby_xml_html_parser.c +3 -6
  8. data/ext/xml/ruby_xml_html_parser.h +1 -1
  9. data/ext/xml/ruby_xml_node.c +87 -70
  10. data/ext/xml/ruby_xml_node.h +2 -1
  11. data/ext/xml/ruby_xml_node_set.c +32 -111
  12. data/ext/xml/ruby_xml_node_set.h +5 -11
  13. data/ext/xml/ruby_xml_ns.c +1 -1
  14. data/ext/xml/ruby_xml_ns.h +1 -1
  15. data/ext/xml/ruby_xml_parser.c +11 -11
  16. data/ext/xml/ruby_xml_parser.h +1 -1
  17. data/ext/xml/ruby_xml_parser_context.c +11 -9
  18. data/ext/xml/ruby_xml_parser_context.h +1 -1
  19. data/ext/xml/ruby_xml_sax_parser.c +1 -1
  20. data/ext/xml/ruby_xml_sax_parser.h +1 -1
  21. data/ext/xml/ruby_xml_state.c +114 -0
  22. data/ext/xml/ruby_xml_state.h +11 -0
  23. data/ext/xml/ruby_xml_tree.c +1 -1
  24. data/ext/xml/ruby_xml_tree.h +1 -1
  25. data/ext/xml/ruby_xml_xinclude.c +1 -1
  26. data/ext/xml/ruby_xml_xinclude.h +1 -1
  27. data/ext/xml/ruby_xml_xpath.c +117 -231
  28. data/ext/xml/ruby_xml_xpath.h +4 -5
  29. data/ext/xml/ruby_xml_xpath_context.c +43 -50
  30. data/ext/xml/ruby_xml_xpath_context.h +3 -7
  31. data/ext/xml/ruby_xml_xpath_object.c +246 -0
  32. data/ext/xml/ruby_xml_xpath_object.h +29 -0
  33. data/ext/xml/ruby_xml_xpointer.c +8 -14
  34. data/ext/xml/ruby_xml_xpointer.h +1 -1
  35. data/ext/xml/ruby_xml_xpointer_context.c +1 -1
  36. data/ext/xml/ruby_xml_xpointer_context.h +1 -1
  37. data/ext/xml/sax_parser_callbacks.inc +1 -1
  38. data/tests/tc_xml_document.rb +5 -4
  39. data/tests/tc_xml_html_parser.rb +7 -4
  40. data/tests/tc_xml_node.rb +6 -5
  41. data/tests/tc_xml_node_set.rb +2 -2
  42. data/tests/tc_xml_node_set2.rb +3 -3
  43. data/tests/tc_xml_xpath.rb +3 -3
  44. data/tests/tc_xml_xpointer.rb +2 -2
  45. metadata +16 -10
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node.h 138 2007-08-29 18:00:35Z danj $ */
1
+ /* $Id: ruby_xml_node.h 189 2007-09-26 15:04:47Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -18,6 +18,7 @@ VALUE
18
18
  ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode);
19
19
 
20
20
  void ruby_xml_node_free(ruby_xml_node *rxn);
21
+ void ruby_xml_node_mark_common(xmlNodePtr n);
21
22
  void ruby_init_xml_node(void);
22
23
  VALUE ruby_xml_node_child_set(VALUE self, VALUE obj);
23
24
  VALUE ruby_xml_node_name_get(VALUE self);
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node_set.c 138 2007-08-29 18:00:35Z danj $ */
1
+ /* $Id: ruby_xml_node_set.c 192 2007-10-05 15:13:17Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -23,21 +23,15 @@ VALUE cXMLNodeSet;
23
23
  */
24
24
  VALUE
25
25
  ruby_xml_node_set_to_a(VALUE self) {
26
- int i;
27
26
  ruby_xml_node_set *rxnset;
28
- VALUE nodeobj, set_ary;
27
+ VALUE r;
29
28
 
30
29
  Data_Get_Struct(self, ruby_xml_node_set, rxnset);
31
-
32
- set_ary = rb_ary_new();
33
- if (!((rxnset->node_set == NULL) || (rxnset->node_set->nodeNr == 0))) {
34
- for (i = 0; i < rxnset->node_set->nodeNr; i++) {
35
- nodeobj = ruby_xml_node2_wrap(cXMLNode, rxnset->node_set->nodeTab[i]);
36
- rb_ary_push(set_ary, nodeobj);
37
- }
38
- }
39
-
40
- return(set_ary);
30
+ r=ruby_xml_xpath_object_to_a(rxnset->rxpop);
31
+ #ifdef NODE_DEBUG
32
+ fprintf(stderr,"node_set_to_a %s\n",rb_str2cstr(rb_ary_to_s(r),0));
33
+ #endif
34
+ return r;
41
35
  }
42
36
 
43
37
 
@@ -49,27 +43,10 @@ ruby_xml_node_set_to_a(VALUE self) {
49
43
  */
50
44
  VALUE
51
45
  ruby_xml_node_set_each(VALUE self) {
52
- int i;
53
46
  ruby_xml_node_set *rxnset;
54
- VALUE nodeobj;
55
47
 
56
48
  Data_Get_Struct(self, ruby_xml_node_set, rxnset);
57
-
58
- if (rxnset->node_set == NULL)
59
- return(Qnil);
60
-
61
- for (i = 0; i < rxnset->node_set->nodeNr; i++) {
62
- switch(rxnset->node_set->nodeTab[i]->type) {
63
- case XML_ATTRIBUTE_NODE:
64
- nodeobj = ruby_xml_attr_wrap(cXMLAttr, (xmlAttrPtr)rxnset->node_set->nodeTab[i]);
65
- break;
66
- default:
67
- nodeobj = ruby_xml_node2_wrap(cXMLNode, rxnset->node_set->nodeTab[i]);
68
- }
69
-
70
- rb_yield(nodeobj);
71
- }
72
- return(self);
49
+ return ruby_xml_xpath_object_each(rxnset->rxpop);
73
50
  }
74
51
 
75
52
 
@@ -82,8 +59,9 @@ ruby_xml_node_set_each(VALUE self) {
82
59
  VALUE
83
60
  ruby_xml_node_set_empty_q(VALUE self) {
84
61
  ruby_xml_node_set *rxnset;
85
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
86
- return ( rxnset->node_set == NULL || rxnset->node_set->nodeNr <= 0 ) ? Qtrue : Qfalse;
62
+
63
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
64
+ return ruby_xml_xpath_object_empty_q(rxnset->rxpop);
87
65
  }
88
66
 
89
67
 
@@ -95,50 +73,12 @@ ruby_xml_node_set_empty_q(VALUE self) {
95
73
  */
96
74
  VALUE
97
75
  ruby_xml_node_set_first(VALUE self) {
98
- ruby_xml_node_set *rxnset;
99
- VALUE nodeobj;
76
+ ruby_xml_node_set *rxnset;
100
77
 
101
78
  Data_Get_Struct(self, ruby_xml_node_set, rxnset);
102
-
103
- if (rxnset->node_set == NULL || rxnset->node_set->nodeNr < 1)
104
- return(Qnil);
105
-
106
- switch(rxnset->node_set->nodeTab[0]->type) {
107
- case XML_ATTRIBUTE_NODE:
108
- nodeobj = ruby_xml_attr_wrap(cXMLAttr, (xmlAttrPtr)rxnset->node_set->nodeTab[0]);
109
- break;
110
- default:
111
- nodeobj = ruby_xml_node2_wrap(cXMLNode, rxnset->node_set->nodeTab[0]);
112
- }
113
-
114
- return(nodeobj);
79
+ return ruby_xml_xpath_object_first(rxnset->rxpop);
115
80
  }
116
81
 
117
-
118
- void
119
- ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
120
- void *data;
121
-
122
- switch(rxnset->data_type) {
123
- case RUBY_LIBXML_SRC_TYPE_NULL:
124
- break;
125
- case RUBY_LIBXML_SRC_TYPE_XPATH:
126
- data = (void*)(rx_xpath_data *)rxnset->data;
127
- free((rx_xpath_data *)data);
128
- default:
129
- rb_fatal("Unknown data type, %d", rxnset->data_type);
130
- }
131
-
132
- /* Don't need to free the node set because the nodeset is a child of
133
- the XPath object that created the set.
134
- if (rxnset->node_set != NULL)
135
- xmlXPathFreeNodeSet(rxnset->node_set);
136
- */
137
-
138
- free(rxnset);
139
- }
140
-
141
-
142
82
  /*
143
83
  * call-seq:
144
84
  * nodeset.length => num
@@ -148,45 +88,40 @@ ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
148
88
  VALUE
149
89
  ruby_xml_node_set_length(VALUE self) {
150
90
  ruby_xml_node_set *rxnset;
91
+
151
92
  Data_Get_Struct(self, ruby_xml_node_set, rxnset);
152
- if (rxnset->node_set == NULL)
153
- return(INT2FIX(0));
154
- else
155
- return(INT2NUM(rxnset->node_set->nodeNr));
93
+ return ruby_xml_xpath_object_length(rxnset->rxpop);
156
94
  }
157
95
 
158
96
 
159
97
  static void
160
98
  ruby_xml_node_set_mark(ruby_xml_node_set *rxnset) {
161
- if (rxnset == NULL) return;
162
- if (!NIL_P(rxnset->xd)) rb_gc_mark(rxnset->xd);
163
- if (!NIL_P(rxnset->xpath)) rb_gc_mark(rxnset->xpath);
99
+ if (!NIL_P(rxnset->rxpop)) rb_gc_mark(rxnset->rxpop);
164
100
  }
165
101
 
102
+ static void
103
+ ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
104
+ free(rxnset);
105
+ }
166
106
 
167
107
  VALUE
168
- ruby_xml_node_set_new(VALUE class, VALUE xd, VALUE xpath,
169
- xmlNodeSetPtr node_set) {
108
+ ruby_xml_node_set_new(VALUE class, VALUE rxpop)
109
+ {
170
110
  ruby_xml_node_set *rxnset;
171
-
172
111
  rxnset = ALLOC(ruby_xml_node_set);
173
- rxnset->node_set = node_set;
174
- rxnset->data = NULL;
175
- rxnset->data_type = RUBY_LIBXML_SRC_TYPE_NULL;
176
- rxnset->xd = xd;
177
- rxnset->xpath = xpath;
178
- return(Data_Wrap_Struct(class, ruby_xml_node_set_mark,
179
- ruby_xml_node_set_free, rxnset));
112
+ rxnset->rxpop=rxpop;
113
+ return Data_Wrap_Struct(class,
114
+ ruby_xml_node_set_mark,
115
+ ruby_xml_node_set_free,
116
+ rxnset);
180
117
  }
181
118
 
182
-
183
119
  VALUE
184
- ruby_xml_node_set_new2(VALUE xd, VALUE xpath,
185
- xmlNodeSetPtr node_set) {
186
- return(ruby_xml_node_set_new(cXMLNodeSet, xd, xpath, node_set));
120
+ ruby_xml_node_set_new2(VALUE rxpop)
121
+ {
122
+ return ruby_xml_node_set_new(cXMLNodeSet,rxpop);
187
123
  }
188
124
 
189
-
190
125
  /*
191
126
  * call-seq:
192
127
  * nodeset.xpath => xpath
@@ -195,13 +130,7 @@ ruby_xml_node_set_new2(VALUE xd, VALUE xpath,
195
130
  */
196
131
  VALUE
197
132
  ruby_xml_node_set_xpath_get(VALUE self) {
198
- ruby_xml_node_set *rxnset;
199
-
200
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
201
- if (NIL_P(rxnset->xpath))
202
- return(Qnil);
203
- else
204
- return(rxnset->xpath);
133
+ rb_raise(rb_eRuntimeError,"xpath retrival is no longer supported");
205
134
  }
206
135
 
207
136
 
@@ -214,15 +143,7 @@ ruby_xml_node_set_xpath_get(VALUE self) {
214
143
  */
215
144
  VALUE
216
145
  ruby_xml_node_set_xpath_data_get(VALUE self) {
217
- ruby_xml_node_set *rxnset;
218
- rx_xpath_data *rxxpd;
219
-
220
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
221
- if (rxnset->data_type != RUBY_LIBXML_SRC_TYPE_XPATH)
222
- return(Qnil);
223
-
224
- rxxpd = (rx_xpath_data *)rxnset->data;
225
- return(rxxpd->ctxt);
146
+ rb_raise(rb_eRuntimeError,"xpath data retrival is no longer supported");
226
147
  }
227
148
 
228
149
  // Rdoc needs to know
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node_set.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_node_set.h 183 2007-09-21 14:09:52Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -8,19 +8,13 @@
8
8
  extern VALUE cXMLNodeSet;
9
9
 
10
10
  typedef struct ruby_xml_node_set {
11
- xmlNodeSetPtr node_set;
12
- VALUE xd;
13
- VALUE xpath;
14
- int data_type;
15
- void *data;
11
+ VALUE rxpop;
16
12
  } ruby_xml_node_set;
17
13
 
18
- void ruby_xml_node_set_free(ruby_xml_node_set *rxnset);
19
14
  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);
15
+ VALUE ruby_xml_node_set_new(VALUE class, VALUE xpop);
16
+ VALUE ruby_xml_node_set_new2(VALUE xpop);
24
17
  VALUE ruby_xml_node_set_each(VALUE self);
18
+ VALUE ruby_xml_node_set_first(VALUE self);
25
19
 
26
20
  #endif
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_ns.c 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_ns.c 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_ns.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_ns.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,5 +1,4 @@
1
- /* $Id: ruby_xml_parser.c 138 2007-08-29 18:00:35Z danj $ */
2
- /* $Id: ruby_xml_parser.c 138 2007-08-29 18:00:35Z danj $ */
1
+ /* $Id: ruby_xml_parser.c 192 2007-10-05 15:13:17Z danj $ */
3
2
 
4
3
  /* Please see the LICENSE file for copyright and distribution information */
5
4
 
@@ -9,7 +8,6 @@
9
8
  static VALUE libxml_xmlRubyErrorProc = Qnil;
10
9
  static int id_call;
11
10
 
12
- int ruby_xml_parser_count = 0;
13
11
  VALUE cXMLParser;
14
12
  VALUE eXMLParserParseError;
15
13
 
@@ -798,10 +796,6 @@ void
798
796
  ruby_xml_parser_free(ruby_xml_parser *rxp) {
799
797
  void *data;
800
798
 
801
- ruby_xml_parser_count--;
802
- if (ruby_xml_parser_count == 0)
803
- xmlCleanupParser();
804
-
805
799
  switch(rxp->data_type) {
806
800
  case RUBY_LIBXML_SRC_TYPE_NULL:
807
801
  break;
@@ -940,6 +934,8 @@ ruby_xml_parser_mark(ruby_xml_parser *rxp) {
940
934
  if (rxp == NULL) return;
941
935
  if (!NIL_P(rxp->ctxt)) rb_gc_mark(rxp->ctxt);
942
936
 
937
+ ruby_xml_state_marker();
938
+
943
939
  switch(rxp->data_type) {
944
940
  case RUBY_LIBXML_SRC_TYPE_NULL:
945
941
  break;
@@ -1007,16 +1003,20 @@ ruby_xml_parser_memory_used(VALUE self) {
1007
1003
  VALUE
1008
1004
  ruby_xml_parser_new(VALUE class) {
1009
1005
  ruby_xml_parser *rxp;
1006
+ VALUE r;
1007
+
1008
+ r=Data_Make_Struct(class,
1009
+ ruby_xml_parser,
1010
+ ruby_xml_parser_mark,
1011
+ ruby_xml_parser_free,
1012
+ rxp);
1010
1013
 
1011
- ruby_xml_parser_count++;
1012
- rxp = ALLOC(ruby_xml_parser);
1013
1014
  rxp->ctxt = Qnil;
1014
1015
  rxp->data_type = RUBY_LIBXML_SRC_TYPE_NULL;
1015
1016
  rxp->data = NULL;
1016
1017
  rxp->parsed = 0;
1017
1018
 
1018
- return(Data_Wrap_Struct(class, ruby_xml_parser_mark,
1019
- ruby_xml_parser_free, rxp));
1019
+ return r;
1020
1020
  }
1021
1021
 
1022
1022
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_parser.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser_context.c 138 2007-08-29 18:00:35Z danj $ */
1
+ /* $Id: ruby_xml_parser_context.c 189 2007-09-26 15:04:47Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -140,18 +140,19 @@ ruby_xml_parser_context_errno_get(VALUE self) {
140
140
 
141
141
  void
142
142
  ruby_xml_parser_context_free(ruby_xml_parser_context *rxpc) {
143
- if (rxpc->ctxt != NULL && !rxpc->is_ptr) {
143
+ if (rxpc->ctxt != NULL) {
144
144
  xmlFreeParserCtxt(rxpc->ctxt);
145
- ruby_xml_parser_count--;
146
145
  rxpc->ctxt = NULL;
147
146
  }
148
147
 
149
- if (ruby_xml_parser_count == 0)
150
- xmlCleanupParser();
151
-
152
148
  free(rxpc);
153
149
  }
154
150
 
151
+ void
152
+ ruby_xml_parser_context_mark(void *v) {
153
+ if ( v == NULL ) return;
154
+ ruby_xml_state_marker();
155
+ }
155
156
 
156
157
  /*
157
158
  * call-seq:
@@ -370,11 +371,12 @@ ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt) {
370
371
  ruby_xml_parser_context *rxpc;
371
372
 
372
373
  rxpc = ALLOC(ruby_xml_parser_context);
373
- ruby_xml_parser_count++;
374
374
 
375
375
  rxpc->ctxt = ctxt;
376
- rxpc->is_ptr = 0;
377
- return(Data_Wrap_Struct(class, 0, ruby_xml_parser_context_free, rxpc));
376
+ return Data_Wrap_Struct(class,
377
+ ruby_xml_parser_context_mark,
378
+ ruby_xml_parser_context_free,
379
+ rxpc);
378
380
  }
379
381
 
380
382
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_parser_context.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_sax_parser.c 111 2006-11-20 01:39:14Z roscopeco $ */
1
+ /* $Id: ruby_xml_sax_parser.c 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_sax_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
1
+ /* $Id: ruby_xml_sax_parser.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -0,0 +1,114 @@
1
+ /* $Id$ */
2
+
3
+ #include "libxml.h"
4
+
5
+ VALUE cXMLState;
6
+ static VALUE weak_holder;
7
+ static int id_inst;
8
+
9
+ ID id_state;
10
+
11
+ #undef DEBUG
12
+
13
+ void
14
+ ruby_xml_state_free(int * dummy) {
15
+ if ( dummy==NULL ) return;
16
+ xmlCleanupParser();
17
+ free(dummy);
18
+ dummy=NULL;
19
+ weak_holder=Qnil;
20
+ rb_ivar_set(cXMLState,id_state,Qnil);
21
+ }
22
+
23
+ void
24
+ ruby_xml_state_mark(void * a) {
25
+ #ifdef DEBUG
26
+ fprintf(stderr,"marked 0x%x\n",NUM2INT(rb_ivar_get(cXMLState,id_state)));
27
+ #endif
28
+ }
29
+
30
+ VALUE
31
+ ruby_xml_state_object() {
32
+ VALUE obj,id;
33
+ int *dummy;
34
+
35
+ id=rb_ivar_get(cXMLState,id_state);
36
+ if (NIL_P(id)) {
37
+ obj = Data_Make_Struct(cXMLState, int,
38
+ ruby_xml_state_mark,
39
+ ruby_xml_state_free,
40
+ dummy);
41
+ rb_ivar_set(cXMLState,id_state,id=rb_obj_id(obj));
42
+ *dummy=0;
43
+ weak_holder=obj;
44
+ return obj;
45
+ }
46
+
47
+ #ifdef DEBUG
48
+ fprintf(stderr,"getting 0x%x\n",NUM2INT(id));
49
+ #endif
50
+ return weak_holder;
51
+
52
+ return rb_funcall(rb_const_get(rb_cModule,rb_intern("ObjectSpace")),
53
+ rb_intern("_id2ref"),
54
+ 1,
55
+ id);
56
+ }
57
+
58
+ VALUE
59
+ ruby_xml_state_object_find_aux(VALUE id) {
60
+ rb_funcall(rb_const_get(rb_cModule,rb_intern("ObjectSpace")),
61
+ rb_intern("_id2ref"),
62
+ 1,
63
+ id);
64
+ }
65
+
66
+
67
+ static VALUE
68
+ find_failed() {
69
+ return Qnil;
70
+ }
71
+
72
+ VALUE
73
+ ruby_xml_state_object_find(VALUE id) {
74
+ return rb_rescue(ruby_xml_state_object_find_aux, id, find_failed, 0);
75
+ }
76
+ /*
77
+ * This will establish a use and mark it or mark an existing use.
78
+ * should be called by parser.mark and document.mark
79
+ */
80
+ void
81
+ ruby_xml_state_marker(void) {
82
+ ruby_xml_state_object();
83
+ rb_gc_mark(weak_holder);
84
+ }
85
+
86
+ VALUE
87
+ ruby_xml_state_used_p(VALUE klass)
88
+ {
89
+ return rb_ivar_get(cXMLState,id_state);
90
+ }
91
+
92
+ VALUE
93
+ ruby_xml_state_use(VALUE klass)
94
+ {
95
+ return ruby_xml_state_object();
96
+ }
97
+
98
+ // Rdoc needs to know
99
+ #ifdef RDOC_NEVER_DEFINED
100
+ mXML = rb_define_module("XML");
101
+ #endif
102
+
103
+
104
+ void
105
+ ruby_init_state(void) {
106
+ cXMLState = rb_define_class_under(mXML, "State", rb_cObject);
107
+
108
+ rb_define_singleton_method(cXMLState, "used?",
109
+ ruby_xml_state_used_p, 0);
110
+ rb_define_singleton_method(cXMLState, "use",
111
+ ruby_xml_state_use, 0);
112
+
113
+ rb_ivar_set(cXMLState, id_state=rb_intern("@stateid"), Qnil);
114
+ }