Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
numeric_ext.c
Go to the documentation of this file.
1 #include <limits.h>
2 #include "mruby.h"
3 #include "mruby/numeric.h"
4 
5 static mrb_value
6 mrb_int_chr(mrb_state *mrb, mrb_value x)
7 {
8  mrb_int chr;
9  char c;
10 
11  chr = mrb_fixnum(x);
12  if (chr >= (1 << CHAR_BIT)) {
13  mrb_raisef(mrb, E_RANGE_ERROR, "%S out of char range", x);
14  }
15  c = (char)chr;
16 
17  return mrb_str_new(mrb, &c, 1);
18 }
19 
20 void
22 {
23  struct RClass *i = mrb_class_get(mrb, "Integer");
24 
25  mrb_define_method(mrb, i, "chr", mrb_int_chr, MRB_ARGS_NONE());
26 }
27 
28 void
30 {
31 }