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.
- 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,22 @@
|
|
|
1
|
+
/* $Id: ruby_xml_parser_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_PARSER_CONTEXT__
|
|
6
|
+
#define __RUBY_XML_PARSER_CONTEXT__
|
|
7
|
+
|
|
8
|
+
extern VALUE cXMLParserContext;
|
|
9
|
+
|
|
10
|
+
typedef struct ruby_xml_parser_context {
|
|
11
|
+
xmlParserCtxtPtr ctxt;
|
|
12
|
+
int is_ptr;
|
|
13
|
+
} ruby_xml_parser_context;
|
|
14
|
+
|
|
15
|
+
void ruby_xml_parser_context_free(ruby_xml_parser_context *ctxt);
|
|
16
|
+
void ruby_init_xml_parser_context(void);
|
|
17
|
+
VALUE ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt);
|
|
18
|
+
VALUE ruby_xml_parser_context_new2(VALUE class);
|
|
19
|
+
VALUE ruby_xml_parser_context_new3();
|
|
20
|
+
VALUE ruby_xml_parser_context_each(VALUE self);
|
|
21
|
+
|
|
22
|
+
#endif
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/* $Id: ruby_xml_sax_parser.c,v 1.4 2006/04/14 23:46:06 roscopeco Exp $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
#include "libxml.h"
|
|
6
|
+
#include "ruby_xml_sax_parser.h"
|
|
7
|
+
|
|
8
|
+
VALUE cXMLSaxParser;
|
|
9
|
+
VALUE callsym;
|
|
10
|
+
|
|
11
|
+
#include "sax_parser_callbacks.inc"
|
|
12
|
+
|
|
13
|
+
void
|
|
14
|
+
ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp) {
|
|
15
|
+
/* Apparently this isn't needed: time will tell */
|
|
16
|
+
/* if (rxsp->xsh != NULL) */
|
|
17
|
+
/* xmlFreeSax_Parser(rxsp->sax_parser); */
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#define mark_handler(rxsp, handler) \
|
|
21
|
+
if (rxsp->cbp->handler && (rxsp->cbp->handler != Qnil)) \
|
|
22
|
+
rb_gc_mark(rxsp->cbp->handler)
|
|
23
|
+
|
|
24
|
+
void
|
|
25
|
+
ruby_xml_sax_parser_mark(ruby_xml_sax_parser *rxsp) {
|
|
26
|
+
mark_handler(rxsp, internalSubset);
|
|
27
|
+
mark_handler(rxsp, isStandalone);
|
|
28
|
+
mark_handler(rxsp, hasInternalSubset);
|
|
29
|
+
mark_handler(rxsp, hasExternalSubset);
|
|
30
|
+
mark_handler(rxsp, startDocument);
|
|
31
|
+
mark_handler(rxsp, endDocument);
|
|
32
|
+
mark_handler(rxsp, startElement);
|
|
33
|
+
mark_handler(rxsp, endElement);
|
|
34
|
+
mark_handler(rxsp, reference);
|
|
35
|
+
mark_handler(rxsp, characters);
|
|
36
|
+
mark_handler(rxsp, processingInstruction);
|
|
37
|
+
mark_handler(rxsp, comment);
|
|
38
|
+
mark_handler(rxsp, xmlParserWarning);
|
|
39
|
+
mark_handler(rxsp, xmlParserError);
|
|
40
|
+
mark_handler(rxsp, xmlParserFatalError);
|
|
41
|
+
mark_handler(rxsp, cdataBlock);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* call-seq:
|
|
47
|
+
* XML::SaxParser.new => sax_parser
|
|
48
|
+
*
|
|
49
|
+
* Create a new XML::SaxParser instance.
|
|
50
|
+
*/
|
|
51
|
+
VALUE
|
|
52
|
+
ruby_xml_sax_parser_new(VALUE class) {
|
|
53
|
+
ruby_xml_sax_parser *rxsp;
|
|
54
|
+
|
|
55
|
+
rxsp = ALLOC(ruby_xml_sax_parser);
|
|
56
|
+
rxsp->cbp = ALLOC(ruby_xml_sax_parser_callbacks);
|
|
57
|
+
memset(rxsp->cbp, 0, sizeof(ruby_xml_sax_parser_callbacks));
|
|
58
|
+
rxsp->xsh = &rubySAXHandlerStruct;
|
|
59
|
+
|
|
60
|
+
rxsp->xpc = NULL;
|
|
61
|
+
rxsp->filename = Qnil;
|
|
62
|
+
rxsp->str = Qnil;
|
|
63
|
+
|
|
64
|
+
return(Data_Wrap_Struct(class, ruby_xml_sax_parser_mark,
|
|
65
|
+
ruby_xml_sax_parser_free, rxsp));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* call-seq:
|
|
71
|
+
* sax_parser.filename => "filename"
|
|
72
|
+
*
|
|
73
|
+
* Obtain the filename this parser reads from.
|
|
74
|
+
*/
|
|
75
|
+
VALUE
|
|
76
|
+
ruby_xml_sax_parser_filename_get(VALUE self) {
|
|
77
|
+
ruby_xml_sax_parser *rxsp;
|
|
78
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
|
79
|
+
return(rxsp->filename);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* call-seq:
|
|
85
|
+
* sax_parser.filename = "filename"
|
|
86
|
+
*
|
|
87
|
+
* Set the filename this parser reads from.
|
|
88
|
+
*/
|
|
89
|
+
VALUE
|
|
90
|
+
ruby_xml_sax_parser_filename_set(VALUE self, VALUE filename) {
|
|
91
|
+
ruby_xml_sax_parser *rxsp;
|
|
92
|
+
Check_Type(filename, T_STRING);
|
|
93
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
|
94
|
+
rxsp->filename = filename;
|
|
95
|
+
return(rxsp->filename);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#define set_handler(self, argc, argv, handler) \
|
|
99
|
+
VALUE proc; \
|
|
100
|
+
rb_scan_args(argc, argv, "0&", &proc); \
|
|
101
|
+
ruby_xml_sax_parser *rxsp; \
|
|
102
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp); \
|
|
103
|
+
rxsp->cbp->handler = proc; \
|
|
104
|
+
return(Qnil);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* call-seq:
|
|
109
|
+
* parser.on_internal_subset { |name, external_id, system_id| ... } => nil
|
|
110
|
+
*
|
|
111
|
+
* Set the callback block for an internal subset event.
|
|
112
|
+
*/
|
|
113
|
+
VALUE
|
|
114
|
+
ruby_xml_sax_parser_on_internal_subset(int argc, VALUE *argv, VALUE self) {
|
|
115
|
+
set_handler(self, argc, argv, internalSubset);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* call-seq:
|
|
121
|
+
* parser.on_is_standalone { || ... } => nil
|
|
122
|
+
*
|
|
123
|
+
* Set the callback proc for 'is standalone' event.
|
|
124
|
+
*/
|
|
125
|
+
VALUE
|
|
126
|
+
ruby_xml_sax_parser_on_is_standalone(int argc, VALUE *argv, VALUE self) {
|
|
127
|
+
set_handler(self, argc, argv, isStandalone);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
* call-seq:
|
|
133
|
+
* parser.on_has_internal_subset { || ... } => nil
|
|
134
|
+
*
|
|
135
|
+
* Set the callback proc for an internal subset notification event.
|
|
136
|
+
*/
|
|
137
|
+
VALUE
|
|
138
|
+
ruby_xml_sax_parser_on_has_internal_subset(int argc, VALUE *argv, VALUE self) {
|
|
139
|
+
set_handler(self, argc, argv, hasInternalSubset);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* call-seq:
|
|
145
|
+
* parser.on_has_external_subset { || ... } => nil
|
|
146
|
+
*
|
|
147
|
+
* Set the callback proc for an external subset notification event.
|
|
148
|
+
*/
|
|
149
|
+
VALUE
|
|
150
|
+
ruby_xml_sax_parser_on_has_external_subset(int argc, VALUE *argv, VALUE self) {
|
|
151
|
+
set_handler(self, argc, argv, hasExternalSubset);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
* call-seq:
|
|
157
|
+
* parser.on_start_document { || ... } => nil
|
|
158
|
+
*
|
|
159
|
+
* Set the callback proc for a start document event.
|
|
160
|
+
*/
|
|
161
|
+
VALUE
|
|
162
|
+
ruby_xml_sax_parser_on_start_document(int argc, VALUE *argv, VALUE self) {
|
|
163
|
+
set_handler(self, argc, argv, startDocument);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* call-seq:
|
|
169
|
+
* parser.on_end_document { || ... } => nil
|
|
170
|
+
*
|
|
171
|
+
* Set the callback proc for an end document event.
|
|
172
|
+
*/
|
|
173
|
+
VALUE
|
|
174
|
+
ruby_xml_sax_parser_on_end_document(int argc, VALUE *argv, VALUE self) {
|
|
175
|
+
set_handler(self, argc, argv, endDocument);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
/*
|
|
180
|
+
* call-seq:
|
|
181
|
+
* parser.on_start_element { |name, attr_hash| ... } => nil
|
|
182
|
+
*
|
|
183
|
+
* Set the callback proc for an element start event.
|
|
184
|
+
*/
|
|
185
|
+
VALUE
|
|
186
|
+
ruby_xml_sax_parser_on_start_element(int argc, VALUE *argv, VALUE self) {
|
|
187
|
+
set_handler(self, argc, argv, startElement);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
/*
|
|
192
|
+
* call-seq:
|
|
193
|
+
* parser.on_end_element { |name| ... } => nil
|
|
194
|
+
*
|
|
195
|
+
* Set the callback proc for an element end event.
|
|
196
|
+
*/
|
|
197
|
+
VALUE
|
|
198
|
+
ruby_xml_sax_parser_on_end_element(int argc, VALUE *argv, VALUE self) {
|
|
199
|
+
set_handler(self, argc, argv, endElement);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
* call-seq:
|
|
205
|
+
* parser.on_reference { |name| ... } => nil
|
|
206
|
+
*
|
|
207
|
+
* Set the callback proc for a reference event.
|
|
208
|
+
*/
|
|
209
|
+
VALUE
|
|
210
|
+
ruby_xml_sax_parser_on_reference(int argc, VALUE *argv, VALUE self) {
|
|
211
|
+
set_handler(self, argc, argv, reference);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
/*
|
|
216
|
+
* call-seq:
|
|
217
|
+
* parser.on_characters { |chars| ... } => nil
|
|
218
|
+
*
|
|
219
|
+
* Set the callback proc for a characters event.
|
|
220
|
+
*/
|
|
221
|
+
VALUE
|
|
222
|
+
ruby_xml_sax_parser_on_characters(int argc, VALUE *argv, VALUE self) {
|
|
223
|
+
set_handler(self, argc, argv, characters);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
/*
|
|
228
|
+
* call-seq:
|
|
229
|
+
* parser.on_processing_instruction { |target, data| ... } => nil
|
|
230
|
+
*
|
|
231
|
+
* Set the callback proc for an processing instruction event.
|
|
232
|
+
*/
|
|
233
|
+
VALUE
|
|
234
|
+
ruby_xml_sax_parser_on_processing_instruction(int argc, VALUE *argv, VALUE self) {
|
|
235
|
+
set_handler(self, argc, argv, processingInstruction);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
* call-seq:
|
|
241
|
+
* parser.on_comment { |msg| ... } => nil
|
|
242
|
+
*
|
|
243
|
+
* Set the callback proc for a comment event.
|
|
244
|
+
*/
|
|
245
|
+
VALUE
|
|
246
|
+
ruby_xml_sax_parser_on_comment(int argc, VALUE *argv, VALUE self) {
|
|
247
|
+
set_handler(self, argc, argv, comment);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
* call-seq:
|
|
253
|
+
* parser.on_parser_warning { |msg| ... } => nil
|
|
254
|
+
*
|
|
255
|
+
* Set the callback proc that receives parser warnings.
|
|
256
|
+
*/
|
|
257
|
+
VALUE
|
|
258
|
+
ruby_xml_sax_parser_on_parser_warning(int argc, VALUE *argv, VALUE self) {
|
|
259
|
+
set_handler(self, argc, argv, xmlParserWarning);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
/*
|
|
264
|
+
* call-seq:
|
|
265
|
+
* parser.on_parser_error { |msg| ... } => nil
|
|
266
|
+
*
|
|
267
|
+
* Set the callback proc that receives parser errors.
|
|
268
|
+
*/
|
|
269
|
+
VALUE
|
|
270
|
+
ruby_xml_sax_parser_on_parser_error(int argc, VALUE *argv, VALUE self) {
|
|
271
|
+
set_handler(self, argc, argv, xmlParserError);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
/*
|
|
276
|
+
* call-seq:
|
|
277
|
+
* parser.on_parser_fatal_error { |msg| ... } => nil
|
|
278
|
+
*
|
|
279
|
+
* Set the callback proc that receives fatal parser errors.
|
|
280
|
+
*/
|
|
281
|
+
VALUE
|
|
282
|
+
ruby_xml_sax_parser_on_parser_fatal_error(int argc, VALUE *argv, VALUE self) {
|
|
283
|
+
set_handler(self, argc, argv, xmlParserFatalError);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/*
|
|
287
|
+
* call-seq:
|
|
288
|
+
* parser.on_cdata_block { |cdata| ... } => nil
|
|
289
|
+
*
|
|
290
|
+
* Set the callback proc for a CDATA block event.
|
|
291
|
+
*/
|
|
292
|
+
VALUE
|
|
293
|
+
ruby_xml_sax_parser_on_cdata_block(int argc, VALUE *argv, VALUE self) {
|
|
294
|
+
set_handler(self, argc, argv, cdataBlock);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/*
|
|
298
|
+
* call-seq:
|
|
299
|
+
* parser.on_external_subset { |name, external_id, system_id| ... } => nil
|
|
300
|
+
*
|
|
301
|
+
* Set the callback proc for an external subset event.
|
|
302
|
+
*/
|
|
303
|
+
VALUE
|
|
304
|
+
ruby_xml_sax_parser_on_external_subset(int argc, VALUE *argv, VALUE self) {
|
|
305
|
+
set_handler(self, argc, argv, externalSubset);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
/*
|
|
310
|
+
* call-seq:
|
|
311
|
+
* parser.parse => (true|false)
|
|
312
|
+
*
|
|
313
|
+
* Parse the input XML, generating callbacks to the procs
|
|
314
|
+
* registered with the parser (via the on_xxxx attributes).
|
|
315
|
+
*/
|
|
316
|
+
VALUE
|
|
317
|
+
ruby_xml_sax_parser_parse(VALUE self) {
|
|
318
|
+
char *str;
|
|
319
|
+
int status = 1;
|
|
320
|
+
ruby_xml_sax_parser *rxsp;
|
|
321
|
+
|
|
322
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
|
323
|
+
|
|
324
|
+
if (rxsp->filename != Qnil) {
|
|
325
|
+
status = xmlSAXUserParseFile(rxsp->xsh, rxsp->cbp, StringValuePtr(rxsp->filename));
|
|
326
|
+
} else if (rxsp->str != Qnil) {
|
|
327
|
+
str = StringValuePtr(rxsp->str);
|
|
328
|
+
status = //ruby_xml_document_new(cXMLDocument,
|
|
329
|
+
xmlSAXUserParseMemory(rxsp->xsh, rxsp->cbp,
|
|
330
|
+
str, strlen(str)); //);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* XXX This should return an exception for the various error codes
|
|
334
|
+
* that can come back in status, but I'm too lazy to do that right
|
|
335
|
+
* now. */
|
|
336
|
+
if (status)
|
|
337
|
+
return(Qfalse);
|
|
338
|
+
else
|
|
339
|
+
return(Qtrue);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
/*
|
|
344
|
+
* call-seq:
|
|
345
|
+
* parser.string => "xml"
|
|
346
|
+
*
|
|
347
|
+
* Obtain the parser's input string.
|
|
348
|
+
*/
|
|
349
|
+
VALUE
|
|
350
|
+
ruby_xml_sax_parser_str_get(VALUE self) {
|
|
351
|
+
ruby_xml_sax_parser *rxsp;
|
|
352
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
|
353
|
+
return(rxsp->str);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
* call-seq:
|
|
359
|
+
* parser.string = "xml"
|
|
360
|
+
*
|
|
361
|
+
* Set the parser's input string.
|
|
362
|
+
*/
|
|
363
|
+
VALUE
|
|
364
|
+
ruby_xml_sax_parser_str_set(VALUE self, VALUE str) {
|
|
365
|
+
ruby_xml_sax_parser *rxsp;
|
|
366
|
+
Check_Type(str, T_STRING);
|
|
367
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
|
368
|
+
rxsp->str = str;
|
|
369
|
+
return(rxsp->str);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Rdoc needs to know
|
|
373
|
+
#ifdef RDOC_NEVER_DEFINED
|
|
374
|
+
mXML = rb_define_module("XML");
|
|
375
|
+
#endif
|
|
376
|
+
|
|
377
|
+
void
|
|
378
|
+
ruby_init_xml_sax_parser(void) {
|
|
379
|
+
cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
|
|
380
|
+
callsym = rb_intern("call");
|
|
381
|
+
|
|
382
|
+
rb_define_singleton_method(cXMLSaxParser, "new", ruby_xml_sax_parser_new, 0);
|
|
383
|
+
|
|
384
|
+
rb_define_method(cXMLSaxParser, "filename",
|
|
385
|
+
ruby_xml_sax_parser_filename_get, 0);
|
|
386
|
+
rb_define_method(cXMLSaxParser, "filename=",
|
|
387
|
+
ruby_xml_sax_parser_filename_set, 1);
|
|
388
|
+
rb_define_method(cXMLSaxParser, "parse", ruby_xml_sax_parser_parse, 0);
|
|
389
|
+
rb_define_method(cXMLSaxParser, "string", ruby_xml_sax_parser_str_get, 0);
|
|
390
|
+
rb_define_method(cXMLSaxParser, "string=", ruby_xml_sax_parser_str_set, 1);
|
|
391
|
+
|
|
392
|
+
rb_define_method(cXMLSaxParser, "on_internal_subset",
|
|
393
|
+
ruby_xml_sax_parser_on_internal_subset, -1);
|
|
394
|
+
rb_define_method(cXMLSaxParser, "on_is_standalone",
|
|
395
|
+
ruby_xml_sax_parser_on_is_standalone, -1);
|
|
396
|
+
rb_define_method(cXMLSaxParser, "on_has_internal_subset",
|
|
397
|
+
ruby_xml_sax_parser_on_has_internal_subset, -1);
|
|
398
|
+
rb_define_method(cXMLSaxParser, "on_has_external_subset",
|
|
399
|
+
ruby_xml_sax_parser_on_has_external_subset, -1);
|
|
400
|
+
rb_define_method(cXMLSaxParser, "on_start_document",
|
|
401
|
+
ruby_xml_sax_parser_on_start_document, -1);
|
|
402
|
+
rb_define_method(cXMLSaxParser, "on_end_document",
|
|
403
|
+
ruby_xml_sax_parser_on_end_document, -1);
|
|
404
|
+
rb_define_method(cXMLSaxParser, "on_start_element",
|
|
405
|
+
ruby_xml_sax_parser_on_start_element, -1);
|
|
406
|
+
rb_define_method(cXMLSaxParser, "on_end_element",
|
|
407
|
+
ruby_xml_sax_parser_on_end_element, -1);
|
|
408
|
+
rb_define_method(cXMLSaxParser, "on_reference",
|
|
409
|
+
ruby_xml_sax_parser_on_reference, -1);
|
|
410
|
+
rb_define_method(cXMLSaxParser, "on_characters",
|
|
411
|
+
ruby_xml_sax_parser_on_characters, -1);
|
|
412
|
+
rb_define_method(cXMLSaxParser, "on_processing_instruction",
|
|
413
|
+
ruby_xml_sax_parser_on_processing_instruction, -1);
|
|
414
|
+
rb_define_method(cXMLSaxParser, "on_comment",
|
|
415
|
+
ruby_xml_sax_parser_on_comment, -1);
|
|
416
|
+
rb_define_method(cXMLSaxParser, "on_parser_warning",
|
|
417
|
+
ruby_xml_sax_parser_on_parser_warning, -1);
|
|
418
|
+
rb_define_method(cXMLSaxParser, "on_parser_error",
|
|
419
|
+
ruby_xml_sax_parser_on_parser_error, -1);
|
|
420
|
+
rb_define_method(cXMLSaxParser, "on_parser_fatal_error",
|
|
421
|
+
ruby_xml_sax_parser_on_parser_fatal_error, -1);
|
|
422
|
+
rb_define_method(cXMLSaxParser, "on_cdata_block",
|
|
423
|
+
ruby_xml_sax_parser_on_cdata_block, -1);
|
|
424
|
+
rb_define_method(cXMLSaxParser, "on_external_subset",
|
|
425
|
+
ruby_xml_sax_parser_on_external_subset, -1);
|
|
426
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* $Id: ruby_xml_sax_parser.h,v 1.2 2006/04/14 14:45:52 roscopeco Exp $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
#ifndef __RUBY_XML_SAX_PARSER__
|
|
6
|
+
#define __RUBY_XML_SAX_PARSER__
|
|
7
|
+
|
|
8
|
+
extern VALUE cXMLSaxParser;
|
|
9
|
+
|
|
10
|
+
typedef struct ruby_xml_sax_parser_callbacks {
|
|
11
|
+
VALUE internalSubset;
|
|
12
|
+
VALUE isStandalone;
|
|
13
|
+
VALUE hasInternalSubset;
|
|
14
|
+
VALUE hasExternalSubset;
|
|
15
|
+
VALUE resolveEntity;
|
|
16
|
+
VALUE getEntity;
|
|
17
|
+
VALUE entityDecl;
|
|
18
|
+
VALUE notationDecl;
|
|
19
|
+
VALUE attributeDecl;
|
|
20
|
+
VALUE elementDecl;
|
|
21
|
+
VALUE unparsedEntityDecl;
|
|
22
|
+
VALUE setDocumentLocator;
|
|
23
|
+
VALUE startDocument;
|
|
24
|
+
VALUE endDocument;
|
|
25
|
+
VALUE startElement;
|
|
26
|
+
VALUE endElement;
|
|
27
|
+
VALUE reference;
|
|
28
|
+
VALUE characters;
|
|
29
|
+
VALUE ignorableWhitespace;
|
|
30
|
+
VALUE processingInstruction;
|
|
31
|
+
VALUE comment;
|
|
32
|
+
VALUE xmlParserWarning;
|
|
33
|
+
VALUE xmlParserError;
|
|
34
|
+
VALUE xmlParserFatalError;
|
|
35
|
+
VALUE getParameterEntity;
|
|
36
|
+
VALUE cdataBlock;
|
|
37
|
+
VALUE externalSubset;
|
|
38
|
+
} ruby_xml_sax_parser_callbacks;
|
|
39
|
+
|
|
40
|
+
typedef struct ruby_xml_sax_parser {
|
|
41
|
+
xmlParserCtxtPtr xpc;
|
|
42
|
+
xmlSAXHandlerPtr xsh;
|
|
43
|
+
ruby_xml_sax_parser_callbacks *cbp;
|
|
44
|
+
VALUE filename;
|
|
45
|
+
VALUE str;
|
|
46
|
+
} ruby_xml_sax_parser;
|
|
47
|
+
|
|
48
|
+
void ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp);
|
|
49
|
+
void ruby_init_xml_sax_parser(void);
|
|
50
|
+
VALUE ruby_xml_sax_parser_new(VALUE class);
|
|
51
|
+
|
|
52
|
+
#endif
|