obsolete mrb_object; opposite of bc870ce

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