Squeak Callbacks support

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Squeak Callbacks support

KiranMutt
Hello:

I am working at interfacing an external C library ( static/dynamic ), in that context wanted to know,
whether  Squeak supports callbacks and any examples on using the same is highly appreciated.

Thanks & Regards
Kiran
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Squeak Callbacks support

Philipp Tessenow
Hello Kiran,

as far as I know the Alien FFI supports callbacks
(http://wiki.squeak.org/squeak/6100).
It looks pretty cool, but the wiki page says it supports Mac only, so if
you want callbacks in Unix or Windows you may go another way:

Fork a new process that waits on a registered semaphore ('semaIndex :=
Smalltalk registerExternalObject: (example_semaphore).').
Then write a Squeak plugin that implements the callback you need. Every
time your callback is called, signal the registered semaphore
('interpreterProxy->signalSemaphoreWithIndex(semaIndex)') so your Squeak
process can do whatever it needs to do.

See http://www.hpi.uni-potsdam.de/hirschfeld/projects/phidgetlab/ for an
example of the second way.

I hope that helps ;)

Best regards,
  Philipp


KiranMutt schrieb:

> Hello:
>
> I am working at interfacing an external C library ( static/dynamic ), in
> that context wanted to know,
> whether  Squeak supports callbacks and any examples on using the same is
> highly appreciated.
>
> Thanks & Regards
> Kiran
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Squeak Callbacks support

Eliot Miranda-2


On Sun, Jul 26, 2009 at 12:37 PM, Philipp Tessenow <[hidden email]> wrote:
Hello Kiran,

as far as I know the Alien FFI supports callbacks
(http://wiki.squeak.org/squeak/6100).
It looks pretty cool, but the wiki page says it supports Mac only,

That's incorrect.  Alien supports x86 only.
 
so if
you want callbacks in Unix or Windows you may go another way:

Fork a new process that waits on a registered semaphore ('semaIndex :=
Smalltalk registerExternalObject: (example_semaphore).').
Then write a Squeak plugin that implements the callback you need. Every
time your callback is called, signal the registered semaphore
('interpreterProxy->signalSemaphoreWithIndex(semaIndex)') so your Squeak
process can do whatever it needs to do.

See http://www.hpi.uni-potsdam.de/hirschfeld/projects/phidgetlab/ for an
example of the second way.

I hope that helps ;)

Best regards,
 Philipp


KiranMutt schrieb:
> Hello:
>
> I am working at interfacing an external C library ( static/dynamic ), in
> that context wanted to know,
> whether  Squeak supports callbacks and any examples on using the same is
> highly appreciated.
>
> Thanks & Regards
> Kiran
>