Project

General

Profile

Bug #199 ยป 1.8.6p230_smartleaf_fix.patch

Anonymous, 06/25/2008 10:04 AM

View differences:

class.c (revision 17218)
48 48
    return rb_class_boot(super);
49 49
}
50 50

  
51
struct clone_method_data {
52
    st_table *tbl;
53
    VALUE klass;
54
};
55

  
56 51
static int
57
clone_method(mid, body, data)
52
clone_method(mid, body, tbl)
58 53
    ID mid;
59 54
    NODE *body;
60
    struct clone_method_data *data;
55
    st_table *tbl;
61 56
{
62
    NODE *fbody = body->nd_body;
63

  
64
    if (fbody && nd_type(fbody) == NODE_SCOPE) {
65
	VALUE cref = data->klass ?
66
	    (VALUE)NEW_NODE(NODE_CREF,data->klass,0,fbody->nd_rval) :
67
	    fbody->nd_rval;
68
	fbody = NEW_NODE(NODE_SCOPE, fbody->nd_tbl, cref, fbody->nd_next);
69
    }
70
    st_insert(data->tbl, mid, (st_data_t)NEW_METHOD(fbody, body->nd_noex));
57
    st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
71 58
    return ST_CONTINUE;
72 59
}
73 60

  
......
78 65
{
79 66
    rb_obj_init_copy(clone, orig);
80 67
    if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
81
	RBASIC(clone)->klass = RBASIC(orig)->klass;
82
	RBASIC(clone)->klass = rb_singleton_class_clone(clone);
68
	RBASIC(clone)->klass = rb_singleton_class_clone(orig);
83 69
    }
84 70
    RCLASS(clone)->super = RCLASS(orig)->super;
85 71
    if (RCLASS(orig)->iv_tbl) {
......
92 78
	st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
93 79
    }
94 80
    if (RCLASS(orig)->m_tbl) {
95
	struct clone_method_data data;
96

  
97
	data.tbl = RCLASS(clone)->m_tbl = st_init_numtable();
98
	data.klass = (VALUE)clone;
99

  
100
	st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
81
	RCLASS(clone)->m_tbl = st_init_numtable();
82
	st_foreach(RCLASS(orig)->m_tbl, clone_method,
83
	  (st_data_t)RCLASS(clone)->m_tbl);
101 84
    }
102 85

  
103 86
    return clone;
......
143 126
	if (RCLASS(klass)->iv_tbl) {
144 127
	    clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
145 128
	}
146
	{
147
	    struct clone_method_data data;
148

  
149
	    data.tbl = clone->m_tbl = st_init_numtable();
150
	    switch (TYPE(obj)) {
151
	      case T_CLASS:
152
	      case T_MODULE:
153
		data.klass = obj;
154
		break;
155
	      default:
156
		data.klass = 0;
157
		break;
158
	    }
159

  
160
	    st_foreach(RCLASS(klass)->m_tbl, clone_method, (st_data_t)&data);
161
	}
129
	clone->m_tbl = st_init_numtable();
130
	st_foreach(RCLASS(klass)->m_tbl, clone_method,
131
	  (st_data_t)clone->m_tbl);
162 132
	rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
163 133
	FL_SET(clone, FL_SINGLETON);
164 134
	return (VALUE)clone;
ChangeLog (revision 17218)
82 82
Fri Jun 13 13:14:31 2008  Yukihiro Matsumoto  <matz@ruby-lang.org>
83 83

  
84 84
	* ext/dl/ptr.c (dlmem_each_i): typo fixed.  a patch from IKOMA
85
Sun Jun 15 21:06:12 2008  Yukihiro Matsumoto  <matz@ruby-lang.org>
86

  
87
	* class.c (clone_method): should copy cref as well.
88
	  [ruby-core:15833]
89

  
90 85
	  Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
91 86

  
92 87
Fri Jun 13 13:13:23 2008  URABE Shyouhei  <shyouhei@ice.uec.ac.jp>