lib/pp.rb: fix object address.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2002-06-28 08:55:10 +00:00
Родитель eb5ea93c7c
Коммит ee852ed46d
2 изменённых файлов: 15 добавлений и 7 удалений

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

@ -1,3 +1,7 @@
Fri Jun 28 17:54:07 2002 Tanaka Akira <akr@m17n.org>
* lib/pp.rb: fix object address.
Thu Jun 27 23:55:50 2002 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_stat): fix buffer overflow. (ruby-bugs:PR#329)

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

@ -77,7 +77,7 @@ PP#pp to print the object.
returns the sharing detection flag as boolean value.
It is false by default.
--- PP.sharing_detection = value
--- PP.sharing_detection = boolean_value
sets the sharing detection flag.
== methods
@ -195,14 +195,17 @@ class PP < PrettyPrint
group(1, '#<' + obj.class.name, '>', &block)
end
def object_address_group(obj, &block)
group(1, sprintf('#<%s:0x%x', obj.class.name, obj.__id__ * 2), '>', &block)
end
def comma_breakable
text ','
breakable
end
def pp_object(obj)
object_group(obj) {
text sprintf(':0x%x', obj.__id__)
object_address_group(obj) {
obj.pretty_print_instance_variables.each {|v|
v = v.to_s if Symbol === v
text ',' unless first?
@ -244,7 +247,7 @@ class PP < PrettyPrint
# specific pretty_print is not defined, try specific inspect.
begin
old = Thread.current[Key]
result1 = sprintf('#<%s:0x%x pretty_printed>', self.class.name, self.__id__)
result1 = sprintf('#<%s:0x%x pretty_printed>', self.class.name, self.__id__ * 2)
Thread.current[Key] = [pp, result1]
result2 = ObjectMixin.pp_call_inspect(self)
ensure
@ -271,9 +274,10 @@ class PP < PrettyPrint
end
def pretty_print_cycled(pp)
pp.text sprintf("#<%s:0x%x", self.class.name, self.__id__)
pp.breakable
pp.text sprintf("...>")
pp.object_address_group(self) {
pp.breakable
pp.text '...'
}
end
def pretty_print_instance_variables