1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib: do not use __send__ to access private methods. [ruby-dev:26935]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-09-02 14:53:02 +00:00
parent c6cdbda54f
commit cd5c822ac8
15 changed files with 47 additions and 41 deletions

View file

@ -1,8 +1,10 @@
Fri Sep 2 23:51:08 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Sep 2 23:51:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <matz@ruby-lang.org>
* eval.c (rb_call0): wrong condition for $SAFE restoration.

View file

@ -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
#

View file

@ -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}

View file

@ -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

View file

@ -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)

View file

@ -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}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}"

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)