Call `MRB_SET_INSTANCE_TT` for `Complex` and `Rational`.

parent e968bdf6
......@@ -132,7 +132,11 @@ void mrb_mruby_complex_gem_init(mrb_state *mrb)
mrb_assert(sizeof(struct mrb_complex) < ISTRUCT_DATA_SIZE);
#endif
comp = mrb_define_class(mrb, "Complex", mrb_class_get(mrb, "Numeric"));
//MRB_SET_INSTANCE_TT(comp, MRB_TT_ISTRUCT);
#ifdef COMPLEX_USE_ISTRUCT
MRB_SET_INSTANCE_TT(comp, MRB_TT_ISTRUCT);
#else
MRB_SET_INSTANCE_TT(comp, MRB_TT_DATA);
#endif
mrb_undef_class_method(mrb, comp, "new");
mrb_define_class_method(mrb, comp, "rectangular", complex_s_rect, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
mrb_define_class_method(mrb, comp, "rect", complex_s_rect, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
......
......@@ -183,10 +183,13 @@ void mrb_mruby_rational_gem_init(mrb_state *mrb)
{
struct RClass *rat;
#ifdef COMPLEX_USE_RATIONAL
rat = mrb_define_class(mrb, "Rational", mrb_class_get(mrb, "Numeric"));
#ifdef RATIONAL_USE_ISTRUCT
MRB_SET_INSTANCE_TT(rat, MRB_TT_ISTRUCT);
mrb_assert(sizeof(struct mrb_rational) < ISTRUCT_DATA_SIZE);
#else
MRB_SET_INSTANCE_TT(rat, MRB_TT_DATA);
#endif
rat = mrb_define_class(mrb, "Rational", mrb_class_get(mrb, "Numeric"));
mrb_undef_class_method(mrb, rat, "new");
mrb_define_class_method(mrb, rat, "_new", rational_s_new, MRB_ARGS_REQ(2));
mrb_define_method(mrb, rat, "numerator", rational_numerator, MRB_ARGS_NONE());
......
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