summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-18 05:56:05 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-18 05:56:05 +0000
commitf35971afdfd05304d0b5d2b0e3042a0c739f877f (patch)
tree7b2ec9bc16cac781813584423a00482fc94869aa /class.c
parentc068201c50bea13d3d48ab7460cdc407946af0ba (diff)
* regex.c (NUM_FAILURE_ITEMS): was confusing NUM_REG_ITEMS and
NUM_NONREG_ITEMS, which have happened to be same value. * class.c (rb_class_new): subclass check moved to this function. * class.c (rb_class_boot): check less version of rb_class_new(). * eval.c (proc_invoke): should preserve iter status for embedded frame in the block. * file.c (rb_file_s_expand_path): may overrun buffer on stack. * string.c (rb_str_insert): forgot to call rb_str_modify(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/class.c b/class.c
index 6f6c5d2..1c3391a 100644
--- a/class.c
+++ b/class.c
@@ -19,7 +19,7 @@
extern st_table *rb_class_tbl;
VALUE
-rb_class_new(super)
+rb_class_boot(super)
VALUE super;
{
NEWOBJ(klass, struct RClass);
@@ -33,6 +33,20 @@ rb_class_new(super)
return (VALUE)klass;
}
+VALUE
+rb_class_new(super)
+ VALUE super;
+{
+ Check_Type(super, T_CLASS);
+ if (super == rb_cClass) {
+ rb_raise(rb_eTypeError, "can't make subclass of Class");
+ }
+ if (FL_TEST(super, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
+ return rb_class_boot(super);
+}
+
static int
clone_method(mid, body, tbl)
ID mid;
@@ -78,7 +92,7 @@ VALUE
rb_singleton_class_new(super)
VALUE super;
{
- VALUE klass = rb_class_new(super);
+ VALUE klass = rb_class_boot(super);
FL_SET(klass, FL_SINGLETON);
return klass;