зеркало из https://github.com/github/ruby.git
* gc.c (define_final): cannot define finalizer for immediate
values. [ruby-core:21500] * gc.c (define_final): freezes or hides internal values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3899c1bed7
Коммит
55bde4fbbd
|
@ -1,3 +1,10 @@
|
|||
Thu Jan 22 12:19:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (define_final): cannot define finalizer for immediate
|
||||
values. [ruby-core:21500]
|
||||
|
||||
* gc.c (define_final): freezes or hides internal values.
|
||||
|
||||
Thu Jan 22 11:33:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (rb_time_timeval): made a real prototype. a patch from
|
||||
|
|
11
gc.c
11
gc.c
|
@ -2290,9 +2290,14 @@ define_final(int argc, VALUE *argv, VALUE os)
|
|||
rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
|
||||
rb_obj_classname(block));
|
||||
}
|
||||
FL_SET(obj, FL_FINALIZE);
|
||||
if (!FL_ABLE(obj)) {
|
||||
rb_raise(rb_eArgError, "cannot define finalizer for %s",
|
||||
rb_obj_classname(obj));
|
||||
}
|
||||
RBASIC(obj)->flags |= FL_FINALIZE;
|
||||
|
||||
block = rb_ary_new3(2, INT2FIX(rb_safe_level()), block);
|
||||
OBJ_FREEZE(block);
|
||||
|
||||
if (!finalizer_table) {
|
||||
finalizer_table = st_init_numtable();
|
||||
|
@ -2301,7 +2306,9 @@ define_final(int argc, VALUE *argv, VALUE os)
|
|||
rb_ary_push(table, block);
|
||||
}
|
||||
else {
|
||||
st_add_direct(finalizer_table, obj, rb_ary_new3(1, block));
|
||||
table = rb_ary_new3(1, block);
|
||||
RBASIC(table)->klass = 0;
|
||||
st_add_direct(finalizer_table, obj, table);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче