超漢字上で、mrubyを使ってhello worldを表示させる。
Révision | 5048c78be9679f7eb7bb6e9609cb9992fb12a7d9 (tree) |
---|---|
l'heure | 2017-06-05 23:21:02 |
Auteur | ornse01 <ornse01@user...> |
Commiter | ornse01 |
Merge branch 'switch_1.2'
@@ -14,16 +14,10 @@ TARGET = "hello" | ||
14 | 14 | TARGET_MAP = "#{TARGET}.map" |
15 | 15 | TARGET_BIN = "#{TARGET}.out" |
16 | 16 | |
17 | -MRBTEST = "mrbtest" | |
18 | -MRBTEST_MAP = "#{MRBTEST}.map" | |
19 | -MRBTEST_BIN = "#{MRBTEST}.out" | |
20 | - | |
21 | 17 | SRCS = FileList["../src/*.c"] |
22 | -OBJS_HELLO = SRCS.pathmap("%f").ext('o').exclude("driver.o") | |
23 | -OBJS_TEST = SRCS.pathmap("%f").ext('o').exclude("hello.o") | |
18 | +OBJS_HELLO = SRCS.pathmap("%f").ext('o') | |
24 | 19 | |
25 | 20 | CLEAN.include(OBJS_HELLO) |
26 | -CLEAN.include(OBJS_TEST) | |
27 | 21 | CLOBBER.include(TARGET_MAP) |
28 | 22 | CLOBBER.include(TARGET_BIN) |
29 | 23 | CLOBBER.include("Dependencies.mf") |
@@ -44,16 +38,6 @@ file TARGET_BIN => OBJS_HELLO do |t| | ||
44 | 38 | sh "#{CC} #{LDFLAGS} #{t.prerequisites.join(' ')} mruby/pcat/lib/libmruby.a #{LOADLIBES} -o #{t.name} " |
45 | 39 | end |
46 | 40 | |
47 | -task "test" => ["mruby_lib_test", MRBTEST_MAP] | |
48 | - | |
49 | -task "mruby_lib_test" do | |
50 | - sh "ruby ../src/mruby/minirake MRUBY_CONFIG=../src/build_config.rb MRUBY_BUILD_DIR=./mruby -f ../src/mruby/Rakefile test" | |
51 | -end | |
52 | - | |
53 | -file MRBTEST_BIN => OBJS_TEST do |t| | |
54 | - sh "#{CC} #{LDFLAGS} #{t.prerequisites.join(' ')} mruby/pcat/test/mrbtest.a mruby/pcat/lib/libmruby.a #{LOADLIBES} -o #{t.name} " | |
55 | -end | |
56 | - | |
57 | 41 | rule '.o' => [proc{|t| t.pathmap("../src/%n.c") }] do |t| |
58 | 42 | sh "#{CC} #{CFLAGS} #{CPPFLAGS} -c #{t.source} -o #{t.name}" |
59 | 43 | end |
@@ -92,21 +92,35 @@ MRuby::CrossBuild.new('pcat') do |conf| | ||
92 | 92 | conf.cc do |cc| |
93 | 93 | cc.command = "#{ENV['GNUi386']}/bin/gcc386" |
94 | 94 | cc.flags = "-O2 -fno-strength-reduce -mpreferred-stack-boundary=2 -Wall" |
95 | - cc.include_paths = ["#{root}/include", "#{ENV['BD']}/include", "../src/posix_include"] | |
96 | - cc.defines = %w(DISABLE_STDIO PCAT) | |
95 | + cc.include_paths = ["#{root}/include", "../src/posix_include", "#{ENV['BD']}/include"] | |
96 | + cc.defines = %w(MRB_DISABLE_STDIO PCAT) | |
97 | 97 | end |
98 | 98 | |
99 | + # Linker settings | |
100 | + conf.linker do |linker| | |
101 | + linker.command = "#{ENV['GNUi386']}/bin/gcc386" | |
102 | + linker.flags = [ENV['LDFLAGS'] || []] | |
103 | + linker.flags_before_libraries = [] | |
104 | + linker.libraries = %w(img app tf gcc main_r dbg lang g sys g f svc) | |
105 | + linker.flags_after_libraries = [] | |
106 | + linker.library_paths = ["#{ENV['BD']}/lib/i386e2"] | |
107 | + linker.option_library = '-l%s' | |
108 | + linker.option_library_path = '-L%s' | |
109 | + linker.link_options = "%{flags} -o %{outfile} %{objs} %{libs}" | |
110 | + end | |
111 | + | |
99 | 112 | # Archiver settings |
100 | 113 | conf.archiver do |archiver| |
101 | 114 | archiver.command = "#{ENV['GNUi386']}/bin/ar" |
102 | 115 | archiver.archive_options = 'rvl %{outfile} %{objs}' |
103 | 116 | end |
104 | 117 | |
105 | - conf.build_mrbtest_lib_only | |
106 | - | |
107 | 118 | @bins = [] # for disable to link mrbc for target. |
108 | 119 | |
120 | + conf.gem 'mrbgems_port/mruby-brightv-posixwrapper' | |
109 | 121 | conf.gem 'mrbgems_port/mruby-brightv-print' |
122 | + conf.gem 'mruby/mrbgems/mruby-compiler' | |
123 | + conf.gem 'mrbgems_port/mruby-test' | |
110 | 124 | # |
111 | 125 | # conf.test_runner.command = 'env' |
112 | 126 | # |
@@ -0,0 +1,5 @@ | ||
1 | +MRuby::Gem::Specification.new('mruby-brightv-posixwrapper') do |spec| | |
2 | + spec.license = 'MIT' | |
3 | + spec.authors = ['ornse01'] | |
4 | + spec.summary = 'posix wrapper for B-right/V port' | |
5 | +end |
@@ -1,9 +1,11 @@ | ||
1 | -#include "posix_include/stdio.h" | |
2 | -#include "posix_include/math.h" | |
1 | +#include "../../../posix_include/stdio.h" | |
2 | +#include "../../../posix_include/math.h" | |
3 | 3 | #include <bstring.h> |
4 | 4 | #include <bstdarg.h> |
5 | 5 | #include <bstdlib.h> |
6 | 6 | |
7 | +#include "mruby.h" | |
8 | + | |
7 | 9 | double __nan() |
8 | 10 | { |
9 | 11 | static char nan_byte[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff}; |
@@ -71,3 +73,13 @@ int snprintf(char *s, size_t len, const char* format, ...) | ||
71 | 73 | |
72 | 74 | return ret; |
73 | 75 | } |
76 | + | |
77 | +void | |
78 | +mrb_mruby_brightv_posixwrapper_gem_init(mrb_state* mrb) | |
79 | +{ | |
80 | +} | |
81 | + | |
82 | +void | |
83 | +mrb_mruby_brightv_posixwrapper_gem_final(mrb_state* mrb) | |
84 | +{ | |
85 | +} |
@@ -0,0 +1,7 @@ | ||
1 | +Running Tests | |
2 | +============= | |
3 | + | |
4 | +To run the tests, execute the following from the project's root directory. | |
5 | + | |
6 | + $ make test | |
7 | + |
@@ -5,7 +5,6 @@ | ||
5 | 5 | ** against the current mruby implementation. |
6 | 6 | */ |
7 | 7 | |
8 | -/* copy from mruby/test/driver.c and port to B-right/V */ | |
9 | 8 | |
10 | 9 | #include <basic.h> |
11 | 10 | #include <bstdio.h> |
@@ -13,14 +12,15 @@ | ||
13 | 12 | #include <bstring.h> |
14 | 13 | #include <btron/btron.h> |
15 | 14 | |
16 | -#include <mruby.h> | |
17 | -#include <mruby/proc.h> | |
18 | -#include <mruby/data.h> | |
19 | -#include <mruby/compile.h> | |
20 | -#include <mruby/string.h> | |
21 | -#include <mruby/variable.h> | |
15 | +#include "mruby.h" | |
16 | +#include "mruby/proc.h" | |
17 | +#include "mruby/data.h" | |
18 | +#include "mruby/compile.h" | |
19 | +#include "mruby/string.h" | |
20 | +#include "mruby/variable.h" | |
21 | +#include "mruby/array.h" | |
22 | 22 | |
23 | -#include "posix_include/stdlib.h" | |
23 | +#include "../../posix_include/stdlib.h" | |
24 | 24 | |
25 | 25 | void |
26 | 26 | mrb_init_mrbtest(mrb_state *); |
@@ -46,14 +46,11 @@ check_error(mrb_state *mrb) | ||
46 | 46 | static int |
47 | 47 | eval_test(mrb_state *mrb) |
48 | 48 | { |
49 | - mrb_value return_value; | |
50 | - const char *prog = "report()"; | |
51 | - | |
52 | 49 | /* evaluate the test */ |
53 | - return_value = mrb_load_string(mrb, prog); | |
50 | + mrb_funcall(mrb, mrb_top_self(mrb), "report", 0); | |
54 | 51 | /* did an exception occur? */ |
55 | 52 | if (mrb->exc) { |
56 | - mrb_p(mrb, return_value); | |
53 | + mrb_print_error(mrb); | |
57 | 54 | mrb->exc = 0; |
58 | 55 | return EXIT_FAILURE; |
59 | 56 | } |
@@ -70,7 +67,7 @@ t_printstr(mrb_state *mrb, mrb_value obj) | ||
70 | 67 | |
71 | 68 | if (mrb_string_p(obj)) { |
72 | 69 | s = RSTRING_PTR(obj); |
73 | - printf("%s", s); | |
70 | + printf("%s", s); | |
74 | 71 | } |
75 | 72 | } |
76 | 73 |
@@ -85,12 +82,68 @@ mrb_t_printstr(mrb_state *mrb, mrb_value self) | ||
85 | 82 | return argv; |
86 | 83 | } |
87 | 84 | |
88 | -EXPORT W MAIN(MESSAGE *msg) | |
85 | +void | |
86 | +mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose) | |
87 | +{ | |
88 | + struct RClass *krn, *mrbtest; | |
89 | + | |
90 | + krn = mrb->kernel_module; | |
91 | + mrb_define_method(mrb, krn, "__t_printstr__", mrb_t_printstr, MRB_ARGS_REQ(1)); | |
92 | + | |
93 | + mrbtest = mrb_define_module(mrb, "Mrbtest"); | |
94 | + | |
95 | + mrb_define_const(mrb, mrbtest, "FIXNUM_MAX", mrb_fixnum_value(MRB_INT_MAX)); | |
96 | + mrb_define_const(mrb, mrbtest, "FIXNUM_MIN", mrb_fixnum_value(MRB_INT_MIN)); | |
97 | + mrb_define_const(mrb, mrbtest, "FIXNUM_BIT", mrb_fixnum_value(MRB_INT_BIT)); | |
98 | + | |
99 | + if (verbose) { | |
100 | + mrb_gv_set(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"), mrb_true_value()); | |
101 | + } | |
102 | +} | |
103 | + | |
104 | +void | |
105 | +mrb_t_pass_result(mrb_state *mrb_dst, mrb_state *mrb_src) | |
106 | +{ | |
107 | + mrb_value res_src; | |
108 | + | |
109 | + if (mrb_src->exc) { | |
110 | + mrb_print_error(mrb_src); | |
111 | + exit(EXIT_FAILURE); | |
112 | + } | |
113 | + | |
114 | +#define TEST_COUNT_PASS(name) \ | |
115 | + do { \ | |
116 | + res_src = mrb_gv_get(mrb_src, mrb_intern_lit(mrb_src, "$" #name)); \ | |
117 | + if (mrb_fixnum_p(res_src)) { \ | |
118 | + mrb_value res_dst = mrb_gv_get(mrb_dst, mrb_intern_lit(mrb_dst, "$" #name)); \ | |
119 | + mrb_gv_set(mrb_dst, mrb_intern_lit(mrb_dst, "$" #name), mrb_fixnum_value(mrb_fixnum(res_dst) + mrb_fixnum(res_src))); \ | |
120 | + } \ | |
121 | + } while (FALSE) \ | |
122 | + | |
123 | + TEST_COUNT_PASS(ok_test); | |
124 | + TEST_COUNT_PASS(ko_test); | |
125 | + TEST_COUNT_PASS(kill_test); | |
126 | + | |
127 | +#undef TEST_COUNT_PASS | |
128 | + | |
129 | + res_src = mrb_gv_get(mrb_src, mrb_intern_lit(mrb_src, "$asserts")); | |
130 | + | |
131 | + if (mrb_array_p(res_src)) { | |
132 | + mrb_int i; | |
133 | + mrb_value res_dst = mrb_gv_get(mrb_dst, mrb_intern_lit(mrb_dst, "$asserts")); | |
134 | + for (i = 0; i < RARRAY_LEN(res_src); ++i) { | |
135 | + mrb_value val_src = RARRAY_PTR(res_src)[i]; | |
136 | + mrb_ary_push(mrb_dst, res_dst, mrb_str_new(mrb_dst, RSTRING_PTR(val_src), RSTRING_LEN(val_src))); | |
137 | + } | |
138 | + } | |
139 | +} | |
140 | + | |
141 | +EXPORT W | |
142 | +MAIN(MESSAGE *msg) | |
89 | 143 | { |
90 | 144 | mrb_state *mrb; |
91 | - struct RClass *krn; | |
92 | - struct RClass *mrbtest; | |
93 | 145 | int ret; |
146 | + mrb_bool verbose = FALSE; | |
94 | 147 | |
95 | 148 | print_hint(); |
96 | 149 |
@@ -101,22 +154,14 @@ EXPORT W MAIN(MESSAGE *msg) | ||
101 | 154 | return EXIT_FAILURE; |
102 | 155 | } |
103 | 156 | |
104 | -/* | |
157 | + /* | |
105 | 158 | if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v') { |
106 | 159 | printf("verbose mode: enable\n\n"); |
107 | - mrb_gv_set(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"), mrb_true_value()); | |
160 | + verbose = TRUE; | |
108 | 161 | } |
109 | -*/ | |
110 | - | |
111 | - krn = mrb->kernel_module; | |
112 | - mrb_define_method(mrb, krn, "__t_printstr__", mrb_t_printstr, MRB_ARGS_REQ(1)); | |
113 | - | |
114 | - mrbtest = mrb_define_module(mrb, "Mrbtest"); | |
115 | - | |
116 | - mrb_define_const(mrb, mrbtest, "FIXNUM_MAX", mrb_fixnum_value(MRB_INT_MAX)); | |
117 | - mrb_define_const(mrb, mrbtest, "FIXNUM_MIN", mrb_fixnum_value(MRB_INT_MIN)); | |
118 | - mrb_define_const(mrb, mrbtest, "FIXNUM_BIT", mrb_fixnum_value(MRB_INT_BIT)); | |
162 | + */ | |
119 | 163 | |
164 | + mrb_init_test_driver(mrb, verbose); | |
120 | 165 | mrb_init_mrbtest(mrb); |
121 | 166 | ret = eval_test(mrb); |
122 | 167 | mrb_close(mrb); |
@@ -0,0 +1,40 @@ | ||
1 | +#include <stdlib.h> | |
2 | +#include "mruby.h" | |
3 | +#include "mruby/irep.h" | |
4 | +#include "mruby/variable.h" | |
5 | + | |
6 | +extern const uint8_t mrbtest_assert_irep[]; | |
7 | +extern const uint8_t mrbtest_irep[]; | |
8 | + | |
9 | +void mrbgemtest_init(mrb_state* mrb); | |
10 | +void mrb_init_test_driver(mrb_state* mrb, mrb_bool verbose); | |
11 | +void mrb_t_pass_result(mrb_state *mrb_dst, mrb_state *mrb_src); | |
12 | + | |
13 | +void | |
14 | +mrb_init_mrbtest(mrb_state *mrb) | |
15 | +{ | |
16 | + mrb_state *core_test; | |
17 | + | |
18 | + mrb_load_irep(mrb, mrbtest_assert_irep); | |
19 | + | |
20 | + core_test = mrb_open_core(mrb_default_allocf, NULL); | |
21 | + if (core_test == NULL) { | |
22 | + printf("Invalid mrb_state, exiting %s", __FUNCTION__); | |
23 | + exit(EXIT_FAILURE); | |
24 | + } | |
25 | + mrb_init_test_driver(core_test, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose")))); | |
26 | + mrb_load_irep(core_test, mrbtest_assert_irep); | |
27 | + mrb_load_irep(core_test, mrbtest_irep); | |
28 | + mrb_t_pass_result(mrb, core_test); | |
29 | + | |
30 | +#ifndef DISABLE_GEMS | |
31 | + mrbgemtest_init(mrb); | |
32 | +#endif | |
33 | + | |
34 | + if (mrb->exc) { | |
35 | + mrb_print_error(mrb); | |
36 | + exit(EXIT_FAILURE); | |
37 | + } | |
38 | + mrb_close(core_test); | |
39 | +} | |
40 | + |
@@ -0,0 +1,174 @@ | ||
1 | +MRuby::Gem::Specification.new('mruby-test') do |spec| | |
2 | + spec.license = 'MIT' | |
3 | + spec.author = ['mruby developers', 'ornse01'] | |
4 | + spec.summary = 'mruby test' | |
5 | + | |
6 | + build.bins << 'mrbtest' | |
7 | + spec.add_dependency('mruby-compiler', :core => 'mruby-compiler') | |
8 | + | |
9 | + clib = "#{build_dir}/mrbtest.c" | |
10 | + mlib = clib.ext(exts.object) | |
11 | + mrbs = Dir.glob("#{MRUBY_ROOT}/test/t/*.rb") | |
12 | + exec = exefile("#{build.build_dir}/bin/mrbtest") | |
13 | + | |
14 | + libmruby = libfile("#{build.build_dir}/lib/libmruby") | |
15 | + libmruby_core = libfile("#{build.build_dir}/lib/libmruby_core") | |
16 | + | |
17 | + mrbtest_lib = libfile("#{build_dir}/mrbtest") | |
18 | + mrbtest_objs = [] | |
19 | + | |
20 | + driver_obj = objfile("#{build_dir}/driver") | |
21 | + driver = "#{spec.dir}/driver.c" | |
22 | + | |
23 | + assert_c = "#{build_dir}/assert.c" | |
24 | + assert_rb = "#{MRUBY_ROOT}/test/assert.rb" | |
25 | + assert_lib = assert_c.ext(exts.object) | |
26 | + mrbtest_objs << assert_lib | |
27 | + | |
28 | + file assert_lib => assert_c | |
29 | + file assert_c => [build.mrbcfile, assert_rb] do |t| | |
30 | + open(t.name, 'w') do |f| | |
31 | + mrbc.run f, assert_rb, 'mrbtest_assert_irep' | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + gem_table = build.gems.generate_gem_table build | |
36 | + | |
37 | + build.gems.each do |g| | |
38 | + test_rbobj = g.test_rbireps.ext(exts.object) | |
39 | + g.test_objs << test_rbobj | |
40 | + dep_list = build.gems.tsort_dependencies(g.test_dependencies, gem_table).select(&:generate_functions) | |
41 | + | |
42 | + file test_rbobj => g.test_rbireps | |
43 | + file g.test_rbireps => [g.test_rbfiles].flatten + [File.join(g.dir, 'mrbgem.rake'), g.build.mrbcfile, "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"] do |t| | |
44 | + FileUtils.mkdir_p File.dirname(t.name) | |
45 | + open(t.name, 'w') do |f| | |
46 | + g.print_gem_test_header(f) | |
47 | + test_preload = g.test_preload and [g.dir, MRUBY_ROOT].map {|dir| | |
48 | + File.expand_path(g.test_preload, dir) | |
49 | + }.find {|file| File.exist?(file) } | |
50 | + | |
51 | + f.puts %Q[/*] | |
52 | + f.puts %Q[ * This file contains a test code for #{g.name} gem.] | |
53 | + f.puts %Q[ *] | |
54 | + f.puts %Q[ * IMPORTANT:] | |
55 | + f.puts %Q[ * This file was generated!] | |
56 | + f.puts %Q[ * All manual changes will get lost.] | |
57 | + f.puts %Q[ */] | |
58 | + if test_preload.nil? | |
59 | + f.puts %Q[extern const uint8_t mrbtest_assert_irep[];] | |
60 | + else | |
61 | + g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload" | |
62 | + end | |
63 | + g.test_rbfiles.flatten.each_with_index do |rbfile, i| | |
64 | + g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}" | |
65 | + end | |
66 | + f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty? | |
67 | + dep_list.each do |d| | |
68 | + f.puts %Q[void GENERATED_TMP_mrb_#{d.funcname}_gem_init(mrb_state *mrb);] | |
69 | + f.puts %Q[void GENERATED_TMP_mrb_#{d.funcname}_gem_final(mrb_state *mrb);] | |
70 | + end | |
71 | + f.puts %Q[void mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose);] | |
72 | + f.puts %Q[void mrb_t_pass_result(mrb_state *dst, mrb_state *src);] | |
73 | + f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb) {] | |
74 | + unless g.test_rbfiles.empty? | |
75 | + f.puts %Q[ mrb_state *mrb2;] | |
76 | + unless g.test_args.empty? | |
77 | + f.puts %Q[ mrb_value test_args_hash;] | |
78 | + end | |
79 | + f.puts %Q[ int ai;] | |
80 | + g.test_rbfiles.count.times do |i| | |
81 | + f.puts %Q[ ai = mrb_gc_arena_save(mrb);] | |
82 | + f.puts %Q[ mrb2 = mrb_open_core(mrb_default_allocf, NULL);] | |
83 | + f.puts %Q[ if (mrb2 == NULL) {] | |
84 | + f.puts %Q[ printf("Invalid mrb_state, exiting \%s", __FUNCTION__);] | |
85 | + f.puts %Q[ exit(EXIT_FAILURE);] | |
86 | + f.puts %Q[ }] | |
87 | + dep_list.each do |d| | |
88 | + f.puts %Q[ GENERATED_TMP_mrb_#{d.funcname}_gem_init(mrb2);] | |
89 | + f.puts %Q[ mrb_state_atexit(mrb2, GENERATED_TMP_mrb_#{d.funcname}_gem_final);] | |
90 | + end | |
91 | + f.puts %Q[ mrb_init_test_driver(mrb2, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));] | |
92 | + if test_preload.nil? | |
93 | + f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);] | |
94 | + else | |
95 | + f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);] | |
96 | + end | |
97 | + f.puts %Q[ if (mrb2->exc) {] | |
98 | + f.puts %Q[ mrb_print_error(mrb2);] | |
99 | + f.puts %Q[ exit(EXIT_FAILURE);] | |
100 | + f.puts %Q[ }] | |
101 | + f.puts %Q[ mrb_const_set(mrb2, mrb_obj_value(mrb2->object_class), mrb_intern_lit(mrb2, "GEMNAME"), mrb_str_new(mrb2, "#{g.name}", #{g.name.length}));] | |
102 | + | |
103 | + unless g.test_args.empty? | |
104 | + f.puts %Q[ test_args_hash = mrb_hash_new_capa(mrb, #{g.test_args.length}); ] | |
105 | + g.test_args.each do |arg_name, arg_value| | |
106 | + escaped_arg_name = arg_name.gsub('\\', '\\\\\\\\').gsub('"', '\"') | |
107 | + escaped_arg_value = arg_value.gsub('\\', '\\\\\\\\').gsub('"', '\"') | |
108 | + f.puts %Q[ mrb_hash_set(mrb2, test_args_hash, mrb_str_new(mrb2, "#{escaped_arg_name.to_s}", #{escaped_arg_name.to_s.length}), mrb_str_new(mrb2, "#{escaped_arg_value.to_s}", #{escaped_arg_value.to_s.length})); ] | |
109 | + end | |
110 | + f.puts %Q[ mrb_const_set(mrb2, mrb_obj_value(mrb2->object_class), mrb_intern_lit(mrb2, "TEST_ARGS"), test_args_hash); ] | |
111 | + end | |
112 | + | |
113 | + f.puts %Q[ mrb_#{g.funcname}_gem_test(mrb2);] if g.custom_test_init? | |
114 | + | |
115 | + f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_#{i});] | |
116 | + f.puts %Q[ ] | |
117 | + | |
118 | + f.puts %Q[ mrb_t_pass_result(mrb, mrb2);] | |
119 | + f.puts %Q[ mrb_close(mrb2);] | |
120 | + f.puts %Q[ mrb_gc_arena_restore(mrb, ai);] | |
121 | + end | |
122 | + end | |
123 | + f.puts %Q[}] | |
124 | + end | |
125 | + end | |
126 | + end | |
127 | + | |
128 | + build.gems.each do |v| | |
129 | + mrbtest_objs.concat v.test_objs | |
130 | + end | |
131 | + | |
132 | + file mrbtest_lib => mrbtest_objs do |t| | |
133 | + build.archiver.run t.name, t.prerequisites | |
134 | + end | |
135 | + | |
136 | + unless build.build_mrbtest_lib_only? | |
137 | + file exec => [driver_obj, mlib, mrbtest_lib, libmruby_core, libmruby] do |t| | |
138 | + gem_flags = build.gems.map { |g| g.linker.flags } | |
139 | + gem_flags_before_libraries = build.gems.map { |g| g.linker.flags_before_libraries } | |
140 | + gem_flags_after_libraries = build.gems.map { |g| g.linker.flags_after_libraries } | |
141 | + gem_libraries = build.gems.map { |g| g.linker.libraries } | |
142 | + gem_library_paths = build.gems.map { |g| g.linker.library_paths } | |
143 | + build.linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries | |
144 | + end | |
145 | + end | |
146 | + | |
147 | + init = "#{spec.dir}/init_mrbtest.c" | |
148 | + file mlib => clib | |
149 | + file clib => [build.mrbcfile, init] + mrbs do |t| | |
150 | + _pp "GEN", "*.rb", "#{clib.relative_path}" | |
151 | + FileUtils.mkdir_p File.dirname(clib) | |
152 | + open(clib, 'w') do |f| | |
153 | + f.puts %Q[/*] | |
154 | + f.puts %Q[ * This file contains a list of all] | |
155 | + f.puts %Q[ * test functions.] | |
156 | + f.puts %Q[ *] | |
157 | + f.puts %Q[ * IMPORTANT:] | |
158 | + f.puts %Q[ * This file was generated!] | |
159 | + f.puts %Q[ * All manual changes will get lost.] | |
160 | + f.puts %Q[ */] | |
161 | + f.puts %Q[] | |
162 | + f.puts IO.read(init) | |
163 | + mrbc.run f, mrbs, 'mrbtest_irep' | |
164 | + build.gems.each do |g| | |
165 | + f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);] | |
166 | + end | |
167 | + f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {] | |
168 | + build.gems.each do |g| | |
169 | + f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);] | |
170 | + end | |
171 | + f.puts %Q[}] | |
172 | + end | |
173 | + end | |
174 | +end |
@@ -1 +1 @@ | ||
1 | -Subproject commit 18eb0e744086e015891714d543114be582a62336 | |
1 | +Subproject commit bde5311e90353bdf994cb86ba98633927469ce8d |
@@ -1,6 +1,8 @@ | ||
1 | 1 | #ifndef __LIMITS_H__ |
2 | 2 | #define __LIMITS_H__ |
3 | 3 | |
4 | -#define CHAR_BIT 8 | |
5 | - | |
4 | +#define CHAR_BIT (8) | |
5 | +#define INT_MIN (−2147483648) | |
6 | +#define INT_MAX (2147483647) | |
7 | + | |
6 | 8 | #endif |
@@ -4,9 +4,11 @@ | ||
4 | 4 | typedef unsigned char uint8_t; |
5 | 5 | typedef unsigned short uint16_t; |
6 | 6 | typedef unsigned int uint32_t; |
7 | +typedef unsigned long long int uint64_t; | |
7 | 8 | typedef char int8_t; |
8 | 9 | typedef short int16_t; |
9 | 10 | typedef int int32_t; |
11 | +typedef long long int int64_t; | |
10 | 12 | |
11 | 13 | typedef int intptr_t; |
12 | 14 | typedef unsigned int uintptr_t; |