mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* class.c (rb_check_inheritable): new function. [ruby-dev:22316]
* intern.h: add prototype. * eval.c (superclass): use rb_check_inheritable(). * object.c (rb_class_initialize): check argument validity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3e67076db0
commit
7c34e359a1
5 changed files with 28 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sun Dec 21 17:29:00 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* class.c (rb_check_inheritable): new function. [ruby-dev:22316]
|
||||
|
||||
* intern.h: add prototype.
|
||||
|
||||
* eval.c (superclass): use rb_check_inheritable().
|
||||
|
||||
* object.c (rb_class_initialize): check argument validity.
|
||||
|
||||
Sun Dec 21 16:25:10 2003 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/pathname.rb (Pathname#+): re-implemented to resolve ".." in
|
||||
|
|
13
class.c
13
class.c
|
@ -178,6 +178,19 @@ rb_define_class_id(id, super)
|
|||
return klass;
|
||||
}
|
||||
|
||||
void
|
||||
rb_check_inheritable(super)
|
||||
VALUE super;
|
||||
{
|
||||
if (TYPE(super) != T_CLASS) {
|
||||
rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
|
||||
rb_obj_classname(super));
|
||||
}
|
||||
if (RBASIC(super)->flags & FL_SINGLETON) {
|
||||
rb_raise(rb_eTypeError, "can't make subclass of virtual class");
|
||||
}
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_class_inherited(super, klass)
|
||||
VALUE super, klass;
|
||||
|
|
8
eval.c
8
eval.c
|
@ -1699,13 +1699,7 @@ superclass(self, node)
|
|||
}
|
||||
JUMP_TAG(state);
|
||||
}
|
||||
if (TYPE(val) != T_CLASS) {
|
||||
rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
|
||||
rb_obj_classname(val));
|
||||
}
|
||||
if (FL_TEST(val, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError, "can't make subclass of virtual class");
|
||||
}
|
||||
rb_check_inheritable(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
1
intern.h
1
intern.h
|
@ -102,6 +102,7 @@ VALUE rb_class_init_copy _((VALUE, VALUE));
|
|||
VALUE rb_singleton_class_clone _((VALUE));
|
||||
void rb_singleton_class_attached _((VALUE,VALUE));
|
||||
VALUE rb_make_metaclass _((VALUE, VALUE));
|
||||
void rb_check_inheritable _((VALUE));
|
||||
VALUE rb_class_inherited _((VALUE, VALUE));
|
||||
VALUE rb_define_class_id _((ID, VALUE));
|
||||
VALUE rb_module_new _((void));
|
||||
|
|
3
object.c
3
object.c
|
@ -776,6 +776,9 @@ rb_class_initialize(argc, argv, klass)
|
|||
if (rb_scan_args(argc, argv, "01", &super) == 0) {
|
||||
super = rb_cObject;
|
||||
}
|
||||
else {
|
||||
rb_check_inheritable(super);
|
||||
}
|
||||
RCLASS(klass)->super = super;
|
||||
rb_make_metaclass(klass, RBASIC(super)->klass);
|
||||
rb_mod_initialize(klass);
|
||||
|
|
Loading…
Add table
Reference in a new issue