* gc.c (gc_stat_internal): support comatible layer for
GC.stat(symbol) type acess. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5d5c95f28e
commit
a84b2a6afd
@ -1,3 +1,8 @@
|
|||||||
|
Fri Nov 14 16:33:06 2014 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* gc.c (gc_stat_internal): support comatible layer for
|
||||||
|
GC.stat(symbol) type acess.
|
||||||
|
|
||||||
Fri Nov 14 16:19:08 2014 Koichi Sasada <ko1@atdot.net>
|
Fri Nov 14 16:19:08 2014 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* gc.c (gc_stat_internal): add compatible layer.
|
* gc.c (gc_stat_internal): add compatible layer.
|
||||||
|
25
gc.c
25
gc.c
@ -6513,12 +6513,11 @@ setup_gc_stat_symbols(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv)
|
compat_key(VALUE key)
|
||||||
{
|
{
|
||||||
VALUE key = argv[1];
|
VALUE new_key = rb_hash_aref(gc_stat_compat_table, key);
|
||||||
VALUE new_key = Qnil;
|
|
||||||
|
|
||||||
if ((new_key = rb_hash_aref(gc_stat_compat_table, key)) != Qnil) {
|
if (!NIL_P(new_key)) {
|
||||||
static int warned = 0;
|
static int warned = 0;
|
||||||
if (warned == 0) {
|
if (warned == 0) {
|
||||||
rb_warn("GC.stat keys were changed from Ruby 2.1. "
|
rb_warn("GC.stat keys were changed from Ruby 2.1. "
|
||||||
@ -6527,6 +6526,18 @@ default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv)
|
|||||||
key, new_key);
|
key, new_key);
|
||||||
warned = 1;
|
warned = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv)
|
||||||
|
{
|
||||||
|
VALUE key = argv[1];
|
||||||
|
VALUE new_key = Qnil;
|
||||||
|
|
||||||
|
if ((new_key = compat_key(key)) != Qnil) {
|
||||||
return rb_hash_aref(hash, new_key);
|
return rb_hash_aref(hash, new_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6566,6 +6577,7 @@ gc_stat_internal(VALUE hash_or_sym)
|
|||||||
else if (hash != Qnil) \
|
else if (hash != Qnil) \
|
||||||
rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
|
rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
|
||||||
|
|
||||||
|
again:
|
||||||
SET(count, objspace->profile.count);
|
SET(count, objspace->profile.count);
|
||||||
|
|
||||||
/* implementation dependent counters */
|
/* implementation dependent counters */
|
||||||
@ -6610,6 +6622,11 @@ gc_stat_internal(VALUE hash_or_sym)
|
|||||||
#undef SET
|
#undef SET
|
||||||
|
|
||||||
if (!NIL_P(key)) { /* matched key should return above */
|
if (!NIL_P(key)) { /* matched key should return above */
|
||||||
|
VALUE new_key;
|
||||||
|
if ((new_key = compat_key(key)) != Qnil) {
|
||||||
|
key = new_key;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
|
rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user