mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_f_callee_name): add __method__ and __callee__ again.
__callee__ need to rework to adopt YARV. [ruby-core:10671] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4503c8daeb
commit
edec8b39f9
2 changed files with 59 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Mar 20 16:20:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_f_callee_name): add __method__ and __callee__ again.
|
||||
__callee__ need to rework to adopt YARV. [ruby-core:10671]
|
||||
|
||||
Tue Mar 20 11:09:00 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/set.rb: Revise rdoc.
|
||||
|
|
54
eval.c
54
eval.c
|
@ -2828,6 +2828,57 @@ rb_f_local_variables(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* __method__ => string
|
||||
*
|
||||
* Returns the name of the current method as a Symbol.
|
||||
* If called from inside of an aliased method it will return the original
|
||||
* nonaliased name.
|
||||
* If called outside of a method, it returns <code>nil</code>.
|
||||
* See also <code>\_\_callee__</code>.
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
rb_f_method_name(void)
|
||||
{
|
||||
ID fname = rb_frame_callee();
|
||||
|
||||
if (fname) {
|
||||
return ID2SYM(fname);
|
||||
}
|
||||
else {
|
||||
return Qnil;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* __callee__ => string
|
||||
*
|
||||
* Returns the name of the current method as Symbol.
|
||||
* If called from inside of an aliased method it will return the aliased
|
||||
* name.
|
||||
* If called outside of a method, it returns <code>nil</code>.
|
||||
* See also <code>\_\_method__</code>.
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
rb_f_callee_name(void)
|
||||
{
|
||||
/* xxx need to get callee name */
|
||||
ID callee = rb_frame_callee();
|
||||
|
||||
if (callee) {
|
||||
return ID2SYM(callee);
|
||||
}
|
||||
else {
|
||||
return Qnil;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Init_eval(void)
|
||||
{
|
||||
|
@ -2877,6 +2928,9 @@ Init_eval(void)
|
|||
rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
|
||||
rb_define_global_function("local_variables", rb_f_local_variables, 0);
|
||||
|
||||
rb_define_global_function("__method__", rb_f_method_name, 0);
|
||||
rb_define_global_function("__callee__", rb_f_callee_name, 0);
|
||||
|
||||
rb_define_method(rb_cBasicObject, "send", rb_f_send, -1);
|
||||
rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
|
||||
rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1);
|
||||
|
|
Loading…
Reference in a new issue