Permalink
Browse files

add mrb_mod_cv_get

  • Loading branch information...
1 parent 3c28241 commit 5a65a7258f2bbd92901531ccafcccb48a5f66f52 @skandhas skandhas committed Dec 20, 2012
Showing with 16 additions and 0 deletions.
  1. +1 −0 include/mruby/variable.h
  2. +15 −0 src/variable.c
View
1 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*);
View
15 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)

0 comments on commit 5a65a72

Please sign in to comment.