Restore old function names for compatibility; fix
Rename new functions:
`mrb_convert_type(mrb,val,type,tname,method)`
=> `mrb_type_convert(mrb,val,type,tname,method)`
`mrb_check_convert_type(mrb,val,type,tname,method)`
=> `mrb_type_convert_check(mrb,val,type,tname,method)`
Old names are defined by macros (support `tname` drop and
`char*` => `mrb_sym` conversion).
MODIFY
include/mruby.h
include/mruby.h
@@ -1245,12 +1245,15 @@ MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*
} while (0)
MRB_API void mrb_write_barrier(mrb_state *, struct RBasic*);
-MRB_API mrb_value mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
+MRB_API mrb_value mrb_type_convert(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
+#define mrb_convert_type(mrb, val, type, tname, method) mrb_type_convert(mrb, val, type, mrb_intern_lit(mrb, method))
+MRB_API mrb_value mrb_type_convert_check(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
+#define mrb_check_convert_type(mrb, val, type, tname, method) mrb_type_convert_check(mrb, val, type, mrb_intern_lit(mrb, method))
+
MRB_API mrb_value mrb_any_to_s(mrb_state *mrb, mrb_value obj);
MRB_API const char * mrb_obj_classname(mrb_state *mrb, mrb_value obj);
MRB_API struct RClass* mrb_obj_class(mrb_state *mrb, mrb_value obj);
MRB_API mrb_value mrb_class_path(mrb_state *mrb, struct RClass *c);
-MRB_API mrb_value mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
MRB_API mrb_bool mrb_obj_is_kind_of(mrb_state *mrb, mrb_value obj, struct RClass *c);
MRB_API mrb_value mrb_obj_inspect(mrb_state *mrb, mrb_value self);
MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);

MODIFY
mrbgems/mruby-kernel-ext/src/kernel.c
mrbgems/mruby-kernel-ext/src/kernel.c
@@ -151,7 +151,7 @@ mrb_f_string(mrb_state *mrb, mrb_value self)
mrb_value arg = mrb_get_arg1(mrb);
mrb_value tmp;
- tmp = mrb_convert_type(mrb, arg, MRB_TT_STRING, MRB_SYM(to_s));
+ tmp = mrb_type_convert(mrb, arg, MRB_TT_STRING, MRB_SYM(to_s));
return tmp;
}
@@ -170,7 +170,7 @@ mrb_f_array(mrb_state *mrb, mrb_value self)
mrb_value arg = mrb_get_arg1(mrb);
mrb_value tmp;
- tmp = mrb_check_convert_type(mrb, arg, MRB_TT_ARRAY, MRB_SYM(to_a));
+ tmp = mrb_type_convert_check(mrb, arg, MRB_TT_ARRAY, MRB_SYM(to_a));
if (mrb_nil_p(tmp)) {
return mrb_ary_new_from_values(mrb, 1, &arg);
}

MODIFY
mrbgems/mruby-print/src/print.c
mrbgems/mruby-print/src/print.c
@@ -24,7 +24,7 @@ printstr(mrb_state *mrb, const char *p, mrb_int len)
DWORD written;
int wlen = MultiByteToWideChar(CP_UTF8, 0, p, (int)len, NULL, 0);
wchar_t* utf16 = (wchar_t*)mrb_malloc(mrb, (wlen+1) * sizeof(wchar_t));
- if (MultiByteToWideChar(CP_UTF8, 0, p, len, utf16, wlen) > 0) {
+ if (MultiByteToWideChar(CP_UTF8, 0, p, (int)len, utf16, wlen) > 0) {
utf16[wlen] = 0;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),
utf16, (DWORD)wlen, &written, NULL);

MODIFY
src/object.c
src/object.c
@@ -369,7 +369,7 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, m
}
MRB_API mrb_value
-mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
+mrb_type_convert(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
{
mrb_value v;
const char *tname;
@@ -385,7 +385,7 @@ mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym met
}
MRB_API mrb_value
-mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
+mrb_type_convert_check(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
{
mrb_value v;
@@ -584,7 +584,7 @@ mrb_Float(mrb_state *mrb, mrb_value val)
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
default:
- return mrb_convert_type(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
+ return mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
}
}
#endif

MODIFY
src/string.c
src/string.c
@@ -1100,7 +1100,7 @@ mrb_str_to_str(mrb_state *mrb, mrb_value str)
case MRB_TT_MODULE:
return mrb_mod_to_s(mrb, str);
default:
- return mrb_convert_type(mrb, str, MRB_TT_STRING, MRB_SYM(to_s));
+ return mrb_type_convert(mrb, str, MRB_TT_STRING, MRB_SYM(to_s));
}
}

MODIFY
src/vm.c
src/vm.c
@@ -1423,8 +1423,8 @@ RETRY_TRY_BLOCK:
recv = regs[a];
blk = regs[bidx];
if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) {
- blk = mrb_convert_type(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
- /* The stack might have been reallocated during mrb_convert_type(),
+ blk = mrb_type_convert(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
+ /* The stack might have been reallocated during mrb_type_convert(),
see #3622 */
regs[bidx] = blk;
}
@@ -1605,9 +1605,9 @@ RETRY_TRY_BLOCK:
}
blk = regs[bidx];
if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) {
- blk = mrb_convert_type(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
+ blk = mrb_type_convert(mrb, blk, MRB_TT_PROC, MRB_SYM(to_proc));
/* The stack or ci stack might have been reallocated during
- mrb_convert_type(), see #3622 and #3784 */
+ mrb_type_convert(), see #3622 and #3784 */
regs[bidx] = blk;
ci = mrb->c->ci;
}

Restore old function names for compatibility; fix #5070

Rename new functions:

- `mrb_convert_type(mrb,val,type,tname,method)`
   => `mrb_type_convert(mrb,val,type,tname,method)`
- `mrb_check_convert_type(mrb,val,type,tname,method)`
   => `mrb_type_convert_check(mrb,val,type,tname,method)`

Old names are defined by macros (support `tname` drop and
`char*` => `mrb_sym` conversion).