diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-04-06 05:42:43 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-04-06 05:42:43 +0000 |
commit | 0c176f00c12c32bbfa2d197fd9bf2f2c81c1573d (patch) | |
tree | 4a147a1436c047ffa126e887ab3684fbe999e1c9 /class.c | |
parent | 2c29a1c0e9ab81f993e2391a80c2c12cdca458dd (diff) |
* variable.c (rb_const_get): no recursion to show full class path
for modules.
* eval.c (rb_set_safe_level): should set safe level in curr_thread
as well.
* eval.c (safe_setter): ditto.
* object.c (rb_obj_is_instance_of): nil belongs to false, not true.
* time.c (make_time_t): proper (I hope) daylight saving time
handling for both US and Europe. I HATE SUMMER TIME!
* eval.c (rb_thread_wait_for): non blocked signal interrupt should
stop the interval.
* class.c (rb_mod_clone): should copy method bodies too.
* bignum.c (bigdivrem): should trim trailing zero bdigits of
remainder, even if dd == 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 56 |
1 files changed, 46 insertions, 10 deletions
@@ -33,16 +33,6 @@ rb_class_new(super) return (VALUE)klass; } -VALUE -rb_singleton_class_new(super) - VALUE super; -{ - VALUE klass = rb_class_new(super); - - FL_SET(klass, FL_SINGLETON); - return klass; -} - static int clone_method(mid, body, tbl) ID mid; @@ -54,6 +44,47 @@ clone_method(mid, body, tbl) } VALUE +rb_mod_clone(module) + VALUE module; +{ + NEWOBJ(clone, struct RClass); + CLONESETUP(clone, module); + + clone->super = RCLASS(module)->super; + if (RCLASS(module)->iv_tbl) { + clone->iv_tbl = st_copy(RCLASS(module)->iv_tbl); + } + if (RCLASS(module)->m_tbl) { + clone->m_tbl = st_init_numtable(); + st_foreach(RCLASS(module)->m_tbl, clone_method, clone->m_tbl); + } + + return (VALUE)clone; +} + +VALUE +rb_mod_dup(mod) + VALUE mod; +{ + VALUE dup = rb_mod_clone(mod); + OBJSETUP(dup, RBASIC(mod)->klass, BUILTIN_TYPE(mod)); + if (FL_TEST(mod, FL_SINGLETON)) { + FL_SET(dup, FL_SINGLETON); + } + return dup; +} + +VALUE +rb_singleton_class_new(super) + VALUE super; +{ + VALUE klass = rb_class_new(super); + + FL_SET(klass, FL_SINGLETON); + return klass; +} + +VALUE rb_singleton_class_clone(klass) VALUE klass; { @@ -226,6 +257,11 @@ rb_include_module(klass, module) if (!OBJ_TAINTED(klass)) { rb_secure(4); } + + rb_frozen_class_p(klass); + if (!OBJ_TAINTED(klass)) { + rb_secure(4); + } if (NIL_P(module)) return; if (klass == module) return; |