nodewrap 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +59 -0
- data/LEGAL +6 -0
- data/LGPL +515 -0
- data/LICENSE +6 -0
- data/README +31 -0
- data/TODO +9 -0
- data/example/README +5 -0
- data/example/simple_client.rb +12 -0
- data/example/simple_server.rb +11 -0
- data/example/triangle_client.rb +7 -0
- data/example/triangle_server.rb +24 -0
- data/ext/MANIFEST +11 -0
- data/ext/builtins.h +25 -0
- data/ext/cached/ruby-1.6.3/COPYING +340 -0
- data/ext/cached/ruby-1.6.3/README +3 -0
- data/ext/cached/ruby-1.6.3/classpath.c +3 -0
- data/ext/cached/ruby-1.6.3/classpath.h +8 -0
- data/ext/cached/ruby-1.6.3/evalinfo.h +62 -0
- data/ext/cached/ruby-1.6.3/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.3/insns_info.c +40 -0
- data/ext/cached/ruby-1.6.3/insns_info.h +19 -0
- data/ext/cached/ruby-1.6.3/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.6.3/nodeinfo.c +3182 -0
- data/ext/cached/ruby-1.6.3/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.6.4/COPYING +340 -0
- data/ext/cached/ruby-1.6.4/README +3 -0
- data/ext/cached/ruby-1.6.4/classpath.c +3 -0
- data/ext/cached/ruby-1.6.4/classpath.h +8 -0
- data/ext/cached/ruby-1.6.4/evalinfo.h +62 -0
- data/ext/cached/ruby-1.6.4/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.4/insns_info.c +40 -0
- data/ext/cached/ruby-1.6.4/insns_info.h +19 -0
- data/ext/cached/ruby-1.6.4/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.6.4/nodeinfo.c +3182 -0
- data/ext/cached/ruby-1.6.4/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.6.5/COPYING +56 -0
- data/ext/cached/ruby-1.6.5/GPL +340 -0
- data/ext/cached/ruby-1.6.5/LEGAL +325 -0
- data/ext/cached/ruby-1.6.5/LGPL +504 -0
- data/ext/cached/ruby-1.6.5/README +3 -0
- data/ext/cached/ruby-1.6.5/classpath.c +3 -0
- data/ext/cached/ruby-1.6.5/classpath.h +8 -0
- data/ext/cached/ruby-1.6.5/evalinfo.h +63 -0
- data/ext/cached/ruby-1.6.5/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.5/insns_info.c +40 -0
- data/ext/cached/ruby-1.6.5/insns_info.h +19 -0
- data/ext/cached/ruby-1.6.5/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.6.5/nodeinfo.c +3182 -0
- data/ext/cached/ruby-1.6.5/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.6.7/COPYING +56 -0
- data/ext/cached/ruby-1.6.7/GPL +340 -0
- data/ext/cached/ruby-1.6.7/LEGAL +308 -0
- data/ext/cached/ruby-1.6.7/LGPL +504 -0
- data/ext/cached/ruby-1.6.7/README +3 -0
- data/ext/cached/ruby-1.6.7/classpath.c +3 -0
- data/ext/cached/ruby-1.6.7/classpath.h +8 -0
- data/ext/cached/ruby-1.6.7/evalinfo.h +63 -0
- data/ext/cached/ruby-1.6.7/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.7/insns_info.c +40 -0
- data/ext/cached/ruby-1.6.7/insns_info.h +19 -0
- data/ext/cached/ruby-1.6.7/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.6.7/nodeinfo.c +3182 -0
- data/ext/cached/ruby-1.6.7/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.6.8/COPYING +56 -0
- data/ext/cached/ruby-1.6.8/GPL +340 -0
- data/ext/cached/ruby-1.6.8/LEGAL +308 -0
- data/ext/cached/ruby-1.6.8/LGPL +504 -0
- data/ext/cached/ruby-1.6.8/README +3 -0
- data/ext/cached/ruby-1.6.8/classpath.c +3 -0
- data/ext/cached/ruby-1.6.8/classpath.h +8 -0
- data/ext/cached/ruby-1.6.8/evalinfo.h +63 -0
- data/ext/cached/ruby-1.6.8/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.8/insns_info.c +40 -0
- data/ext/cached/ruby-1.6.8/insns_info.h +19 -0
- data/ext/cached/ruby-1.6.8/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.6.8/nodeinfo.c +3182 -0
- data/ext/cached/ruby-1.6.8/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.0/COPYING +56 -0
- data/ext/cached/ruby-1.8.0/GPL +340 -0
- data/ext/cached/ruby-1.8.0/LEGAL +371 -0
- data/ext/cached/ruby-1.8.0/LGPL +504 -0
- data/ext/cached/ruby-1.8.0/README +3 -0
- data/ext/cached/ruby-1.8.0/classpath.c +27 -0
- data/ext/cached/ruby-1.8.0/classpath.h +14 -0
- data/ext/cached/ruby-1.8.0/evalinfo.h +65 -0
- data/ext/cached/ruby-1.8.0/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.0/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.0/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.0/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.0/nodeinfo.c +3199 -0
- data/ext/cached/ruby-1.8.0/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.1/COPYING +56 -0
- data/ext/cached/ruby-1.8.1/GPL +340 -0
- data/ext/cached/ruby-1.8.1/LEGAL +371 -0
- data/ext/cached/ruby-1.8.1/LGPL +504 -0
- data/ext/cached/ruby-1.8.1/README +3 -0
- data/ext/cached/ruby-1.8.1/classpath.c +27 -0
- data/ext/cached/ruby-1.8.1/classpath.h +14 -0
- data/ext/cached/ruby-1.8.1/evalinfo.h +59 -0
- data/ext/cached/ruby-1.8.1/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.1/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.1/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.1/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.1/nodeinfo.c +3199 -0
- data/ext/cached/ruby-1.8.1/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.2/COPYING +56 -0
- data/ext/cached/ruby-1.8.2/GPL +340 -0
- data/ext/cached/ruby-1.8.2/LEGAL +371 -0
- data/ext/cached/ruby-1.8.2/LGPL +504 -0
- data/ext/cached/ruby-1.8.2/README +3 -0
- data/ext/cached/ruby-1.8.2/classpath.c +45 -0
- data/ext/cached/ruby-1.8.2/classpath.h +17 -0
- data/ext/cached/ruby-1.8.2/evalinfo.h +60 -0
- data/ext/cached/ruby-1.8.2/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.2/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.2/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.2/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.2/nodeinfo.c +3199 -0
- data/ext/cached/ruby-1.8.2/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.3/COPYING +56 -0
- data/ext/cached/ruby-1.8.3/GPL +340 -0
- data/ext/cached/ruby-1.8.3/LEGAL +370 -0
- data/ext/cached/ruby-1.8.3/LGPL +504 -0
- data/ext/cached/ruby-1.8.3/README +3 -0
- data/ext/cached/ruby-1.8.3/classpath.c +45 -0
- data/ext/cached/ruby-1.8.3/classpath.h +17 -0
- data/ext/cached/ruby-1.8.3/evalinfo.h +61 -0
- data/ext/cached/ruby-1.8.3/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.3/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.3/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.3/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.3/nodeinfo.c +3199 -0
- data/ext/cached/ruby-1.8.3/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.4/COPYING +56 -0
- data/ext/cached/ruby-1.8.4/GPL +340 -0
- data/ext/cached/ruby-1.8.4/LEGAL +370 -0
- data/ext/cached/ruby-1.8.4/LGPL +504 -0
- data/ext/cached/ruby-1.8.4/README +3 -0
- data/ext/cached/ruby-1.8.4/classpath.c +45 -0
- data/ext/cached/ruby-1.8.4/classpath.h +17 -0
- data/ext/cached/ruby-1.8.4/evalinfo.h +61 -0
- data/ext/cached/ruby-1.8.4/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.4/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.4/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.4/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.4/nodeinfo.c +3199 -0
- data/ext/cached/ruby-1.8.4/nodeinfo.h +66 -0
- data/ext/cached/ruby-1.8.5/COPYING +56 -0
- data/ext/cached/ruby-1.8.5/GPL +340 -0
- data/ext/cached/ruby-1.8.5/LEGAL +370 -0
- data/ext/cached/ruby-1.8.5/LGPL +504 -0
- data/ext/cached/ruby-1.8.5/README +3 -0
- data/ext/cached/ruby-1.8.5/classpath.c +45 -0
- data/ext/cached/ruby-1.8.5/classpath.h +17 -0
- data/ext/cached/ruby-1.8.5/evalinfo.h +61 -0
- data/ext/cached/ruby-1.8.5/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.5/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.5/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.5/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.5/nodeinfo.c +3187 -0
- data/ext/cached/ruby-1.8.5/nodeinfo.h +64 -0
- data/ext/cached/ruby-1.8.6/COPYING +56 -0
- data/ext/cached/ruby-1.8.6/GPL +340 -0
- data/ext/cached/ruby-1.8.6/LEGAL +370 -0
- data/ext/cached/ruby-1.8.6/LGPL +504 -0
- data/ext/cached/ruby-1.8.6/README +3 -0
- data/ext/cached/ruby-1.8.6/classpath.c +45 -0
- data/ext/cached/ruby-1.8.6/classpath.h +17 -0
- data/ext/cached/ruby-1.8.6/evalinfo.h +61 -0
- data/ext/cached/ruby-1.8.6/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.6/insns_info.c +40 -0
- data/ext/cached/ruby-1.8.6/insns_info.h +19 -0
- data/ext/cached/ruby-1.8.6/node_type_descrip.c +150 -0
- data/ext/cached/ruby-1.8.6/nodeinfo.c +3187 -0
- data/ext/cached/ruby-1.8.6/nodeinfo.h +64 -0
- data/ext/classpath.c +42 -0
- data/ext/classpath.c.rpp +28 -0
- data/ext/classpath.h +17 -0
- data/ext/classpath.h.rpp +35 -0
- data/ext/evalinfo.h +21 -0
- data/ext/evalinfo.h.rpp +49 -0
- data/ext/extconf.rb +68 -0
- data/ext/generate.rb +201 -0
- data/ext/generate_cached.rb +49 -0
- data/ext/global_entry.h +10 -0
- data/ext/global_entry.h.rpp +25 -0
- data/ext/insns_info.c +6079 -0
- data/ext/insns_info.c.rpp +210 -0
- data/ext/insns_info.h +819 -0
- data/ext/insns_info.h.rpp +50 -0
- data/ext/node_type_descrip.c +148 -0
- data/ext/node_type_descrip.c.rpp +72 -0
- data/ext/node_type_descrip.h +17 -0
- data/ext/node_type_descrip.rb +169 -0
- data/ext/nodeinfo.c +3164 -0
- data/ext/nodeinfo.c.rpp +519 -0
- data/ext/nodeinfo.h +67 -0
- data/ext/nodeinfo.h.rpp +27 -0
- data/ext/nodewrap.c +2576 -0
- data/ext/nodewrap.h +20 -0
- data/ext/read_node_h.rb +19 -0
- data/ext/ruby_source_dir.rb +15 -0
- data/ext/ruby_version.h +12 -0
- data/ext/ruby_version_code.rb +16 -0
- data/ext/rubypp.rb +97 -0
- data/ext/test.rb +15 -0
- data/generate_rdoc.rb +33 -0
- data/install.rb +1022 -0
- data/lib/as_code.rb +347 -0
- data/lib/as_expression.rb +657 -0
- data/lib/bytedecoder.rb +848 -0
- data/lib/classtree.rb +54 -0
- data/lib/methodsig.rb +266 -0
- data/lib/node_to_a.rb +34 -0
- data/lib/nodepp.rb +71 -0
- data/lib/nwdebug.rb +18 -0
- data/lib/nwdump.rb +53 -0
- data/lib/nwobfusc.rb +57 -0
- data/lib/procsig.rb +182 -0
- data/lib/test.rb +8 -0
- data/metaconfig +10 -0
- data/post-config.rb +53 -0
- data/post-setup.rb +9 -0
- data/pre-config.rb +1 -0
- data/run_tests.rb +48 -0
- data/test/expression_samples.rb +158 -0
- data/test/node_samples.rb +122 -0
- data/test/test.rb +39 -0
- data/test/test2.rb +7 -0
- data/test/test3.rb +5 -0
- data/test/test4.rb +5 -0
- data/test/test_as_code.rb +249 -0
- data/test/test_as_expression.rb +222 -0
- data/test/test_methodsig.rb +189 -0
- data/test/test_nodewrap.rb +369 -0
- metadata +286 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
#ifndef nodeinfo_h
|
2
|
+
#define nodeinfo_h
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
#include "node.h"
|
6
|
+
#include "nodewrap.h"
|
7
|
+
|
8
|
+
enum Node_Elem_Name
|
9
|
+
{
|
10
|
+
NEN_NONE,
|
11
|
+
NEN_1ST,
|
12
|
+
NEN_2ND,
|
13
|
+
NEN_AID,
|
14
|
+
NEN_ALEN,
|
15
|
+
NEN_ARGC,
|
16
|
+
NEN_ARGS,
|
17
|
+
NEN_BEG,
|
18
|
+
NEN_BODY,
|
19
|
+
NEN_CFLAG,
|
20
|
+
NEN_CFNC,
|
21
|
+
NEN_CLSS,
|
22
|
+
NEN_CNT,
|
23
|
+
NEN_COND,
|
24
|
+
NEN_CPATH,
|
25
|
+
NEN_CVAL,
|
26
|
+
NEN_DEFN,
|
27
|
+
NEN_ELSE,
|
28
|
+
NEN_END,
|
29
|
+
NEN_ENSR,
|
30
|
+
NEN_ENTRY,
|
31
|
+
NEN_FRML,
|
32
|
+
NEN_HEAD,
|
33
|
+
NEN_IBDY,
|
34
|
+
NEN_ITER,
|
35
|
+
NEN_LIT,
|
36
|
+
NEN_MID,
|
37
|
+
NEN_MODL,
|
38
|
+
NEN_NEXT,
|
39
|
+
NEN_NOEX,
|
40
|
+
NEN_NTH,
|
41
|
+
NEN_OPT,
|
42
|
+
NEN_ORIG,
|
43
|
+
NEN_RECV,
|
44
|
+
NEN_RESQ,
|
45
|
+
NEN_REST,
|
46
|
+
NEN_RVAL,
|
47
|
+
NEN_STATE,
|
48
|
+
NEN_STTS,
|
49
|
+
NEN_SUPER,
|
50
|
+
NEN_TAG,
|
51
|
+
NEN_TBL,
|
52
|
+
NEN_TVAL,
|
53
|
+
NEN_VALUE,
|
54
|
+
NEN_VAR,
|
55
|
+
NEN_VID,
|
56
|
+
};
|
57
|
+
|
58
|
+
VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash);
|
59
|
+
void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash);
|
60
|
+
VALUE node_s_members(VALUE klass);
|
61
|
+
void define_node_subclass_methods();
|
62
|
+
|
63
|
+
#endif
|
64
|
+
|
data/ext/classpath.c
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#include "classpath.h"
|
2
|
+
|
3
|
+
VALUE
|
4
|
+
class2path(VALUE klass)
|
5
|
+
{
|
6
|
+
VALUE path = rb_class_path(klass);
|
7
|
+
char *n = RSTRING_PTR(path);
|
8
|
+
|
9
|
+
if (n[0] == '#') {
|
10
|
+
rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
|
11
|
+
(TYPE(klass) == T_CLASS ? "class" : "module"),
|
12
|
+
n);
|
13
|
+
}
|
14
|
+
if (rb_path2class(n) != rb_class_real(klass)) {
|
15
|
+
rb_raise(rb_eTypeError, "%s can't be referred", n);
|
16
|
+
}
|
17
|
+
return path;
|
18
|
+
}
|
19
|
+
|
20
|
+
VALUE
|
21
|
+
path2class(const char *path)
|
22
|
+
{
|
23
|
+
VALUE v = rb_path2class(path);
|
24
|
+
|
25
|
+
if (TYPE(v) != T_CLASS) {
|
26
|
+
rb_raise(rb_eArgError, "%s does not refer class", path);
|
27
|
+
}
|
28
|
+
return v;
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
path2module(const char *path)
|
33
|
+
{
|
34
|
+
VALUE v = rb_path2class(path);
|
35
|
+
|
36
|
+
if (TYPE(v) != T_MODULE) {
|
37
|
+
rb_raise(rb_eArgError, "%s does not refer module", path);
|
38
|
+
}
|
39
|
+
return v;
|
40
|
+
}
|
41
|
+
|
42
|
+
|
data/ext/classpath.c.rpp
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#include "classpath.h"
|
2
|
+
|
3
|
+
#ruby <<END
|
4
|
+
require 'ruby_source_dir'
|
5
|
+
|
6
|
+
marshal_c_location = "#{RUBY_SOURCE_DIR}/marshal.c"
|
7
|
+
File.open(marshal_c_location) do |marshal_c|
|
8
|
+
write = false
|
9
|
+
stopwrite = false
|
10
|
+
while (line = marshal_c.gets) != nil do
|
11
|
+
case line
|
12
|
+
when /^(path2class|path2module|class2path)/
|
13
|
+
puts "VALUE" if not write
|
14
|
+
write = true
|
15
|
+
stopwrite = false
|
16
|
+
when /^\}/
|
17
|
+
stopwrite = true if write
|
18
|
+
end
|
19
|
+
puts line if write
|
20
|
+
if stopwrite then
|
21
|
+
stopwrite = false
|
22
|
+
write = false
|
23
|
+
puts ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
END
|
28
|
+
|
data/ext/classpath.h
ADDED
data/ext/classpath.h.rpp
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#ifndef CLASSPATH_H
|
2
|
+
#define CLASSPATH_H
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
|
6
|
+
#ruby <<END
|
7
|
+
require 'ruby_source_dir'
|
8
|
+
|
9
|
+
defn = nil
|
10
|
+
marshal_c_location = "#{RUBY_SOURCE_DIR}/marshal.c"
|
11
|
+
File.open(marshal_c_location) do |marshal_c|
|
12
|
+
write = false
|
13
|
+
while (line = marshal_c.gets) != nil do
|
14
|
+
case line
|
15
|
+
when /^(path2class|path2module|class2path)/
|
16
|
+
record_defn = true
|
17
|
+
defn = []
|
18
|
+
when /^\{/
|
19
|
+
if record_defn then
|
20
|
+
record_defn = false
|
21
|
+
puts "VALUE #{defn[0].sub(/\(.*/, '')}("
|
22
|
+
vars = defn[1..-1].map { |d| d.sub(/;.*/, '') }
|
23
|
+
puts vars.join(",\n")
|
24
|
+
puts ");"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
if record_defn then
|
28
|
+
defn << line.chomp
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
END
|
33
|
+
|
34
|
+
#endif
|
35
|
+
|
data/ext/evalinfo.h
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#ifndef evalinfo__h_
|
2
|
+
#define evalinfo__h_
|
3
|
+
|
4
|
+
#include "ruby_version.h"
|
5
|
+
|
6
|
+
#ifdef RUBY_HAS_YARV
|
7
|
+
#include "yarvcore.h"
|
8
|
+
#else
|
9
|
+
#include "env.h"
|
10
|
+
#endif
|
11
|
+
|
12
|
+
struct METHOD {
|
13
|
+
VALUE klass, rklass;
|
14
|
+
VALUE recv;
|
15
|
+
ID id, oid;
|
16
|
+
NODE *body;
|
17
|
+
};
|
18
|
+
|
19
|
+
|
20
|
+
#endif
|
21
|
+
|
data/ext/evalinfo.h.rpp
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#ifndef evalinfo__h_
|
2
|
+
#define evalinfo__h_
|
3
|
+
|
4
|
+
#include "ruby_version.h"
|
5
|
+
|
6
|
+
#ifdef RUBY_HAS_YARV
|
7
|
+
#include "yarvcore.h"
|
8
|
+
#else
|
9
|
+
#include "env.h"
|
10
|
+
#endif
|
11
|
+
|
12
|
+
#ruby <<END
|
13
|
+
require 'ruby_source_dir'
|
14
|
+
proc_c_location = "#{RUBY_SOURCE_DIR}/proc.c"
|
15
|
+
vm_c_location = "#{RUBY_SOURCE_DIR}/vm.c"
|
16
|
+
eval_c_location = "#{RUBY_SOURCE_DIR}/eval.c"
|
17
|
+
|
18
|
+
[ proc_c_location, vm_c_location, eval_c_location ].each do |file|
|
19
|
+
next if not File.exist?(file)
|
20
|
+
|
21
|
+
File.open(file) do |eval_c|
|
22
|
+
write = false
|
23
|
+
stopwrite = false
|
24
|
+
while (line = eval_c.gets) != nil do
|
25
|
+
case line
|
26
|
+
when /^struct (METHOD|BLOCK)/
|
27
|
+
write = true
|
28
|
+
stopwrite = false
|
29
|
+
when /^compile_error/
|
30
|
+
puts 'static void'
|
31
|
+
write = true
|
32
|
+
stopwrite = false
|
33
|
+
when /^\}/
|
34
|
+
stopwrite = true if write
|
35
|
+
end
|
36
|
+
puts line if write
|
37
|
+
if stopwrite then
|
38
|
+
stopwrite = false
|
39
|
+
write = false
|
40
|
+
puts ''
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
nil
|
46
|
+
END
|
47
|
+
|
48
|
+
#endif
|
49
|
+
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
cmdline_ruby_source_path = arg_config('--ruby-source-path')
|
4
|
+
configured_ruby_source_dir = nil
|
5
|
+
begin
|
6
|
+
require 'ruby_source_dir'
|
7
|
+
configured_ruby_source_dir = RUBY_SOURCE_DIR
|
8
|
+
rescue InstallError
|
9
|
+
end
|
10
|
+
|
11
|
+
rb_files = Dir['*.rb']
|
12
|
+
|
13
|
+
rpp_files = Dir['*.rpp']
|
14
|
+
generated_files = rpp_files.map { |f| f.sub(/\.rpp$/, '') }
|
15
|
+
|
16
|
+
srcs = Dir['*.c']
|
17
|
+
generated_files.each do |f|
|
18
|
+
if f =~ /\.c$/ then
|
19
|
+
srcs << f
|
20
|
+
end
|
21
|
+
end
|
22
|
+
srcs.uniq!
|
23
|
+
$objs = srcs.map { |f| f.sub(/\.c$/, ".#{$OBJEXT}") }
|
24
|
+
$CFLAGS << ' -Wall -g'
|
25
|
+
create_makefile('nodewrap')
|
26
|
+
|
27
|
+
append_to_makefile = ''
|
28
|
+
|
29
|
+
# (nil and not configured => cached
|
30
|
+
# '' => cached
|
31
|
+
# not configured => cached
|
32
|
+
|
33
|
+
if (not cmdline_ruby_source_path and not configured_ruby_source_dir) or \
|
34
|
+
cmdline_ruby_source_path == '' then
|
35
|
+
|
36
|
+
rpp_files.each do |rpp_file|
|
37
|
+
dest_file = rpp_file.sub(/\.rpp$/, '')
|
38
|
+
append_to_makefile << <<END
|
39
|
+
#{dest_file}: #{rpp_file} #{rb_files.join(' ')}
|
40
|
+
@$(RUBY) -rftools -e 'File.copy("cached/ruby-#{RUBY_VERSION}/#{dest_file}", ".", true)'
|
41
|
+
END
|
42
|
+
end
|
43
|
+
|
44
|
+
else
|
45
|
+
|
46
|
+
rpp_files.each do |rpp_file|
|
47
|
+
dest_file = rpp_file.sub(/\.rpp$/, '')
|
48
|
+
append_to_makefile << <<END
|
49
|
+
#{dest_file}: #{rpp_file} #{rb_files.join(' ')}
|
50
|
+
$(RUBY) rubypp.rb #{rpp_file} #{dest_file}
|
51
|
+
END
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
generated_headers = generated_files.select { |x| x =~ /\.h$/ }
|
58
|
+
append_to_makefile << <<END
|
59
|
+
$(OBJS): #{generated_headers.join(' ')}
|
60
|
+
clean: clean_generated_files
|
61
|
+
clean_generated_files:
|
62
|
+
@$(RM) #{generated_files.join(' ')}
|
63
|
+
END
|
64
|
+
|
65
|
+
File.open('Makefile', 'a') do |makefile|
|
66
|
+
makefile.puts(append_to_makefile)
|
67
|
+
end
|
68
|
+
|
data/ext/generate.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'ruby_source_dir'
|
3
|
+
|
4
|
+
class Pattern
|
5
|
+
attr_reader :search_files
|
6
|
+
|
7
|
+
def initialize(*search_files)
|
8
|
+
@search_files = search_files
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches_start(str)
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
def matches_end(str)
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
|
19
|
+
def dump(captured, out)
|
20
|
+
captured.each do |line|
|
21
|
+
out.puts line
|
22
|
+
end
|
23
|
+
out.puts ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class FunctionDefinitionPattern < Pattern
|
28
|
+
def initialize(return_type, name, *search_files)
|
29
|
+
@return_type = return_type
|
30
|
+
@name = name
|
31
|
+
super(*search_files)
|
32
|
+
end
|
33
|
+
|
34
|
+
def matches_start(str)
|
35
|
+
return str =~ /^#{@name}/
|
36
|
+
end
|
37
|
+
|
38
|
+
def matches_end(str)
|
39
|
+
return str =~ /^\}/
|
40
|
+
end
|
41
|
+
|
42
|
+
def dump(captured, out)
|
43
|
+
out.puts @return_type
|
44
|
+
super(captured, out)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def FunctionDefinition(return_type, name, *search_files)
|
49
|
+
return FunctionDefinitionPattern.new(return_type, name, *search_files)
|
50
|
+
end
|
51
|
+
|
52
|
+
class FunctionDeclarationPattern < Pattern
|
53
|
+
def initialize(name, *search_files)
|
54
|
+
@name = name
|
55
|
+
super(*search_files)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def FunctionDeclaration(name, *search_files)
|
60
|
+
return FunctionDeclarationPattern.new(name, *search_files)
|
61
|
+
end
|
62
|
+
|
63
|
+
class StructPattern < Pattern
|
64
|
+
def initialize(name, *search_files)
|
65
|
+
@name = name
|
66
|
+
super(*search_files)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def Struct(name, *search_files)
|
71
|
+
return StructPattern.new(name, *search_files)
|
72
|
+
end
|
73
|
+
|
74
|
+
class IncludePattern < Pattern
|
75
|
+
def initialize(name, use_quotes=false)
|
76
|
+
@name = name
|
77
|
+
@use_quotes = false
|
78
|
+
super()
|
79
|
+
end
|
80
|
+
|
81
|
+
def dump(captured, out)
|
82
|
+
if @use_quotes then
|
83
|
+
out.puts "#include \"#{@name}\""
|
84
|
+
else
|
85
|
+
out.puts "#include <#{@name}>"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def Include(name, use_quotes=false)
|
91
|
+
return IncludePattern.new(name, use_quotes)
|
92
|
+
end
|
93
|
+
|
94
|
+
class IfDefPattern
|
95
|
+
def initialize(name, iftrue, iffalse)
|
96
|
+
@name = name
|
97
|
+
@iftrue = iftrue
|
98
|
+
@iffalse = iffalse
|
99
|
+
super()
|
100
|
+
end
|
101
|
+
|
102
|
+
def matches_start(str)
|
103
|
+
return @iftrue.matches_start(str) || @iffalse.matches_start(str)
|
104
|
+
end
|
105
|
+
|
106
|
+
def matches_end(str)
|
107
|
+
return @iftrue.matches_end(str) || @iffalse.matches_end(str)
|
108
|
+
end
|
109
|
+
|
110
|
+
def dump(captured, out)
|
111
|
+
out.puts "#ifdef #{@name}"
|
112
|
+
@iftrue.dump(captured, out)
|
113
|
+
out.puts "#else"
|
114
|
+
@iffalse.dump(captured, out)
|
115
|
+
out.puts "#endif"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def IfDefined(name, iftrue, iffalse)
|
120
|
+
return IfDefPattern.new(name, iftrue, iffalse)
|
121
|
+
end
|
122
|
+
|
123
|
+
class BlankLinePattern < Pattern
|
124
|
+
def initialize()
|
125
|
+
super()
|
126
|
+
end
|
127
|
+
|
128
|
+
def dump(captured, out)
|
129
|
+
out.puts
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def BlankLine
|
134
|
+
return BlankLinePattern.new
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def generate(patterns, io, out)
|
139
|
+
found = {}
|
140
|
+
using = {}
|
141
|
+
captured = {}
|
142
|
+
|
143
|
+
while (line = io.gets) != nil do
|
144
|
+
patterns.each do |pattern|
|
145
|
+
if pattern.matches_start(line) then
|
146
|
+
found[pattern] = true
|
147
|
+
using[pattern] = true
|
148
|
+
end
|
149
|
+
|
150
|
+
if using[pattern] then
|
151
|
+
captured[pattern] ||= []
|
152
|
+
captured[pattern] << line
|
153
|
+
end
|
154
|
+
|
155
|
+
if using[pattern] and pattern.matches_end(line) then
|
156
|
+
using.delete(pattern)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
patterns.each do |pattern|
|
162
|
+
pattern.dump(captured[pattern], out)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
G = {
|
169
|
+
'classpath.c' => [
|
170
|
+
Include('classpath.h', true),
|
171
|
+
BlankLine(),
|
172
|
+
FunctionDefinition('VALUE', 'path2class', 'marshal.c'),
|
173
|
+
FunctionDefinition('VALUE', 'path2module', 'marshal.c'),
|
174
|
+
FunctionDefinition('VALUE', 'class2path', 'marshal.c'),
|
175
|
+
],
|
176
|
+
'classpath.h' => [
|
177
|
+
Include('ruby.h'),
|
178
|
+
FunctionDeclaration('path2class', 'marshal.c'),
|
179
|
+
FunctionDeclaration('path2module', 'marshal.c'),
|
180
|
+
FunctionDeclaration('class2path', 'marshal.c'),
|
181
|
+
],
|
182
|
+
'global_entry.h' => [
|
183
|
+
Include('ruby.h'),
|
184
|
+
Struct('global_entry', 'variable.c'),
|
185
|
+
],
|
186
|
+
'evalinfo.h' => [
|
187
|
+
Include('ruby_version.h'),
|
188
|
+
IfDefined(
|
189
|
+
'RUBY_HAS_YARV',
|
190
|
+
[ Include('yarvcore.h') ],
|
191
|
+
[ Include('env.h') ]
|
192
|
+
),
|
193
|
+
Struct('METHOD', 'eval.c', 'proc.c'),
|
194
|
+
Struct('BLOCK', 'eval.c'),
|
195
|
+
],
|
196
|
+
}
|
197
|
+
|
198
|
+
File.open("#{RUBY_SOURCE_DIR}/marshal.c") do |marshal_c|
|
199
|
+
generate(G['classpath.c'], marshal_c, $stdout)
|
200
|
+
end
|
201
|
+
|