mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
/* $Id: ruby_xml_xpath.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_XPATH__
|
6
|
+
#define __RUBY_XML_XPATH__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPath;
|
9
|
+
extern VALUE eXMLXPathInvalidPath;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpath {
|
12
|
+
VALUE xd;
|
13
|
+
VALUE ctxt;
|
14
|
+
xmlXPathObjectPtr xpop;
|
15
|
+
} ruby_xml_xpath;
|
16
|
+
|
17
|
+
void ruby_xml_xpath_free(ruby_xml_xpath *rxxp);
|
18
|
+
VALUE ruby_xml_xpath_find(int argc, VALUE *argv, VALUE class);
|
19
|
+
VALUE ruby_xml_xpath_find2(int argc, VALUE *argv);
|
20
|
+
VALUE ruby_xml_xpath_new(VALUE class, VALUE xd, VALUE xxpc,
|
21
|
+
xmlXPathObjectPtr xpop);
|
22
|
+
void ruby_init_xml_xpath(void);
|
23
|
+
|
24
|
+
#endif
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/* $Id: ruby_xml_xpath_context.c,v 1.2 2006/02/27 12:55:32 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
#include "ruby_xml_xpath_context.h"
|
7
|
+
|
8
|
+
VALUE cXMLXPathContext;
|
9
|
+
|
10
|
+
/*
|
11
|
+
* call-seq:
|
12
|
+
* context.doc => document
|
13
|
+
*
|
14
|
+
* Obtain the XML::Document associated with this XPath.
|
15
|
+
*/
|
16
|
+
VALUE
|
17
|
+
ruby_xml_xpath_context_doc_get(VALUE self) {
|
18
|
+
ruby_xml_xpath_context *rxxpc;
|
19
|
+
Data_Get_Struct(self, ruby_xml_xpath_context, rxxpc);
|
20
|
+
|
21
|
+
return(rxxpc->xd);
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
void
|
26
|
+
ruby_xml_xpath_context_free(ruby_xml_xpath_context *rxxpc) {
|
27
|
+
if (rxxpc->ctxt != NULL) {
|
28
|
+
xmlXPathFreeContext(rxxpc->ctxt);
|
29
|
+
rxxpc->ctxt = NULL;
|
30
|
+
}
|
31
|
+
|
32
|
+
free(rxxpc);
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
void
|
37
|
+
ruby_xml_xpath_context_mark(ruby_xml_xpath_context *rxxpc) {
|
38
|
+
if (rxxpc == NULL) return;
|
39
|
+
if (!NIL_P(rxxpc->xd)) rb_gc_mark(rxxpc->xd);
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
VALUE
|
44
|
+
ruby_xml_xpath_context_new(VALUE class, VALUE xd,
|
45
|
+
xmlXPathContextPtr xxpc) {
|
46
|
+
ruby_xml_xpath_context *rxxpc;
|
47
|
+
|
48
|
+
rxxpc = ALLOC(ruby_xml_xpath_context);
|
49
|
+
rxxpc->ctxt = xxpc;
|
50
|
+
rxxpc->xd = xd;
|
51
|
+
return(Data_Wrap_Struct(class, ruby_xml_xpath_context_mark,
|
52
|
+
ruby_xml_xpath_context_free, rxxpc));
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
VALUE
|
57
|
+
ruby_xml_xpath_context_new2(VALUE xd, xmlXPathContextPtr xxpc) {
|
58
|
+
return(ruby_xml_xpath_context_new(cXMLXPathContext, xd, xxpc));
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
VALUE
|
63
|
+
ruby_xml_xpath_context_new3(VALUE xd) {
|
64
|
+
ruby_xml_document *rxd;
|
65
|
+
xmlXPathContextPtr ctxt;
|
66
|
+
|
67
|
+
Data_Get_Struct(xd, ruby_xml_document, rxd);
|
68
|
+
if (rxd->doc == NULL)
|
69
|
+
return(Qnil);
|
70
|
+
|
71
|
+
ctxt = xmlXPathNewContext(rxd->doc);
|
72
|
+
if (ctxt == NULL)
|
73
|
+
return(Qnil);
|
74
|
+
|
75
|
+
return(ruby_xml_xpath_context_new2(xd, ctxt));
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
VALUE
|
80
|
+
ruby_xml_xpath_context_new4(VALUE rnode) {
|
81
|
+
ruby_xml_node *node;
|
82
|
+
|
83
|
+
Data_Get_Struct(rnode, ruby_xml_node, node);
|
84
|
+
return(ruby_xml_xpath_context_new3(node->xd));
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
/*
|
89
|
+
* call-seq:
|
90
|
+
* context.register_namespace(prefix, uri) => (true|false)
|
91
|
+
*
|
92
|
+
* Register the specified namespace URI with the specified prefix
|
93
|
+
* in this context.
|
94
|
+
*/
|
95
|
+
VALUE
|
96
|
+
ruby_xml_xpath_context_register_namespace(VALUE self, VALUE prefix, VALUE uri) {
|
97
|
+
ruby_xml_xpath_context *rxxpc;
|
98
|
+
|
99
|
+
Data_Get_Struct(self, ruby_xml_xpath_context, rxxpc);
|
100
|
+
if (xmlXPathRegisterNs(rxxpc->ctxt,
|
101
|
+
(xmlChar*)StringValuePtr(prefix),
|
102
|
+
(xmlChar*)StringValuePtr(uri))
|
103
|
+
== 0) {
|
104
|
+
return(Qtrue);
|
105
|
+
} else {
|
106
|
+
/* Should raise an exception, IMHO */
|
107
|
+
return(Qfalse);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
// Rdoc needs to know
|
112
|
+
#ifdef RDOC_NEVER_DEFINED
|
113
|
+
mXML = rb_define_module("XML");
|
114
|
+
cXMLXPath = rb_define_class_under(mXML, "XPath", rb_cObject);
|
115
|
+
#endif
|
116
|
+
|
117
|
+
void
|
118
|
+
ruby_init_xml_xpath_context(void) {
|
119
|
+
cXMLXPathContext = rb_define_class_under(cXMLXPath, "Context", rb_cObject);
|
120
|
+
|
121
|
+
rb_define_method(cXMLXPathContext, "register_namespace",
|
122
|
+
ruby_xml_xpath_context_register_namespace, 2);
|
123
|
+
rb_define_method(cXMLXPathContext, "doc",
|
124
|
+
ruby_xml_xpath_context_doc_get, 0);
|
125
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/* $Id: ruby_xml_xpath_context.h,v 1.2 2006/02/27 12:55:32 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_XPATH_CONTEXT__
|
6
|
+
#define __RUBY_XML_XPATH_CONTEXT__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPathContext;
|
9
|
+
|
10
|
+
typedef struct ruby_xml_xpath_context {
|
11
|
+
VALUE xd;
|
12
|
+
xmlXPathContextPtr ctxt;
|
13
|
+
} ruby_xml_xpath_context;
|
14
|
+
|
15
|
+
void ruby_xml_xpath_context_free(ruby_xml_xpath_context *rxxpc);
|
16
|
+
VALUE ruby_xml_xpath_context_new(VALUE class, VALUE xd,
|
17
|
+
xmlXPathContextPtr ctxt);
|
18
|
+
VALUE ruby_xml_xpath_context_new2(VALUE xd, xmlXPathContextPtr ctxt);
|
19
|
+
VALUE ruby_xml_xpath_context_new3(VALUE xd);
|
20
|
+
VALUE ruby_xml_xpath_context_new4(VALUE rnode);
|
21
|
+
VALUE ruby_xml_xpath_context_register_namespace(VALUE self, VALUE prefix, VALUE uri);
|
22
|
+
void ruby_init_xml_xpath_context(void);
|
23
|
+
|
24
|
+
#endif
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/* $Id: ruby_xml_xpointer.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_xpointer.h"
|
7
|
+
|
8
|
+
VALUE cXMLXPointer;
|
9
|
+
VALUE eXMLXPointerInvalidExpression;
|
10
|
+
|
11
|
+
VALUE
|
12
|
+
ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
|
13
|
+
#ifdef LIBXML_XPTR_ENABLED
|
14
|
+
ruby_xml_node *node;
|
15
|
+
ruby_xml_xpath_context *xxpc;
|
16
|
+
VALUE rxptr_xpth_ctxt, rxxp;
|
17
|
+
xmlXPathObjectPtr xpath;
|
18
|
+
|
19
|
+
Check_Type(xptr_str, T_STRING);
|
20
|
+
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
21
|
+
rb_raise(rb_eTypeError, "require an XML::Node object");
|
22
|
+
|
23
|
+
Data_Get_Struct(rnode, ruby_xml_node, node);
|
24
|
+
|
25
|
+
rxptr_xpth_ctxt = ruby_xml_xpath_context_new(cXMLXPathContext, node->xd,
|
26
|
+
xmlXPtrNewContext(node->node->doc, node->node, NULL));
|
27
|
+
if (NIL_P(rxptr_xpth_ctxt))
|
28
|
+
return(Qnil);
|
29
|
+
Data_Get_Struct(rxptr_xpth_ctxt, ruby_xml_xpath_context, xxpc);
|
30
|
+
|
31
|
+
xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xxpc->ctxt);
|
32
|
+
if (xpath == NULL)
|
33
|
+
rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
|
34
|
+
|
35
|
+
rxxp = ruby_xml_xpath_new(cXMLXPath, node->xd, rxptr_xpth_ctxt, xpath);
|
36
|
+
return(rxxp);
|
37
|
+
#else
|
38
|
+
rb_warn("libxml was compiled without XPointer support");
|
39
|
+
return(Qfalse);
|
40
|
+
#endif
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
VALUE
|
45
|
+
ruby_xml_xpointer_point2(VALUE node, VALUE xptr_str) {
|
46
|
+
return(ruby_xml_xpointer_point(cXMLXPointer, node, xptr_str));
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
/*
|
51
|
+
* call-seq:
|
52
|
+
* XML::XPointer.range(start_node, end_node) => xpath
|
53
|
+
*
|
54
|
+
* Create an xpath representing the range between the supplied
|
55
|
+
* start and end node.
|
56
|
+
*/
|
57
|
+
VALUE
|
58
|
+
ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
|
59
|
+
#ifdef LIBXML_XPTR_ENABLED
|
60
|
+
ruby_xml_node *start, *end;
|
61
|
+
VALUE rxxp;
|
62
|
+
xmlXPathObjectPtr xpath;
|
63
|
+
|
64
|
+
if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
|
65
|
+
rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
|
66
|
+
if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
|
67
|
+
rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
|
68
|
+
|
69
|
+
Data_Get_Struct(rstart, ruby_xml_node, start);
|
70
|
+
if (start->node == NULL)
|
71
|
+
return(Qnil);
|
72
|
+
|
73
|
+
Data_Get_Struct(rend, ruby_xml_node, end);
|
74
|
+
if (end->node == NULL)
|
75
|
+
return(Qnil);
|
76
|
+
|
77
|
+
xpath = xmlXPtrNewRangeNodes(start->node, end->node);
|
78
|
+
if (xpath == NULL)
|
79
|
+
rb_fatal("You shouldn't be able to have this happen");
|
80
|
+
|
81
|
+
rxxp = ruby_xml_xpath_new(cXMLXPath, start->xd, Qnil, xpath);
|
82
|
+
return(rxxp);
|
83
|
+
#else
|
84
|
+
rb_warn("libxml was compiled without XPointer support");
|
85
|
+
return(Qfalse);
|
86
|
+
#endif
|
87
|
+
}
|
88
|
+
|
89
|
+
// Rdoc needs to know
|
90
|
+
#ifdef RDOC_NEVER_DEFINED
|
91
|
+
mXML = rb_define_module("XML");
|
92
|
+
#endif
|
93
|
+
|
94
|
+
void
|
95
|
+
ruby_init_xml_xpointer(void) {
|
96
|
+
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
97
|
+
eXMLXPointerInvalidExpression = rb_define_class_under(cXMLXPointer, "InvalidExpression", rb_eException);
|
98
|
+
|
99
|
+
rb_define_singleton_method(cXMLXPointer, "range", ruby_xml_xpointer_range, 2);
|
100
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* $Id: ruby_xml_xpointer.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_XPOINTER__
|
6
|
+
#define __RUBY_XML_XPOINTER__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPointer;
|
9
|
+
extern VALUE eXMLXPointerInvalidExpression;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpointer {
|
12
|
+
VALUE xd;
|
13
|
+
VALUE ctxt;
|
14
|
+
/*
|
15
|
+
* This needs to go into a xpointer data struct:
|
16
|
+
*
|
17
|
+
* xmlLocationSetPtr xptr;
|
18
|
+
*
|
19
|
+
* I also need an xpointer data struct type.
|
20
|
+
*/
|
21
|
+
} ruby_xml_xpointer;
|
22
|
+
|
23
|
+
VALUE ruby_xml_xpointer_point(VALUE class, VALUE node, VALUE xptr_string);
|
24
|
+
VALUE ruby_xml_xpointer_point2(VALUE node, VALUE xptr_string);
|
25
|
+
void ruby_init_xml_xpointer(void);
|
26
|
+
|
27
|
+
#endif
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* $Id: ruby_xml_xpointer_context.c,v 1.2 2006/02/27 12:55:32 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
#include "ruby_xml_xpointer_context.h"
|
7
|
+
|
8
|
+
VALUE cXMLXPointerContext;
|
9
|
+
VALUE eXMLXPointerContextInvalidPath;
|
10
|
+
|
11
|
+
// Rdoc needs to know
|
12
|
+
#ifdef RDOC_NEVER_DEFINED
|
13
|
+
mXML = rb_define_module("XML");
|
14
|
+
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
15
|
+
#endif
|
16
|
+
|
17
|
+
void
|
18
|
+
ruby_init_xml_xpointer_context(void) {
|
19
|
+
cXMLXPointerContext = rb_define_class_under(cXMLXPointer, "Context", cXMLXPathContext);
|
20
|
+
eXMLXPointerContextInvalidPath = rb_define_class_under(cXMLXPointerContext, "InvalidPath", rb_eException);
|
21
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/* $Id: ruby_xml_xpointer_context.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_XPOINTER_CONTEXT__
|
6
|
+
#define __RUBY_XML_XPOINTER_CONTEXT__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPointerContext;
|
9
|
+
extern VALUE eXMLXPointerContextInvalidPath;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpointer_context {
|
12
|
+
VALUE xd;
|
13
|
+
xmlXPathContextPtr ctxt;
|
14
|
+
} ruby_xml_xpointer_context;
|
15
|
+
|
16
|
+
void ruby_init_xml_xpointer_context(void);
|
17
|
+
|
18
|
+
#endif
|
@@ -0,0 +1,202 @@
|
|
1
|
+
/* $Id: sax_parser_callbacks.inc,v 1.1 2006/04/14 14:50:58 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
/*
|
6
|
+
* SAX CALLBACK HANDLERS
|
7
|
+
*/
|
8
|
+
static void internal_subset_func(ruby_xml_sax_parser_callbacks *cbp,
|
9
|
+
const char *name,
|
10
|
+
const char *extid,
|
11
|
+
const char *sysid) {
|
12
|
+
VALUE handler = cbp->internalSubset;
|
13
|
+
|
14
|
+
if (handler && handler != Qnil) {
|
15
|
+
rb_funcall(handler, callsym, 3, rb_str_new2(name),
|
16
|
+
rb_str_new2(extid), rb_str_new2(sysid));
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
static void is_standalone_func(ruby_xml_sax_parser_callbacks *cbp) {
|
21
|
+
VALUE handler = cbp->isStandalone;
|
22
|
+
|
23
|
+
if (handler && handler != Qnil) {
|
24
|
+
rb_funcall(handler,callsym,0);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
static void has_internal_subset_func(ruby_xml_sax_parser_callbacks *cbp) {
|
29
|
+
VALUE handler = cbp->hasInternalSubset;
|
30
|
+
|
31
|
+
if (handler && handler != Qnil) {
|
32
|
+
rb_funcall(handler,callsym,0);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
static void has_external_subset_func(ruby_xml_sax_parser_callbacks *cbp) {
|
37
|
+
VALUE handler = cbp->hasExternalSubset;
|
38
|
+
|
39
|
+
if (handler && handler != Qnil) {
|
40
|
+
rb_funcall(handler,callsym,0);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
static void start_document_func(ruby_xml_sax_parser_callbacks *cbp) {
|
45
|
+
VALUE handler = cbp->startDocument;
|
46
|
+
|
47
|
+
if (handler && handler != Qnil) {
|
48
|
+
rb_funcall(handler,callsym,0);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
static void end_document_func(ruby_xml_sax_parser_callbacks *cbp) {
|
53
|
+
VALUE handler = cbp->endDocument;
|
54
|
+
|
55
|
+
if (handler && handler != Qnil) {
|
56
|
+
rb_funcall(handler,callsym,0);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
static void start_element_func(ruby_xml_sax_parser_callbacks *cbp,
|
61
|
+
const char *name, const char **attrs) {
|
62
|
+
VALUE handler = cbp->startElement;
|
63
|
+
VALUE ahsh = rb_hash_new();
|
64
|
+
const char *attr, *value;
|
65
|
+
|
66
|
+
if (attrs) {
|
67
|
+
while ((attr = *(attrs++))) {
|
68
|
+
value = *(attrs++);
|
69
|
+
rb_hash_aset(ahsh, rb_str_new2(attr), rb_str_new2(value));
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
if (handler && handler != Qnil) {
|
74
|
+
rb_funcall(handler,callsym,2,rb_str_new2(name),ahsh);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
static void end_element_func(ruby_xml_sax_parser_callbacks *cbp,
|
79
|
+
const char *name) {
|
80
|
+
VALUE handler = cbp->endElement;
|
81
|
+
|
82
|
+
if (handler && handler != Qnil) {
|
83
|
+
rb_funcall(handler,callsym,1,rb_str_new2(name));
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
static void reference_func(ruby_xml_sax_parser_callbacks *cbp,
|
88
|
+
const char *name) {
|
89
|
+
VALUE handler = cbp->reference;
|
90
|
+
|
91
|
+
if (handler && handler != Qnil) {
|
92
|
+
rb_funcall(handler,callsym,1,rb_str_new2(name));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
static void characters_func(ruby_xml_sax_parser_callbacks *cbp,
|
97
|
+
const char *chars, int len) {
|
98
|
+
VALUE handler = cbp->characters;
|
99
|
+
|
100
|
+
if (handler && handler != Qnil) {
|
101
|
+
rb_funcall(handler,callsym,1,rb_str_new(chars, len));
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
static void processing_instruction_func(ruby_xml_sax_parser_callbacks *cbp,
|
106
|
+
const char *target, const char *data) {
|
107
|
+
VALUE handler = cbp->processingInstruction;
|
108
|
+
|
109
|
+
if (handler && handler != Qnil) {
|
110
|
+
rb_funcall(handler, callsym, 2,
|
111
|
+
rb_str_new2(target),rb_str_new2(data));
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
static void comment_func(ruby_xml_sax_parser_callbacks *cbp,
|
116
|
+
const char *msg) {
|
117
|
+
VALUE handler = cbp->comment;
|
118
|
+
|
119
|
+
if (handler && handler != Qnil) {
|
120
|
+
rb_funcall(handler,callsym,1,rb_str_new2(msg));
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
// TODO these next three should actually be formatting messages.
|
125
|
+
static void warning_func(ruby_xml_sax_parser_callbacks *cbp,
|
126
|
+
const char *msg, ...) {
|
127
|
+
VALUE handler = cbp->xmlParserWarning;
|
128
|
+
|
129
|
+
if (handler && handler != Qnil) {
|
130
|
+
rb_funcall(handler,callsym,1,rb_str_new2(msg));
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
static void error_func(ruby_xml_sax_parser_callbacks *cbp,
|
135
|
+
const char *msg, ...) {
|
136
|
+
VALUE handler = cbp->xmlParserError;
|
137
|
+
|
138
|
+
if (handler && handler != Qnil) {
|
139
|
+
rb_funcall(handler,callsym,1,rb_str_new2(msg));
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
static void fatal_error_func(ruby_xml_sax_parser_callbacks *cbp,
|
144
|
+
const char *msg, ...) {
|
145
|
+
VALUE handler = cbp->xmlParserFatalError;
|
146
|
+
|
147
|
+
if (handler && handler != Qnil) {
|
148
|
+
rb_funcall(handler,callsym,1,rb_str_new2(msg));
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
static void cdata_block_func(ruby_xml_sax_parser_callbacks *cbp,
|
153
|
+
const char *value, int len) {
|
154
|
+
VALUE handler = cbp->cdataBlock;
|
155
|
+
|
156
|
+
if (handler && handler != Qnil) {
|
157
|
+
rb_funcall(handler,callsym,1,rb_str_new(value, len));
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
static void external_subset_func(ruby_xml_sax_parser_callbacks *cbp,
|
162
|
+
const char *name,
|
163
|
+
const char *extid,
|
164
|
+
const char *sysid) {
|
165
|
+
VALUE handler = cbp->externalSubset;
|
166
|
+
|
167
|
+
if (handler && handler != Qnil) {
|
168
|
+
rb_funcall(handler, callsym, 3, rb_str_new2(name),
|
169
|
+
rb_str_new2(extid), rb_str_new2(sysid));
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
static xmlSAXHandler rubySAXHandlerStruct = {
|
174
|
+
(internalSubsetSAXFunc)internal_subset_func,
|
175
|
+
(isStandaloneSAXFunc)is_standalone_func,
|
176
|
+
(hasInternalSubsetSAXFunc)has_internal_subset_func,
|
177
|
+
(hasExternalSubsetSAXFunc)has_external_subset_func,
|
178
|
+
0, /* resolveEntity */
|
179
|
+
0, /* getEntity */
|
180
|
+
0, /* entityDecl */
|
181
|
+
0, /* notationDecl */
|
182
|
+
0, /* attributeDecl */
|
183
|
+
0, /* elementDecl */
|
184
|
+
0, /* unparsedEntityDecl */
|
185
|
+
0, /* setDocumentLocator */
|
186
|
+
(startDocumentSAXFunc)start_document_func,
|
187
|
+
(endDocumentSAXFunc)end_document_func,
|
188
|
+
(startElementSAXFunc)start_element_func,
|
189
|
+
(endElementSAXFunc)end_element_func,
|
190
|
+
(referenceSAXFunc)reference_func,
|
191
|
+
(charactersSAXFunc)characters_func,
|
192
|
+
0, /* ignorableWhitespace */
|
193
|
+
(processingInstructionSAXFunc)processing_instruction_func,
|
194
|
+
(commentSAXFunc)comment_func,
|
195
|
+
(warningSAXFunc)warning_func,
|
196
|
+
(errorSAXFunc)error_func,
|
197
|
+
(fatalErrorSAXFunc)fatal_error_func,
|
198
|
+
0, /* xmlGetParameterEntity */
|
199
|
+
(cdataBlockSAXFunc)cdata_block_func,
|
200
|
+
(externalSubsetSAXFunc)external_subset_func,
|
201
|
+
1
|
202
|
+
};
|