mkrf 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,82 @@
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RUBY_LIBXML_H__
4
+ #define __RUBY_LIBXML_H__
5
+
6
+ /* Don't nuke this block! It is used for automatically updating the
7
+ * versions below. VERSION = string formatting, VERNUM = numbered
8
+ * version for inline testing: increment both or none at all. */
9
+ #define RUBY_LIBXML_VERSION "0.3.8"
10
+ #define RUBY_LIBXML_VERNUM 38
11
+ #define RUBY_LIBXML_VER_MAJ 0
12
+ #define RUBY_LIBXML_VER_MIN 3
13
+ #define RUBY_LIBXML_VER_MIC 8
14
+
15
+ #include <ruby.h>
16
+ #include <rubyio.h>
17
+ #include <util.h>
18
+ #include <libxml/parser.h>
19
+ #include <libxml/parserInternals.h>
20
+ #include <libxml/debugXML.h>
21
+ #include <libxml/xmlversion.h>
22
+ #include <libxml/xmlmemory.h>
23
+ #include <libxml/xpath.h>
24
+ #include <libxml/valid.h>
25
+ #include <libxml/catalog.h>
26
+ #ifdef LIBXML_DEBUG_ENABLED
27
+ #include <libxml/xpathInternals.h>
28
+ #endif
29
+ #ifdef LIBXML_XINCLUDE_ENABLED
30
+ #include <libxml/xinclude.h>
31
+ #endif
32
+ #ifdef LIBXML_XPTR_ENABLED
33
+ #include <libxml/xpointer.h>
34
+ #endif
35
+
36
+ #define RUBY_LIBXML_SRC_TYPE_NULL 0
37
+ #define RUBY_LIBXML_SRC_TYPE_FILE 1
38
+ #define RUBY_LIBXML_SRC_TYPE_STRING 2
39
+ #define RUBY_LIBXML_SRC_TYPE_IO 3
40
+ #define RUBY_LIBXML_SRC_TYPE_XPATH 4
41
+
42
+ typedef struct rx_file_data {
43
+ VALUE filename; /* Filename/path to self */
44
+ } rx_file_data;
45
+
46
+ typedef struct rx_io_data {
47
+ VALUE io;
48
+ } rx_io_data;
49
+
50
+ typedef struct rx_string_data {
51
+ VALUE str;
52
+ } rx_string_data;
53
+
54
+ typedef struct rx_xpath_data {
55
+ VALUE ctxt;
56
+ } rx_xpath_data;
57
+
58
+ #include "ruby_xml_attr.h"
59
+ #include "ruby_xml_attribute.h"
60
+ #include "ruby_xml_document.h"
61
+ #include "ruby_xml_node.h"
62
+ #include "ruby_xml_node_set.h"
63
+ #include "ruby_xml_ns.h"
64
+ #include "ruby_xml_parser.h"
65
+ #include "ruby_xml_parser_context.h"
66
+ #include "ruby_xml_sax_parser.h"
67
+ #include "ruby_xml_tree.h"
68
+ #include "ruby_xml_xinclude.h"
69
+ #include "ruby_xml_xpath.h"
70
+ #include "ruby_xml_xpath_context.h"
71
+ #include "ruby_xml_xpointer.h"
72
+ #include "ruby_xml_xpointer_context.h"
73
+ #include "ruby_xml_input_cbg.h"
74
+ #include "ruby_xml_dtd.h"
75
+ #include "ruby_xml_schema.h"
76
+
77
+ extern VALUE mXML;
78
+
79
+ void ruby_init_parser(void);
80
+ void ruby_xml_parser_free(ruby_xml_parser *rxp);
81
+
82
+ #endif
@@ -0,0 +1,107 @@
1
+ # $Id: libxml.rb,v 1.1 2006/04/17 13:30:22 roscopeco Exp $
2
+ # Please see the LICENSE file for copyright and distribution information
3
+ require 'xml/libxml_so'
4
+
5
+ class XML::Node::Set
6
+ def empty? #:nodoc:
7
+ self.length <= 0
8
+ end
9
+
10
+ def first #:nodoc:
11
+ self.each { |n| return n }
12
+ end
13
+ end
14
+
15
+ class XML::Document
16
+ include Enumerable
17
+
18
+ # maybe, maybe not...
19
+ def each(&blk) #:nodoc:
20
+ find('//*').each(&blk)
21
+ end
22
+ end
23
+
24
+ class XML::Node::Set
25
+ # inefficient, but maybe can find a way to cache the
26
+ # ary and dump on change?
27
+ def [](i, count = nil) #:nodoc:
28
+ if count
29
+ to_a[i,count]
30
+ else
31
+ to_a[i]
32
+ end
33
+ end
34
+
35
+ def to_s #:nodoc:
36
+ to_a.to_s
37
+ end
38
+ end
39
+
40
+ module XML::SiblingEnum #:nodoc:all
41
+ private
42
+
43
+ # Iterates nodes and attributes
44
+ def siblings(node, &blk)
45
+ if n = node
46
+ loop do
47
+ blk.call(n)
48
+ break unless n = n.next
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ class XML::Node
55
+ include XML::SiblingEnum
56
+ include Enumerable
57
+ include Comparable
58
+
59
+ # maybe these don't belong on all nodes...
60
+ def each_child(&blk) #:nodoc:
61
+ siblings(child, &blk)
62
+ end
63
+
64
+ def each_attr(&blk) #:nodoc:
65
+ siblings(properties, &blk)
66
+ end
67
+
68
+ # all siblings INCLUDING self
69
+ def each_sibling(&blk) #:nodoc:
70
+ siblings(self, &blk)
71
+ end
72
+
73
+ # I guess this is what you'd expect?
74
+ alias :each :each_child
75
+
76
+ def to_a #:nodoc:
77
+ inject([]) { |ary,n| ary << n }
78
+ end
79
+
80
+ def <=>(other) #:nodoc:
81
+ to_s <=> other.to_s
82
+ end
83
+ end
84
+
85
+ class XML::Attr
86
+ include XML::SiblingEnum
87
+ include Enumerable
88
+
89
+ def each_sibling(&blk) #:nodoc:
90
+ siblings(self,&blk)
91
+ end
92
+
93
+ alias :each_attr :each_sibling
94
+ alias :each :each_sibling
95
+
96
+ def to_h #:nodoc:
97
+ inject({}) do |h,a| h[a.name] = a.value end
98
+ end
99
+
100
+ def to_a #:nodoc:
101
+ inject([]) do |ary,a| ary << [a.name, a.value] end
102
+ end
103
+
104
+ def to_s #:nodoc:
105
+ "#{name} = #{value}"
106
+ end
107
+ end
@@ -0,0 +1 @@
1
+ # Logfile created on Mon Jun 26 13:34:01 PDT 2006 by logger.rb/1.5.2.4
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mkmf'
4
+
5
+ if defined?(CFLAGS)
6
+ if CFLAGS.index(CONFIG['CCDLFLAGS'])
7
+ $CFLAGS = CFLAGS
8
+ else
9
+ $CFLAGS = CFLAGS + ' ' + CONFIG['CCDLFLAGS']
10
+ end
11
+ else
12
+ $CFLAGS = CONFIG['CFLAGS']
13
+ end
14
+ $LDFLAGS = CONFIG['LDFLAGS']
15
+ $LIBPATH.push(Config::CONFIG['libdir'])
16
+
17
+ def crash(str)
18
+ printf(" extconf failure: %s\n", str)
19
+ exit 1
20
+ end
21
+
22
+ dir_config('iconv')
23
+ dir_config('xml2')
24
+ dir_config('zlib')
25
+
26
+ have_library('socket','socket')
27
+ have_library('nsl','gethostbyname')
28
+
29
+ unless have_library('m', 'atan')
30
+ # try again for gcc 4.0
31
+ saveflags = $CFLAGS
32
+ $CFLAGS += ' -fno-builtin'
33
+ unless have_library('m', 'atan')
34
+ crash('need libm')
35
+ end
36
+ $CFLAGS = saveflags
37
+ end
38
+
39
+ unless have_library('z', 'inflate')
40
+ crash('need zlib')
41
+ else
42
+ $defs.push('-DHAVE_ZLIB_H')
43
+ end
44
+
45
+ unless have_library('iconv','iconv_open') or
46
+ have_library('c','iconv_open') or
47
+ have_library('recode','iconv_open') or
48
+ have_library('iconv')
49
+ crash(<<EOL)
50
+ need libiconv.
51
+
52
+ Install the libiconv or try passing one of the following options
53
+ to extconf.rb:
54
+
55
+ --with-iconv-dir=/path/to/iconv
56
+ --with-iconv-lib=/path/to/iconv/lib
57
+ --with-iconv-include=/path/to/iconv/include
58
+ EOL
59
+ end
60
+
61
+ unless (have_library('xml2', 'xmlParseDoc') or
62
+ find_library('xml2', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
63
+ (have_header('libxml/xmlversion.h') or
64
+ find_header('libxml/xmlversion.h',
65
+ '/opt/include/libxml2',
66
+ '/usr/local/include/libxml2',
67
+ '/usr/include/libxml2'))
68
+ crash(<<EOL)
69
+ need libxml2.
70
+
71
+ Install the library or try one of the following options to extconf.rb:
72
+
73
+ --with-xml2-dir=/path/to/libxml2
74
+ --with-xml2-lib=/path/to/libxml2/lib
75
+ --with-xml2-include=/path/to/libxml2/include
76
+ EOL
77
+ end
78
+
79
+ unless have_library('xml2', 'xmlDocFormatDump')
80
+ crash('Your version of libxml2 is too old. Please upgrade.')
81
+ end
82
+
83
+ unless have_func('docbCreateFileParserCtxt')
84
+ crash('Need docbCreateFileParserCtxt')
85
+ end
86
+
87
+ if try_compile('int main() { return 0; }','-Wall')
88
+ $CFLAGS << ' -Wall'
89
+ end
90
+
91
+ $CFLAGS << ' ' << $INCFLAGS
92
+ $INSTALLFILES = [["../xml/libxml.rb", "$(RUBYLIBDIR)", "../xml"]]
93
+
94
+ create_header()
95
+ create_makefile('xml/libxml_so')
@@ -0,0 +1,372 @@
1
+ /* $Id: ruby_xml_attr.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_attr.h"
7
+
8
+ VALUE cXMLAttr;
9
+
10
+ void
11
+ ruby_xml_attr_free(ruby_xml_attr *rxa) {
12
+ if (rxa->attr != NULL && !rxa->is_ptr) {
13
+ xmlUnlinkNode((xmlNodePtr)rxa->attr);
14
+ xmlFreeNode((xmlNodePtr)rxa->attr);
15
+ rxa->attr = NULL;
16
+ }
17
+
18
+ free(rxa);
19
+ }
20
+
21
+
22
+ /*
23
+ * call-seq:
24
+ * attr.child => node
25
+ *
26
+ * Obtain this attribute's child attribute(s).
27
+ */
28
+ VALUE
29
+ ruby_xml_attr_child_get(VALUE self) {
30
+ ruby_xml_attr *rxa;
31
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
32
+ if (rxa->attr->children == NULL)
33
+ return(Qnil);
34
+ else
35
+ return(ruby_xml_node_new2(cXMLNode, rxa->xd, rxa->attr->children));
36
+ }
37
+
38
+
39
+ /*
40
+ * call-seq:
41
+ * attr.child? => (true|false)
42
+ *
43
+ * Determine whether this attribute has child attributes.
44
+ */
45
+ VALUE
46
+ ruby_xml_attr_child_q(VALUE self) {
47
+ ruby_xml_attr *rxa;
48
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
49
+ if (rxa->attr->children == NULL)
50
+ return(Qfalse);
51
+ else
52
+ return(Qtrue);
53
+ }
54
+
55
+
56
+ /*
57
+ * call-seq:
58
+ * attr.doc => document
59
+ *
60
+ * Obtain the XML::Document this attribute is associated with,
61
+ * if any.
62
+ */
63
+ VALUE
64
+ ruby_xml_attr_doc_get(VALUE self) {
65
+ ruby_xml_attr *rxa;
66
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
67
+ if (rxa->attr->doc == NULL)
68
+ return(Qnil);
69
+ else
70
+ return(ruby_xml_document_new(cXMLDocument, rxa->attr->doc));
71
+ }
72
+
73
+
74
+ /*
75
+ * call-seq:
76
+ * attr.doc? => (true|false)
77
+ *
78
+ * Determine whether this attribute is associated with an
79
+ * XML::Document.
80
+ */
81
+ VALUE
82
+ ruby_xml_attr_doc_q(VALUE self) {
83
+ ruby_xml_attr *rxa;
84
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
85
+ if (rxa->attr->doc == NULL)
86
+ return(Qfalse);
87
+ else
88
+ return(Qtrue);
89
+ }
90
+
91
+
92
+ /*
93
+ * call-seq:
94
+ * attr.last => node
95
+ *
96
+ * Obtain the last attribute.
97
+ */
98
+ VALUE
99
+ ruby_xml_attr_last_get(VALUE self) {
100
+ ruby_xml_attr *rxa;
101
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
102
+ if (rxa->attr->last == NULL)
103
+ return(Qnil);
104
+ else
105
+ return(ruby_xml_node_new2(cXMLNode, rxa->xd, rxa->attr->last));
106
+ }
107
+
108
+
109
+ /*
110
+ * call-seq:
111
+ * attr.last? => (true|false)
112
+ *
113
+ * Determine whether this is the last attribute.
114
+ */
115
+ VALUE
116
+ ruby_xml_attr_last_q(VALUE self) {
117
+ ruby_xml_attr *rxa;
118
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
119
+ if (rxa->attr->last == NULL)
120
+ return(Qfalse);
121
+ else
122
+ return(Qtrue);
123
+ }
124
+
125
+
126
+ static void
127
+ ruby_xml_attr_mark(ruby_xml_attr *rxa) {
128
+ if (rxa == NULL) return;
129
+ if (!NIL_P(rxa->xd)) rb_gc_mark(rxa->xd);
130
+ }
131
+
132
+
133
+ /*
134
+ * call-seq:
135
+ * attr.name => "name"
136
+ *
137
+ * Obtain this attribute's name.
138
+ */
139
+ VALUE
140
+ ruby_xml_attr_name_get(VALUE self) {
141
+ ruby_xml_attr *rxa;
142
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
143
+
144
+ if (rxa->attr->name == NULL)
145
+ return(Qnil);
146
+ else
147
+ return(rb_str_new2((const char*)rxa->attr->name));
148
+ }
149
+
150
+
151
+ VALUE
152
+ ruby_xml_attr_new(VALUE class, VALUE xd, xmlAttrPtr attr) {
153
+ ruby_xml_attr *rxa;
154
+
155
+ rxa = ALLOC(ruby_xml_attr);
156
+ rxa->attr = attr;
157
+ rxa->xd = xd;
158
+ rxa->is_ptr = 0;
159
+ return(Data_Wrap_Struct(class, ruby_xml_attr_mark,
160
+ ruby_xml_attr_free, rxa));
161
+ }
162
+
163
+
164
+ VALUE
165
+ ruby_xml_attr_new2(VALUE class, VALUE xd, xmlAttrPtr attr) {
166
+ ruby_xml_attr *rxa;
167
+
168
+ rxa = ALLOC(ruby_xml_attr);
169
+ rxa->attr = xmlCopyProp(attr->parent, attr);
170
+ rxa->xd = xd;
171
+ rxa->is_ptr = 0;
172
+ return(Data_Wrap_Struct(class, ruby_xml_attr_mark,
173
+ ruby_xml_attr_free, rxa));
174
+ }
175
+
176
+
177
+ /*
178
+ * call-seq:
179
+ * attr.next => node
180
+ *
181
+ * Obtain the next attribute.
182
+ */
183
+ VALUE
184
+ ruby_xml_attr_next_get(VALUE self) {
185
+ ruby_xml_attr *rxa;
186
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
187
+ if (rxa->attr->next == NULL)
188
+ return(Qnil);
189
+ else
190
+ return(ruby_xml_attr_new(cXMLAttr, rxa->xd, rxa->attr->next));
191
+ }
192
+
193
+
194
+ /*
195
+ * call-seq:
196
+ * attr.next? => (true|false)
197
+ *
198
+ * Determine whether there is a next attribute.
199
+ */
200
+ VALUE
201
+ ruby_xml_attr_next_q(VALUE self) {
202
+ ruby_xml_attr *rxa;
203
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
204
+ if (rxa->attr->next == NULL)
205
+ return(Qfalse);
206
+ else
207
+ return(Qtrue);
208
+ }
209
+
210
+
211
+ /*
212
+ * call-seq:
213
+ * attr.type_name => "attribute"
214
+ *
215
+ * Obtain this attribute node's type name.
216
+ */
217
+ VALUE
218
+ ruby_xml_attr_node_type_name(VALUE self) {
219
+ /* I think libxml2's naming convention blows monkey ass */
220
+ return(rb_str_new2("attribute"));
221
+ }
222
+
223
+
224
+ /*
225
+ * call-seq:
226
+ * attr.ns => namespace
227
+ *
228
+ * Obtain this attribute's associated XML::NS, if any.
229
+ */
230
+ VALUE
231
+ ruby_xml_attr_ns_get(VALUE self) {
232
+ ruby_xml_attr *rxa;
233
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
234
+ if (rxa->attr->ns == NULL)
235
+ return(Qnil);
236
+ else
237
+ return(ruby_xml_ns_new2(cXMLNS, rxa->xd, rxa->attr->ns));
238
+ }
239
+
240
+
241
+ /*
242
+ * call-seq:
243
+ * attr.ns? => (true|false)
244
+ *
245
+ * Determine whether this attribute has an associated
246
+ * namespace.
247
+ */
248
+ VALUE
249
+ ruby_xml_attr_ns_q(VALUE self) {
250
+ ruby_xml_attr *rxa;
251
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
252
+ if (rxa->attr->ns == NULL)
253
+ return(Qfalse);
254
+ else
255
+ return(Qtrue);
256
+ }
257
+
258
+
259
+ /*
260
+ * call-seq:
261
+ * attr.parent => node
262
+ *
263
+ * Obtain this attribute node's parent.
264
+ */
265
+ VALUE
266
+ ruby_xml_attr_parent_get(VALUE self) {
267
+ ruby_xml_attr *rxa;
268
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
269
+ if (rxa->attr->parent == NULL)
270
+ return(Qnil);
271
+ else
272
+ return(ruby_xml_node_new2(cXMLNode, rxa->xd, rxa->attr->parent));
273
+ }
274
+
275
+
276
+ /*
277
+ * call-seq:
278
+ * attr.parent? => (true|false)
279
+ *
280
+ * Determine whether this attribute has a parent.
281
+ */
282
+ VALUE
283
+ ruby_xml_attr_parent_q(VALUE self) {
284
+ ruby_xml_attr *rxa;
285
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
286
+ if (rxa->attr->parent == NULL)
287
+ return(Qfalse);
288
+ else
289
+ return(Qtrue);
290
+ }
291
+
292
+
293
+ /*
294
+ * call-seq:
295
+ * attr.prev => node
296
+ *
297
+ * Obtain the previous attribute.
298
+ */
299
+ VALUE
300
+ ruby_xml_attr_prev_get(VALUE self) {
301
+ ruby_xml_attr *rxa;
302
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
303
+ if (rxa->attr->prev == NULL)
304
+ return(Qnil);
305
+ else
306
+ return(ruby_xml_attr_new(cXMLAttr, rxa->xd, rxa->attr->prev));
307
+ }
308
+
309
+
310
+ /*
311
+ * call-seq:
312
+ * attr.prev? => (true|false)
313
+ *
314
+ * Determine whether there is a previous attribute.
315
+ */
316
+ VALUE
317
+ ruby_xml_attr_prev_q(VALUE self) {
318
+ ruby_xml_attr *rxa;
319
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
320
+ if (rxa->attr->prev == NULL)
321
+ return(Qfalse);
322
+ else
323
+ return(Qtrue);
324
+ }
325
+
326
+
327
+ /*
328
+ * call-seq:
329
+ * attr.value => "value"
330
+ *
331
+ * Obtain the value of this attribute.
332
+ */
333
+ VALUE
334
+ ruby_xml_attr_value(VALUE self) {
335
+ ruby_xml_attr *rxa;
336
+ xmlChar *value;
337
+
338
+ Data_Get_Struct(self, ruby_xml_attr, rxa);
339
+ if (ruby_xml_attr_parent_q(self) == Qtrue) {
340
+ value = xmlGetProp(rxa->attr->parent, rxa->attr->name);
341
+ if (value != NULL)
342
+ return(rb_str_new2((const char*)value));
343
+ }
344
+ return(Qnil);
345
+ }
346
+
347
+ // Rdoc needs to know
348
+ #ifdef RDOC_NEVER_DEFINED
349
+ mXML = rb_define_module("XML");
350
+ #endif
351
+
352
+ void
353
+ ruby_init_xml_attr(void) {
354
+ cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
355
+ rb_define_method(cXMLAttr, "child", ruby_xml_attr_child_get, 0);
356
+ rb_define_method(cXMLAttr, "child?", ruby_xml_attr_child_q, 0);
357
+ rb_define_method(cXMLAttr, "doc", ruby_xml_attr_doc_get, 0);
358
+ rb_define_method(cXMLAttr, "doc?", ruby_xml_attr_doc_q, 0);
359
+ rb_define_method(cXMLAttr, "last", ruby_xml_attr_last_get, 0);
360
+ rb_define_method(cXMLAttr, "last?", ruby_xml_attr_last_q, 0);
361
+ rb_define_method(cXMLAttr, "name", ruby_xml_attr_name_get, 0);
362
+ rb_define_method(cXMLAttr, "next", ruby_xml_attr_next_get, 0);
363
+ rb_define_method(cXMLAttr, "next?", ruby_xml_attr_next_q, 0);
364
+ rb_define_method(cXMLAttr, "node_type_name", ruby_xml_attr_node_type_name, 0);
365
+ rb_define_method(cXMLAttr, "ns", ruby_xml_attr_ns_get, 0);
366
+ rb_define_method(cXMLAttr, "ns?", ruby_xml_attr_ns_q, 0);
367
+ rb_define_method(cXMLAttr, "parent", ruby_xml_attr_parent_get, 0);
368
+ rb_define_method(cXMLAttr, "parent?", ruby_xml_attr_parent_q, 0);
369
+ rb_define_method(cXMLAttr, "prev", ruby_xml_attr_prev_get, 0);
370
+ rb_define_method(cXMLAttr, "prev?", ruby_xml_attr_prev_q, 0);
371
+ rb_define_method(cXMLAttr, "value", ruby_xml_attr_value, 0);
372
+ }