From 3ceadfa5b256c9fca0a8e7f4af3cdb1b31e6e354 Mon Sep 17 00:00:00 2001 From: Yukihiro Matz Matsumoto Date: Mon, 5 Nov 2012 06:10:22 +0900 Subject: inline include/mruby/object.h --- include/mruby/object.h | 48 ------------------------------------------------ include/mruby/value.h | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 50 deletions(-) delete mode 100644 include/mruby/object.h (limited to 'include') diff --git a/include/mruby/object.h b/include/mruby/object.h deleted file mode 100644 index ee45b1e60..000000000 --- a/include/mruby/object.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** mruby/object.h - Object, NilClass, TrueClass, FalseClass class -** -** See Copyright Notice in mruby.h -*/ - -#ifndef MRUBY_OBJECT_H -#define MRUBY_OBJECT_H - -#define MRB_OBJECT_HEADER \ - enum mrb_vtype tt:8;\ - unsigned int color:3;\ - unsigned int flags:21;\ - struct RClass *c;\ - struct RBasic *gcnext - -/* white: 011, black: 100, gray: 000 */ -#define MRB_GC_GRAY 0 -#define MRB_GC_WHITE_A 1 -#define MRB_GC_WHITE_B (1 << 1) -#define MRB_GC_BLACK (1 << 2) -#define MRB_GC_WHITES (MRB_GC_WHITE_A | MRB_GC_WHITE_B) -#define MRB_GC_COLOR_MASK 7 - -#define paint_gray(o) ((o)->color = MRB_GC_GRAY) -#define paint_black(o) ((o)->color = MRB_GC_BLACK) -#define paint_white(o) ((o)->color = MRB_GC_WHITES) -#define paint_partial_white(s, o) ((o)->color = (s)->current_white_part) -#define is_gray(o) ((o)->color == MRB_GC_GRAY) -#define is_white(o) ((o)->color & MRB_GC_WHITES) -#define is_black(o) ((o)->color & MRB_GC_BLACK) -#define is_dead(s, o) (((o)->color & other_white_part(s) & MRB_GC_WHITES) || (o)->tt == MRB_TT_FREE) -#define flip_white_part(s) ((s)->current_white_part = other_white_part(s)) -#define other_white_part(s) ((s)->current_white_part ^ MRB_GC_WHITES) - -struct RBasic { - MRB_OBJECT_HEADER; -}; - -struct RObject { - MRB_OBJECT_HEADER; - struct iv_tbl *iv; -}; - -#define mrb_obj_ptr(v) ((struct RObject*)((v).value.p)) -#define mrb_basic(v) ((struct RBasic*)((v).value.p)) - -#endif /* MRUBY_OBJECT_H */ diff --git a/include/mruby/value.h b/include/mruby/value.h index dd0349e8d..90c011a7e 100644 --- a/include/mruby/value.h +++ b/include/mruby/value.h @@ -159,8 +159,44 @@ mrb_float_value(mrb_float f) #define mrb_hash_p(o) (mrb_type(o) == MRB_TT_HASH) #define mrb_test(o) (mrb_type(o) != MRB_TT_FALSE) -#include "mruby/object.h" +#define MRB_OBJECT_HEADER \ + enum mrb_vtype tt:8;\ + unsigned int color:3;\ + unsigned int flags:21;\ + struct RClass *c;\ + struct RBasic *gcnext + +/* white: 011, black: 100, gray: 000 */ +#define MRB_GC_GRAY 0 +#define MRB_GC_WHITE_A 1 +#define MRB_GC_WHITE_B (1 << 1) +#define MRB_GC_BLACK (1 << 2) +#define MRB_GC_WHITES (MRB_GC_WHITE_A | MRB_GC_WHITE_B) +#define MRB_GC_COLOR_MASK 7 + +#define paint_gray(o) ((o)->color = MRB_GC_GRAY) +#define paint_black(o) ((o)->color = MRB_GC_BLACK) +#define paint_white(o) ((o)->color = MRB_GC_WHITES) +#define paint_partial_white(s, o) ((o)->color = (s)->current_white_part) +#define is_gray(o) ((o)->color == MRB_GC_GRAY) +#define is_white(o) ((o)->color & MRB_GC_WHITES) +#define is_black(o) ((o)->color & MRB_GC_BLACK) +#define is_dead(s, o) (((o)->color & other_white_part(s) & MRB_GC_WHITES) || (o)->tt == MRB_TT_FREE) +#define flip_white_part(s) ((s)->current_white_part = other_white_part(s)) +#define other_white_part(s) ((s)->current_white_part ^ MRB_GC_WHITES) + +struct RBasic { + MRB_OBJECT_HEADER; +}; + +#define mrb_basic(v) ((struct RBasic*)((v).value.p)) + +struct RObject { + MRB_OBJECT_HEADER; + struct iv_tbl *iv; +}; +#define mrb_obj_ptr(v) ((struct RObject*)((v).value.p)) #define mrb_immediate_p(x) (mrb_type(x) <= MRB_TT_MAIN) #define mrb_special_const_p(x) mrb_immediate_p(x) @@ -186,7 +222,7 @@ static inline mrb_value mrb_obj_value(void *p) { mrb_value v; - struct RBasic *b = (struct RBasic*) p; + struct RBasic *b = (struct RBasic*)p; MRB_SET_VALUE(v, b->tt, value.p, p); return v; -- cgit v1.2.3