mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user