summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-07-31 16:48:50 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-08-25 09:13:09 +0900
commitfd086833ff6673ab11e6ecea573851593263ae6a (patch)
tree9cdbf143ab227132396c9cdd71c16bb05951bd37 /include
parentbfd11aab35ab942363359a989712e9a6f35b9295 (diff)
downloadmruby-fd086833ff6673ab11e6ecea573851593263ae6a.tar.gz
mruby-fd086833ff6673ab11e6ecea573851593263ae6a.zip
Reorganize flags values for classes; fix #3975
Renamed flag macro names as well: `MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN` `MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED` `MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN` `MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
Diffstat (limited to 'include')
-rw-r--r--include/mruby/class.h20
-rw-r--r--include/mruby/object.h9
2 files changed, 17 insertions, 12 deletions
diff --git a/include/mruby/class.h b/include/mruby/class.h
index 706a4d37c..ddcbd5f98 100644
--- a/include/mruby/class.h
+++ b/include/mruby/class.h
@@ -53,19 +53,25 @@ mrb_class(mrb_state *mrb, mrb_value v)
}
}
-/* TODO: figure out where to put user flags */
-/* flags bits >= 18 is reserved */
-#define MRB_FLAG_IS_PREPENDED (1 << 19)
-#define MRB_FLAG_IS_ORIGIN (1 << 20)
+/* flags:
+ 20: frozen
+ 19: is_prepended
+ 18: is_origin
+ 17: is_inherited (used by method cache)
+ 16: unused
+ 0-15: instance type
+*/
+#define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
+#define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
#define MRB_CLASS_ORIGIN(c) do {\
- if (c->flags & MRB_FLAG_IS_PREPENDED) {\
+ if (c->flags & MRB_FL_CLASS_IS_PREPENDED) {\
c = c->super;\
- while (!(c->flags & MRB_FLAG_IS_ORIGIN)) {\
+ while (!(c->flags & MRB_FL_CLASS_IS_ORIGIN)) {\
c = c->super;\
}\
}\
} while (0)
-#define MRB_FLAG_IS_INHERITED (1 << 21)
+#define MRB_FL_CLASS_IS_INHERITED (1 << 17)
#define MRB_INSTANCE_TT_MASK (0xFF)
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~MRB_INSTANCE_TT_MASK) | (char)tt)
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & MRB_INSTANCE_TT_MASK)
diff --git a/include/mruby/object.h b/include/mruby/object.h
index 4f2134ae2..25584a1d4 100644
--- a/include/mruby/object.h
+++ b/include/mruby/object.h
@@ -22,11 +22,10 @@ struct RBasic {
};
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
-/* flags bits >= 18 is reserved */
-#define MRB_FLAG_IS_FROZEN (1 << 18)
-#define MRB_FROZEN_P(o) ((o)->flags & MRB_FLAG_IS_FROZEN)
-#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FLAG_IS_FROZEN)
-#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FLAG_IS_FROZEN)
+#define MRB_FL_OBJ_IS_FROZEN (1 << 20)
+#define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
+#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
+#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
struct RObject {
MRB_OBJECT_HEADER;