libxml-ruby 0.5.4 → 0.6.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 (139) hide show
  1. data/LICENSE +23 -23
  2. data/README +144 -144
  3. data/ext/libxml/extconf.rb +26 -27
  4. data/ext/libxml/libxml.c +7 -37
  5. data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
  6. data/ext/libxml/ruby_xml_attr.c +405 -387
  7. data/ext/libxml/ruby_xml_attr.h +19 -18
  8. data/ext/libxml/ruby_xml_document.c +1111 -1115
  9. data/ext/libxml/ruby_xml_document.h +27 -24
  10. data/ext/libxml/ruby_xml_dtd.c +168 -168
  11. data/ext/libxml/ruby_xml_html_parser.c +449 -450
  12. data/ext/libxml/ruby_xml_html_parser.h +1 -1
  13. data/ext/libxml/ruby_xml_input_cbg.c +158 -158
  14. data/ext/libxml/ruby_xml_node.c +2410 -2395
  15. data/ext/libxml/ruby_xml_node.h +1 -1
  16. data/ext/libxml/ruby_xml_node_set.c +170 -170
  17. data/ext/libxml/ruby_xml_node_set.h +1 -1
  18. data/ext/libxml/ruby_xml_ns.c +153 -153
  19. data/ext/libxml/ruby_xml_ns.h +1 -1
  20. data/ext/libxml/ruby_xml_parser.c +1425 -1422
  21. data/ext/libxml/ruby_xml_parser.h +1 -1
  22. data/ext/libxml/ruby_xml_parser_context.c +750 -716
  23. data/ext/libxml/ruby_xml_parser_context.h +1 -1
  24. data/ext/libxml/ruby_xml_reader.c +900 -896
  25. data/ext/libxml/ruby_xml_sax_parser.c +485 -485
  26. data/ext/libxml/ruby_xml_sax_parser.h +1 -1
  27. data/ext/libxml/ruby_xml_schema.c +146 -142
  28. data/ext/libxml/ruby_xml_state.c +5 -6
  29. data/ext/libxml/ruby_xml_state.h +1 -0
  30. data/ext/libxml/ruby_xml_tree.c +43 -43
  31. data/ext/libxml/ruby_xml_tree.h +1 -1
  32. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  33. data/ext/libxml/ruby_xml_xinclude.h +1 -1
  34. data/ext/libxml/ruby_xml_xpath.c +243 -252
  35. data/ext/libxml/ruby_xml_xpath.h +1 -1
  36. data/ext/libxml/ruby_xml_xpath_context.c +118 -118
  37. data/ext/libxml/ruby_xml_xpath_context.h +1 -1
  38. data/ext/libxml/ruby_xml_xpath_object.c +43 -29
  39. data/ext/libxml/ruby_xml_xpath_object.h +0 -1
  40. data/ext/libxml/ruby_xml_xpointer.c +100 -100
  41. data/ext/libxml/ruby_xml_xpointer.h +1 -1
  42. data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
  43. data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
  44. data/ext/libxml/sax_parser_callbacks.inc +213 -213
  45. data/ext/libxml/version.h +9 -9
  46. data/lib/libxml.rb +24 -3
  47. data/mingw/libiconv-2.dll +0 -0
  48. data/mingw/libxml2-2.dll +0 -0
  49. data/mingw/libxml_ruby.so +0 -0
  50. data/mingw/mingw.rake +36 -0
  51. data/test/dtd-test.rb +24 -24
  52. data/test/etc_doc_to_s.rb +1 -3
  53. data/test/ets_copy_bug.rb +21 -21
  54. data/test/ets_copy_bug2.rb +32 -32
  55. data/test/ets_copy_bug3.rb +38 -0
  56. data/test/ets_doc_file.rb +1 -0
  57. data/test/{model/default_validation_bug.rb → gc.log} +0 -0
  58. data/test/merge_bug.rb +55 -55
  59. data/test/schema-test.rb +74 -74
  60. data/test/tc_well_formed.rb +11 -0
  61. data/test/tc_xml_document.rb +52 -52
  62. data/test/tc_xml_document_write.rb +24 -24
  63. data/test/tc_xml_document_write2.rb +54 -54
  64. data/test/tc_xml_document_write3.rb +96 -96
  65. data/test/tc_xml_html_parser.rb +63 -63
  66. data/test/tc_xml_node.rb +59 -59
  67. data/test/tc_xml_node2.rb +25 -25
  68. data/test/tc_xml_node3.rb +27 -27
  69. data/test/tc_xml_node4.rb +86 -86
  70. data/test/tc_xml_node5.rb +52 -52
  71. data/test/tc_xml_node6.rb +27 -27
  72. data/test/tc_xml_node7.rb +35 -35
  73. data/test/tc_xml_node8.rb +32 -32
  74. data/test/tc_xml_node9.rb +32 -32
  75. data/test/tc_xml_node_set.rb +24 -24
  76. data/test/tc_xml_node_set2.rb +37 -37
  77. data/test/tc_xml_node_xlink.rb +28 -28
  78. data/test/tc_xml_parser.rb +190 -178
  79. data/test/tc_xml_parser2.rb +16 -17
  80. data/test/tc_xml_parser3.rb +23 -23
  81. data/test/tc_xml_parser4.rb +33 -33
  82. data/test/tc_xml_parser5.rb +27 -27
  83. data/test/tc_xml_parser6.rb +23 -23
  84. data/test/tc_xml_parser7.rb +28 -28
  85. data/test/tc_xml_parser8.rb +32 -32
  86. data/test/tc_xml_parser9.rb +11 -0
  87. data/test/tc_xml_parser_context.rb +88 -88
  88. data/test/tc_xml_reader.rb +112 -109
  89. data/test/tc_xml_sax_parser.rb +104 -94
  90. data/test/tc_xml_sax_parser2.rb +51 -0
  91. data/test/tc_xml_xinclude.rb +30 -30
  92. data/test/tc_xml_xpath.rb +38 -38
  93. data/test/tc_xml_xpath2.rb +14 -0
  94. data/test/tc_xml_xpointer.rb +78 -78
  95. data/vc/libxml.sln +20 -0
  96. data/vc/libxml.vcproj +389 -0
  97. data/work/Rakefile +247 -0
  98. data/work/task/make +26 -0
  99. data/work/task/memory +37 -0
  100. data/work/task/rdoc +39 -0
  101. data/work/task/setup +1616 -0
  102. data/work/task/test +29 -0
  103. data/work/test/ets_runner.rb +33 -0
  104. data/work/test/libxml_test.rb +3 -0
  105. data/work/test/runner.rb +0 -0
  106. data/work/test/runner_ets.rb +33 -0
  107. data/work/vc/debug/libxml.exp +0 -0
  108. data/work/vc/debug/libxml.ilk +0 -0
  109. data/work/vc/debug/libxml.lib +0 -0
  110. data/work/vc/debug/libxml.pdb +0 -0
  111. data/work/vc/debug/libxml.so +0 -0
  112. metadata +158 -189
  113. data/MANIFEST +0 -138
  114. data/NOTES +0 -9
  115. data/Rakefile +0 -38
  116. data/TODO +0 -75
  117. data/VERSION +0 -1
  118. data/log/Changelog-0.txt +0 -426
  119. data/log/Changelog.txt +0 -435
  120. data/meta/project.yaml +0 -27
  121. data/meta/unixname +0 -1
  122. data/setup.rb +0 -1472
  123. data/site/css/normal.css +0 -182
  124. data/site/img/raze-tiny.png +0 -0
  125. data/site/img/red-cube.jpg +0 -0
  126. data/site/img/xml-ruby.png +0 -0
  127. data/site/index.xml +0 -43
  128. data/site/install.xml +0 -77
  129. data/site/layout.rhtml +0 -38
  130. data/site/layout.xsl +0 -67
  131. data/site/license.xml +0 -32
  132. data/site/log/changelog.xml +0 -1324
  133. data/site/log/changelog.xsl +0 -42
  134. data/test/model/merge_bug_data.xml +0 -58
  135. data/test/model/rubynet.xml +0 -78
  136. data/test/model/rubynet_project +0 -13
  137. data/test/model/saxtest.xml +0 -5
  138. data/test/model/simple.xml +0 -7
  139. data/test/model/xinclude.xml +0 -5
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node.h 225 2007-12-07 04:58:09Z transami $ */
1
+ /* $Id: ruby_xml_node.h 207 2007-11-14 07:51:46Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,170 +1,170 @@
1
- /* $Id: ruby_xml_node_set.c 225 2007-12-07 04:58:09Z transami $ */
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
- /*
9
- * Document-class: XML::Node::Set
10
- *
11
- * Includes Enumerable.
12
- */
13
- VALUE cXMLNodeSet;
14
-
15
- // TODO maybe we should support [] on nodeset?
16
- // Would also give us on xpath too...
17
-
18
- /*
19
- * call-seq:
20
- * nodeset.to_a => [node, ..., node]
21
- *
22
- * Obtain an array of the nodes in this set.
23
- */
24
- VALUE
25
- ruby_xml_node_set_to_a(VALUE self) {
26
- ruby_xml_node_set *rxnset;
27
- VALUE r;
28
-
29
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
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;
35
- }
36
-
37
-
38
- /*
39
- * call-seq:
40
- * nodeset.each { |node| ... } => self
41
- *
42
- * Call the supplied block for each node in this set.
43
- */
44
- VALUE
45
- ruby_xml_node_set_each(VALUE self) {
46
- ruby_xml_node_set *rxnset;
47
-
48
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
49
- return ruby_xml_xpath_object_each(rxnset->rxpop);
50
- }
51
-
52
-
53
- /*
54
- * call-seq:
55
- * nodeset.empty? => (true|false)
56
- *
57
- * Determine whether this nodeset is empty (contains no nodes).
58
- */
59
- VALUE
60
- ruby_xml_node_set_empty_q(VALUE self) {
61
- ruby_xml_node_set *rxnset;
62
-
63
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
64
- return ruby_xml_xpath_object_empty_q(rxnset->rxpop);
65
- }
66
-
67
-
68
- /*
69
- * call-seq:
70
- * nodeset.first => node
71
- *
72
- * Returns the first node in this node set, or nil if none exist.
73
- */
74
- VALUE
75
- ruby_xml_node_set_first(VALUE self) {
76
- ruby_xml_node_set *rxnset;
77
-
78
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
79
- return ruby_xml_xpath_object_first(rxnset->rxpop);
80
- }
81
-
82
- /*
83
- * call-seq:
84
- * nodeset.length => num
85
- *
86
- * Obtain the length of this nodeset.
87
- */
88
- VALUE
89
- ruby_xml_node_set_length(VALUE self) {
90
- ruby_xml_node_set *rxnset;
91
-
92
- Data_Get_Struct(self, ruby_xml_node_set, rxnset);
93
- return ruby_xml_xpath_object_length(rxnset->rxpop);
94
- }
95
-
96
-
97
- static void
98
- ruby_xml_node_set_mark(ruby_xml_node_set *rxnset) {
99
- if (!NIL_P(rxnset->rxpop)) rb_gc_mark(rxnset->rxpop);
100
- }
101
-
102
- static void
103
- ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
104
- free(rxnset);
105
- }
106
-
107
- VALUE
108
- ruby_xml_node_set_new(VALUE class, VALUE rxpop)
109
- {
110
- ruby_xml_node_set *rxnset;
111
- rxnset = ALLOC(ruby_xml_node_set);
112
- rxnset->rxpop=rxpop;
113
- return Data_Wrap_Struct(class,
114
- ruby_xml_node_set_mark,
115
- ruby_xml_node_set_free,
116
- rxnset);
117
- }
118
-
119
- VALUE
120
- ruby_xml_node_set_new2(VALUE rxpop)
121
- {
122
- return ruby_xml_node_set_new(cXMLNodeSet,rxpop);
123
- }
124
-
125
- /*
126
- * call-seq:
127
- * nodeset.xpath => xpath
128
- *
129
- * Obtain the xpath corresponding to this nodeset, if any.
130
- */
131
- VALUE
132
- ruby_xml_node_set_xpath_get(VALUE self) {
133
- rb_raise(rb_eRuntimeError,"xpath retrival is no longer supported");
134
- }
135
-
136
-
137
- /*
138
- * call-seq:
139
- * nodeset.xpath_ctxt => context
140
- *
141
- * Return the xpath context corresponding to this nodeset,
142
- * if any.
143
- */
144
- VALUE
145
- ruby_xml_node_set_xpath_data_get(VALUE self) {
146
- rb_raise(rb_eRuntimeError,"xpath data retrival is no longer supported");
147
- }
148
-
149
- // Rdoc needs to know
150
- #ifdef RDOC_NEVER_DEFINED
151
- mXML = rb_define_module("XML");
152
- cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
153
- #endif
154
-
155
- void
156
- ruby_init_xml_node_set(void) {
157
- cXMLNodeSet = rb_define_class_under(cXMLNode, "Set", rb_cObject);
158
- rb_include_module(cXMLNodeSet, rb_const_get(rb_cObject, rb_intern("Enumerable")));
159
-
160
- rb_define_method(cXMLNodeSet, "each", ruby_xml_node_set_each, 0);
161
- rb_define_method(cXMLNodeSet, "empty?", ruby_xml_node_set_empty_q, 0);
162
- rb_define_method(cXMLNodeSet, "first", ruby_xml_node_set_first, 0);
163
- rb_define_method(cXMLNodeSet, "length", ruby_xml_node_set_length, 0);
164
- rb_define_method(cXMLNodeSet, "size", ruby_xml_node_set_length, 0);
165
- rb_define_method(cXMLNodeSet, "to_a", ruby_xml_node_set_to_a, 0);
166
- rb_define_method(cXMLNodeSet, "xpath", ruby_xml_node_set_xpath_get, 0);
167
- rb_define_method(cXMLNodeSet, "xpath_ctxt",
168
- ruby_xml_node_set_xpath_data_get, 0);
169
-
170
- }
1
+ /* $Id: ruby_xml_node_set.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_node_set.h"
7
+
8
+ /*
9
+ * Document-class: XML::Node::Set
10
+ *
11
+ * Includes Enumerable.
12
+ */
13
+ VALUE cXMLNodeSet;
14
+
15
+ // TODO maybe we should support [] on nodeset?
16
+ // Would also give us on xpath too...
17
+
18
+ /*
19
+ * call-seq:
20
+ * nodeset.to_a => [node, ..., node]
21
+ *
22
+ * Obtain an array of the nodes in this set.
23
+ */
24
+ VALUE
25
+ ruby_xml_node_set_to_a(VALUE self) {
26
+ ruby_xml_node_set *rxnset;
27
+ VALUE r;
28
+
29
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
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;
35
+ }
36
+
37
+
38
+ /*
39
+ * call-seq:
40
+ * nodeset.each { |node| ... } => self
41
+ *
42
+ * Call the supplied block for each node in this set.
43
+ */
44
+ VALUE
45
+ ruby_xml_node_set_each(VALUE self) {
46
+ ruby_xml_node_set *rxnset;
47
+
48
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
49
+ return ruby_xml_xpath_object_each(rxnset->rxpop);
50
+ }
51
+
52
+
53
+ /*
54
+ * call-seq:
55
+ * nodeset.empty? => (true|false)
56
+ *
57
+ * Determine whether this nodeset is empty (contains no nodes).
58
+ */
59
+ VALUE
60
+ ruby_xml_node_set_empty_q(VALUE self) {
61
+ ruby_xml_node_set *rxnset;
62
+
63
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
64
+ return ruby_xml_xpath_object_empty_q(rxnset->rxpop);
65
+ }
66
+
67
+
68
+ /*
69
+ * call-seq:
70
+ * nodeset.first => node
71
+ *
72
+ * Returns the first node in this node set, or nil if none exist.
73
+ */
74
+ VALUE
75
+ ruby_xml_node_set_first(VALUE self) {
76
+ ruby_xml_node_set *rxnset;
77
+
78
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
79
+ return ruby_xml_xpath_object_first(rxnset->rxpop);
80
+ }
81
+
82
+ /*
83
+ * call-seq:
84
+ * nodeset.length => num
85
+ *
86
+ * Obtain the length of this nodeset.
87
+ */
88
+ VALUE
89
+ ruby_xml_node_set_length(VALUE self) {
90
+ ruby_xml_node_set *rxnset;
91
+
92
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
93
+ return ruby_xml_xpath_object_length(rxnset->rxpop);
94
+ }
95
+
96
+
97
+ static void
98
+ ruby_xml_node_set_mark(ruby_xml_node_set *rxnset) {
99
+ if (!NIL_P(rxnset->rxpop)) rb_gc_mark(rxnset->rxpop);
100
+ }
101
+
102
+ static void
103
+ ruby_xml_node_set_free(ruby_xml_node_set *rxnset) {
104
+ ruby_xfree(rxnset);
105
+ }
106
+
107
+ VALUE
108
+ ruby_xml_node_set_new(VALUE class, VALUE rxpop)
109
+ {
110
+ ruby_xml_node_set *rxnset;
111
+ rxnset = ALLOC(ruby_xml_node_set);
112
+ rxnset->rxpop=rxpop;
113
+ return Data_Wrap_Struct(class,
114
+ ruby_xml_node_set_mark,
115
+ ruby_xml_node_set_free,
116
+ rxnset);
117
+ }
118
+
119
+ VALUE
120
+ ruby_xml_node_set_new2(VALUE rxpop)
121
+ {
122
+ return ruby_xml_node_set_new(cXMLNodeSet,rxpop);
123
+ }
124
+
125
+ /*
126
+ * call-seq:
127
+ * nodeset.xpath => xpath
128
+ *
129
+ * Obtain the xpath corresponding to this nodeset, if any.
130
+ */
131
+ VALUE
132
+ ruby_xml_node_set_xpath_get(VALUE self) {
133
+ rb_raise(rb_eRuntimeError,"xpath retrival is no longer supported");
134
+ }
135
+
136
+
137
+ /*
138
+ * call-seq:
139
+ * nodeset.xpath_ctxt => context
140
+ *
141
+ * Return the xpath context corresponding to this nodeset,
142
+ * if any.
143
+ */
144
+ VALUE
145
+ ruby_xml_node_set_xpath_data_get(VALUE self) {
146
+ rb_raise(rb_eRuntimeError,"xpath data retrival is no longer supported");
147
+ }
148
+
149
+ // Rdoc needs to know
150
+ #ifdef RDOC_NEVER_DEFINED
151
+ mXML = rb_define_module("XML");
152
+ cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
153
+ #endif
154
+
155
+ void
156
+ ruby_init_xml_node_set(void) {
157
+ cXMLNodeSet = rb_define_class_under(cXMLNode, "Set", rb_cObject);
158
+ rb_include_module(cXMLNodeSet, rb_const_get(rb_cObject, rb_intern("Enumerable")));
159
+
160
+ rb_define_method(cXMLNodeSet, "each", ruby_xml_node_set_each, 0);
161
+ rb_define_method(cXMLNodeSet, "empty?", ruby_xml_node_set_empty_q, 0);
162
+ rb_define_method(cXMLNodeSet, "first", ruby_xml_node_set_first, 0);
163
+ rb_define_method(cXMLNodeSet, "length", ruby_xml_node_set_length, 0);
164
+ rb_define_method(cXMLNodeSet, "size", ruby_xml_node_set_length, 0);
165
+ rb_define_method(cXMLNodeSet, "to_a", ruby_xml_node_set_to_a, 0);
166
+ rb_define_method(cXMLNodeSet, "xpath", ruby_xml_node_set_xpath_get, 0);
167
+ rb_define_method(cXMLNodeSet, "xpath_ctxt",
168
+ ruby_xml_node_set_xpath_data_get, 0);
169
+
170
+ }
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node_set.h 225 2007-12-07 04:58:09Z transami $ */
1
+ /* $Id: ruby_xml_node_set.h 207 2007-11-14 07:51:46Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,153 +1,153 @@
1
- /* $Id: ruby_xml_ns.c 225 2007-12-07 04:58:09Z transami $ */
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
- }
1
+ /* $Id: ruby_xml_ns.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_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
+ ruby_xfree(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
+ }
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_ns.h 225 2007-12-07 04:58:09Z transami $ */
1
+ /* $Id: ruby_xml_ns.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4