1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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:
nobu 2009-01-22 03:18:16 +00:00
parent 3899c1bed7
commit 55bde4fbbd
2 changed files with 16 additions and 2 deletions

View file

@ -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
View file

@ -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;
}