diff --git a/include/mruby/internal.h b/include/mruby/internal.h index b8387b303..0c719ce27 100644 --- a/include/mruby/internal.h +++ b/include/mruby/internal.h @@ -176,11 +176,12 @@ size_t mrb_obj_iv_tbl_memsize(mrb_value); mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*); void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v); mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod); +mrb_value mrb_mod_const_at(mrb_state *mrb, struct RClass *c, mrb_value ary); mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self); mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value); 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); -mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym); +mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass *c, mrb_sym sym); +mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass *c, mrb_sym sym); mrb_bool mrb_ident_p(const char *s, mrb_int len); mrb_value mrb_exc_const_get(mrb_state *mrb, mrb_sym sym); diff --git a/src/variable.c b/src/variable.c index ce55952af..c72093dfa 100644 --- a/src/variable.c +++ b/src/variable.c @@ -924,6 +924,13 @@ const_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p) return 0; } +mrb_value +mrb_mod_const_at(mrb_state *mrb, struct RClass *c, mrb_value ary) +{ + iv_foreach(mrb, class_iv_ptr(c), const_i, &ary); + return ary; +} + /* 15.2.2.4.24 */ /* * call-seq: @@ -941,7 +948,7 @@ mrb_mod_constants(mrb_state *mrb, mrb_value mod) mrb_get_args(mrb, "|b", &inherit); ary = mrb_ary_new(mrb); while (c) { - iv_foreach(mrb, class_iv_ptr(c), const_i, &ary); + mrb_mod_const_at(mrb, c, ary); if (!inherit) break; c = c->super; if (c == mrb->object_class) break;