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).
parent 9b8e5658
...@@ -1245,12 +1245,15 @@ MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic* ...@@ -1245,12 +1245,15 @@ MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*
} while (0) } while (0)
MRB_API void mrb_write_barrier(mrb_state *, struct RBasic*); 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 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 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 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_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_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_inspect(mrb_state *mrb, mrb_value self);
MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self); MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);
......
...@@ -151,7 +151,7 @@ mrb_f_string(mrb_state *mrb, mrb_value self) ...@@ -151,7 +151,7 @@ mrb_f_string(mrb_state *mrb, mrb_value self)
mrb_value arg = mrb_get_arg1(mrb); mrb_value arg = mrb_get_arg1(mrb);
mrb_value tmp; 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; return tmp;
} }
...@@ -170,7 +170,7 @@ mrb_f_array(mrb_state *mrb, mrb_value self) ...@@ -170,7 +170,7 @@ mrb_f_array(mrb_state *mrb, mrb_value self)
mrb_value arg = mrb_get_arg1(mrb); mrb_value arg = mrb_get_arg1(mrb);
mrb_value tmp; 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)) { if (mrb_nil_p(tmp)) {
return mrb_ary_new_from_values(mrb, 1, &arg); return mrb_ary_new_from_values(mrb, 1, &arg);
} }
......
...@@ -24,7 +24,7 @@ printstr(mrb_state *mrb, const char *p, mrb_int len) ...@@ -24,7 +24,7 @@ printstr(mrb_state *mrb, const char *p, mrb_int len)
DWORD written; DWORD written;
int wlen = MultiByteToWideChar(CP_UTF8, 0, p, (int)len, NULL, 0); int wlen = MultiByteToWideChar(CP_UTF8, 0, p, (int)len, NULL, 0);
wchar_t* utf16 = (wchar_t*)mrb_malloc(mrb, (wlen+1) * sizeof(wchar_t)); 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; utf16[wlen] = 0;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),
utf16, (DWORD)wlen, &written, NULL); utf16, (DWORD)wlen, &written, NULL);
......
...@@ -369,7 +369,7 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, m ...@@ -369,7 +369,7 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, m
} }
MRB_API mrb_value 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; mrb_value v;
const char *tname; const char *tname;
...@@ -385,7 +385,7 @@ mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym met ...@@ -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_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; mrb_value v;
...@@ -584,7 +584,7 @@ mrb_Float(mrb_state *mrb, mrb_value val) ...@@ -584,7 +584,7 @@ mrb_Float(mrb_state *mrb, mrb_value val)
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE)); return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
default: 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 #endif
......
...@@ -1100,7 +1100,7 @@ mrb_str_to_str(mrb_state *mrb, mrb_value str) ...@@ -1100,7 +1100,7 @@ mrb_str_to_str(mrb_state *mrb, mrb_value str)
case MRB_TT_MODULE: case MRB_TT_MODULE:
return mrb_mod_to_s(mrb, str); return mrb_mod_to_s(mrb, str);
default: 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));
} }
} }
......
...@@ -1423,8 +1423,8 @@ RETRY_TRY_BLOCK: ...@@ -1423,8 +1423,8 @@ RETRY_TRY_BLOCK:
recv = regs[a]; recv = regs[a];
blk = regs[bidx]; blk = regs[bidx];
if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) { 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 might have been reallocated during mrb_convert_type(), /* The stack might have been reallocated during mrb_type_convert(),
see #3622 */ see #3622 */
regs[bidx] = blk; regs[bidx] = blk;
} }
...@@ -1605,9 +1605,9 @@ RETRY_TRY_BLOCK: ...@@ -1605,9 +1605,9 @@ RETRY_TRY_BLOCK:
} }
blk = regs[bidx]; blk = regs[bidx];
if (!mrb_nil_p(blk) && !mrb_proc_p(blk)) { 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 /* 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; regs[bidx] = blk;
ci = mrb->c->ci; ci = mrb->c->ci;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment