Last change
on this file since 270 was 270, checked in by coas-nagasima, 7 years ago |
mruby版ECNLプロトタイピング・ツールを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Id
-
Property svn:mime-type
set to
text/x-csrc
|
File size:
536 bytes
|
Line | |
---|
1 | #include <limits.h>
|
---|
2 | #include "mruby.h"
|
---|
3 |
|
---|
4 | static mrb_value
|
---|
5 | mrb_int_chr(mrb_state *mrb, mrb_value x)
|
---|
6 | {
|
---|
7 | mrb_int chr;
|
---|
8 | char c;
|
---|
9 |
|
---|
10 | chr = mrb_fixnum(x);
|
---|
11 | if (chr >= (1 << CHAR_BIT)) {
|
---|
12 | mrb_raisef(mrb, E_RANGE_ERROR, "%S out of char range", x);
|
---|
13 | }
|
---|
14 | c = (char)chr;
|
---|
15 |
|
---|
16 | return mrb_str_new(mrb, &c, 1);
|
---|
17 | }
|
---|
18 |
|
---|
19 | void
|
---|
20 | mrb_mruby_numeric_ext_gem_init(mrb_state* mrb)
|
---|
21 | {
|
---|
22 | struct RClass *i = mrb_class_get(mrb, "Integer");
|
---|
23 |
|
---|
24 | mrb_define_method(mrb, i, "chr", mrb_int_chr, MRB_ARGS_NONE());
|
---|
25 | }
|
---|
26 |
|
---|
27 | void
|
---|
28 | mrb_mruby_numeric_ext_gem_final(mrb_state* mrb)
|
---|
29 | {
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.