mkrf 0.1.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 (186) hide show
  1. data/CHANGELOG +2 -0
  2. data/MIT-LICENSE +7 -0
  3. data/README +54 -0
  4. data/Rakefile +107 -0
  5. data/lib/mkrf.rb +4 -0
  6. data/lib/mkrf/availability.rb +219 -0
  7. data/lib/mkrf/generator.rb +146 -0
  8. data/test/abstract_unit.rb +4 -0
  9. data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
  10. data/test/fixtures/stdmkrf.h +1 -0
  11. data/test/sample_files/libtrivial/Rakefile +31 -0
  12. data/test/sample_files/libtrivial/extconf.rb +3 -0
  13. data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
  14. data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
  15. data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
  16. data/test/sample_files/libtrivial/mkrf.log +1 -0
  17. data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
  18. data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
  19. data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
  20. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
  21. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
  22. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
  23. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
  24. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
  25. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
  26. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
  27. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
  28. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
  29. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
  30. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
  31. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
  32. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
  33. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
  34. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
  35. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
  36. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
  37. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
  38. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
  39. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
  40. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
  41. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
  42. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
  43. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
  44. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
  45. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
  46. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
  47. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
  48. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
  49. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
  50. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
  51. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
  52. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
  53. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
  54. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
  55. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
  56. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
  57. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
  58. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
  59. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
  60. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
  61. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
  62. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
  63. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
  64. data/test/sample_files/syck-0.55/CHANGELOG +186 -0
  65. data/test/sample_files/syck-0.55/COPYING +54 -0
  66. data/test/sample_files/syck-0.55/Makefile +582 -0
  67. data/test/sample_files/syck-0.55/Makefile.am +5 -0
  68. data/test/sample_files/syck-0.55/Makefile.in +582 -0
  69. data/test/sample_files/syck-0.55/README +105 -0
  70. data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
  71. data/test/sample_files/syck-0.55/README.EXT +444 -0
  72. data/test/sample_files/syck-0.55/RELEASE +123 -0
  73. data/test/sample_files/syck-0.55/TODO +25 -0
  74. data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
  75. data/test/sample_files/syck-0.55/bootstrap +7 -0
  76. data/test/sample_files/syck-0.55/config.h +79 -0
  77. data/test/sample_files/syck-0.55/config.h.in +78 -0
  78. data/test/sample_files/syck-0.55/config.status +1197 -0
  79. data/test/sample_files/syck-0.55/config/README +14 -0
  80. data/test/sample_files/syck-0.55/config/depcomp +529 -0
  81. data/test/sample_files/syck-0.55/config/install-sh +323 -0
  82. data/test/sample_files/syck-0.55/config/missing +357 -0
  83. data/test/sample_files/syck-0.55/configure +6728 -0
  84. data/test/sample_files/syck-0.55/configure.in +36 -0
  85. data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
  86. data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
  87. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
  88. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
  89. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
  90. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
  91. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
  92. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
  93. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
  94. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
  95. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
  96. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
  97. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
  98. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
  99. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
  100. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
  101. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
  102. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
  103. data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
  104. data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
  105. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
  106. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
  107. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
  108. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
  109. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
  110. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
  111. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
  112. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
  113. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
  114. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
  115. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
  116. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
  117. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
  118. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
  119. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
  120. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
  121. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
  122. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
  123. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
  124. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
  125. data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
  126. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
  127. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
  128. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
  129. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
  130. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
  131. data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
  132. data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
  133. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
  134. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
  135. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
  136. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
  137. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
  138. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
  139. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
  140. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
  141. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
  142. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
  143. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
  144. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
  145. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
  146. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
  147. data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
  148. data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
  149. data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
  150. data/test/sample_files/syck-0.55/lib/Makefile +497 -0
  151. data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
  152. data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
  153. data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
  154. data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
  155. data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
  156. data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
  157. data/test/sample_files/syck-0.55/lib/gram.h +79 -0
  158. data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
  159. data/test/sample_files/syck-0.55/lib/gram.y +481 -0
  160. data/test/sample_files/syck-0.55/lib/handler.c +174 -0
  161. data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
  162. data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
  163. data/test/sample_files/syck-0.55/lib/node.c +407 -0
  164. data/test/sample_files/syck-0.55/lib/syck.c +504 -0
  165. data/test/sample_files/syck-0.55/lib/syck.h +458 -0
  166. data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
  167. data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
  168. data/test/sample_files/syck-0.55/lib/token.c +2707 -0
  169. data/test/sample_files/syck-0.55/lib/token.re +1139 -0
  170. data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
  171. data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
  172. data/test/sample_files/syck-0.55/stamp-h1 +1 -0
  173. data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
  174. data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
  175. data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
  176. data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
  177. data/test/sample_files/syck-0.55/tests/Makefile +480 -0
  178. data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
  179. data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
  180. data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
  181. data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
  182. data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
  183. data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
  184. data/test/test_availability.rb +68 -0
  185. data/test/test_generator.rb +74 -0
  186. metadata +252 -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,248 @@
