mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -1945,6 +1945,9 @@ mrb_instance_alloc(mrb_state *mrb, mrb_value cv)
|
||||
ttype = MRB_TT_OBJECT;
|
||||
}
|
||||
if (ttype <= MRB_TT_CPTR) {
|
||||
if (ttype == MRB_TT_UNDEF) {
|
||||
mrb_raisef(mrb, E_TYPE_ERROR, "allocator undefined for %v", cv);
|
||||
}
|
||||
mrb_raisef(mrb, E_TYPE_ERROR, "can't create instance of %v", cv);
|
||||
}
|
||||
o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c);
|
||||
|
||||
Reference in New Issue
Block a user