method
initialize_copy
v1_8_7_72 -
Show latest stable
- Class:
Module
initialize_copy(p1)public
No documentation available.
/* :nodoc: */
VALUE
rb_mod_init_copy(clone, orig)
VALUE clone, orig;
{
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
RBASIC(clone)->klass = RBASIC(orig)->klass;
RBASIC(clone)->klass = rb_singleton_class_clone(clone);
}
RCLASS(clone)->super = RCLASS(orig)->super;
if (RCLASS(orig)->iv_tbl) {
ID id;
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(orig)->m_tbl) {
struct clone_method_data data;
data.tbl = RCLASS(clone)->m_tbl = st_init_numtable();
data.klass = (VALUE)clone;
st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
}
return clone;
}