mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Use RString in mesg instead.
This commit is contained in:
@@ -14,11 +14,11 @@ extern "C" {
|
||||
struct RException {
|
||||
MRB_OBJECT_HEADER;
|
||||
struct iv_tbl *iv;
|
||||
mrb_value mesg;
|
||||
struct RString *mesg;
|
||||
};
|
||||
|
||||
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
|
||||
#define MRB_EXC_MESG_INIT_FLAG 0x100
|
||||
#define MRB_EXC_MESG_STRING_FLAG 0x100
|
||||
|
||||
void mrb_sys_fail(mrb_state *mrb, const char *mesg);
|
||||
mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
|
||||
|
||||
+11
-4
@@ -21,15 +21,22 @@
|
||||
static void
|
||||
exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg)
|
||||
{
|
||||
exc->flags |= MRB_EXC_MESG_INIT_FLAG;
|
||||
exc->mesg = mesg;
|
||||
mrb_field_write_barrier_value(mrb, (struct RBasic*)exc, mesg);
|
||||
if (mrb_string_p(mesg)) {
|
||||
exc->flags |= MRB_EXC_MESG_STRING_FLAG;
|
||||
exc->mesg = RSTRING(mesg);
|
||||
mrb_field_write_barrier_value(mrb, (struct RBasic*)exc, mesg);
|
||||
}
|
||||
else if (!mrb_nil_p(mesg)) {
|
||||
exc->flags &= ~MRB_EXC_MESG_STRING_FLAG;
|
||||
mrb_obj_iv_set(mrb, (struct RObject*)exc, mrb_intern_lit(mrb, "mesg"), mesg);
|
||||
}
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
exc_mesg_get(mrb_state *mrb, struct RException *exc)
|
||||
{
|
||||
return (exc->flags & MRB_EXC_MESG_INIT_FLAG) != 0 ? exc->mesg : mrb_nil_value();
|
||||
return (exc->flags & MRB_EXC_MESG_STRING_FLAG) != 0
|
||||
? mrb_obj_value(exc->mesg) : mrb_obj_iv_get(mrb, (struct RObject*)exc, mrb_intern_lit(mrb, "mesg"));
|
||||
}
|
||||
|
||||
mrb_value
|
||||
|
||||
@@ -582,8 +582,8 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
|
||||
|
||||
case MRB_TT_EXCEPTION:
|
||||
mrb_gc_mark_iv(mrb, (struct RObject*)obj);
|
||||
if ((obj->flags & MRB_EXC_MESG_INIT_FLAG) != 0) {
|
||||
mrb_gc_mark_value(mrb, ((struct RException*)obj)->mesg);
|
||||
if ((obj->flags & MRB_EXC_MESG_STRING_FLAG) != 0) {
|
||||
mrb_gc_mark(mrb, (struct RBasic*)((struct RException*)obj)->mesg);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -808,7 +808,7 @@ gc_gray_mark(mrb_state *mrb, struct RBasic *obj)
|
||||
|
||||
case MRB_TT_EXCEPTION:
|
||||
children += mrb_gc_mark_iv_size(mrb, (struct RObject*)obj);
|
||||
if ((obj->flags & MRB_EXC_MESG_INIT_FLAG) != 0) {
|
||||
if ((obj->flags & MRB_EXC_MESG_STRING_FLAG) != 0) {
|
||||
children++;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user