mruby.h: obsolete `mrb_to_str()`.
Replace them by `mrb_ensure_string_type()`.
MODIFY
include/mruby.h
include/mruby.h
@@ -1376,14 +1376,13 @@ MRB_API mrb_value mrb_ensure_string_type(mrb_state *mrb, mrb_value str);
MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
/* obsolete: use mrb_ensure_string_type() instead */
#define mrb_string_type(mrb, str) mrb_ensure_string_type(mrb,str)
+#define mrb_to_str(mrb, str) mrb_ensure_string_type(mrb,str)
/* obsolete: use mrb_obj_as_string() instead */
#define mrb_str_to_str(mrb, str) mrb_obj_as_string(mrb, str)
-
MRB_API mrb_value mrb_to_int(mrb_state *mrb, mrb_value val);
#define mrb_as_int(mrb, val) mrb_integer(mrb_to_int(mrb, val))
/* string type checking (contrary to the name, it doesn't convert) */
-MRB_API mrb_value mrb_to_str(mrb_state *mrb, mrb_value val);
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)

MODIFY
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
@@ -586,7 +586,7 @@ mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fm
++argc;
--argv;
- mrb_to_str(mrb, fmt);
+ mrb_ensure_string_type(mrb, fmt);
p = RSTRING_PTR(fmt);
end = p + RSTRING_LEN(fmt);
blen = 0;

MODIFY
mrbgems/mruby-struct/src/struct.c
mrbgems/mruby-struct/src/struct.c
@@ -202,7 +202,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass *kl
}
else {
/* old style: should we warn? */
- mrb_to_str(mrb, name);
+ mrb_ensure_string_type(mrb, name);
id = mrb_obj_to_sym(mrb, name);
if (!mrb_const_name_p(mrb, RSTRING_PTR(name), RSTRING_LEN(name))) {
mrb_name_error(mrb, id, "identifier %v needs to be constant", name);

MODIFY
src/error.c
src/error.c
@@ -27,7 +27,7 @@ mrb_exc_new(mrb_state *mrb, struct RClass *c, const char *ptr, size_t len)
MRB_API mrb_value
mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str)
{
- mrb_to_str(mrb, str);
+ mrb_ensure_string_type(mrb, str);
return mrb_obj_new(mrb, c, 1, &str);
}

MODIFY
src/kernel.c
src/kernel.c
@@ -652,7 +652,6 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */
mrb_define_method(mrb, krn, "__case_eqq", mrb_obj_ceqq, MRB_ARGS_REQ(1)); /* internal */
mrb_define_method(mrb, krn, "__to_int", mrb_to_int, MRB_ARGS_NONE()); /* internal */
- mrb_define_method(mrb, krn, "__to_str", mrb_to_str, MRB_ARGS_NONE()); /* internal */
mrb_include_module(mrb, mrb->object_class, mrb->kernel_module);
}

MODIFY
src/object.c
src/object.c
@@ -518,12 +518,6 @@ mrb_to_float(mrb_state *mrb, mrb_value val)
}
#endif
-MRB_API mrb_value
-mrb_to_str(mrb_state *mrb, mrb_value val)
-{
- return mrb_ensure_string_type(mrb, val);
-}
-
MRB_API mrb_value
mrb_ensure_string_type(mrb_state *mrb, mrb_value str)
{

MODIFY
src/string.c
src/string.c
@@ -237,7 +237,7 @@ str_modify_keep_ascii(mrb_state *mrb, struct RString *s)
static void
check_null_byte(mrb_state *mrb, mrb_value str)
{
- mrb_to_str(mrb, str);
+ mrb_ensure_string_type(mrb, str);
if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str))) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
}
@@ -1071,7 +1071,7 @@ mrb_string_value_ptr(mrb_state *mrb, mrb_value str)
MRB_API mrb_int
mrb_string_value_len(mrb_state *mrb, mrb_value ptr)
{
- mrb_to_str(mrb, ptr);
+ mrb_ensure_string_type(mrb, ptr);
return RSTRING_LEN(ptr);
}
@@ -1358,8 +1358,7 @@ mrb_str_aset(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen, mrb_
{
mrb_int beg, len, charlen;
- mrb_to_str(mrb, replace);
-
+ mrb_ensure_string_type(mrb, replace);
switch (str_convert_range(mrb, str, indx, alen, &beg, &len)) {
case STR_OUT_OF_RANGE:
default:
@@ -2400,7 +2399,7 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck)
const char *s;
mrb_int len;
- mrb_to_str(mrb, str);
+ mrb_ensure_string_type(mrb, str);
s = RSTRING_PTR(str);
len = RSTRING_LEN(str);
return mrb_str_len_to_inum(mrb, s, len, base, badcheck);
@@ -2699,7 +2698,7 @@ mrb_str_cat_str(mrb_state *mrb, mrb_value str, mrb_value str2)
MRB_API mrb_value
mrb_str_append(mrb_state *mrb, mrb_value str1, mrb_value str2)
{
- mrb_to_str(mrb, str2);
+ mrb_ensure_string_type(mrb, str2);
return mrb_str_cat_str(mrb, str1, str2);
}

mruby.h: obsolete `mrb_to_str()`.

Replace them by `mrb_ensure_string_type()`.