diff options
| author | skandhas <[email protected]> | 2012-12-20 21:29:35 +0800 |
|---|---|---|
| committer | skandhas <[email protected]> | 2012-12-20 21:29:35 +0800 |
| commit | 5a65a7258f2bbd92901531ccafcccb48a5f66f52 (patch) | |
| tree | 9e709a7cffce6ad2705aea1484277de3fb890da7 | |
| parent | 3c28241bd76466bafec5555028283e3fc6f2799a (diff) | |
| download | mruby-5a65a7258f2bbd92901531ccafcccb48a5f66f52.tar.gz mruby-5a65a7258f2bbd92901531ccafcccb48a5f66f52.zip | |
add mrb_mod_cv_get
| -rw-r--r-- | include/mruby/variable.h | 1 | ||||
| -rw-r--r-- | src/variable.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/mruby/variable.h b/include/mruby/variable.h index 7189ef690..d33a20d5e 100644 --- a/include/mruby/variable.h +++ b/include/mruby/variable.h @@ -55,6 +55,7 @@ mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value); mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*); mrb_sym mrb_class_sym(mrb_state *mrb, struct RClass *c, struct RClass *outer); mrb_value mrb_mod_class_variables(mrb_state*, mrb_value); +mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym); /* GC functions */ void mrb_gc_mark_gv(mrb_state*); diff --git a/src/variable.c b/src/variable.c index 992663408..b4e262f8d 100644 --- a/src/variable.c +++ b/src/variable.c @@ -673,6 +673,21 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod) return ary; } +mrb_value +mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym) +{ + while (c) { + if (c->iv) { + iv_tbl *t = c->iv; + mrb_value v; + + if (iv_get(mrb, t, sym, &v)) + return v; + } + c = c->super; + } + return mrb_nil_value(); +} mrb_value mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym) |
