summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorMichael Leibowitz <michael.leibowitz@intel.com>2013-08-15 15:02:54 -0700
committerMichael Leibowitz <michael.leibowitz@intel.com>2013-08-15 15:02:54 -0700
commit6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06 (patch)
treed9d59f4b502927634d32832e963db76629ff5a2e /class.c
parent3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748 (diff)
downloadruby-6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06.tar.gz
ruby-6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06.tar.bz2
ruby-6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06.zip
Imported Upstream version 1.9.3.p448upstream/1.9.3.p448upstream
Diffstat (limited to 'class.c')
-rw-r--r--class.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/class.c b/class.c
index 450c334..30295f2 100644
--- a/class.c
+++ b/class.c
@@ -2,7 +2,7 @@
class.c -
- $Author: yugui $
+ $Author: usa $
created at: Tue Aug 10 15:05:44 JST 1993
Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -159,10 +159,27 @@ clone_const_i(st_data_t key, st_data_t value, st_data_t data)
return clone_const((ID)key, (const rb_const_entry_t *)value, (st_table *)data);
}
+static void
+class_init_copy_check(VALUE clone, VALUE orig)
+{
+ if (orig == rb_cBasicObject) {
+ rb_raise(rb_eTypeError, "can't copy the root class");
+ }
+ if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) {
+ rb_raise(rb_eTypeError, "already initialized class");
+ }
+ if (FL_TEST(orig, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't copy singleton class");
+ }
+}
+
/* :nodoc: */
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
+ if (RB_TYPE_P(clone, T_CLASS)) {
+ class_init_copy_check(clone, orig);
+ }
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
RBASIC(clone)->klass = rb_singleton_class_clone(orig);
@@ -203,22 +220,6 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
return clone;
}
-/* :nodoc: */
-VALUE
-rb_class_init_copy(VALUE clone, VALUE orig)
-{
- if (orig == rb_cBasicObject) {
- rb_raise(rb_eTypeError, "can't copy the root class");
- }
- if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) {
- rb_raise(rb_eTypeError, "already initialized class");
- }
- if (FL_TEST(orig, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't copy singleton class");
- }
- return rb_mod_init_copy(clone, orig);
-}
-
VALUE
rb_singleton_class_clone(VALUE obj)
{
@@ -698,6 +699,8 @@ rb_include_module(VALUE klass, VALUE module)
c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c));
if (RMODULE_M_TBL(module) && RMODULE_M_TBL(module)->num_entries)
changed = 1;
+ if (RMODULE_CONST_TBL(module) && RMODULE_CONST_TBL(module)->num_entries)
+ changed = 1;
skip:
module = RCLASS_SUPER(module);
}