Commit b30ca87b authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Integrate mrblib/float.rb into src/numeric.c

- Avoid hack for `MRB_WITHOUT_FLOAT` in build scripts
- Avoid runtime dispatch for `MRB_WITHOUT_FLOAT`
parent 1c574b06
##
# Float
#
# ISO 15.2.9
class Float
# mruby special - since mruby integers may be upgraded to floats,
# floats should be compatible to integers.
include Integral
end if Object.const_defined?(:Float)
......@@ -8,9 +8,6 @@ MRuby.each_target do
file objfile("#{current_build_dir}/mrblib") => "#{current_build_dir}/mrblib.c"
file "#{current_build_dir}/mrblib.c" => [mrbcfile, __FILE__] + Dir.glob("#{current_dir}/*.rb").sort do |t|
_, _, *rbfiles = t.prerequisites
if self.cc.defines.flatten.include?("MRB_WITHOUT_FLOAT")
rbfiles.delete("#{current_dir}/float.rb")
end
FileUtils.mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f|
_pp "GEN", "*.rb", "#{t.name.relative_path}"
......
......@@ -1487,11 +1487,13 @@ flo_plus(mrb_state *mrb, mrb_value x)
void
mrb_init_numeric(mrb_state *mrb)
{
struct RClass *numeric, *integer, *fixnum;
struct RClass *numeric, *integer, *fixnum, *integral;
#ifndef MRB_WITHOUT_FLOAT
struct RClass *fl;
#endif
integral = mrb_define_module(mrb, "Integral");
/* Numeric Class */
numeric = mrb_define_class(mrb, "Numeric", mrb->object_class); /* 15.2.7 */
......@@ -1578,6 +1580,7 @@ mrb_init_numeric(mrb_state *mrb)
#ifdef NAN
mrb_define_const(mrb, fl, "NAN", mrb_float_value(mrb, NAN));
#endif
mrb_include_module(mrb, fl, integral);
#endif
mrb_define_module(mrb, "Integral");
}
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