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

* lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct

backtrace.  [ruby-dev:34019]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-03-11 08:03:26 +00:00
parent 1c411796ef
commit c0667c0187
2 changed files with 12 additions and 9 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 11 17:03:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
backtrace. [ruby-dev:34019]
Tue Mar 11 16:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Mar 11 16:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (rb_w32_cmdvector): terminate shrunken command line. * win32/win32.c (rb_w32_cmdvector): terminate shrunken command line.

View file

@ -115,6 +115,7 @@
# implementation, see SimpleDelegator. # implementation, see SimpleDelegator.
# #
class Delegator class Delegator
IgnoreBacktracePat = %r"\A#{Regexp.quote(__FILE__)}:\d+:in `"
# #
# Pass in the _obj_ to delegate method calls to. All methods supported by # Pass in the _obj_ to delegate method calls to. All methods supported by
@ -133,14 +134,12 @@ class Delegator
for method in obj.methods for method in obj.methods
next if preserved.include? method next if preserved.include? method
begin begin
eval <<-EOS eval <<-EOS, nil, __FILE__, __LINE__+1
def self.#{method}(*args, &block) def self.#{method}(*args, &block)
begin begin
__getobj__.__send__(:#{method}, *args, &block) __getobj__.__send__(:#{method}, *args, &block)
rescue Exception ensure
$@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` $@.delete_if{|s|IgnoreBacktracePat=~s}
$@.delete_if{|s| /^\\(eval\\):/ =~ s}
Kernel::raise
end end
end end
EOS EOS
@ -291,13 +290,12 @@ def DelegateClass(superclass)
} }
for method in methods for method in methods
begin begin
klass.module_eval <<-EOS klass.module_eval <<-EOS, __FILE__, __LINE__+1
def #{method}(*args, &block) def #{method}(*args, &block)
begin begin
@_dc_obj.__send__(:#{method}, *args, &block) @_dc_obj.__send__(:#{method}, *args, &block)
rescue ensure
$@[0,2] = nil $@.delete_if{|s| ::Delegator::IgnoreBacktracePat =~ s}
raise
end end
end end
EOS EOS