Support MRB_WIHTOUT_FLOAT to mruby-object-ext
MODIFY
mrbgems/mruby-object-ext/src/object.c
mrbgems/mruby-object-ext/src/object.c
@@ -16,6 +16,7 @@ nil_to_a(mrb_state *mrb, mrb_value obj)
return mrb_ary_new(mrb);
}
+#ifndef MRB_WITHOUT_FLOAT
/*
* call-seq:
* nil.to_f -> 0.0
@@ -28,6 +29,7 @@ nil_to_f(mrb_state *mrb, mrb_value obj)
{
return mrb_float_value(mrb, 0.0);
}
+#endif
/*
* call-seq:
@@ -77,7 +79,9 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
switch (mrb_type(self)) {
case MRB_TT_SYMBOL:
case MRB_TT_FIXNUM:
+#ifndef MRB_WITHOUT_FLOAT
case MRB_TT_FLOAT:
+#endif
c = NULL;
break;
default:
@@ -94,7 +98,9 @@ mrb_mruby_object_ext_gem_init(mrb_state* mrb)
struct RClass * n = mrb->nil_class;
mrb_define_method(mrb, n, "to_a", nil_to_a, MRB_ARGS_NONE());
+#ifndef MRB_WITHOUT_FLOAT
mrb_define_method(mrb, n, "to_f", nil_to_f, MRB_ARGS_NONE());
+#endif
mrb_define_method(mrb, n, "to_i", nil_to_i, MRB_ARGS_NONE());
mrb_define_method(mrb, mrb->kernel_module, "instance_exec", mrb_obj_instance_exec, MRB_ARGS_ANY() | MRB_ARGS_BLOCK());

MODIFY
mrbgems/mruby-object-ext/test/nil.rb
mrbgems/mruby-object-ext/test/nil.rb
@@ -4,7 +4,7 @@ end
assert('NilClass#to_f') do
assert_equal 0.0, nil.to_f
-end
+end if class_defined?("Float")
assert('NilClass#to_i') do
assert_equal 0, nil.to_i

Support MRB_WIHTOUT_FLOAT to mruby-object-ext