超漢字上で、mrubyを使ってhello worldを表示させる。
リビジョン | 20f69555e2fe5dbad78dc10af80a7503b617278a (tree) |
---|---|
日時 | 2017-06-05 23:18:29 |
作者 | ornse01 <ornse01@user...> |
コミッター | ornse01 |
fix for B-right/V environment.
@@ -6,9 +6,11 @@ | ||
6 | 6 | */ |
7 | 7 | |
8 | 8 | |
9 | -#include <stdio.h> | |
10 | -#include <stdlib.h> | |
11 | -#include <string.h> | |
9 | +#include <basic.h> | |
10 | +#include <bstdio.h> | |
11 | +#include <bstdlib.h> | |
12 | +#include <bstring.h> | |
13 | +#include <btron/btron.h> | |
12 | 14 | |
13 | 15 | #include "mruby.h" |
14 | 16 | #include "mruby/proc.h" |
@@ -18,6 +20,8 @@ | ||
18 | 20 | #include "mruby/variable.h" |
19 | 21 | #include "mruby/array.h" |
20 | 22 | |
23 | +#include "../../posix_include/stdlib.h" | |
24 | + | |
21 | 25 | void |
22 | 26 | mrb_init_mrbtest(mrb_state *); |
23 | 27 |
@@ -60,12 +64,10 @@ static void | ||
60 | 64 | t_printstr(mrb_state *mrb, mrb_value obj) |
61 | 65 | { |
62 | 66 | char *s; |
63 | - int len; | |
64 | 67 | |
65 | 68 | if (mrb_string_p(obj)) { |
66 | 69 | s = RSTRING_PTR(obj); |
67 | - len = RSTRING_LEN(obj); | |
68 | - fwrite(s, len, 1, stdout); | |
70 | + printf("%s", s); | |
69 | 71 | } |
70 | 72 | } |
71 | 73 |
@@ -136,8 +138,8 @@ mrb_t_pass_result(mrb_state *mrb_dst, mrb_state *mrb_src) | ||
136 | 138 | } |
137 | 139 | } |
138 | 140 | |
139 | -int | |
140 | -main(int argc, char **argv) | |
141 | +EXPORT W | |
142 | +MAIN(MESSAGE *msg) | |
141 | 143 | { |
142 | 144 | mrb_state *mrb; |
143 | 145 | int ret; |
@@ -148,14 +150,16 @@ main(int argc, char **argv) | ||
148 | 150 | /* new interpreter instance */ |
149 | 151 | mrb = mrb_open(); |
150 | 152 | if (mrb == NULL) { |
151 | - fprintf(stderr, "Invalid mrb_state, exiting test driver"); | |
153 | + printf("Invalid mrb_state, exiting test driver"); | |
152 | 154 | return EXIT_FAILURE; |
153 | 155 | } |
154 | 156 | |
157 | + /* | |
155 | 158 | if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v') { |
156 | 159 | printf("verbose mode: enable\n\n"); |
157 | 160 | verbose = TRUE; |
158 | 161 | } |
162 | + */ | |
159 | 163 | |
160 | 164 | mrb_init_test_driver(mrb, verbose); |
161 | 165 | mrb_init_mrbtest(mrb); |
@@ -19,7 +19,7 @@ mrb_init_mrbtest(mrb_state *mrb) | ||
19 | 19 | |
20 | 20 | core_test = mrb_open_core(mrb_default_allocf, NULL); |
21 | 21 | if (core_test == NULL) { |
22 | - fprintf(stderr, "Invalid mrb_state, exiting %s", __FUNCTION__); | |
22 | + printf("Invalid mrb_state, exiting %s", __FUNCTION__); | |
23 | 23 | exit(EXIT_FAILURE); |
24 | 24 | } |
25 | 25 | mrb_init_test_driver(core_test, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose")))); |
@@ -1,6 +1,6 @@ | ||
1 | 1 | MRuby::Gem::Specification.new('mruby-test') do |spec| |
2 | 2 | spec.license = 'MIT' |
3 | - spec.author = 'mruby developers' | |
3 | + spec.author = ['mruby developers', 'ornse01'] | |
4 | 4 | spec.summary = 'mruby test' |
5 | 5 | |
6 | 6 | build.bins << 'mrbtest' |
@@ -81,7 +81,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| | ||
81 | 81 | f.puts %Q[ ai = mrb_gc_arena_save(mrb);] |
82 | 82 | f.puts %Q[ mrb2 = mrb_open_core(mrb_default_allocf, NULL);] |
83 | 83 | f.puts %Q[ if (mrb2 == NULL) {] |
84 | - f.puts %Q[ fprintf(stderr, "Invalid mrb_state, exiting \%s", __FUNCTION__);] | |
84 | + f.puts %Q[ printf("Invalid mrb_state, exiting \%s", __FUNCTION__);] | |
85 | 85 | f.puts %Q[ exit(EXIT_FAILURE);] |
86 | 86 | f.puts %Q[ }] |
87 | 87 | dep_list.each do |d| |