1
+ /* $Id: ruby_xml_node_set.c,v 1.3 2006/04/14 14:45:25 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
+ /*
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
+ int i;
27
+ ruby_xml_node_set *rxnset;
28
+ VALUE nodeobj, set_ary;
29
+
30
+ 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_node_new2(cXMLNode, rxnset->xd, rxnset->node_set->nodeTab[i]);
36
+ rb_ary_push(set_ary, nodeobj);
37
+ }
38
+ }
39
+
40
+ return(set_ary);
41
+ }
42
+
43
+
44
+ /*
45
+ * call-seq:
46
+ * nodeset.each { |node| ... } => self
47
+ *
48
+ * Call the supplied block for each node in this set.
49
+ */
50
+ VALUE
51
+ ruby_xml_node_set_each(VALUE self) {
52
+ int i;
53
+ ruby_xml_node_set *rxnset;
54
+ VALUE nodeobj;
55
+
56
+ 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_new2(cXMLAttr, rxnset->xd, (xmlAttrPtr)rxnset->node_set->nodeTab[i]);
65
+ break;
66
+ default:
67
+ nodeobj = ruby_xml_node_new2(cXMLNode, rxnset->xd, rxnset->node_set->nodeTab[i]);
68
+ }
69
+
70
+ rb_yield(nodeobj);
71
+ }
72
+ return(self);
73
+ }
74
+
75
+
76
+ /*
77
+ * call-seq:
78
+ * nodeset.empty? => (true|false)
79
+ *
80
+ * Determine whether this nodeset is empty (contains no nodes).
81
+ */
82
+ VALUE
83
+ ruby_xml_node_set_empty_q(VALUE self) {
84
+ 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;
87
+ }
88
+
89
+
90
+ /*
91
+ * call-seq:
92
+ * nodeset.first => node
93
+ *
94
+ * Returns the first node in this node set, or nil if none exist.
95
+ */
96
+ VALUE
97
+ ruby_xml_node_set_first(VALUE self) {
98
+ ruby_xml_node_set *rxnset;
99
+ VALUE nodeobj;
100
+
101
+ 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_new2(cXMLAttr, rxnset->xd, (xmlAttrPtr)rxnset->node_set->nodeTab[0]);
109
+ break;
110
+ default:
111
+ nodeobj = ruby_xml_node_new2(cXMLNode, rxnset->xd, rxnset->node_set->nodeTab[0]);
112
+ }
113
+
114
+ return(nodeobj);
115
+ }
116
+
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
+ /*
143
+ * call-seq:
144
+ * nodeset.length => num
145
+ *
146
+ * Obtain the length of this nodeset.
147
+ */
148
+ VALUE
149
+ ruby_xml_node_set_length(VALUE self) {
150
+ ruby_xml_node_set *rxnset;
151
+ Data_Get_Struct(self, ruby_xml_node_set, rxnset);
152
+ if (rxnset->node_set == NULL)
153
+ return(Qnil);
154
+ else
155
+ return(INT2NUM(rxnset->node_set->nodeNr));
156
+ }
157
+
158
+
159
+ static void
160
+ 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);
164
+ }
165
+
166
+
167
+ VALUE
168
+ ruby_xml_node_set_new(VALUE class, VALUE xd, VALUE xpath,
169
+ xmlNodeSetPtr node_set) {
170
+ ruby_xml_node_set *rxnset;
171
+
172
+ 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));
180
+ }
181
+
182
+
183
+ 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));
187
+ }
188
+
189
+
190
+ /*
191
+ * call-seq:
192
+ * nodeset.xpath => xpath
193
+ *
194
+ * Obtain the xpath corresponding to this nodeset, if any.
195
+ */
196
+ VALUE
197
+ 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);
205
+ }
206
+
207
+
208
+ /*
209
+ * call-seq:
210
+ * nodeset.xpath_ctxt => context
211
+ *
212
+ * Return the xpath context corresponding to this nodeset,
213
+ * if any.
214
+ */
215
+ VALUE
216
+ 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);
226
+ }
227
+
228
+ // Rdoc needs to know
229
+ #ifdef RDOC_NEVER_DEFINED
230
+ mXML = rb_define_module("XML");
231
+ cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
232
+ #endif
233
+
234
+ void
235
+ ruby_init_xml_node_set(void) {
236
+ cXMLNodeSet = rb_define_class_under(cXMLNode, "Set", rb_cObject);
237
+ rb_include_module(cXMLNodeSet, rb_const_get(rb_cObject, rb_intern("Enumerable")));
238
+
239
+ rb_define_method(cXMLNodeSet, "each", ruby_xml_node_set_each, 0);
240
+ rb_define_method(cXMLNodeSet, "empty?", ruby_xml_node_set_empty_q, 0);
241
+ rb_define_method(cXMLNodeSet, "first", ruby_xml_node_set_first, 0);
242
+ rb_define_method(cXMLNodeSet, "length", ruby_xml_node_set_length, 0);
243
+ rb_define_method(cXMLNodeSet, "to_a", ruby_xml_node_set_to_a, 0);
244
+ rb_define_method(cXMLNodeSet, "xpath", ruby_xml_node_set_xpath_get, 0);
245
+ rb_define_method(cXMLNodeSet, "xpath_ctxt",
246
+ ruby_xml_node_set_xpath_data_get, 0);
247
+
248
+ }
@@ -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
+ }