diff --git a/ChangeLog b/ChangeLog index 8cd19c868c..1c04c79698 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -Fri Sep 2 23:51:08 2005 Nobuyoshi Nakada +Fri Sep 2 23:51:54 2005 Nobuyoshi Nakada * parse.y (f_arg): f_norm_arg is a VALUE in ripper, not an ID. fixed: [ruby-dev:26942] + * lib: do not use __send__ to access private methods. [ruby-dev:26935] + Thu Sep 1 17:11:25 2005 Yukihiro Matsumoto * eval.c (rb_call0): wrong condition for $SAFE restoration. diff --git a/lib/monitor.rb b/lib/monitor.rb index a573af2bae..6bd14d0789 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -87,11 +87,11 @@ module MonitorMixin class Timeout < Exception; end def wait(timeout = nil) - @monitor.__send__(:mon_check_owner) + @monitor.instance_eval {mon_check_owner()} timer = create_timer(timeout) Thread.critical = true - count = @monitor.__send__(:mon_exit_for_cond) + count = @monitor.instance_eval {mon_exit_for_cond()} @waiters.push(Thread.current) begin @@ -107,7 +107,7 @@ module MonitorMixin if @waiters.include?(Thread.current) # interrupted? @waiters.delete(Thread.current) end - @monitor.__send__(:mon_enter_for_cond, count) + @monitor.instance_eval {mon_enter_for_cond(count)} Thread.critical = false end end @@ -125,7 +125,7 @@ module MonitorMixin end def signal - @monitor.__send__(:mon_check_owner) + @monitor.instance_eval {mon_check_owner()} Thread.critical = true t = @waiters.shift t.wakeup if t @@ -134,7 +134,7 @@ module MonitorMixin end def broadcast - @monitor.__send__(:mon_check_owner) + @monitor.instance_eval {mon_check_owner()} Thread.critical = true for t in @waiters t.wakeup @@ -172,7 +172,7 @@ module MonitorMixin def self.extend_object(obj) super(obj) - obj.__send__(:mon_initialize) + obj.instance_eval {mon_initialize()} end # diff --git a/lib/rss/maker/content.rb b/lib/rss/maker/content.rb index 96f3ccb6d9..18590d0cf8 100644 --- a/lib/rss/maker/content.rb +++ b/lib/rss/maker/content.rb @@ -10,8 +10,8 @@ module RSS ::RSS::ContentModel::ELEMENTS.each do |element| klass.add_need_initialize_variable(element) klass.add_other_element(element) - klass.__send__(:attr_accessor, element) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_accessor :#{element} def setup_#{element}(rss, current) if #{element} and current.respond_to?(:#{element}=) current.#{element} = @#{element} if @#{element} diff --git a/lib/rss/maker/dublincore.rb b/lib/rss/maker/dublincore.rb index 29da1c39d9..e038378329 100644 --- a/lib/rss/maker/dublincore.rb +++ b/lib/rss/maker/dublincore.rb @@ -18,8 +18,8 @@ module RSS klass.add_need_initialize_variable(full_plural_name, "make_#{full_plural_name}") klass.add_other_element(full_plural_name) - klass.__send__(:attr_accessor, full_plural_name) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_accessor :#{full_plural_name} def make_#{full_plural_name} #{full_plural_klass_name}.new(@maker) end diff --git a/lib/rss/maker/image.rb b/lib/rss/maker/image.rb index 9e3772f09c..85d9d9c95e 100644 --- a/lib/rss/maker/image.rb +++ b/lib/rss/maker/image.rb @@ -11,8 +11,8 @@ module RSS name = "#{RSS::IMAGE_PREFIX}_item" klass.add_need_initialize_variable(name, "make_#{name}") klass.add_other_element(name) - klass.__send__(:attr_reader, name) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_reader :#{name} def setup_#{name}(rss, current) if @#{name} @#{name}.to_rss(rss, current) @@ -52,8 +52,8 @@ EOC name = "#{RSS::IMAGE_PREFIX}_favicon" klass.add_need_initialize_variable(name, "make_#{name}") klass.add_other_element(name) - klass.__send__(:attr_reader, name) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_reader :#{name} def setup_#{name}(rss, current) if @#{name} @#{name}.to_rss(rss, current) diff --git a/lib/rss/maker/syndication.rb b/lib/rss/maker/syndication.rb index 72d00c63ea..3717086257 100644 --- a/lib/rss/maker/syndication.rb +++ b/lib/rss/maker/syndication.rb @@ -10,8 +10,8 @@ module RSS ::RSS::SyndicationModel::ELEMENTS.each do |element| klass.add_need_initialize_variable(element) klass.add_other_element(element) - klass.__send__(:attr_accessor, element) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_accessor :#{element} def setup_#{element}(rss, current) if #{element} and current.respond_to?(:#{element}=) current.#{element} = @#{element} if @#{element} diff --git a/lib/rss/maker/trackback.rb b/lib/rss/maker/trackback.rb index 3df21924dd..b334079582 100644 --- a/lib/rss/maker/trackback.rb +++ b/lib/rss/maker/trackback.rb @@ -11,8 +11,8 @@ module RSS name = "#{RSS::TRACKBACK_PREFIX}_ping" klass.add_need_initialize_variable(name) klass.add_other_element(name) - klass.__send__(:attr_accessor, name) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_accessor :#{name} def setup_#{name}(rss, current) if #{name} and current.respond_to?(:#{name}=) current.#{name} = #{name} @@ -23,8 +23,8 @@ module RSS name = "#{RSS::TRACKBACK_PREFIX}_abouts" klass.add_need_initialize_variable(name, "make_#{name}") klass.add_other_element(name) - klass.__send__(:attr_accessor, name) - klass.module_eval(<<-EOC, __FILE__, __LINE__) + klass.module_eval(<<-EOC, __FILE__, __LINE__+1) + attr_accessor :#{name} def make_#{name} self.class::TrackBackAbouts.new(self) end diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb index df268da1e7..6b3fe06419 100644 --- a/lib/rss/parser.rb +++ b/lib/rss/parser.rb @@ -409,7 +409,7 @@ module RSS next_element.do_validate = @do_validate prefix = "" prefix << "#{klass.required_prefix}_" if klass.required_prefix - previous.__send__(:set_next_element, prefix, tag_name, next_element) + previous.instance_eval {set_next_element(prefix, tag_name, next_element)} @last_element = next_element @proc_stack.push Proc.new { |text, tags| p(@last_element.class) if DEBUG diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb index c200f8956a..0d3da8b51a 100644 --- a/lib/rss/rss.rb +++ b/lib/rss/rss.rb @@ -659,7 +659,7 @@ EOC if parent.respond_to?(plural_name) target = parent.__send__(plural_name) __send__(plural_name).each do |elem| - elem.__send__("setup_maker", target) + elem.setup_maker(target) end end end diff --git a/lib/rss/trackback.rb b/lib/rss/trackback.rb index 973a1035d1..6c083504ae 100644 --- a/lib/rss/trackback.rb +++ b/lib/rss/trackback.rb @@ -38,7 +38,7 @@ module RSS super unless klass.class == Module - klass.__send__(:include, TrackBackUtils) + klass.module_eval {include TrackBackUtils} %w(ping).each do |name| var_name = "#{TRACKBACK_PREFIX}_#{name}" diff --git a/lib/soap/mapping/mapping.rb b/lib/soap/mapping/mapping.rb index 626df8c82f..cc0e6ff9da 100644 --- a/lib/soap/mapping/mapping.rb +++ b/lib/soap/mapping/mapping.rb @@ -254,7 +254,7 @@ module Mapping def self.define_singleton_method(obj, name, &block) sclass = (class << obj; self; end) - sclass.__send__(:define_method, name, &block) + sclass.class_eval {define_method(name, &block)} end def self.get_attribute(obj, attr_name) diff --git a/lib/soap/rpc/driver.rb b/lib/soap/rpc/driver.rb index cb10ed92b5..096a54f01a 100644 --- a/lib/soap/rpc/driver.rb +++ b/lib/soap/rpc/driver.rb @@ -26,13 +26,14 @@ class Driver if RUBY_VERSION >= "1.7.0" def __attr_proxy(symbol, assignable = false) name = symbol.to_s - self.__send__(:define_method, name, proc { + define_method(name) { @proxy.__send__(name) - }) + } if assignable - self.__send__(:define_method, name + '=', proc { |rhs| - @proxy.__send__(name + '=', rhs) - }) + aname = name + '=' + define_method(aname) { |rhs| + @proxy.__send__(aname, rhs) + } end end else diff --git a/lib/soap/wsdlDriver.rb b/lib/soap/wsdlDriver.rb index 3431d5d673..edd069e4f6 100644 --- a/lib/soap/wsdlDriver.rb +++ b/lib/soap/wsdlDriver.rb @@ -159,13 +159,14 @@ class WSDLDriver if RUBY_VERSION >= "1.7.0" def __attr_proxy(symbol, assignable = false) name = symbol.to_s - self.__send__(:define_method, name, proc { + define_method(name) { @servant.__send__(name) - }) + } if assignable - self.__send__(:define_method, name + '=', proc { |rhs| - @servant.__send__(name + '=', rhs) - }) + aname = name + '=' + define_method(aname) { |rhs| + @servant.__send__(aname, rhs) + } end end else diff --git a/lib/wsdl/xmlSchema/attribute.rb b/lib/wsdl/xmlSchema/attribute.rb index cfd4c68422..c82bd13bde 100644 --- a/lib/wsdl/xmlSchema/attribute.rb +++ b/lib/wsdl/xmlSchema/attribute.rb @@ -18,10 +18,11 @@ class Attribute < Info if RUBY_VERSION > "1.7.0" def attr_reader_ref(symbol) name = symbol.to_s - self.__send__(:define_method, name, proc { - instance_variable_get("@#{name}") || + iv = "@#{name}" + define_method(name) { + instance_variable_get(iv) || (refelement ? refelement.__send__(name) : nil) - }) + } end else def attr_reader_ref(symbol) diff --git a/lib/wsdl/xmlSchema/element.rb b/lib/wsdl/xmlSchema/element.rb index 584afe9dc6..4a144cd522 100644 --- a/lib/wsdl/xmlSchema/element.rb +++ b/lib/wsdl/xmlSchema/element.rb @@ -18,10 +18,11 @@ class Element < Info if RUBY_VERSION > "1.7.0" def attr_reader_ref(symbol) name = symbol.to_s - self.__send__(:define_method, name, proc { - instance_variable_get("@#{name}") || + iv = "@#{name}" + define_method(name) { + instance_variable_get(iv) || (refelement ? refelement.__send__(name) : nil) - }) + } end else def attr_reader_ref(symbol)