Allow Class#allocate to be prohibited

Calling `Class#allocate` with `UnboundMethod#bind_call` usually succeeds without problems.
If this behavior does not make us happy, we can now prohibit it with `MRB_SET_INSTANCE_TT(klass, MRB_TT_UNDEF)`.

At the same time, it applies to the `Binding`, `Complex`, `Data`, `Float`, `Integer`, `Method`, `Rational` and `UnboundMethod` classes.
This commit is contained in:
dearblue
2023-04-09 21:14:07 +09:00
parent c3ba76794f
commit d3128ce58a
8 changed files with 13 additions and 5 deletions
+2 -2
View File
@@ -2219,7 +2219,7 @@ mrb_init_numeric(mrb_state *mrb)
/* Integer Class */
mrb->integer_class = integer = mrb_define_class(mrb, "Integer", numeric); /* 15.2.8 */
MRB_SET_INSTANCE_TT(integer, MRB_TT_INTEGER);
MRB_SET_INSTANCE_TT(integer, MRB_TT_UNDEF);
mrb_undef_class_method(mrb, integer, "new");
mrb_define_method(mrb, integer, "**", int_pow, MRB_ARGS_REQ(1));
mrb_define_method(mrb, integer, "<=>", num_cmp, MRB_ARGS_REQ(1)); /* 15.2.8.3.1 */
@@ -2264,7 +2264,7 @@ mrb_init_numeric(mrb_state *mrb)
#ifndef MRB_NO_FLOAT
/* Float Class */
mrb->float_class = fl = mrb_define_class(mrb, "Float", numeric); /* 15.2.9 */
MRB_SET_INSTANCE_TT(fl, MRB_TT_FLOAT);
MRB_SET_INSTANCE_TT(fl, MRB_TT_UNDEF);
mrb_undef_class_method(mrb, fl, "new");
mrb_define_method(mrb, fl, "**", flo_pow, MRB_ARGS_REQ(1));
mrb_define_method(mrb, fl, "/", flo_div, MRB_ARGS_REQ(1)); /* 15.2.9.3.6 */