Commit 0cae5eaf authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2791 from cremno/remove-mrb_define_method_vm

remove mrb_define_method_vm() function
parents 579ba2d9 2106d4d4
......@@ -55,7 +55,6 @@ MRB_API struct RClass* mrb_define_class_id(mrb_state*, mrb_sym, struct RClass*);
MRB_API struct RClass* mrb_define_module_id(mrb_state*, mrb_sym);
MRB_API struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
MRB_API struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_define_method_vm(mrb_state*, struct RClass*, mrb_sym, mrb_value);
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, struct RProc *);
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
MRB_API void mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
......
......@@ -347,22 +347,6 @@ mrb_define_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t
mrb_define_method_id(mrb, c, mrb_intern_cstr(mrb, name), func, aspec);
}
MRB_API void
mrb_define_method_vm(mrb_state *mrb, struct RClass *c, mrb_sym name, mrb_value body)
{
khash_t(mt) *h = c->mt;
khiter_t k;
struct RProc *p;
if (!h) h = c->mt = kh_init(mt, mrb);
k = kh_put(mt, mrb, h, name);
p = mrb_proc_ptr(body);
kh_value(h, k) = p;
if (p) {
mrb_field_write_barrier(mrb, (struct RBasic *)c, (struct RBasic *)p);
}
}
/* a function to raise NotImplementedError with current method name */
MRB_API void
mrb_notimplement(mrb_state *mrb)
......@@ -1516,7 +1500,7 @@ mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b)
{
struct RProc *m = mrb_method_search(mrb, c, b);
mrb_define_method_vm(mrb, c, a, mrb_obj_value(m));
mrb_define_method_raw(mrb, c, a, m);
}
/*!
......@@ -1608,14 +1592,11 @@ mrb_mod_alias(mrb_state *mrb, mrb_value mod)
static void
undef_method(mrb_state *mrb, struct RClass *c, mrb_sym a)
{
mrb_value m;
if (!mrb_obj_respond_to(mrb, c, a)) {
mrb_name_error(mrb, a, "undefined method '%S' for class '%S'", mrb_sym2str(mrb, a), mrb_obj_value(c));
}
else {
SET_PROC_VALUE(m, 0);
mrb_define_method_vm(mrb, c, a, m);
mrb_define_method_raw(mrb, c, a, NULL);
}
}
......
......@@ -2303,8 +2303,9 @@ RETRY_TRY_BLOCK:
/* A B R(A).newmethod(Syms(B),R(A+1)) */
int a = GETARG_A(i);
struct RClass *c = mrb_class_ptr(regs[a]);
struct RProc *p = mrb_proc_ptr(regs[a+1]);
mrb_define_method_vm(mrb, c, syms[GETARG_B(i)], regs[a+1]);
mrb_define_method_raw(mrb, c, syms[GETARG_B(i)], p);
ARENA_RESTORE(mrb, ai);
NEXT;
}
......
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