diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-26 09:40:05 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-26 09:40:05 +0000 |
commit | 5ee95c149cb25c5def7b4579fb7cfec3e6b5a664 (patch) | |
tree | 9b9143b6cda6ed56b216aa3e5ae80fb9f122e8d6 | |
parent | 0da299e54169da1773fd247783298036eb02e6c3 (diff) | |
download | ruby-5ee95c149cb25c5def7b4579fb7cfec3e6b5a664.tar.gz ruby-5ee95c149cb25c5def7b4579fb7cfec3e6b5a664.tar.xz ruby-5ee95c149cb25c5def7b4579fb7cfec3e6b5a664.zip |
* eval.c (Init_eval): rename #invoke_method and
#invoke_functional_method to __send and __send! respectively.
* eval.c (remove_method): prohibit removing __send and __send!.
* eval.c (rb_undef): prohibit undef'ing __send and __send!.
* eval.c (rb_eval): prohibit redefining __send and __send!.
* lib/delegate.rb (Delegator): preserve __send.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | .cvsignore | 2 | ||||
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | eval.c | 23 | ||||
-rw-r--r-- | lib/delegate.rb | 8 |
4 files changed, 32 insertions, 14 deletions
diff --git a/.cvsignore b/.cvsignore index 62afb836b..a0b3033e1 100644 --- a/.cvsignore +++ b/.cvsignore @@ -6,6 +6,8 @@ .ccmalloc .ppack .ext +.git +.svn .rbconfig.time COPYING.LIB ChangeLog.pre-alpha @@ -1,3 +1,16 @@ +Wed Jul 26 18:33:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (Init_eval): rename #invoke_method and + #invoke_functional_method to __send and __send! respectively. + + * eval.c (remove_method): prohibit removing __send and __send!. + + * eval.c (rb_undef): prohibit undef'ing __send and __send!. + + * eval.c (rb_eval): prohibit redefining __send and __send!. + + * lib/delegate.rb (Delegator): preserve __send. + Wed Jul 26 18:14:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org> * ext/pty/pty.c (getDevice): retry once after GC on failure. @@ -410,7 +410,7 @@ rb_clear_cache_by_class(VALUE klass) static ID init, eqq, each, aref, aset, match, missing; static ID added, singleton_added; -static ID __id__, __send__, respond_to; +static ID object_id, __send, __send_bang, respond_to; #define NOEX_SAFE(n) ((n) >> 5) #define NOEX_WITH(n, v) ((n) | (v) << 5) @@ -580,7 +580,7 @@ remove_method(VALUE klass, ID mid) rb_raise(rb_eSecurityError, "Insecure: can't remove method"); } if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); - if (mid == __id__ || mid == __send__ || mid == init) { + if (mid == object_id || mid == __send || mid == __send_bang || mid == init) { rb_warn("removing `%s' may cause serious problem", rb_id2name(mid)); } if (!st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body) || @@ -1967,7 +1967,7 @@ rb_undef(VALUE klass, ID id) rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'", rb_id2name(id)); } rb_frozen_class_p(klass); - if (id == __id__ || id == __send__ || id == init) { + if (id == object_id || id == __send || id == __send_bang || id == init) { rb_warn("undefining `%s' may cause serious problem", rb_id2name(id)); } body = search_method(klass, id, &origin, LOOKUP_NOSKIP, 0); @@ -3746,7 +3746,8 @@ rb_eval(VALUE self, NODE *n) if (ruby_cbase == rb_cObject && node->nd_mid == init) { rb_warn("redefining Object#initialize may cause infinite loop"); } - if (node->nd_mid == __id__ || node->nd_mid == __send__) { + if (node->nd_mid == object_id || + node->nd_mid == __send || node->nd_mid == __send_bang) { rb_warn("redefining `%s' may cause serious problem", rb_id2name(node->nd_mid)); } @@ -6016,8 +6017,8 @@ send_funcall(int argc, VALUE *argv, VALUE recv, calling_scope_t scope) /* * 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 * arguments specified. You can use <code>\_\_send__</code> if the name @@ -6054,6 +6055,7 @@ rb_f_send(int argc, VALUE *argv, VALUE recv) /* * call-seq: * obj.funcall(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 @@ -7858,8 +7860,9 @@ Init_eval(void) undefined = rb_intern("method_undefined"); singleton_undefined = rb_intern("singleton_method_undefined"); - __id__ = rb_intern("__id__"); - __send__ = rb_intern("__send__"); + object_id = rb_intern("object_id"); + __send = rb_intern("__send"); + __send_bang = rb_intern("__send!"); rb_global_variable((VALUE*)&top_scope); rb_global_variable((VALUE*)&ruby_eval_tree); @@ -7899,9 +7902,9 @@ 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, "invoke_method", 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, "invoke_functional_method", rb_f_funcall, -1); + 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); diff --git a/lib/delegate.rb b/lib/delegate.rb index e8a731ae0..165e54a72 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -115,7 +115,7 @@ # implementation, see SimpleDelegator. # class Delegator - preserved = ["__id__", "object_id", "__send__", "respond_to?", "send", "funcall"] + preserved = ["__id__", "object_id", "__send__", "__send", "__send!", "respond_to?", "send", "funcall"] instance_methods.each do |m| next if preserved.include?(m) undef_method m @@ -137,7 +137,7 @@ class Delegator 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 @@ def DelegateClass(superclass) klass = Class.new methods = superclass.public_instance_methods(true) methods -= [ - "__id__", "object_id", "__send__", "respond_to?", "send", "funcall", + "__id__", "object_id", "__send__", "__send", "__send!", "respond_to?", "send", "funcall", "==", "equal?", "initialize", "method_missing", "__getobj__", "__setobj__", "clone", "dup", "marshal_dump", "marshal_load", ] @@ -281,7 +281,7 @@ def DelegateClass(superclass) klass.module_eval <<-EOS, __FILE__, __LINE__+1 def #{method}(*args, &block) begin - @_dc_obj.__send__(:#{method}, *args, &block) + @_dc_obj.__send(:#{method}, *args, &block) rescue $@[0,2] = nil raise |