Small refactoring.

The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-08-02 18:01:39 +09:00
parent f3564a405e
commit 4c974b9523
2 changed files with 5 additions and 9 deletions
-3
View File
@@ -22,9 +22,6 @@ struct RClass {
};
#define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v)))
#define RCLASS_SUPER(v) (((struct RClass*)(mrb_ptr(v)))->super)
#define RCLASS_IV_TBL(v) (((struct RClass*)(mrb_ptr(v)))->iv)
#define RCLASS_M_TBL(v) (((struct RClass*)(mrb_ptr(v)))->mt)
static inline struct RClass*
mrb_class(mrb_state *mrb, mrb_value v)
+5 -6
View File
@@ -24,19 +24,18 @@ struct_class(mrb_state *mrb)
}
static inline mrb_value
struct_ivar_get(mrb_state *mrb, mrb_value c, mrb_sym id)
struct_ivar_get(mrb_state *mrb, mrb_value cls, mrb_sym id)
{
struct RClass* kclass;
struct RClass* c = mrb_class_ptr(cls);
struct RClass* sclass = struct_class(mrb);
mrb_value ans;
for (;;) {
ans = mrb_iv_get(mrb, c, id);
ans = mrb_iv_get(mrb, mrb_obj_value(c), id);
if (!mrb_nil_p(ans)) return ans;
kclass = RCLASS_SUPER(c);
if (kclass == 0 || kclass == sclass)
c = c->super;
if (c == sclass || c == 0)
return mrb_nil_value();
c = mrb_obj_value(kclass);
}
}