mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_f_send): allow send/__send__ to call methods of all
visibility again. we no longer provide __send, __send!. * eval.c (rb_invoke_method): new method to honor private visibility. if it's invoked in a function call style, it calls private methods as well (previous 1.9 send behavior). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ed823523e3
commit
1eee78b876
28 changed files with 92 additions and 101 deletions
ChangeLog
bootstraptest
compile.ceval.ceval_method.ciid.cinsnhelper.cilib
test
pathname
rss
ruby
socket
yarvtest
|
@ -17,6 +17,15 @@ Mon Nov 5 01:02:56 2007 Minero Aoki <aamine@loveruby.net>
|
||||||
User-Agent to fix 500 error on some corrupted HTTP servers.
|
User-Agent to fix 500 error on some corrupted HTTP servers.
|
||||||
[ruby-core:13135]
|
[ruby-core:13135]
|
||||||
|
|
||||||
|
Mon Nov 5 00:32:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_f_send): allow send/__send__ to call methods of all
|
||||||
|
visibility again. we no longer provide __send, __send!.
|
||||||
|
|
||||||
|
* eval.c (rb_invoke_method): new method to honor private
|
||||||
|
visibility. if it's invoked in a function call style, it calls
|
||||||
|
private methods as well (previous 1.9 send behavior).
|
||||||
|
|
||||||
Mon Nov 5 00:24:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Mon Nov 5 00:24:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32/Makefile.sub: vendor_ruby support.
|
* win32/Makefile.sub: vendor_ruby support.
|
||||||
|
|
|
@ -89,12 +89,12 @@ assert_equal %q{1}, %q{
|
||||||
eval('a')
|
eval('a')
|
||||||
}
|
}
|
||||||
assert_equal %q{ok}, %q{
|
assert_equal %q{ok}, %q{
|
||||||
__send! :eval, %{
|
__send__ :eval, %{
|
||||||
:ok
|
:ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert_equal %q{ok}, %q{
|
assert_equal %q{ok}, %q{
|
||||||
1.__send! :instance_eval, %{
|
1.__send__ :instance_eval, %{
|
||||||
:ok
|
:ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,9 +314,9 @@ assert_equal '1', %q( class C; def m(x,a=7) a end end;
|
||||||
assert_equal '[1, 2]', %q( class C; def m(*a) a end end;
|
assert_equal '[1, 2]', %q( class C; def m(*a) a end end;
|
||||||
C.new.send(:m,1,2).inspect )
|
C.new.send(:m,1,2).inspect )
|
||||||
assert_equal '1', %q( class C; def m() 7 end; private :m end
|
assert_equal '1', %q( class C; def m() 7 end; private :m end
|
||||||
begin C.new.send(:m); rescue NoMethodError; 1 end )
|
begin C.new.invoke_method(:m); rescue NoMethodError; 1 end )
|
||||||
assert_equal '1', %q( class C; def m() 1 end; private :m end
|
assert_equal '1', %q( class C; def m() 1 end; private :m end
|
||||||
C.new.send!(:m) )
|
C.new.send(:m) )
|
||||||
|
|
||||||
# with block
|
# with block
|
||||||
assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
|
assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
|
||||||
|
@ -867,8 +867,6 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias send! send unless defined? send!
|
|
||||||
|
|
||||||
c1 = c2 = nil
|
c1 = c2 = nil
|
||||||
|
|
||||||
lambda{
|
lambda{
|
||||||
|
@ -899,8 +897,8 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{
|
||||||
test{o2.mm}
|
test{o2.mm}
|
||||||
test{o1.send :m}
|
test{o1.send :m}
|
||||||
test{o2.send :mm}
|
test{o2.send :mm}
|
||||||
test{o1.send! :m}
|
test{o1.invoke_method :m}
|
||||||
test{o2.send! :mm}
|
test{o2.invoke_method :mm}
|
||||||
test{o1.method(:m).call}
|
test{o1.method(:m).call}
|
||||||
test{o2.method(:mm).call}
|
test{o2.method(:mm).call}
|
||||||
$ans
|
$ans
|
||||||
|
|
|
@ -1483,11 +1483,11 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mid == idSend || mid == id__send ||
|
if (mid == idSend || mid == id__send ||
|
||||||
mid == idSendBang || mid == id__send_bang ||
|
mid == idSendBang ||
|
||||||
mid == id__send__ ) {
|
mid == id__send__ ) {
|
||||||
OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BIT);
|
OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BIT);
|
||||||
}
|
}
|
||||||
if (mid == idSendBang || mid == id__send_bang) {
|
if (mid == idSendBang) {
|
||||||
OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BANG_BIT);
|
OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BANG_BIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
48
eval.c
48
eval.c
|
@ -25,7 +25,7 @@ static VALUE rb_frame_self(void);
|
||||||
static ID removed, singleton_removed, undefined, singleton_undefined;
|
static ID removed, singleton_removed, undefined, singleton_undefined;
|
||||||
static ID init, eqq, each, aref, aset, match, missing;
|
static ID init, eqq, each, aref, aset, match, missing;
|
||||||
static ID added, singleton_added;
|
static ID added, singleton_added;
|
||||||
static ID object_id, __send, __send_bang, respond_to;
|
static ID object_id, __send__, respond_to;
|
||||||
|
|
||||||
VALUE rb_eLocalJumpError;
|
VALUE rb_eLocalJumpError;
|
||||||
VALUE rb_eSysStackError;
|
VALUE rb_eSysStackError;
|
||||||
|
@ -1471,7 +1471,7 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.send(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
|
* Invokes the method identified by _symbol_, passing it any
|
||||||
* arguments specified. You can use <code>__send__</code> if the name
|
* arguments specified. You can use <code>__send__</code> if the name
|
||||||
|
@ -1488,6 +1488,24 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope)
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_f_send(int argc, VALUE *argv, VALUE recv)
|
rb_f_send(int argc, VALUE *argv, VALUE recv)
|
||||||
|
{
|
||||||
|
return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* obj.invoke_method(symbol [, args...]) => obj
|
||||||
|
*
|
||||||
|
* Invokes the method identified by _symbol_, passing it any
|
||||||
|
* 1arguments specified. Unlike send, invoke_method calls public
|
||||||
|
* methods only, unless it's invoked in a function call style.
|
||||||
|
*
|
||||||
|
* 1.invoke_method(:puts, "hello") # causes NoMethodError
|
||||||
|
*/
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_invoke_method(int argc, VALUE *argv, VALUE recv)
|
||||||
{
|
{
|
||||||
int scope = NOEX_PUBLIC;
|
int scope = NOEX_PUBLIC;
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
@ -1500,25 +1518,6 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
|
||||||
return send_internal(argc, argv, recv, scope);
|
return send_internal(argc, argv, recv, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* 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 public methods only
|
|
||||||
* when it is invoked in function call style, send! always aware of
|
|
||||||
* private methods.
|
|
||||||
*
|
|
||||||
* 1.send!(:puts, "hello") # prints "foo"
|
|
||||||
*/
|
|
||||||
|
|
||||||
VALUE
|
|
||||||
rb_f_send_bang(int argc, VALUE *argv, VALUE recv)
|
|
||||||
{
|
|
||||||
return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_funcall(VALUE recv, ID mid, int n, ...)
|
rb_funcall(VALUE recv, ID mid, int n, ...)
|
||||||
{
|
{
|
||||||
|
@ -2718,8 +2717,7 @@ Init_eval(void)
|
||||||
singleton_undefined = rb_intern("singleton_method_undefined");
|
singleton_undefined = rb_intern("singleton_method_undefined");
|
||||||
|
|
||||||
object_id = rb_intern("object_id");
|
object_id = rb_intern("object_id");
|
||||||
__send = rb_intern("__send");
|
__send__ = rb_intern("__send__");
|
||||||
__send_bang = rb_intern("__send!");
|
|
||||||
|
|
||||||
rb_define_virtual_variable("$@", errat_getter, errat_setter);
|
rb_define_virtual_variable("$@", errat_getter, errat_setter);
|
||||||
rb_define_virtual_variable("$!", errinfo_getter, 0);
|
rb_define_virtual_variable("$!", errinfo_getter, 0);
|
||||||
|
@ -2748,9 +2746,7 @@ 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, "__send__", rb_f_send, -1);
|
||||||
rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1);
|
rb_define_method(rb_mKernel, "invoke_method", rb_invoke_method, -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_eval", rb_obj_instance_eval, -1);
|
||||||
rb_define_method(rb_mKernel, "instance_exec", rb_obj_instance_exec, -1);
|
rb_define_method(rb_mKernel, "instance_exec", rb_obj_instance_exec, -1);
|
||||||
|
|
|
@ -158,7 +158,7 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mid == object_id || mid == __send || mid == __send_bang) {
|
if (mid == object_id || mid == __send__) {
|
||||||
if (node && nd_type(node) == RUBY_VM_METHOD_NODE) {
|
if (node && nd_type(node) == RUBY_VM_METHOD_NODE) {
|
||||||
rb_warn("redefining `%s' may cause serious problem",
|
rb_warn("redefining `%s' may cause serious problem",
|
||||||
rb_id2name(mid));
|
rb_id2name(mid));
|
||||||
|
@ -302,7 +302,7 @@ remove_method(VALUE klass, ID mid)
|
||||||
}
|
}
|
||||||
if (OBJ_FROZEN(klass))
|
if (OBJ_FROZEN(klass))
|
||||||
rb_error_frozen("class/module");
|
rb_error_frozen("class/module");
|
||||||
if (mid == object_id || mid == __send || mid == __send_bang || mid == init) {
|
if (mid == object_id || mid == __send__ || mid == init) {
|
||||||
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
|
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
|
||||||
}
|
}
|
||||||
if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) {
|
if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) {
|
||||||
|
@ -466,7 +466,7 @@ rb_undef(VALUE klass, ID id)
|
||||||
rb_id2name(id));
|
rb_id2name(id));
|
||||||
}
|
}
|
||||||
rb_frozen_class_p(klass);
|
rb_frozen_class_p(klass);
|
||||||
if (id == object_id || id == __send || id == __send_bang || id == init) {
|
if (id == object_id || id == __send__ || id == init) {
|
||||||
rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
|
rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
|
||||||
}
|
}
|
||||||
body = search_method(klass, id, &origin);
|
body = search_method(klass, id, &origin);
|
||||||
|
|
2
id.c
2
id.c
|
@ -62,7 +62,5 @@ Init_id(void)
|
||||||
|
|
||||||
idSend = rb_intern("send");
|
idSend = rb_intern("send");
|
||||||
idSendBang = rb_intern("send!");
|
idSendBang = rb_intern("send!");
|
||||||
id__send = rb_intern("__send");
|
|
||||||
id__send_bang = rb_intern("__send!");
|
|
||||||
id__send__ = rb_intern("__send__");
|
id__send__ = rb_intern("__send__");
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,10 +588,9 @@ vm_send_optimize(rb_control_frame_t *reg_cfp,
|
||||||
{
|
{
|
||||||
if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) {
|
if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) {
|
||||||
NODE *node = (*mn)->nd_body;
|
NODE *node = (*mn)->nd_body;
|
||||||
extern VALUE rb_f_send_bang(int argc, VALUE *argv, VALUE recv);
|
|
||||||
extern VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
|
extern VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
|
||||||
|
|
||||||
if (node->nd_cfnc == rb_f_send_bang || node->nd_cfnc == rb_f_send) {
|
if (node->nd_cfnc == rb_f_send) {
|
||||||
int i = *num - 1;
|
int i = *num - 1;
|
||||||
VALUE sym = TOPN(i);
|
VALUE sym = TOPN(i);
|
||||||
*id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
|
*id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
|
||||||
|
@ -604,9 +603,6 @@ vm_send_optimize(rb_control_frame_t *reg_cfp,
|
||||||
*mn = rb_method_node(klass, *id);
|
*mn = rb_method_node(klass, *id);
|
||||||
*num -= 1;
|
*num -= 1;
|
||||||
DEC_SP(1);
|
DEC_SP(1);
|
||||||
}
|
|
||||||
|
|
||||||
if (node->nd_cfnc == rb_f_send_bang) {
|
|
||||||
*flag |= VM_CALL_FCALL_BIT;
|
*flag |= VM_CALL_FCALL_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
lib/date.rb
18
lib/date.rb
|
@ -877,14 +877,14 @@ class Date
|
||||||
when :civil
|
when :civil
|
||||||
g[1].each do |e|
|
g[1].each do |e|
|
||||||
break if elem[e]
|
break if elem[e]
|
||||||
elem[e] = d.__send!(e)
|
elem[e] = d.__send__(e)
|
||||||
end
|
end
|
||||||
elem[:mon] ||= 1
|
elem[:mon] ||= 1
|
||||||
elem[:mday] ||= 1
|
elem[:mday] ||= 1
|
||||||
when :commercial
|
when :commercial
|
||||||
g[1].each do |e|
|
g[1].each do |e|
|
||||||
break if elem[e]
|
break if elem[e]
|
||||||
elem[e] = d.__send!(e)
|
elem[e] = d.__send__(e)
|
||||||
end
|
end
|
||||||
elem[:cweek] ||= 1
|
elem[:cweek] ||= 1
|
||||||
elem[:cwday] ||= 1
|
elem[:cwday] ||= 1
|
||||||
|
@ -893,14 +893,14 @@ class Date
|
||||||
when :wnum0
|
when :wnum0
|
||||||
g[1].each do |e|
|
g[1].each do |e|
|
||||||
break if elem[e]
|
break if elem[e]
|
||||||
elem[e] = d.__send!(e)
|
elem[e] = d.__send__(e)
|
||||||
end
|
end
|
||||||
elem[:wnum0] ||= 0
|
elem[:wnum0] ||= 0
|
||||||
elem[:wday] ||= 0
|
elem[:wday] ||= 0
|
||||||
when :wnum1
|
when :wnum1
|
||||||
g[1].each do |e|
|
g[1].each do |e|
|
||||||
break if elem[e]
|
break if elem[e]
|
||||||
elem[e] = d.__send!(e)
|
elem[e] = d.__send__(e)
|
||||||
end
|
end
|
||||||
elem[:wnum1] ||= 0
|
elem[:wnum1] ||= 0
|
||||||
elem[:wday] ||= 0
|
elem[:wday] ||= 0
|
||||||
|
@ -1727,16 +1727,16 @@ class Time
|
||||||
def to_time() getlocal end
|
def to_time() getlocal end
|
||||||
|
|
||||||
def to_date
|
def to_date
|
||||||
jd = Date.__send!(:civil_to_jd, year, mon, mday, Date::ITALY)
|
jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY)
|
||||||
Date.new!(Date.__send!(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
|
Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_datetime
|
def to_datetime
|
||||||
jd = DateTime.__send!(:civil_to_jd, year, mon, mday, DateTime::ITALY)
|
jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY)
|
||||||
fr = DateTime.__send!(:time_to_day_fraction, hour, min, [sec, 59].min) +
|
fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) +
|
||||||
usec.to_r/86400_000_000
|
usec.to_r/86400_000_000
|
||||||
of = utc_offset.to_r/86400
|
of = utc_offset.to_r/86400
|
||||||
DateTime.new!(DateTime.__send!(:jd_to_ajd, jd, fr, of),
|
DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
|
||||||
of, DateTime::ITALY)
|
of, DateTime::ITALY)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
# implementation, see SimpleDelegator.
|
# implementation, see SimpleDelegator.
|
||||||
#
|
#
|
||||||
class Delegator
|
class Delegator
|
||||||
preserved = [:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!]
|
preserved = [:__id__, :object_id, :__send__, :invoke_method, :respond_to?, :send]
|
||||||
instance_methods.each do |m|
|
instance_methods.each do |m|
|
||||||
next if preserved.include?(m)
|
next if preserved.include?(m)
|
||||||
undef_method m
|
undef_method m
|
||||||
|
@ -137,7 +137,7 @@ class Delegator
|
||||||
unless target.respond_to?(m)
|
unless target.respond_to?(m)
|
||||||
super(m, *args, &block)
|
super(m, *args, &block)
|
||||||
else
|
else
|
||||||
target.__send(m, *args, &block)
|
target.__send__(m, *args, &block)
|
||||||
end
|
end
|
||||||
rescue Exception
|
rescue Exception
|
||||||
$@.delete_if{|s| /^#{__FILE__}:\d+:in `method_missing'$/ =~ s} #`
|
$@.delete_if{|s| /^#{__FILE__}:\d+:in `method_missing'$/ =~ s} #`
|
||||||
|
@ -262,7 +262,7 @@ def DelegateClass(superclass)
|
||||||
klass = Class.new
|
klass = Class.new
|
||||||
methods = superclass.public_instance_methods(true)
|
methods = superclass.public_instance_methods(true)
|
||||||
methods -= [
|
methods -= [
|
||||||
:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!,
|
:__id__, :object_id, :__send__, :invoke_method, :respond_to?, :send,
|
||||||
:==, :equal?, :initialize, :method_missing, :__getobj__, :__setobj__,
|
:==, :equal?, :initialize, :method_missing, :__getobj__, :__setobj__,
|
||||||
:clone, :dup, :marshal_dump, :marshal_load,
|
:clone, :dup, :marshal_dump, :marshal_load,
|
||||||
]
|
]
|
||||||
|
@ -281,7 +281,7 @@ def DelegateClass(superclass)
|
||||||
klass.module_eval <<-EOS, __FILE__, __LINE__+1
|
klass.module_eval <<-EOS, __FILE__, __LINE__+1
|
||||||
def #{method}(*args, &block)
|
def #{method}(*args, &block)
|
||||||
begin
|
begin
|
||||||
@delegate_dc_obj.__send(:#{method}, *args, &block)
|
@delegate_dc_obj.__send__(:#{method}, *args, &block)
|
||||||
rescue
|
rescue
|
||||||
raise $!, $@[2..-1]
|
raise $!, $@[2..-1]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1553,7 +1553,7 @@ module DRb
|
||||||
end
|
end
|
||||||
ary.collect(&@obj)[0]
|
ary.collect(&@obj)[0]
|
||||||
else
|
else
|
||||||
@obj.send!(@msg_id, *@argv)
|
@obj.send(@msg_id, *@argv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ class Matrix
|
||||||
# use to general users.
|
# use to general users.
|
||||||
#
|
#
|
||||||
def initialize(init_method, *argv)
|
def initialize(init_method, *argv)
|
||||||
self.send!(init_method, *argv)
|
self.send(init_method, *argv)
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_rows(rows, copy)
|
def init_rows(rows, copy)
|
||||||
|
|
|
@ -91,13 +91,13 @@ module MonitorMixin
|
||||||
if timeout
|
if timeout
|
||||||
raise NotImplementedError, "timeout is not implemented yet"
|
raise NotImplementedError, "timeout is not implemented yet"
|
||||||
end
|
end
|
||||||
@monitor.send!(:mon_check_owner)
|
@monitor.send(:mon_check_owner)
|
||||||
count = @monitor.send!(:mon_exit_for_cond)
|
count = @monitor.send(:mon_exit_for_cond)
|
||||||
begin
|
begin
|
||||||
@cond.wait(@monitor.instance_variable_get("@mon_mutex"))
|
@cond.wait(@monitor.instance_variable_get("@mon_mutex"))
|
||||||
return true
|
return true
|
||||||
ensure
|
ensure
|
||||||
@monitor.send!(:mon_enter_for_cond, count)
|
@monitor.send(:mon_enter_for_cond, count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ module MonitorMixin
|
||||||
end
|
end
|
||||||
|
|
||||||
def signal
|
def signal
|
||||||
@monitor.send!(:mon_check_owner)
|
@monitor.send(:mon_check_owner)
|
||||||
@cond.signal
|
@cond.signal
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast
|
def broadcast
|
||||||
@monitor.send!(:mon_check_owner)
|
@monitor.send(:mon_check_owner)
|
||||||
@cond.broadcast
|
@cond.broadcast
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ module MonitorMixin
|
||||||
|
|
||||||
def self.extend_object(obj)
|
def self.extend_object(obj)
|
||||||
super(obj)
|
super(obj)
|
||||||
obj.send!(:mon_initialize)
|
obj.send(:mon_initialize)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ module Net
|
||||||
|
|
||||||
class RawData # :nodoc:
|
class RawData # :nodoc:
|
||||||
def send_data(imap)
|
def send_data(imap)
|
||||||
imap.send!(:put_string, @data)
|
imap.send(:put_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1241,7 +1241,7 @@ module Net
|
||||||
|
|
||||||
class Atom # :nodoc:
|
class Atom # :nodoc:
|
||||||
def send_data(imap)
|
def send_data(imap)
|
||||||
imap.send!(:put_string, @data)
|
imap.send(:put_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1253,7 +1253,7 @@ module Net
|
||||||
|
|
||||||
class QuotedString # :nodoc:
|
class QuotedString # :nodoc:
|
||||||
def send_data(imap)
|
def send_data(imap)
|
||||||
imap.send!(:send_quoted_string, @data)
|
imap.send(:send_quoted_string, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1265,7 +1265,7 @@ module Net
|
||||||
|
|
||||||
class Literal # :nodoc:
|
class Literal # :nodoc:
|
||||||
def send_data(imap)
|
def send_data(imap)
|
||||||
imap.send!(:send_literal, @data)
|
imap.send(:send_literal, @data)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1277,7 +1277,7 @@ module Net
|
||||||
|
|
||||||
class MessageSet # :nodoc:
|
class MessageSet # :nodoc:
|
||||||
def send_data(imap)
|
def send_data(imap)
|
||||||
imap.send!(:put_string, format_internal(@data))
|
imap.send(:put_string, format_internal(@data))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -722,7 +722,7 @@ module Net
|
||||||
def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
|
def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
|
||||||
check_auth_method authtype
|
check_auth_method authtype
|
||||||
check_auth_args user, secret
|
check_auth_args user, secret
|
||||||
send! auth_method(authtype), user, secret
|
send auth_method(authtype), user, secret
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_plain(user, secret)
|
def auth_plain(user, secret)
|
||||||
|
|
|
@ -9,12 +9,6 @@ require 'enumerator'
|
||||||
|
|
||||||
class TestPathname < Test::Unit::TestCase
|
class TestPathname < Test::Unit::TestCase
|
||||||
|
|
||||||
if RUBY_VERSION < "1.9"
|
|
||||||
FUNCALL = :__send__
|
|
||||||
else
|
|
||||||
FUNCALL = :send!
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.define_assertion(name, &block)
|
def self.define_assertion(name, &block)
|
||||||
@defassert_num ||= {}
|
@defassert_num ||= {}
|
||||||
@defassert_num[name] ||= 0
|
@defassert_num[name] ||= 0
|
||||||
|
@ -123,7 +117,7 @@ class TestPathname < Test::Unit::TestCase
|
||||||
|
|
||||||
# has_trailing_separator?(path) -> bool
|
# has_trailing_separator?(path) -> bool
|
||||||
def has_trailing_separator?(path)
|
def has_trailing_separator?(path)
|
||||||
Pathname.allocate.send(FUNCALL, :has_trailing_separator?, path)
|
Pathname.allocate.__send__(:has_trailing_separator?, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
defassert(:has_trailing_separator?, false, "/")
|
defassert(:has_trailing_separator?, false, "/")
|
||||||
|
@ -132,11 +126,11 @@ class TestPathname < Test::Unit::TestCase
|
||||||
defassert(:has_trailing_separator?, true, "a/")
|
defassert(:has_trailing_separator?, true, "a/")
|
||||||
|
|
||||||
def add_trailing_separator(path)
|
def add_trailing_separator(path)
|
||||||
Pathname.allocate.send(FUNCALL, :add_trailing_separator, path)
|
Pathname.allocate.__send__(:add_trailing_separator, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def del_trailing_separator(path)
|
def del_trailing_separator(path)
|
||||||
Pathname.allocate.send(FUNCALL, :del_trailing_separator, path)
|
Pathname.allocate.send(__send__, :del_trailing_separator, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
defassert(:del_trailing_separator, "/", "/")
|
defassert(:del_trailing_separator, "/", "/")
|
||||||
|
|
|
@ -85,7 +85,7 @@ EOR
|
||||||
excepted = make_element("#{@prefix}:#{name}", {}, value)
|
excepted = make_element("#{@prefix}:#{name}", {}, value)
|
||||||
meth = "#{RSS::CONTENT_PREFIX}_#{name}_element"
|
meth = "#{RSS::CONTENT_PREFIX}_#{name}_element"
|
||||||
[@rss10, @rss20].each do |rss|
|
[@rss10, @rss20].each do |rss|
|
||||||
assert_equal(excepted, rss.items.last.__send!(meth))
|
assert_equal(excepted, rss.items.last.__send__(meth))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ EOR
|
||||||
excepted = "<#{DC_PREFIX}:#{name}>#{value}</#{DC_PREFIX}:#{name}>"
|
excepted = "<#{DC_PREFIX}:#{name}>#{value}</#{DC_PREFIX}:#{name}>"
|
||||||
parents.each do |parent_readers|
|
parents.each do |parent_readers|
|
||||||
parent = chain_reader(feed, parent_readers)
|
parent = chain_reader(feed, parent_readers)
|
||||||
assert_equal(excepted, parent.__send!("dc_#{name}_elements"))
|
assert_equal(excepted, parent.__send__("dc_#{name}_elements"))
|
||||||
end
|
end
|
||||||
|
|
||||||
plural_suffix = dc_plural_suffix(name, check_backward_compatibility)
|
plural_suffix = dc_plural_suffix(name, check_backward_compatibility)
|
||||||
|
@ -257,7 +257,7 @@ EOR
|
||||||
klass_name = "DublinCore#{Utils.to_class_name(name.to_s)}"
|
klass_name = "DublinCore#{Utils.to_class_name(name.to_s)}"
|
||||||
klass = DublinCoreModel.const_get(klass_name)
|
klass = DublinCoreModel.const_get(klass_name)
|
||||||
elems << klass.new(parent.__send__("dc_#{name}"))
|
elems << klass.new(parent.__send__("dc_#{name}"))
|
||||||
assert_equal(excepted, parent.__send!("dc_#{name}_elements"))
|
assert_equal(excepted, parent.__send__("dc_#{name}_elements"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ EOR
|
||||||
excepted = "<#{@prefix}:#{name}>#{value}</#{@prefix}:#{name}>"
|
excepted = "<#{@prefix}:#{name}>#{value}</#{@prefix}:#{name}>"
|
||||||
@parents.each do |parent|
|
@parents.each do |parent|
|
||||||
assert_equal(excepted,
|
assert_equal(excepted,
|
||||||
@rss.__send__(parent).__send!("sy_#{name}_element"))
|
@rss.__send__(parent).__send__("sy_#{name}_element"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ EOR
|
||||||
def test_to_s
|
def test_to_s
|
||||||
@topics_parents.each do |parent|
|
@topics_parents.each do |parent|
|
||||||
meth = "taxo_topics_element"
|
meth = "taxo_topics_element"
|
||||||
assert_equal(@topics_node, @rss.__send__(parent).__send!(meth))
|
assert_equal(@topics_node, @rss.__send__(parent).__send__(meth))
|
||||||
end
|
end
|
||||||
|
|
||||||
@topic_nodes.each_with_index do |node, i|
|
@topic_nodes.each_with_index do |node, i|
|
||||||
|
|
|
@ -114,7 +114,7 @@ EOR
|
||||||
@parents.each do |parent|
|
@parents.each do |parent|
|
||||||
meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element"
|
meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element"
|
||||||
meth << "s" if name == :about
|
meth << "s" if name == :about
|
||||||
assert_equal(excepted, @rss.__send__(parent).__send!(meth))
|
assert_equal(excepted, @rss.__send__(parent).__send__(meth))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class TestAlias < Test::Unit::TestCase
|
||||||
d = lambda {
|
d = lambda {
|
||||||
$SAFE = 4
|
$SAFE = 4
|
||||||
dclass = Class.new(C)
|
dclass = Class.new(C)
|
||||||
dclass.send!(:alias_method, :mm, :m)
|
dclass.send(:alias_method, :mm, :m)
|
||||||
dclass.new
|
dclass.new
|
||||||
}.call
|
}.call
|
||||||
assert_raise(SecurityError) { d.mm }
|
assert_raise(SecurityError) { d.mm }
|
||||||
|
|
|
@ -652,7 +652,7 @@ class TestAssignmentGen < Test::Unit::TestCase
|
||||||
assign = assign.to_s
|
assign = assign.to_s
|
||||||
code1 = "#{assign}; [#{vars.join(",")}]"
|
code1 = "#{assign}; [#{vars.join(",")}]"
|
||||||
assign.gsub!(/\bv\d+\b/, "o.a")
|
assign.gsub!(/\bv\d+\b/, "o.a")
|
||||||
code2 = "o=[];class << o; self end.send!(:define_method,:a=){|v|self << v};#{assign};o"
|
code2 = "o=[];class << o; self end.send(:define_method,:a=){|v|self << v};#{assign};o"
|
||||||
begin
|
begin
|
||||||
vals1 = eval(code1)
|
vals1 = eval(code1)
|
||||||
rescue Exception
|
rescue Exception
|
||||||
|
|
|
@ -124,7 +124,7 @@ class TestEval < Test::Unit::TestCase
|
||||||
obj.class.class_variable_set :@@cvar, 13
|
obj.class.class_variable_set :@@cvar, 13
|
||||||
# Use same value with env. See also test_instance_variable_cvar.
|
# Use same value with env. See also test_instance_variable_cvar.
|
||||||
obj.class.const_set :Const, 15 unless obj.class.const_defined?(:Const)
|
obj.class.const_set :Const, 15 unless obj.class.const_defined?(:Const)
|
||||||
send! mid, obj
|
send mid, obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ class TestEval < Test::Unit::TestCase
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
def temporally_method_for_test_eval_and_define_method(&block)
|
def temporally_method_for_test_eval_and_define_method(&block)
|
||||||
lambda {
|
lambda {
|
||||||
class << Object.new; self end.send!(:define_method, :zzz, &block)
|
class << Object.new; self end.send(:define_method, :zzz, &block)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
v = eval("temporally_method_for_test_eval_and_define_method {}")
|
v = eval("temporally_method_for_test_eval_and_define_method {}")
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TestRubyPrimitive < Test::Unit::TestCase
|
||||||
assert_equal 3, A::B::C::Const
|
assert_equal 3, A::B::C::Const
|
||||||
assert_equal 3, A::B::C.new.const
|
assert_equal 3, A::B::C.new.const
|
||||||
assert_equal 1, ::TestRubyPrimitive::A::Const
|
assert_equal 1, ::TestRubyPrimitive::A::Const
|
||||||
A::B::C.send!(:remove_const, :Const)
|
A::B::C.send(:remove_const, :Const)
|
||||||
assert_equal 2, A::B::C.new.const
|
assert_equal 2, A::B::C.new.const
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
C::CONST
|
C::CONST
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TestBasicSocket < Test::Unit::TestCase
|
||||||
n = s.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
|
n = s.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
|
||||||
assert_equal([0].pack("i"), n)
|
assert_equal([0].pack("i"), n)
|
||||||
val = Object.new
|
val = Object.new
|
||||||
class << val; self end.send!(:define_method, :to_int) {
|
class << val; self end.send(:define_method, :to_int) {
|
||||||
s.close
|
s.close
|
||||||
Socket::SO_TYPE
|
Socket::SO_TYPE
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class TestBasicSocket < Test::Unit::TestCase
|
||||||
linger = [0, 0].pack("ii")
|
linger = [0, 0].pack("ii")
|
||||||
|
|
||||||
val = Object.new
|
val = Object.new
|
||||||
class << val; self end.send!(:define_method, :to_str) {
|
class << val; self end.send(:define_method, :to_str) {
|
||||||
s.close
|
s.close
|
||||||
linger
|
linger
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class TestBasicSocket < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
val = Object.new
|
val = Object.new
|
||||||
class << val; self end.send!(:define_method, :to_int) {
|
class << val; self end.send(:define_method, :to_int) {
|
||||||
s.close
|
s.close
|
||||||
Socket::SO_LINGER
|
Socket::SO_LINGER
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class TestBasicSocket < Test::Unit::TestCase
|
||||||
def test_listen
|
def test_listen
|
||||||
s = nil
|
s = nil
|
||||||
log = Object.new
|
log = Object.new
|
||||||
class << log; self end.send!(:define_method, :to_int) {
|
class << log; self end.send(:define_method, :to_int) {
|
||||||
s.close
|
s.close
|
||||||
2
|
2
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TestUDPSocket < Test::Unit::TestCase
|
||||||
def test_connect # [ruby-dev:25045]
|
def test_connect # [ruby-dev:25045]
|
||||||
s = UDPSocket.new
|
s = UDPSocket.new
|
||||||
host = Object.new
|
host = Object.new
|
||||||
class << host; self end.send!(:define_method, :to_str) {
|
class << host; self end.send(:define_method, :to_str) {
|
||||||
s.close
|
s.close
|
||||||
"127.0.0.1"
|
"127.0.0.1"
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class TestUDPSocket < Test::Unit::TestCase
|
||||||
def test_bind # [ruby-dev:25057]
|
def test_bind # [ruby-dev:25057]
|
||||||
s = UDPSocket.new
|
s = UDPSocket.new
|
||||||
host = Object.new
|
host = Object.new
|
||||||
class << host; self end.send!(:define_method, :to_str) {
|
class << host; self end.send(:define_method, :to_str) {
|
||||||
s.close
|
s.close
|
||||||
"127.0.0.1"
|
"127.0.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@ class TestEval < YarvTestBase
|
||||||
|
|
||||||
def test_eval_with_send
|
def test_eval_with_send
|
||||||
ae %q{
|
ae %q{
|
||||||
__send! :eval, %{
|
__send__ :eval, %{
|
||||||
:ok
|
:ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ae %q{
|
ae %q{
|
||||||
1.__send! :instance_eval, %{
|
1.__send__ :instance_eval, %{
|
||||||
:ok
|
:ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue