rename mrb_basic to mrb_basic_ptr; close #1011

parent 24366930
......@@ -232,11 +232,11 @@ int mrb_gc_arena_save(mrb_state*);
void mrb_gc_arena_restore(mrb_state*,int);
void mrb_gc_mark(mrb_state*,struct RBasic*);
#define mrb_gc_mark_value(mrb,val) do {\
if (mrb_type(val) >= MRB_TT_OBJECT) mrb_gc_mark((mrb), mrb_basic(val));\
if (mrb_type(val) >= MRB_TT_OBJECT) mrb_gc_mark((mrb), mrb_basic_ptr(val));\
} while (0)
void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*);
#define mrb_field_write_barrier_value(mrb, obj, val) do{\
if ((val.tt >= MRB_TT_OBJECT)) mrb_field_write_barrier((mrb), (obj), mrb_basic(val));\
if ((val.tt >= MRB_TT_OBJECT)) mrb_field_write_barrier((mrb), (obj), mrb_basic_ptr(val));\
} while (0)
void mrb_write_barrier(mrb_state *, struct RBasic*);
......
......@@ -186,7 +186,9 @@ struct RBasic {
MRB_OBJECT_HEADER;
};
#define mrb_basic(v) ((struct RBasic*)((v).value.p))
#define mrb_basic_ptr(v) ((struct RBasic*)((v).value.p))
/* obsolete macro mrb_basic; will be removed soon */
#define mrb_basic(v) mrb_basic_ptr(v)
struct RObject {
MRB_OBJECT_HEADER;
......
......@@ -921,7 +921,7 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
default:
break;
}
obj = mrb_basic(v);
obj = mrb_basic_ptr(v);
prepare_singleton_class(mrb, obj);
return mrb_obj_value(obj->c);
}
......
......@@ -322,7 +322,7 @@ void
mrb_gc_protect(mrb_state *mrb, mrb_value obj)
{
if (mrb_special_const_p(obj)) return;
gc_protect(mrb, mrb_basic(obj));
gc_protect(mrb, mrb_basic_ptr(obj));
}
struct RBasic*
......@@ -1168,8 +1168,8 @@ test_mrb_field_write_barrier(void)
puts("test_mrb_field_write_barrier");
mrb->is_generational_gc_mode = FALSE;
obj = mrb_basic(mrb_ary_new(mrb));
value = mrb_basic(mrb_str_new_cstr(mrb, "value"));
obj = mrb_basic_ptr(mrb_ary_new(mrb));
value = mrb_basic_ptr(mrb_str_new_cstr(mrb, "value"));
paint_black(obj);
paint_partial_white(mrb,value);
......@@ -1210,15 +1210,15 @@ test_mrb_field_write_barrier(void)
{
puts("test_mrb_field_write_barrier_value");
obj = mrb_basic(mrb_ary_new(mrb));
obj = mrb_basic_ptr(mrb_ary_new(mrb));
mrb_value value = mrb_str_new_cstr(mrb, "value");
paint_black(obj);
paint_partial_white(mrb, mrb_basic(value));
paint_partial_white(mrb, mrb_basic_ptr(value));
mrb->gc_state = GC_STATE_MARK;
mrb_field_write_barrier_value(mrb, obj, value);
gc_assert(is_gray(mrb_basic(value)));
gc_assert(is_gray(mrb_basic_ptr(value)));
}
mrb_close(mrb);
......@@ -1231,7 +1231,7 @@ test_mrb_write_barrier(void)
struct RBasic *obj;
puts("test_mrb_write_barrier");
obj = mrb_basic(mrb_ary_new(mrb));
obj = mrb_basic_ptr(mrb_ary_new(mrb));
paint_black(obj);
puts(" in GC_STATE_MARK");
......@@ -1260,12 +1260,12 @@ test_add_gray_list(void)
puts("test_add_gray_list");
change_gen_gc_mode(mrb, FALSE);
gc_assert(mrb->gray_list == NULL);
obj1 = mrb_basic(mrb_str_new_cstr(mrb, "test"));
obj1 = mrb_basic_ptr(mrb_str_new_cstr(mrb, "test"));
add_gray_list(mrb, obj1);
gc_assert(mrb->gray_list == obj1);
gc_assert(is_gray(obj1));
obj2 = mrb_basic(mrb_str_new_cstr(mrb, "test"));
obj2 = mrb_basic_ptr(mrb_str_new_cstr(mrb, "test"));
add_gray_list(mrb, obj2);
gc_assert(mrb->gray_list == obj2);
gc_assert(mrb->gray_list->gcnext == obj1);
......@@ -1294,12 +1294,12 @@ test_gc_gray_mark(void)
puts(" in MRB_TT_ARRAY");
obj_v = mrb_ary_new(mrb);
value_v = mrb_str_new_cstr(mrb, "test");
paint_gray(mrb_basic(obj_v));
paint_partial_white(mrb, mrb_basic(value_v));
paint_gray(mrb_basic_ptr(obj_v));
paint_partial_white(mrb, mrb_basic_ptr(value_v));
mrb_ary_push(mrb, obj_v, value_v);
gray_num = gc_gray_mark(mrb, mrb_basic(obj_v));
gc_assert(is_black(mrb_basic(obj_v)));
gc_assert(is_gray(mrb_basic(value_v)));
gray_num = gc_gray_mark(mrb, mrb_basic_ptr(obj_v));
gc_assert(is_black(mrb_basic_ptr(obj_v)));
gc_assert(is_gray(mrb_basic_ptr(value_v)));
gc_assert(gray_num == 1);
mrb_close(mrb);
......
......@@ -263,7 +263,7 @@ mrb_obj_class_m(mrb_state *mrb, mrb_value self)
struct RClass*
mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
{
struct RClass *klass = mrb_basic(obj)->c;
struct RClass *klass = mrb_basic_ptr(obj)->c;
if (klass->tt != MRB_TT_SCLASS)
return klass;
......
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