* eval.c (rb_f_send_bang): abandon the name funcall for private

aware method call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-08-24 08:15:37 +00:00
Родитель ac150ad226
Коммит 99ab1fed49
8 изменённых файлов: 35 добавлений и 30 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Fri Aug 24 17:06:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_send_bang): abandon the name funcall for private
aware method call.
Thu Aug 23 20:31:31 2007 Koichi Sasada <ko1@atdot.net>
* compile.c: optimize simple massign.

Просмотреть файл

@ -316,7 +316,7 @@ assert_equal '[1, 2]', %q( class C; def m(*a) a end end;
assert_equal '1', %q( class C; def m() 7 end; private :m end
begin C.new.send(:m); rescue NoMethodError; 1 end )
assert_equal '1', %q( class C; def m() 1 end; private :m end
C.new.funcall(:m) )
C.new.send!(:m) )
# with block
assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
@ -867,7 +867,7 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{
end
end
alias funcall send unless defined? funcall
alias send! send unless defined? send!
c1 = c2 = nil
@ -899,8 +899,8 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{
test{o2.mm}
test{o1.send :m}
test{o2.send :mm}
test{o1.funcall :m}
test{o2.funcall :mm}
test{o1.send! :m}
test{o2.send! :mm}
test{o1.method(:m).call}
test{o2.method(:mm).call}
$ans

22
eval.c
Просмотреть файл

@ -1437,7 +1437,7 @@ rb_apply(VALUE recv, ID mid, VALUE args)
}
static VALUE
send_funcall(int argc, VALUE *argv, VALUE recv, int scope)
send_internal(int argc, VALUE *argv, VALUE recv, int scope)
{
VALUE vid;
@ -1479,26 +1479,26 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
scope = NOEX_NOSUPER | NOEX_PRIVATE;
}
return send_funcall(argc, argv, recv, scope);
return send_internal(argc, argv, recv, scope);
}
/*
* call-seq:
* obj.funcall(symbol [, args...]) => obj
* obj.__send!(symbol [, args...]) => obj
* obj.send!(symbol [, args...]) => obj
* obj.__send!(symbol [, args...]) => obj
*
* Invokes the method identified by _symbol_, passing it any
* arguments specified. Unlike send, which calls private methods only
* when it is invoked in function call style, funcall always aware of
* arguments specified. Unlike send, which calls public methods only
* when it is invoked in function call style, send! always aware of
* private methods.
*
* 1.funcall(:puts, "hello") # prints "foo"
* 1.send!(:puts, "hello") # prints "foo"
*/
VALUE
rb_f_funcall(int argc, VALUE *argv, VALUE recv)
rb_f_send_bang(int argc, VALUE *argv, VALUE recv)
{
return send_funcall(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
}
VALUE
@ -2730,8 +2730,8 @@ Init_eval(void)
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);
rb_define_method(rb_cBasicObject, "funcall", rb_f_funcall, -1);
rb_define_method(rb_cBasicObject, "__send!", rb_f_funcall, -1);
rb_define_method(rb_cBasicObject, "send!", rb_f_send_bang, -1);
rb_define_method(rb_cBasicObject, "__send!", rb_f_send_bang, -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);

Просмотреть файл

@ -580,10 +580,10 @@ vm_send_optimize(rb_control_frame_t *reg_cfp,
{
if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) {
NODE *node = (*mn)->nd_body;
extern VALUE rb_f_funcall(int argc, VALUE *argv, VALUE recv);
extern VALUE rb_f_send_bang(int argc, VALUE *argv, VALUE recv);
extern VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
if (node->nd_cfnc == rb_f_funcall || node->nd_cfnc == rb_f_send) {
if (node->nd_cfnc == rb_f_send_bang || node->nd_cfnc == rb_f_send) {
int i = *num - 1;
VALUE sym = TOPN(i);
*id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
@ -598,7 +598,7 @@ vm_send_optimize(rb_control_frame_t *reg_cfp,
DEC_SP(1);
}
if (node->nd_cfnc == rb_f_funcall) {
if (node->nd_cfnc == rb_f_send_bang) {
*flag |= VM_CALL_FCALL_BIT;
}
}

Просмотреть файл

@ -115,7 +115,7 @@
# implementation, see SimpleDelegator.
#
class Delegator
preserved = [:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :funcall]
preserved = [:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!]
instance_methods.each do |m|
next if preserved.include?(m)
undef_method m
@ -262,7 +262,7 @@ def DelegateClass(superclass)
klass = Class.new
methods = superclass.public_instance_methods(true)
methods -= [
:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :funcall,
:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!,
:==, :equal?, :initialize, :method_missing, :__getobj__, :__setobj__,
:clone, :dup, :marshal_dump, :marshal_load,
]

Просмотреть файл

@ -246,7 +246,7 @@ class Matrix
# use to general users.
#
def initialize(init_method, *argv)
self.funcall(init_method, *argv)
self.send!(init_method, *argv)
end
def init_rows(rows, copy)

Просмотреть файл

@ -91,13 +91,13 @@ module MonitorMixin
if timeout
raise NotImplementedError, "timeout is not implemented yet"
end
@monitor.funcall(:mon_check_owner)
count = @monitor.funcall(:mon_exit_for_cond)
@monitor.send!(:mon_check_owner)
count = @monitor.send!(:mon_exit_for_cond)
begin
@cond.wait(@monitor.instance_variable_get("@mon_mutex"))
return true
ensure
@monitor.funcall(:mon_enter_for_cond, count)
@monitor.send!(:mon_enter_for_cond, count)
end
end
@ -114,12 +114,12 @@ module MonitorMixin
end
def signal
@monitor.funcall(:mon_check_owner)
@monitor.send!(:mon_check_owner)
@cond.signal
end
def broadcast
@monitor.funcall(:mon_check_owner)
@monitor.send!(:mon_check_owner)
@cond.broadcast
end
@ -137,7 +137,7 @@ module MonitorMixin
def self.extend_object(obj)
super(obj)
obj.funcall(:mon_initialize)
obj.send!(:mon_initialize)
end
#

Просмотреть файл

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-08-23"
#define RUBY_RELEASE_DATE "2007-08-24"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070823
#define RUBY_RELEASE_CODE 20070824
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 8
#define RUBY_RELEASE_DAY 23
#define RUBY_RELEASE_DAY 24
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];