Skip to content

Improve Fiddle::Pointer#inspect for FFI backend #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2025

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Apr 19, 2025

p Fiddle::Pointer.new(1)

CRuby

#<Fiddle::Pointer:0x0000600000983240 ptr=0x0000000000000001 size=0 free=0x0000000000000000>

JRuby before

#<Fiddle::Pointer ptr=1 size=9223372036854775807 free=nil>

JRuby after

#<Fiddle::Pointer ptr=0x0000000000000001 size=9223372036854775807 free=0x0000000000000000>

Note: size is incorrect for JRuby, which is not addressed with this PR

@ankane ankane force-pushed the ffi-backend-inspect branch from a4257ee to cb7c6ca Compare April 19, 2025 23:30
@kou kou merged commit 582f443 into ruby:master Apr 21, 2025
62 of 66 checks passed
@ankane
Copy link
Contributor Author

ankane commented Apr 21, 2025

Thanks @kou

kou added a commit that referenced this pull request Apr 22, 2025
This PR makes the pointer size consistent between backends. Follow up to
#179.

```ruby
require "fiddle"

ptr = Fiddle::Pointer.new(0)
p ptr.size
p ptr.ref.size

ptr = Fiddle::Pointer["hello world"]
ptr.size = 0
p ptr.to_s
p ptr.to_str
```

JRuby + TruffleRuby before

```text
9223372036854775807
8
""
""
```

CRuby + JRuby + TruffleRuby after

```text
0
0
"hello world"
""
```

---------

Co-authored-by: Sutou Kouhei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants