FFI Callbacks

Alejandro F. Reimondo aleReimondo at smalltalking.net
Fri Sep 1 13:16:05 UTC 2006


> See, it's only four steps. How hard could it possibly be? ;-)
Fine!
Now we are ready to add the point number 5.

5.- it must be realized in 100% smalltalk.
e.g. included in FFI services to be understood
 by squeak users (with at least one example of use).

One point to be considered is that "functions" on smalltalk
 side are full messages (including a receiver) and
 not compiled methods, because each callback instance
 must be managed by a particular receiver.

best,
Ale.


----- Original Message ----- 
From: "Andreas Raab" <andreas.raab at gmx.de>
To: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>
Sent: Thursday, August 31, 2006 10:57 PM
Subject: Re: FFI Callbacks


> Ron Teitelbaum wrote:
> > A quick question, if callbacks are supported by the VM, and a plug-in
can be
> > written to handle callbacks couldn't someone (notice I didn't say "I" or
> > "WE" hoping maybe one of the VM gurus would consider it) combine those
> > features to write a generalized callback framework that would be
available
> > to the image?  For example it would define the function name return
value
> > and parameters, just like FFI but maybe be called <apicallback: ...>.
Then
> > that callback could be invoked within a semaphore on a separate thread.
>
> Yes. That is basically what I meant when I said "you need to pop the
> arguments from the C stack". What you have to do goes somewhat along the
> lines of the following:
> 1. Set up a pool of callback functions that are varargs based. This
> avoids the need to generate callbacks stubs (which may be preferrable on
> some platforms but it doesn't matter). These functions need to "put
> away" the stack pointer for the image to use, signal an FFI semaphore
> and callback into the interpreter.
> 2. When the callback is picked up in the image, the image needs to call
> a set of support functions to take the arguments correctly from the
> stack. This would be based on some ffi spec.
> 3. Once all the arguments are picked up, you run your callback code.
> 4. To return, you need to call another set of support functions for
> storing the return value and return from the callback.
>
> See, it's only four steps. How hard could it possibly be? ;-)
>
> Cheers,
>    - Andreas
>




More information about the Squeak-dev mailing list