Skip to content
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

Fiddle::Function returns FFI::Pointer instead of Fiddle::Pointer #4510

Closed
danini-the-panini opened this issue Feb 25, 2017 · 6 comments
Closed

Comments

@danini-the-panini
Copy link
Contributor

Environment

  • JRuby version: 9.1.8.0-SNAPSHOT
  • Operating System: Mac OS X 10.11.6

Expected Behavior

code:

require 'fiddle'
libc = Fiddle.dlopen('/usr/lib/libc.dylib')
f = Fiddle::Function.new(libc['strcpy'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP)
buff = "000"
str = f.call(buff, "123")

MRI:

str.to_s
#=> "123"

Actual Behavior

JRuby:

str.to_s
#=> "#<FFI::Pointer address=0x7000003137a0>"
@headius
Copy link
Member

headius commented Mar 1, 2017

Ok, I merged your PR, and thanks again for that.

This issue is a bit trickier, since it's trying to let FFI classes masquerade as Fiddle classes. The call for the Fiddle::Function gets bound directly to the call of the FFI::Function, so unsurprisingly it returns an FFI::Pointer. I think we need to rework this to wrap the FFI::Function rather than binding it directly to call, so we can produce an appropriate Fiddle type on the way out.

@headius
Copy link
Member

headius commented Mar 1, 2017

No time to work on this for 9.1.8.0 but with your help we'd like to fix it for 9.1.9.0 or 9.2 (whichever comes first).

@danini-the-panini
Copy link
Contributor Author

@headius I've made a PR to fix this into your Fiddle Fixes branch here: headius#2

@headius
Copy link
Member

headius commented Jul 9, 2020

The PR in question was merged, so hopefully this was fixed around the same time.

@headius headius closed this as completed Jul 9, 2020
@headius headius added this to the JRuby 9.1.8.0 milestone Jul 9, 2020
@danini-the-panini
Copy link
Contributor Author

@headius I believe it was merged into your fork of JRuby, not sure if the changes made it into this repo?

@danini-the-panini
Copy link
Contributor Author

Okay it looks like this commit fixed the issue: 366f9f1
Not mine but it does the same thing 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants