diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-14 01:00:34 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-14 01:00:34 +0900 |
| commit | 90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e (patch) | |
| tree | ab2810a7644a686045eadc34c157666ea19a8506 /src/class.c | |
| parent | b4be82ccc1941df0a4dcbc0f0b9922798cf0cac4 (diff) | |
| download | mruby-90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e.tar.gz mruby-90735a242fc67fdaffd9ccaef3c7e2ccbbbf1b1e.zip | |
mrb_define_{singleton,class}_method should prepare singleton class for the obejct
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 9 |
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 |
