mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
eb5ea93c7c
commit
ee852ed46d
2 changed files with 15 additions and 7 deletions
|
@ -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>
|
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)
|
* win32/win32.c (rb_w32_stat): fix buffer overflow. (ruby-bugs:PR#329)
|
||||||
|
|
18
lib/pp.rb
18
lib/pp.rb
|
@ -77,7 +77,7 @@ PP#pp to print the object.
|
||||||
returns the sharing detection flag as boolean value.
|
returns the sharing detection flag as boolean value.
|
||||||
It is false by default.
|
It is false by default.
|
||||||
|
|
||||||
--- PP.sharing_detection = value
|
--- PP.sharing_detection = boolean_value
|
||||||
sets the sharing detection flag.
|
sets the sharing detection flag.
|
||||||
|
|
||||||
== methods
|
== methods
|
||||||
|
@ -195,14 +195,17 @@ class PP < PrettyPrint
|
||||||
group(1, '#<' + obj.class.name, '>', &block)
|
group(1, '#<' + obj.class.name, '>', &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def object_address_group(obj, &block)
|
||||||
|
group(1, sprintf('#<%s:0x%x', obj.class.name, obj.__id__ * 2), '>', &block)
|
||||||
|
end
|
||||||
|
|
||||||
def comma_breakable
|
def comma_breakable
|
||||||
text ','
|
text ','
|
||||||
breakable
|
breakable
|
||||||
end
|
end
|
||||||
|
|
||||||
def pp_object(obj)
|
def pp_object(obj)
|
||||||
object_group(obj) {
|
object_address_group(obj) {
|
||||||
text sprintf(':0x%x', obj.__id__)
|
|
||||||
obj.pretty_print_instance_variables.each {|v|
|
obj.pretty_print_instance_variables.each {|v|
|
||||||
v = v.to_s if Symbol === v
|
v = v.to_s if Symbol === v
|
||||||
text ',' unless first?
|
text ',' unless first?
|
||||||
|
@ -244,7 +247,7 @@ class PP < PrettyPrint
|
||||||
# specific pretty_print is not defined, try specific inspect.
|
# specific pretty_print is not defined, try specific inspect.
|
||||||
begin
|
begin
|
||||||
old = Thread.current[Key]
|
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]
|
Thread.current[Key] = [pp, result1]
|
||||||
result2 = ObjectMixin.pp_call_inspect(self)
|
result2 = ObjectMixin.pp_call_inspect(self)
|
||||||
ensure
|
ensure
|
||||||
|
@ -271,9 +274,10 @@ class PP < PrettyPrint
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_print_cycled(pp)
|
def pretty_print_cycled(pp)
|
||||||
pp.text sprintf("#<%s:0x%x", self.class.name, self.__id__)
|
pp.object_address_group(self) {
|
||||||
pp.breakable
|
pp.breakable
|
||||||
pp.text sprintf("...>")
|
pp.text '...'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_print_instance_variables
|
def pretty_print_instance_variables
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue