diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-09-15 06:00:30 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-09-15 06:00:30 +0000 |
commit | bbf2ad4ed8a142c5fba8b5e56293006b359f9b18 (patch) | |
tree | 5cd9ec18d5f68c4092ffb4b29004289bd9fad895 /variable.c | |
parent | f57e5b0dc61aab42d2913029080d7e93cc75f71a (diff) |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/variable.c b/variable.c index b37c040681..cd9fe0d48e 100644 --- a/variable.c +++ b/variable.c @@ -1167,11 +1167,10 @@ rb_mod_const_of(mod, ary) VALUE mod; VALUE ary; { - rb_mod_const_at(mod, ary); for (;;) { + rb_mod_const_at(mod, ary); mod = RCLASS(mod)->super; if (!mod) break; - rb_mod_const_at(mod, ary); } return ary; } @@ -1488,6 +1487,40 @@ rb_define_class_variable(klass, name, val) rb_cvar_declare(klass, id, val); } +static int +cv_i(key, value, ary) + ID key; + VALUE value; + VALUE ary; +{ + if (rb_is_class_id(key)) { + VALUE kval = rb_str_new2(rb_id2name(key)); + if (!rb_ary_includes(ary, kval)) { + rb_ary_push(ary, kval); + } + } + return ST_CONTINUE; +} + +VALUE +rb_mod_class_variables(obj) + VALUE obj; +{ + VALUE ary = rb_ary_new(); + + if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) + rb_raise(rb_eSecurityError, "Insecure: can't get metainfo"); + + for (;;) { + if (RCLASS(obj)->iv_tbl) { + st_foreach(RCLASS(obj)->iv_tbl, cv_i, ary); + } + obj = RCLASS(obj)->super; + if (!obj) break; + } + return ary; +} + VALUE rb_iv_get(obj, name) VALUE obj; |