Replace `mrb_fixnum_value()` with `mrb_int_value()`.
Use `mrb_fixnum_value()` only when you are absolutely sure that the
value is within `Fixnum` range, i.e. 31 bits signed integer at least.
MODIFY
src/array.c
src/array.c
@@ -1083,7 +1083,7 @@ mrb_ary_index_m(mrb_state *mrb, mrb_value self)
for (i = 0; i < RARRAY_LEN(self); i++) {
if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
- return mrb_fixnum_value(i);
+ return mrb_int_value(mrb, i);
}
}
return mrb_nil_value();
@@ -1097,7 +1097,7 @@ mrb_ary_rindex_m(mrb_state *mrb, mrb_value self)
for (i = RARRAY_LEN(self) - 1; i >= 0; i--) {
if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
- return mrb_fixnum_value(i);
+ return mrb_int_value(mrb, i);
}
if (i > (len = RARRAY_LEN(self))) {
i = len;
@@ -1136,7 +1136,7 @@ mrb_ary_size(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
- return mrb_fixnum_value(ARY_LEN(a));
+ return mrb_int_value(mrb, ARY_LEN(a));
}
MRB_API mrb_value

MODIFY
src/error.c
src/error.c
@@ -286,7 +286,7 @@ mrb_vformat(mrb_state *mrb, const char *format, va_list ap)
#else
i = *p == 'd' ? (mrb_int)va_arg(ap, int) : va_arg(ap, mrb_int);
#endif
- obj = mrb_fixnum_value(i);
+ obj = mrb_int_value(mrb, i);
goto L_cat_obj;
#ifndef MRB_NO_FLOAT
case 'f':

MODIFY
src/numeric.c
src/numeric.c
@@ -180,7 +180,7 @@ int_idiv(mrb_state *mrb, mrb_value x)
if (y == 0) {
int_zerodiv(mrb);
}
- return mrb_fixnum_value(mrb_integer(x) / y);
+ return mrb_int_value(mrb, mrb_integer(x) / y);
}
static mrb_value

MODIFY
src/string.c
src/string.c
@@ -893,14 +893,14 @@ static mrb_value
mrb_str_size(mrb_state *mrb, mrb_value self)
{
mrb_int len = RSTRING_CHAR_LEN(self);
- return mrb_fixnum_value(len);
+ return mrb_int_value(mrb, len);
}
static mrb_value
mrb_str_bytesize(mrb_state *mrb, mrb_value self)
{
mrb_int len = RSTRING_LEN(self);
- return mrb_fixnum_value(len);
+ return mrb_int_value(mrb, len);
}
/* 15.2.10.5.1 */
@@ -1014,7 +1014,7 @@ mrb_str_cmp_m(mrb_state *mrb, mrb_value str1)
else {
result = mrb_str_cmp(mrb, str1, str2);
}
- return mrb_fixnum_value(result);
+ return mrb_int_value(mrb, result);
}
static mrb_bool
@@ -1235,7 +1235,7 @@ str_replace_partial(mrb_state *mrb, mrb_value src, mrb_int pos, mrb_int end, mrb
if (end > len) { end = len; }
if (pos < 0 || pos > len) {
- str_out_of_index(mrb, mrb_fixnum_value(pos));
+ str_out_of_index(mrb, mrb_int_value(mrb, pos));
}
replen = (mrb_nil_p(rep) ? 0 : RSTRING_LEN(rep));
@@ -1820,7 +1820,7 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
if (pos == -1) return mrb_nil_value();
BYTES_ALIGN_CHECK(pos);
- return mrb_fixnum_value(pos);
+ return mrb_int_value(mrb, pos);
}
/* 15.2.10.5.24 */
@@ -2049,7 +2049,7 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
if (pos >= 0) {
pos = bytes2chars(RSTRING_PTR(str), RSTRING_LEN(str), pos);
BYTES_ALIGN_CHECK(pos);
- return mrb_fixnum_value(pos);
+ return mrb_int_value(mrb, pos);
}
return mrb_nil_value();
}

Replace `mrb_fixnum_value()` with `mrb_int_value()`.

Use `mrb_fixnum_value()` only when you are absolutely sure that the
value is within `Fixnum` range, i.e. 31 bits signed integer at least.