Hallo everyone,
we currently try to integrate a C libary into Squeak. It uses callbacks and I tried to find some information about callbacks in Squeak. It seems, that callbacks are supported in the Squeak VM. But my problem is, that I found no examples which show me in detail how to use them. I only found this post from Andrea Raab: 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. Maybe someone can help me ? Best regards Conrad |
I am also interested into this. If you got a private answer please
let me know. Alexandre On 10 Dec 2007, at 12:50, Conrad Pöpke wrote: > Hallo everyone, > > we currently try to integrate a C libary into Squeak. It uses > callbacks and I tried to find some information about callbacks in > Squeak. It seems, that callbacks are supported in the Squeak VM. > But my problem is, that I found no examples which show me in detail > how to use them. > > I only found this post from Andrea Raab: > 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. > > Maybe someone can help me ? > > Best regards > Conrad > > > -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. |
Hi Alexandre,
got no answer until now, I was hoping that Andreas Raab would answer. I send Andreas a copy, maybe he answers ;-) I googled a little bit about callbacks and Squeak and found these links: http://www.nabble.com/Callbacks%2C-simplified.-tf3294768.html#a9165431 - synchron callbacks http://www.nabble.com/Updated-callbacks-tf3294849.html#a9165690 http://www.nabble.com/Callbacks-%28sigh-%3A-%29-tf1076074.html#a2801345 - someone used asynchron callbacks http://www.nabble.com/FFI-Callbacks-tf2200056.html#a6090814 - discussion about the implementation of callbacks and a short description of how to implement them It seems that some people built in callbacks with semaphores, but I have no clue how they do it. http://lists.squeakfoundation.org/pipermail/vm-dev/2006-June/000748.html - Andreas Raabe posted change sets for the vm to integrate callbacks I applied this change sets and tried to build an own vm with callback support. It didn't work. I think my image and the HEAD revision of the Squeak vm repository are to new. Reading the dev list links, I think it is possible to integrate callback support in an own vm. It would be nice to see callback support in the default vm, I think many plugins could use it. Best regards Conrad Bergel, Alexandre schrieb: > I am also interested into this. If you got a private answer please let > me know. > > Alexandre > > > On 10 Dec 2007, at 12:50, Conrad Pöpke wrote: > >> Hallo everyone, >> >> we currently try to integrate a C libary into Squeak. It uses >> callbacks and I tried to find some information about callbacks in >> Squeak. It seems, that callbacks are supported in the Squeak VM. But >> my problem is, that I found no examples which show me in detail how >> to use them. >> >> I only found this post from Andrea Raab: >> 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. >> >> Maybe someone can help me ? >> >> Best regards >> Conrad >> >> >> > |
On Sat, Dec 15, 2007 at 03:06:28PM +0100, Conrad P?pke wrote:
> > I googled a little bit about callbacks and Squeak and found these links: > http://www.nabble.com/Callbacks%2C-simplified.-tf3294768.html#a9165431 - > synchron callbacks > http://www.nabble.com/Updated-callbacks-tf3294849.html#a9165690 > http://www.nabble.com/Callbacks-%28sigh-%3A-%29-tf1076074.html#a2801345 > - someone used asynchron callbacks > http://www.nabble.com/FFI-Callbacks-tf2200056.html#a6090814 - discussion > about the implementation of callbacks and a short description of how to > implement them > > It seems that some people built in callbacks with semaphores, but I have > no clue how they do it. Conrad, The basic idea is to have the plugin signal a semaphore using InterpreterProxy>>signalSemaphoreWithIndex:. This will refer to a semaphore in the Squeak image that has been registered as an "external object" with SystemDictionary>>registerExternalObject:. You can then set up a process in the image that waits on the semaphore, and does things whenever the plugin signals the semaphore. This sort of callback does not send any data back to the image, it just provides the notification mechanism to tell the image that something must be done. Of course you have have different semaphores corresponding to different kinds of events to be handled, and you can have your plugin provide primitives for getting at whatever data you might want to pass back to the image. Sockets use this mechanism, and if you happen to have OSProcess loaded, take a look at class AioEventHandler for an example that does nothing more than set up the semaphore and listener process for a specific external IO event. The corresponding plugin methods are found in AioPlugin (on SqueakMap). Dave |
Free forum by Nabble | Edit this page |