numeric.c: merge `mrb_as_float` implementation to `mrb_ensure_float_type`.
Since they are basically duplicated functionality. `mrb_as_float` is now
a macro defined using `mrb_ensure_float_type`;
MODIFY
include/mruby.h
include/mruby.h
@@ -1270,6 +1270,7 @@ MRB_API mrb_bool mrb_obj_equal(mrb_state *mrb, mrb_value a, mrb_value b);
MRB_API mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
#ifndef MRB_NO_FLOAT
MRB_API mrb_value mrb_ensure_float_type(mrb_state *mrb, mrb_value val);
+#define mrb_as_float(mrb, x) mrb_float(mrb_ensure_float_type(mrb, x))
/* obsolete: use mrb_ensure_float_type() instead */
#define mrb_to_float(mrb, val) mrb_ensure_float_type(mrb, val)
#endif

MODIFY
include/mruby/numeric.h
include/mruby/numeric.h
@@ -160,7 +160,6 @@ mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
# endif /* MRB_USE_FLOAT32 */
MRB_API mrb_value mrb_float_to_integer(mrb_state *mrb, mrb_value val);
-MRB_API mrb_float mrb_as_float(mrb_state *mrb, mrb_value x);
/* internal functions */
mrb_float mrb_div_float(mrb_float x, mrb_float y);

MODIFY
src/numeric.c
src/numeric.c
#endif
#endif
-#ifndef MRB_NO_FLOAT
-MRB_API mrb_float
-mrb_as_float(mrb_state *mrb, mrb_value val)
-{
- switch (mrb_type(val)) {
- case MRB_TT_INTEGER:
- return (mrb_float)mrb_integer(val);
- case MRB_TT_FLOAT:
- break;
- case MRB_TT_RATIONAL:
- case MRB_TT_COMPLEX:
- val = mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
- break;
- default:
- mrb_raise(mrb, E_TYPE_ERROR, "non float value");
- break;
- }
- return mrb_float(val);
-}
-#endif
-
static void
int_overflow(mrb_state *mrb, const char *reason)
{

numeric.c: merge `mrb_as_float` implementation to `mrb_ensure_float_type`.

Since they are basically duplicated functionality. `mrb_as_float` is now
a macro defined using `mrb_ensure_float_type`; #5620