obsolete mrb_object; opposite of bc870ce

parent c5db1397
......@@ -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_object(val));\
if (mrb_type(val) >= MRB_TT_OBJECT) mrb_gc_mark((mrb), mrb_basic(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_object(val));\
if ((val.tt >= MRB_TT_OBJECT)) mrb_field_write_barrier((mrb), (obj), mrb_basic(val));\
} while (0)
void mrb_write_barrier(mrb_state *, struct RBasic*);
......
......@@ -42,7 +42,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
case MRB_TT_MAIN:
return mrb->object_class;
default:
return mrb_object(v)->c;
return mrb_obj_ptr(v)->c;
}
}
......
......@@ -144,7 +144,6 @@ mrb_float_value(mrb_float f)
#define mrb_fixnum(o) (o).value.i
#define mrb_symbol(o) (o).value.sym
#define mrb_object(o) ((struct RBasic *) (o).value.p)
#define mrb_voidp(o) (o).value.p
#define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
......@@ -195,6 +194,8 @@ struct RObject {
};
#define mrb_obj_ptr(v) ((struct RObject*)((v).value.p))
/* obsolete macro mrb_object; will be removed soon */
#define mrb_object(o) mrb_obj_ptr(o)
#define mrb_immediate_p(x) (mrb_type(x) <= MRB_TT_MAIN)
#define mrb_special_const_p(x) mrb_immediate_p(x)
......
......@@ -921,7 +921,7 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
default:
break;
}
obj = mrb_object(v);
obj = mrb_basic(v);
prepare_singleton_class(mrb, obj);
return mrb_obj_value(obj->c);
}
......
......@@ -206,7 +206,7 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
void
mrb_exc_raise(mrb_state *mrb, mrb_value exc)
{
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
exc_debug_info(mrb, mrb->exc);
if (!mrb->jmp) {
mrb_p(mrb, exc);
......
......@@ -52,10 +52,14 @@ mrb_gc_mark_ht(mrb_state *mrb, struct RHash *hash)
khash_t(ht) *h = hash->ht;
if (!h) return;
for (k = kh_begin(h); k != kh_end(h); k++)
for (k = kh_begin(h); k != kh_end(h); k++) {
if (kh_exist(h, k)) {
mrb_gc_mark_value(mrb, kh_key(h, k));
mrb_gc_mark_value(mrb, kh_value(h, k));
mrb_value key = kh_key(h, k);
mrb_value val = kh_value(h, k);
mrb_gc_mark_value(mrb, key);
mrb_gc_mark_value(mrb, val);
}
}
}
......
......@@ -683,7 +683,7 @@ static void
irep_error(mrb_state *mrb, int n)
{
static const char msg[] = "irep load error";
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
}
#ifdef ENABLE_STDIO
......
......@@ -5157,13 +5157,13 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
n = snprintf(buf, sizeof(buf), "line %d: %s\n",
p->error_buffer[0].lineno, p->error_buffer[0].message);
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
mrb_parser_free(p);
return mrb_undef_value();
}
else {
static const char msg[] = "syntax error";
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SYNTAX_ERROR, msg, sizeof(msg) - 1));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, msg, sizeof(msg) - 1));
mrb_parser_free(p);
return mrb_undef_value();
}
......@@ -5172,7 +5172,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
mrb_parser_free(p);
if (n < 0) {
static const char msg[] = "codegen error";
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
return mrb_nil_value();
}
if (c) {
......
......@@ -478,7 +478,7 @@ localjump_error(mrb_state *mrb, localjump_error_kind kind)
mrb_str_buf_cat(mrb, msg, lead, sizeof(lead) - 1);
mrb_str_buf_cat(mrb, msg, kind_str[kind], kind_str_len[kind]);
exc = mrb_exc_new3(mrb, E_LOCALJUMP_ERROR, msg);
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
}
static void
......@@ -498,7 +498,7 @@ argnum_error(mrb_state *mrb, int num)
mrb->ci->argc, num);
}
exc = mrb_exc_new(mrb, E_ARGUMENT_ERROR, buf, len);
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
}
#ifdef ENABLE_DEBUG
......@@ -780,7 +780,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
CASE(OP_RAISE) {
/* A raise(R(A)) */
mrb->exc = (struct RObject*)mrb_object(regs[GETARG_A(i)]);
mrb->exc = mrb_obj_ptr(regs[GETARG_A(i)]);
goto L_RAISE;
}
......@@ -1062,7 +1062,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
mrb_value exc;
static const char m[] = "super called outside of method";
exc = mrb_exc_new(mrb, E_NOMETHOD_ERROR, m, sizeof(m) - 1);
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
goto L_RAISE;
}
stack = e->stack + 1;
......@@ -1911,7 +1911,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if (!mrb->ci->target_class) {
static const char msg[] = "no target class or module";
mrb_value exc = mrb_exc_new(mrb, E_TYPE_ERROR, msg, sizeof(msg) - 1);
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
goto L_RAISE;
}
regs[GETARG_A(i)] = mrb_obj_value(mrb->ci->target_class);
......@@ -1964,7 +1964,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
else {
exc = mrb_exc_new3(mrb, E_LOCALJUMP_ERROR, msg);
}
mrb->exc = (struct RObject*)mrb_object(exc);
mrb->exc = mrb_obj_ptr(exc);
goto L_RAISE;
}
}
......
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