summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-06-14 01:00:34 +0900
committerYukihiro Matsumoto <[email protected]>2012-06-14 01:00:34 +0900
commit90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e (patch)
treeab2810a7644a686045eadc34c157666ea19a8506 /src
parentb4be82ccc1941df0a4dcbc0f0b9922798cf0cac4 (diff)
downloadmruby-90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e.tar.gz
mruby-90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e.zip
mrb_define_{singleton,class}_method should prepare singleton class for the obejct
Diffstat (limited to 'src')
-rw-r--r--src/class.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/class.c b/src/class.c
index ee6cf78f4..9d89aef61 100644
--- a/src/class.c
+++ b/src/class.c
@@ -708,15 +708,16 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
}
void
-mrb_define_class_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, int aspec)
+mrb_define_singleton_method(mrb_state *mrb, struct RObject *o, const char *name, mrb_func_t func, int aspec)
{
- mrb_define_method_id(mrb, c->c, mrb_intern(mrb, name), func, aspec);
+ o->c = mrb_singleton_class_ptr(mrb, o->c);
+ mrb_define_method_id(mrb, o->c, mrb_intern(mrb, name), func, aspec);
}
void
-mrb_define_singleton_method(mrb_state *mrb, struct RObject *o, const char *name, mrb_func_t func, int aspec)
+mrb_define_class_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, int aspec)
{
- mrb_define_method_id(mrb, mrb_singleton_class_ptr(mrb, o->c), mrb_intern(mrb, name), func, aspec);
+ mrb_define_singleton_method(mrb, (struct RObject*)c, name, func, aspec);
}
void