diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-06 21:50:06 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-06 21:50:06 +0000 |
commit | b51416e21f7c0df7d29a7ccd7660f794b6055620 (patch) | |
tree | c40497dc8c419b596aa0c5679e1d8621cb474562 /class.c | |
parent | 1e51675654ec0a5624d78786e23851df73e14030 (diff) | |
download | ruby-b51416e21f7c0df7d29a7ccd7660f794b6055620.tar.gz |
* eval.c (rb_call0): update ruby_class as well as ruby_cref.
(ruby-bugs-ja PR#540)
* eval.c (rb_yield_0): remove ruby_frame->cbase and unify to
ruby_cref. [ruby-talk:78141]
* eval.c: initialize /* OK */ variables by Qnil to stop warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 35 |
1 files changed, 16 insertions, 19 deletions
@@ -60,39 +60,37 @@ clone_method(mid, body, tbl) } VALUE -rb_mod_clone(module) - VALUE module; +rb_mod_init_copy(clone, orig) + VALUE clone, orig; { - NEWOBJ(clone, struct RClass); - CLONESETUP(clone, module); - - RCLASS(clone)->super = RCLASS(module)->super; - if (RCLASS(module)->iv_tbl) { + rb_obj_init_copy(clone, orig); + RCLASS(clone)->super = RCLASS(orig)->super; + if (RCLASS(orig)->iv_tbl) { ID id; - RCLASS(clone)->iv_tbl = st_copy(RCLASS(module)->iv_tbl); + RCLASS(clone)->iv_tbl = st_copy(RCLASS(orig)->iv_tbl); id = rb_intern("__classpath__"); st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0); id = rb_intern("__classid__"); st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0); } - if (RCLASS(module)->m_tbl) { + if (RCLASS(orig)->m_tbl) { RCLASS(clone)->m_tbl = st_init_numtable(); - st_foreach(RCLASS(module)->m_tbl, clone_method, + st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)RCLASS(clone)->m_tbl); } - return (VALUE)clone; + return clone; } VALUE -rb_mod_dup(mod) - VALUE mod; +rb_class_init_copy(clone, orig) + VALUE clone, orig; { - VALUE dup = rb_mod_clone(mod); - - RBASIC(dup)->flags = RBASIC(mod)->flags & (T_MASK|FL_TAINT|FL_SINGLETON); - return dup; + if (RCLASS(clone)->super != 0) { + rb_raise(rb_eTypeError, "already initialized class"); + } + return rb_mod_init_copy(clone, orig); } VALUE @@ -434,8 +432,7 @@ VALUE rb_mod_ancestors(mod) VALUE mod; { - VALUE ary = rb_ary_new(); - VALUE p; + VALUE p, ary = rb_ary_new(); for (p = mod; p; p = RCLASS(p)->super) { if (FL_TEST(p, FL_SINGLETON)) |