diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-09 13:46:56 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-09 13:46:56 +0000 |
| commit | 3546f02b7769beef32e66287806a0f7848d6154d (patch) | |
| tree | 87fa2311117867ec3c701905def4047db1934737 | |
| parent | d2d48dff00ce8a2d9cacdcffed1c3cb1c38fd6e2 (diff) | |
| download | ruby-3546f02b7769beef32e66287806a0f7848d6154d.tar.gz ruby-3546f02b7769beef32e66287806a0f7848d6154d.tar.xz ruby-3546f02b7769beef32e66287806a0f7848d6154d.zip | |
* eval.c (rb_obj_define_method): add new method
Kernel#define_singleton_method. [ruby-list:42851]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | eval.c | 10 |
2 files changed, 15 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (rb_obj_define_method): add new method + Kernel#define_singleton_method. [ruby-list:42851] + Sat Oct 7 23:53:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org> * string.c (rb_str_scan): small documentation fix. @@ -234,6 +234,7 @@ VALUE rb_cMethod; VALUE rb_cUnboundMethod; static VALUE umethod_bind(VALUE, VALUE); static VALUE rb_mod_define_method(int, VALUE*, VALUE); +static VALUE rb_obj_define_method(int, VALUE*, VALUE); NORETURN(static void rb_raise_jump(VALUE)); static VALUE rb_make_exception(int argc, VALUE *argv); @@ -7910,6 +7911,7 @@ Init_eval(void) rb_define_method(rb_cBasicObject, "__send!", rb_f_funcall, -1); rb_define_method(rb_mKernel, "instance_eval", rb_obj_instance_eval, -1); rb_define_method(rb_mKernel, "instance_exec", rb_obj_instance_exec, -1); + rb_define_method(rb_mKernel, "define_singleton_method", rb_obj_define_method, -1); rb_define_private_method(rb_cModule, "append_features", rb_mod_append_features, 1); rb_define_private_method(rb_cModule, "extend_object", rb_mod_extend_object, 1); @@ -9567,6 +9569,14 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) return body; } +static VALUE +rb_obj_define_method(int argc, VALUE *argv, VALUE obj) +{ + VALUE klass = rb_singleton_class(obj); + + return rb_mod_define_method(argc, argv, klass); +} + /* * <code>Proc</code> objects are blocks of code that have been bound to * a set of local variables. Once bound, the code may be called in |
