From ee852ed46d1a2a0f894e20e939b079c31e1cdb4b Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 28 Jun 2002 08:55:10 +0000 Subject: lib/pp.rb: fix object address. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/pp.rb | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07a15d3c66..1d2b4b5b61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jun 28 17:54:07 2002 Tanaka Akira + + * lib/pp.rb: fix object address. + Thu Jun 27 23:55:50 2002 NAKAMURA Usaku * win32/win32.c (rb_w32_stat): fix buffer overflow. (ruby-bugs:PR#329) diff --git a/lib/pp.rb b/lib/pp.rb index 0c7e6b3bcc..699291c24a 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -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 -- cgit v1.2.3