* lib/pp.rb (PP::PPMethods#guard_inspect_key): support

__recursive_key__.  [ruby-dev:25821]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2005-03-09 14:56:16 +00:00
Родитель 827a62edd7
Коммит 7935361d36
2 изменённых файлов: 19 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Wed Mar 9 23:55:34 2005 Tanaka Akira <akr@m17n.org>
* lib/pp.rb (PP::PPMethods#guard_inspect_key): support
__recursive_key__. [ruby-dev:25821]
Wed Mar 9 19:42:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ssl.c: OpenSSL::SSL::SSLContexts suports callbacks:

Просмотреть файл

@ -91,31 +91,35 @@ class PP < PrettyPrint
end
module PPMethods
InspectKey = :__inspect_key__
def guard_inspect_key
if Thread.current[InspectKey] == nil
Thread.current[InspectKey] = {inspect: []}
if Thread.current[:__recursive_key__] == nil
Thread.current[:__recursive_key__] = {}
end
save = Thread.current[InspectKey][:inspect]
if Thread.current[:__recursive_key__][:inspect] == nil
Thread.current[:__recursive_key__][:inspect] = []
end
save = Thread.current[:__recursive_key__][:inspect]
begin
Thread.current[InspectKey][:inspect] = []
Thread.current[:__recursive_key__][:inspect] = []
yield
ensure
Thread.current[InspectKey][:inspect] = save
Thread.current[:__recursive_key__][:inspect] = save
end
end
def check_inspect_key(id)
Thread.current[InspectKey][:inspect].include?(id)
Thread.current[:__recursive_key__] &&
Thread.current[:__recursive_key__][:inspect] &&
Thread.current[:__recursive_key__][:inspect].include?(id)
end
def push_inspect_key(id)
Thread.current[InspectKey][:inspect] << id
Thread.current[:__recursive_key__][:inspect] << id
end
def pop_inspect_key
Thread.current[InspectKey][:inspect].pop
Thread.current[:__recursive_key__][:inspect].pop
end
# Adds +obj+ to the pretty printing buffer