change class argument of mrb_const_defined_at from `struct RClass*` to...

change class argument of mrb_const_defined_at from `struct RClass*` to `mrb_value` to make it consistent with mrb_const_defined; ref #2593
parent 6b34166b
......@@ -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);
......
......@@ -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)); */
}
......
......@@ -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)",
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment