plugin vs FFI

Martin McClure martin at hand2mouse.com
Sat Feb 21 18:09:21 UTC 2004


Douglas McPherson wrote:
> Thanks for the info. Reading the admonitions about FFI  at the link 
> below, I suspect that an external plugin is what I really want.
> 
> I need to call out from Squeak to an external library of functions 
> written in C, and I need to share data with these functions. The calls 
> will all be synchronous, so I don't need to worry about callbacks. Is an 
> external plugin, accessed by 'named primitive', the best way to do do 
> this? I am running MacOSX 10.3.2, but will later run also on Win or 
> various unixen. Which Mac VM is best/easiest to use in this case?
> 

I've used both external plugins and FFI. If the external C library is 
already complete, I'd use FFI unless you're making thousands of library 
calls per second.

I started my FFI work on MacOS X, backported to MacOS 9, ported to 
Windows, and plan to port to Linux. I'm interfacing with 
platform-dependent video input routines, so different FFI calls are 
required for each platform. I found it a lot easier to build the common 
abstraction layer in Smalltalk than to do it in C.

I'd start with whichever platform has C debugging tools you feel the 
most comfortable with, though I managed to get my FFI stuff working with 
very few trips into the debugger. (The "if it blew up, check your type 
definitions and try again" school of debugging.)

hth,

-Martin




More information about the Squeak-dev mailing list