Skip to content

Commit 61d7023

Browse files
committed
Show the FFI pointer size information if it's available when inpecting the object.
1 parent 36a602c commit 61d7023

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Compatibility:
3737
* Add `rb_syserr_new` function (@rwstauner).
3838
* Add `Enumerator#product` (#3039, @itarato).
3939
* Add `Module#const_added` (#3039, @itarato).
40+
* Show the pointer size information (if available) in `FFI::Pointer#inspect` (@nirvdrum).
4041

4142
Performance:
4243

src/main/ruby/truffleruby/core/truffle/ffi/pointer.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ def inspect
9898
sign = ''
9999
end
100100

101-
"#<#{Primitive.class(self).name} address=#{sign}0x#{addr.to_s(16)}>"
101+
size = Primitive.pointer_size(self)
102+
if size != UNBOUNDED
103+
"#<#{Primitive.class(self).name} address=#{sign}0x#{addr.to_s(16)} size=#{size}>"
104+
else
105+
"#<#{Primitive.class(self).name} address=#{sign}0x#{addr.to_s(16)}>"
106+
end
102107
end
103108

104109
def null?

0 commit comments

Comments
 (0)