-
Notifications
You must be signed in to change notification settings - Fork 157
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
Call a function pointer #31
Comments
Directly? Not really. But I think you have at least two options:
Do you think this is a feature we should lift up to jnr-ffi? |
Oh, absolutely! This is the scenario I'm facing: I'm trying to implement an SPI for a filesystem in Java. The Java method receives a C callback -- a visitor -- which it should then invoke for each file in a directory. AFAIK, JNA has this feature, too. |
+1, very important feature. Also, function pointer and structures as closure parameters would be very useful. |
+1. I am developing a virtual machine which exposes a JNI-like interface, where the C native program receives a struct (like The desired JNR interface should be similar to Closure, albeit it is Java calling C rather than C calling back to Java. The callee is a stateless C function rather than an object-bound Java method, so it should be easier to implement. |
I don't think we've made any progress on this, but it's probably still useful. Anyone want to bring this issue back to life and try to come up with a good API for this? |
I think it's useful, How to implement this kind of callback? https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
setopt(CurlOption.CURLOPT_HEADERFUNCTION, headerHandler);
setopt(CurlOption.CURLOPT_WRITEFUNCTION, contentHandler); |
It seems unlikely that you can't already do this in jnr-ffi via some combination of APIs. Are we simply missing a nice endpoint that says "give me a callable wrapper around this C function pointer? |
I think someone has made such an API here. |
I'm interested by this functionality as well. Is there a better way to accomplish this now? If not, I'll look at |
Is there a way to invoke a function pointer received from C code?
The text was updated successfully, but these errors were encountered: