This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: Function Callbacks?
On Thu, Feb 7, 2013 at 9:29 AM, The Devils Jester
<thedevilsjester@gmail.com> wrote:
> I use libffi because I do not know the details of a particular
> function at compile time. libffi lets me programatically
> collect/generate the needed data and call a function with this data,
> which can all be collected from an external source.
>
> If one of these details happens to be a function call back, which also
> has its details (return type, arguments, etc...) unknown at compile
> time (and in fact, most likely doesn't even exist), how can I
> 'properly' interact with this function if I have to react to a call to
> its 'callback'?
>
> Does libffi have a way to achieve this?
If I understand you right, I think what you are trying to accomplish
can be done with a libffi closure object. You would pass the closure
pointer as an argument to your first function. The closure callback
would then decode the arguments based on a runtime defined function
definition and handle things appropriately.
AG