[前][次][番号順一覧][スレッド一覧]

ruby-changes:2333

From: ko1@a...
Date: 5 Nov 2007 05:37:28 +0900
Subject: [ruby-changes:2333] matz - Ruby:r13824 (trunk): * eval.c (rb_f_send): allow send/__send__ to call methods of all

matz	2007-11-05 05:36:20 +0900 (Mon, 05 Nov 2007)

  New Revision: 13824

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_eval.rb
    trunk/bootstraptest/test_method.rb
    trunk/compile.c
    trunk/eval.c
    trunk/eval_method.ci
    trunk/id.c
    trunk/insnhelper.ci
    trunk/lib/date.rb
    trunk/lib/delegate.rb
    trunk/lib/drb/drb.rb
    trunk/lib/matrix.rb
    trunk/lib/monitor.rb
    trunk/lib/net/imap.rb
    trunk/lib/net/smtp.rb
    trunk/test/pathname/test_pathname.rb
    trunk/test/rss/test_content.rb
    trunk/test/rss/test_dublincore.rb
    trunk/test/rss/test_syndication.rb
    trunk/test/rss/test_taxonomy.rb
    trunk/test/rss/test_trackback.rb
    trunk/test/ruby/test_alias.rb
    trunk/test/ruby/test_assignment.rb
    trunk/test/ruby/test_eval.rb
    trunk/test/ruby/test_primitive.rb
    trunk/test/socket/test_socket.rb
    trunk/test/socket/test_udp.rb
    trunk/yarvtest/test_eval.rb

  Log:
    * 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).

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/yarvtest/test_eval.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/date.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/insnhelper.ci?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_assignment.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/pathname/test_pathname.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/socket/test_socket.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_syndication.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/imap.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/monitor.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/delegate.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_trackback.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/id.c?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_method.ci?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_method.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/socket/test_udp.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/smtp.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/matrix.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_eval.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_alias.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_content.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_taxonomy.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_eval.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_primitive.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_dublincore.rb?r1=13824&r2=13823
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/drb/drb.rb?r1=13824&r2=13823

Index: eval_method.ci
===================================================================
--- eval_method.ci	(revision 13823)
+++ eval_method.ci	(revision 13824)
@@ -158,7 +158,7 @@
 	    }
 	}
 
-	if (mid == object_id || mid == __send || mid == __send_bang) {
+	if (mid == object_id || mid == __send__) {
 	    if (node && nd_type(node) == RUBY_VM_METHOD_NODE) {
 		rb_warn("redefining `%s' may cause serious problem",
 			rb_id2name(mid));
@@ -302,7 +302,7 @@
     }
     if (OBJ_FROZEN(klass))
 	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));
     }
     if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) {
@@ -466,7 +466,7 @@
 		 rb_id2name(id));
     }
     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));
     }
     body = search_method(klass, id, &origin);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13823)
+++ ChangeLog	(revision 13824)
@@ -17,6 +17,15 @@
 	  User-Agent to fix 500 error on some corrupted HTTP servers.
 	  [ruby-core:13135]
 
+Mon Nov  5 00:32:32 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* 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@r...>
 
 	* win32/Makefile.sub: vendor_ruby support.
Index: bootstraptest/test_method.rb
===================================================================
--- bootstraptest/test_method.rb	(revision 13823)
+++ bootstraptest/test_method.rb	(revision 13824)
@@ -314,9 +314,9 @@
 assert_equal '[1, 2]',  %q( class C; def m(*a) a end end;
                             C.new.send(:m,1,2).inspect )
 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
-                            C.new.send!(:m) )
+                            C.new.send(:m) )
 
 # with block
 assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
@@ -867,8 +867,6 @@
     end
   end
 
-  alias send! send unless defined? send!
-
   c1 = c2 = nil
 
   lambda{
@@ -899,8 +897,8 @@
   test{o2.mm}
   test{o1.send :m}
   test{o2.send :mm}
-  test{o1.send! :m}
-  test{o2.send! :mm}
+  test{o1.invoke_method :m}
+  test{o2.invoke_method :mm}
   test{o1.method(:m).call}
   test{o2.method(:mm).call}
   $ans
Index: bootstraptest/test_eval.rb
===================================================================
--- bootstraptest/test_eval.rb	(revision 13823)
+++ bootstraptest/test_eval.rb	(revision 13824)
@@ -89,12 +89,12 @@
   eval('a')
 }
 assert_equal %q{ok}, %q{
-  __send! :eval, %{
+  __send__ :eval, %{
     :ok
   }
 }
 assert_equal %q{ok}, %q{
-  1.__send! :instance_eval, %{
+  1.__send__ :instance_eval, %{
     :ok
   }
 }
Index: lib/monitor.rb
===================================================================
--- lib/monitor.rb	(revision 13823)
+++ lib/monitor.rb	(revision 13824)
@@ -91,13 +91,13 @@
       if timeout
         raise NotImplementedError, "timeout is not implemented yet"
       end
-      @monitor.send!(:mon_check_owner)
-      count = @monitor.send!(: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.send!(:mon_enter_for_cond, count)
+        @monitor.send(:mon_enter_for_cond, count)
       end
     end
     
@@ -114,12 +114,12 @@
     end
     
     def signal
-      @monitor.send!(:mon_check_owner)
+      @monitor.send(:mon_check_owner)
       @cond.signal
     end
     
     def broadcast
-      @monitor.send!(:mon_check_owner)
+      @monitor.send(:mon_check_owner)
       @cond.broadcast
     end
     
@@ -137,7 +137,7 @@
   
   def self.extend_object(obj)
     super(obj)
-    obj.send!(:mon_initialize)
+    obj.send(:mon_initialize)
   end
   
   #
Index: lib/delegate.rb
===================================================================
--- lib/delegate.rb	(revision 13823)
+++ lib/delegate.rb	(revision 13824)
@@ -115,7 +115,7 @@
 # implementation, see SimpleDelegator.
 #
 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|
     next if preserved.include?(m)
     undef_method m
@@ -137,7 +137,7 @@
         unless target.respond_to?(m)
           super(m, *args, &block)
         else
-          target.__send(m, *args, &block)
+          target.__send__(m, *args, &block)
         end
       rescue Exception
         $@.delete_if{|s| /^#{__FILE__}:\d+:in `method_missing'$/ =~ s} #`
@@ -262,7 +262,7 @@
   klass = Class.new
   methods = superclass.public_instance_methods(true)
   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__,
     :clone, :dup, :marshal_dump, :marshal_load,
   ]
@@ -281,7 +281,7 @@
       klass.module_eval <<-EOS, __FILE__, __LINE__+1
         def #{method}(*args, &block)
 	  begin
-	    @delegate_dc_obj.__send(:#{method}, *args, &block)
+	    @delegate_dc_obj.__send__(:#{method}, *args, &block)
 	  rescue
 	    raise $!, $@[2..-1]
 	  end
Index: lib/date.rb
===================================================================
--- lib/date.rb	(revision 13823)
+++ lib/date.rb	(revision 13824)
@@ -877,14 +877,14 @@
       when :civil
 	g[1].each do |e|
 	  break if elem[e]
-	  elem[e] = d.__send!(e)
+	  elem[e] = d.__send__(e)
 	end
 	elem[:mon]  ||= 1
 	elem[:mday] ||= 1
       when :commercial
 	g[1].each do |e|
 	  break if elem[e]
-	  elem[e] = d.__send!(e)
+	  elem[e] = d.__send__(e)
 	end
 	elem[:cweek] ||= 1
 	elem[:cwday] ||= 1
@@ -893,14 +893,14 @@
       when :wnum0
 	g[1].each do |e|
 	  break if elem[e]
-	  elem[e] = d.__send!(e)
+	  elem[e] = d.__send__(e)
 	end
 	elem[:wnum0] ||= 0
 	elem[:wday]  ||= 0
       when :wnum1
 	g[1].each do |e|
 	  break if elem[e]
-	  elem[e] = d.__send!(e)
+	  elem[e] = d.__send__(e)
 	end
 	elem[:wnum1] ||= 0
 	elem[:wday]  ||= 0
@@ -1727,16 +1727,16 @@
   def to_time() getlocal end
 
   def to_date
-    jd = Date.__send!(:civil_to_jd, year, mon, mday, Date::ITALY)
-    Date.new!(Date.__send!(:jd_to_ajd, jd, 0, 0), 0, 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)
   end
 
   def to_datetime
-    jd = DateTime.__send!(:civil_to_jd, year, mon, mday, DateTime::ITALY)
-    fr = DateTime.__send!(:time_to_day_fraction, hour, min, [sec, 59].min) +
+    jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY)
+    fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) +
 	 usec.to_r/86400_000_000
     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)
   end
 
Index: lib/net/smtp.rb
===================================================================
--- lib/net/smtp.rb	(revision 13823)
+++ lib/net/smtp.rb	(revision 13824)
@@ -722,7 +722,7 @@
     def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
       check_auth_method authtype
       check_auth_args user, secret
-      send! auth_method(authtype), user, secret
+      send auth_method(authtype), user, secret
     end
 
     def auth_plain(user, secret)
Index: lib/net/imap.rb
===================================================================
--- lib/net/imap.rb	(revision 13823)
+++ lib/net/imap.rb	(revision 13824)
@@ -1229,7 +1229,7 @@
 
     class RawData # :nodoc:
       def send_data(imap)
-        imap.send!(:put_string, @data)
+        imap.send(:put_string, @data)
       end
 
       private
@@ -1241,7 +1241,7 @@
 
     class Atom # :nodoc:
       def send_data(imap)
-        imap.send!(:put_string, @data)
+        imap.send(:put_string, @data)
       end
 
       private
@@ -1253,7 +1253,7 @@
 
     class QuotedString # :nodoc:
       def send_data(imap)
-        imap.send!(:send_quoted_string, @data)
+        imap.send(:send_quoted_string, @data)
       end
 
       private
@@ -1265,7 +1265,7 @@
 
     class Literal # :nodoc:
       def send_data(imap)
-        imap.send!(:send_literal, @data)
+        imap.send(:send_literal, @data)
       end
 
       private
@@ -1277,7 +1277,7 @@
 
     class MessageSet # :nodoc:
       def send_data(imap)
-        imap.send!(:put_string, format_internal(@data))
+        imap.send(:put_string, format_internal(@data))
       end
 
       private
Index: lib/matrix.rb
===================================================================
--- lib/matrix.rb	(revision 13823)
+++ lib/matrix.rb	(revision 13824)
@@ -246,7 +246,7 @@
   # use to general users.
   #
   def initialize(init_method, *argv)
-    self.send!(init_method, *argv)
+    self.send(init_method, *argv)
   end
   
   def init_rows(rows, copy)
Index: lib/drb/drb.rb
===================================================================
--- lib/drb/drb.rb	(revision 13823)
+++ lib/drb/drb.rb	(revision 13824)
@@ -1553,7 +1553,7 @@
 	  end
 	  ary.collect(&@obj)[0]
 	else
-	  @obj.send!(@msg_id, *@argv)
+	  @obj.send(@msg_id, *@argv)
 	end
       end
 
Index: compile.c
===================================================================
--- compile.c	(revision 13823)
+++ compile.c	(revision 13824)
@@ -1483,11 +1483,11 @@
 	}
 
 	if (mid == idSend || mid == id__send ||
-	    mid == idSendBang || mid == id__send_bang ||
+	    mid == idSendBang ||
 	    mid == id__send__ ) {
 	    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);
 	}
     }
Index: eval.c
===================================================================
--- eval.c	(revision 13823)
+++ eval.c	(revision 13824)
@@ -25,7 +25,7 @@
 static ID removed, singleton_removed, undefined, singleton_undefined;
 static ID init, eqq, each, aref, aset, match, missing;
 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_eSysStackError;
@@ -1471,7 +1471,7 @@
 /*
  *  call-seq:
  *     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. You can use <code>__send__</code> if the name
@@ -1489,34 +1489,33 @@
 VALUE
 rb_f_send(int argc, VALUE *argv, VALUE recv)
 {
-    int scope = NOEX_PUBLIC;
-    rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
-
-    if (SPECIAL_CONST_P(cfp->sp[0])) {
-	scope = NOEX_NOSUPER | NOEX_PRIVATE;
-    }
-
-    return send_internal(argc, argv, recv, scope);
+    return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
 }
 
+
 /*
  *  call-seq:
- *     obj.send!(symbol [, args...])        => obj
- *     obj.__send!(symbol [, args...])      => obj
+ *     obj.invoke_method(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.
+ *  1arguments specified. Unlike send, invoke_method calls public
+ *  methods only, unless it's invoked in a function call style.
  *
- *     1.send!(:puts, "hello")  # prints "foo"
+ *     1.invoke_method(:puts, "hello")  # causes NoMethodError
  */
 
 VALUE
-rb_f_send_bang(int argc, VALUE *argv, VALUE recv)
+rb_invoke_method(int argc, VALUE *argv, VALUE recv)
 {
-    return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
+    int scope = NOEX_PUBLIC;
+    rb_thread_t *th = GET_THREAD();
+    rb_control_frame_t *cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
+
+    if (SPECIAL_CONST_P(cfp->sp[0])) {
+	scope = NOEX_NOSUPER | NOEX_PRIVATE;
+    }
+
+    return send_internal(argc, argv, recv, scope);
 }
 
 VALUE
@@ -2718,8 +2717,7 @@
     singleton_undefined = rb_intern("singleton_method_undefined");
 
     object_id = rb_intern("object_id");
-    __send = rb_intern("__send");
-    __send_bang = rb_intern("__send!");
+    __send__ = rb_intern("__send__");
 
     rb_define_virtual_variable("$@", errat_getter, errat_setter);
     rb_define_virtual_variable("$!", errinfo_getter, 0);
@@ -2748,9 +2746,7 @@
 
     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_bang, -1);
-    rb_define_method(rb_cBasicObject, "__send!", rb_f_send_bang, -1);
+    rb_define_method(rb_mKernel, "invoke_method", rb_invoke_method, -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);
Index: id.c
===================================================================
--- id.c	(revision 13823)
+++ id.c	(revision 13824)
@@ -62,7 +62,5 @@
 
     idSend = rb_intern("send");
     idSendBang = rb_intern("send!");
-    id__send = rb_intern("__send");
-    id__send_bang = rb_intern("__send!");
     id__send__ = rb_intern("__send__");
 }
Index: yarvtest/test_eval.rb
===================================================================
--- yarvtest/test_eval.rb	(revision 13823)
+++ yarvtest/test_eval.rb	(revision 13824)
@@ -16,12 +16,12 @@
 
   def test_eval_with_send
     ae %q{
-      __send! :eval, %{
+      __send__ :eval, %{
         :ok
       }
     }
     ae %q{
-      1.__send! :instance_eval, %{
+      1.__send__ :instance_eval, %{
         :ok
       }
     }
Index: test/ruby/test_alias.rb
===================================================================
--- test/ruby/test_alias.rb	(revision 13823)
+++ test/ruby/test_alias.rb	(revision 13824)
@@ -56,7 +56,7 @@
     d = lambda {
       $SAFE = 4
       dclass = Class.new(C)
-      dclass.send!(:alias_method, :mm, :m)
+      dclass.send(:alias_method, :mm, :m)
       dclass.new
     }.call
     assert_raise(SecurityError) { d.mm }
Index: test/ruby/test_assignment.rb
===================================================================
--- test/ruby/test_assignment.rb	(revision 13823)
+++ test/ruby/test_assignment.rb	(revision 13824)
@@ -652,7 +652,7 @@
     assign = assign.to_s
     code1 = "#{assign}; [#{vars.join(",")}]"
     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
       vals1 = eval(code1)
     rescue Exception
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 13823)
+++ test/ruby/test_eval.rb	(revision 13824)
@@ -124,7 +124,7 @@
       obj.class.class_variable_set :@@cvar, 13
           # Use same value with env. See also test_instance_variable_cvar.
       obj.class.const_set :Const, 15 unless obj.class.const_defined?(:Const)
-      send! mid, obj
+      send mid, obj
     end
   end
 
@@ -364,7 +364,7 @@
     assert_nothing_raised {
       def temporally_method_for_test_eval_and_define_method(&block)
         lambda {
-          class << Object.new; self end.send!(:define_method, :zzz, &block)
+          class << Object.new; self end.send(:define_method, :zzz, &block)
         }
       end
       v = eval("temporally_method_for_test_eval_and_define_method {}")
Index: test/ruby/test_primitive.rb
===================================================================
--- test/ruby/test_primitive.rb	(revision 13823)
+++ test/ruby/test_primitive.rb	(revision 13824)
@@ -50,7 +50,7 @@
     assert_equal 3, A::B::C::Const
     assert_equal 3, A::B::C.new.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_raise(TypeError) {
       C::CONST
Index: test/socket/test_socket.rb
===================================================================
--- test/socket/test_socket.rb	(revision 13823)
+++ test/socket/test_socket.rb	(revision 13824)
@@ -19,7 +19,7 @@
       n = s.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
       assert_equal([0].pack("i"), n)
       val = Object.new
-      class << val; self end.send!(:define_method, :to_int) {
+      class << val; self end.send(:define_method, :to_int) {
         s.close
         Socket::SO_TYPE
       }
@@ -34,7 +34,7 @@
     linger = [0, 0].pack("ii")
 
     val = Object.new
-    class << val; self end.send!(:define_method, :to_str) {
+    class << val; self end.send(:define_method, :to_str) {
       s.close
       linger
     }
@@ -47,7 +47,7 @@
     end
 
     val = Object.new
-    class << val; self end.send!(:define_method, :to_int) {
+    class << val; self end.send(:define_method, :to_int) {
       s.close
       Socket::SO_LINGER
     }
@@ -61,7 +61,7 @@
   def test_listen
     s = nil
     log = Object.new
-    class << log; self end.send!(:define_method, :to_int) {
+    class << log; self end.send(:define_method, :to_int) {
       s.close
       2
     }
Index: test/socket/test_udp.rb
===================================================================
--- test/socket/test_udp.rb	(revision 13823)
+++ test/socket/test_udp.rb	(revision 13824)
@@ -9,7 +9,7 @@
   def test_connect # [ruby-dev:25045]
     s = UDPSocket.new
     host = Object.new
-    class << host; self end.send!(:define_method, :to_str) {
+    class << host; self end.send(:define_method, :to_str) {
       s.close
       "127.0.0.1"
     }
@@ -21,7 +21,7 @@
   def test_bind # [ruby-dev:25057]
     s = UDPSocket.new
     host = Object.new
-    class << host; self end.send!(:define_method, :to_str) {
+    class << host; self end.send(:define_method, :to_str) {
       s.close
       "127.0.0.1"
     }
Index: test/pathname/test_pathname.rb
===================================================================
--- test/pathname/test_pathname.rb	(revision 13823)
+++ test/pathname/test_pathname.rb	(revision 13824)
@@ -9,12 +9,6 @@
 
 class TestPathname < Test::Unit::TestCase
 
-  if RUBY_VERSION < "1.9"
-    FUNCALL = :__send__
-  else
-    FUNCALL = :send!
-  end
-
   def self.define_assertion(name, &block)
     @defassert_num ||= {}
     @defassert_num[name] ||= 0
@@ -123,7 +117,7 @@
 
   # has_trailing_separator?(path) -> bool
   def has_trailing_separator?(path)
-    Pathname.allocate.send(FUNCALL, :has_trailing_separator?, path)
+    Pathname.allocate.__send__(:has_trailing_separator?, path)
   end
 
   defassert(:has_trailing_separator?, false, "/")
@@ -132,11 +126,11 @@
   defassert(:has_trailing_separator?, true, "a/")
 
   def add_trailing_separator(path)
-    Pathname.allocate.send(FUNCALL, :add_trailing_separator, path)
+    Pathname.allocate.__send__(:add_trailing_separator, path)
   end
 
   def del_trailing_separator(path)
-    Pathname.allocate.send(FUNCALL, :del_trailing_separator, path)
+    Pathname.allocate.send(__send__, :del_trailing_separator, path)
   end
 
   defassert(:del_trailing_separator, "/", "/")
Index: test/rss/test_taxonomy.rb
===================================================================
--- test/rss/test_taxonomy.rb	(revision 13823)
+++ test/rss/test_taxonomy.rb	(revision 13824)
@@ -140,7 +140,7 @@
     def test_to_s
       @topics_parents.each do |parent|
         meth = "taxo_topics_element"
-        assert_equal(@topics_node, @rss.__send__(parent).__send!(meth))
+        assert_equal(@topics_node, @rss.__send__(parent).__send__(meth))
       end
 
       @topic_nodes.each_with_index do |node, i|
Index: test/rss/test_syndication.rb
===================================================================
--- test/rss/test_syndication.rb	(revision 13823)
+++ test/rss/test_syndication.rb	(revision 13824)
@@ -107,7 +107,7 @@
         excepted = "<#{@prefix}:#{name}>#{value}</#{@prefix}:#{name}>"
         @parents.each do |parent|
           assert_equal(excepted,
-                       @rss.__send__(parent).__send!("sy_#{name}_element"))
+                       @rss.__send__(parent).__send__("sy_#{name}_element"))
         end
       end
       
Index: test/rss/test_trackback.rb
===================================================================
--- test/rss/test_trackback.rb	(revision 13823)
+++ test/rss/test_trackback.rb	(revision 13824)
@@ -114,7 +114,7 @@
         @parents.each do |parent|
           meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element"
           meth << "s" if name == :about
-          assert_equal(excepted, @rss.__send__(parent).__send!(meth))
+          assert_equal(excepted, @rss.__send__(parent).__send__(meth))
         end
       end
       
Index: test/rss/test_dublincore.rb
===================================================================
--- test/rss/test_dublincore.rb	(revision 13823)
+++ test/rss/test_dublincore.rb	(revision 13824)
@@ -245,7 +245,7 @@
         excepted = "<#{DC_PREFIX}:#{name}>#{value}</#{DC_PREFIX}:#{name}>"
         parents.each do |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
 
         plural_suffix = dc_plural_suffix(name, check_backward_compatibility)
@@ -257,7 +257,7 @@
           klass_name = "DublinCore#{Utils.to_class_name(name.to_s)}"
           klass = DublinCoreModel.const_get(klass_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
 
Index: test/rss/test_content.rb
===================================================================
--- test/rss/test_content.rb	(revision 13823)
+++ test/rss/test_content.rb	(revision 13824)
@@ -85,7 +85,7 @@
         excepted = make_element("#{@prefix}:#{name}", {}, value)
         meth = "#{RSS::CONTENT_PREFIX}_#{name}_element"
         [@rss10, @rss20].each do |rss|
-          assert_equal(excepted, rss.items.last.__send!(meth))
+          assert_equal(excepted, rss.items.last.__send__(meth))
         end
       end
 
Index: insnhelper.ci
===================================================================
--- insnhelper.ci	(revision 13823)
+++ insnhelper.ci	(revision 13824)
@@ -588,10 +588,9 @@
 {
     if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) {
 	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);
 
-	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;
 	    VALUE sym = TOPN(i);
 	    *id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
@@ -604,9 +603,6 @@
 	    *mn = rb_method_node(klass, *id);
 	    *num -= 1;
 	    DEC_SP(1);
-	}
-
-	if (node->nd_cfnc == rb_f_send_bang) {
 	    *flag |= VM_CALL_FCALL_BIT;
 	}
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]