diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-02 18:01:39 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-25 09:16:01 +0900 |
| commit | 4c974b9523cc347a0bbcf46b759a14f0b60fdbf0 (patch) | |
| tree | 3341019089f481ee706b6e263e0ab4cfc3b8b6e2 | |
| parent | f3564a405ee766797be191cedd90aa3ab8b5e5c5 (diff) | |
| download | mruby-4c974b9523cc347a0bbcf46b759a14f0b60fdbf0.tar.gz mruby-4c974b9523cc347a0bbcf46b759a14f0b60fdbf0.zip | |
Small refactoring.
The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
| -rw-r--r-- | include/mruby/class.h | 3 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 11 |
2 files changed, 5 insertions, 9 deletions
diff --git a/include/mruby/class.h b/include/mruby/class.h index ddcbd5f98..96a9f7f95 100644 --- a/include/mruby/class.h +++ b/include/mruby/class.h @@ -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) diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index adeb09bc1..fe7e73f04 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -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); } } |
