Small refactoring.

The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
parent 005ccd9c
...@@ -22,9 +22,6 @@ struct RClass { ...@@ -22,9 +22,6 @@ struct RClass {
}; };
#define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v))) #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* static inline struct RClass*
mrb_class(mrb_state *mrb, mrb_value v) mrb_class(mrb_state *mrb, mrb_value v)
......
...@@ -24,19 +24,18 @@ struct_class(mrb_state *mrb) ...@@ -24,19 +24,18 @@ struct_class(mrb_state *mrb)
} }
static inline mrb_value 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); struct RClass* sclass = struct_class(mrb);
mrb_value ans; mrb_value ans;
for (;;) { 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; if (!mrb_nil_p(ans)) return ans;
kclass = RCLASS_SUPER(c); c = c->super;
if (kclass == 0 || kclass == sclass) if (c == sclass || c == 0)
return mrb_nil_value(); return mrb_nil_value();
c = mrb_obj_value(kclass);
} }
} }
......
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