diff options
| -rw-r--r-- | include/mruby/variable.h | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 2 | ||||
| -rw-r--r-- | src/class.c | 4 | ||||
| -rw-r--r-- | src/variable.c | 11 |
4 files changed, 10 insertions, 9 deletions
diff --git a/include/mruby/variable.h b/include/mruby/variable.h index 8758114b9..2779304eb 100644 --- a/include/mruby/variable.h +++ b/include/mruby/variable.h @@ -50,7 +50,7 @@ MRB_API void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v) MRB_API mrb_bool mrb_iv_defined(mrb_state*, mrb_value, mrb_sym); MRB_API mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym); MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src); -MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, struct RClass *klass, mrb_sym id); +MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id); MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym); MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val); MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym); diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 0c1016b4c..420052e4d 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -263,7 +263,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k if (!is_const_id(mrb, mrb_sym2name_len(mrb, id, NULL))) { mrb_name_error(mrb, id, "identifier %S needs to be constant", name); } - if (mrb_const_defined_at(mrb, klass, id)) { + if (mrb_const_defined_at(mrb, mrb_obj_value(klass), id)) { mrb_warn(mrb, "redefining constant Struct::%S", name); /* ?rb_mod_remove_const(klass, mrb_sym2name(mrb, id)); */ } diff --git a/src/class.c b/src/class.c index c11346223..63b9c3ee0 100644 --- a/src/class.c +++ b/src/class.c @@ -137,7 +137,7 @@ define_module(mrb_state *mrb, mrb_sym name, struct RClass *outer) { struct RClass *m; - if (mrb_const_defined_at(mrb, outer, name)) { + if (mrb_const_defined_at(mrb, mrb_obj_value(outer), name)) { return module_from_sym(mrb, outer, name); } m = mrb_module_new(mrb); @@ -179,7 +179,7 @@ define_class(mrb_state *mrb, mrb_sym name, struct RClass *super, struct RClass * { struct RClass * c; - if (mrb_const_defined_at(mrb, outer, name)) { + if (mrb_const_defined_at(mrb, mrb_obj_value(outer), name)) { c = class_from_sym(mrb, outer, name); if (super && mrb_class_real(c->super) != super) { mrb_raisef(mrb, E_TYPE_ERROR, "superclass mismatch for Class %S (%S not %S)", diff --git a/src/variable.c b/src/variable.c index e9f77b8d9..c4f6fb830 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1081,9 +1081,10 @@ mrb_f_global_variables(mrb_state *mrb, mrb_value self) } static mrb_bool -mrb_const_defined_0(mrb_state *mrb, struct RClass *klass, mrb_sym id, mrb_bool exclude, mrb_bool recurse) +mrb_const_defined_0(mrb_state *mrb, mrb_value mod, mrb_sym id, mrb_bool exclude, mrb_bool recurse) { - struct RClass * tmp; + struct RClass *klass = mrb_class_ptr(mod); + struct RClass *tmp; mrb_bool mod_retry = 0; tmp = klass; @@ -1106,13 +1107,13 @@ retry: MRB_API mrb_bool mrb_const_defined(mrb_state *mrb, mrb_value mod, mrb_sym id) { - return mrb_const_defined_0(mrb, mrb_class_ptr(mod), id, TRUE, TRUE); + return mrb_const_defined_0(mrb, mod, id, TRUE, TRUE); } MRB_API mrb_bool -mrb_const_defined_at(mrb_state *mrb, struct RClass *klass, mrb_sym id) +mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id) { - return mrb_const_defined_0(mrb, klass, id, TRUE, FALSE); + return mrb_const_defined_0(mrb, mod, id, TRUE, FALSE); } MRB_API mrb_value |
