Demo FFI

Hi all,

I've published libffidemo on Github, https://github.com/PierceNg/libffidemo,
and DemoFFI on STH, http://smalltalkhub.com/#!/~PierceNg/DemoFFI.

Together, they show how to use Pharo 5's Unified FFI to obtain an "opaque"
pointer to a C-level struct, in the two usual styles: passing in a pointer
pointer as a parameter, and via a pointer returned by a C function.

They also show how to retrieve an integer through the opaque pointer in two
usual styles: passing in a pointer to integer as a parameter, which involves
creating an integer value holder on the Smalltalk side, and via an integer
returned by a C function.

Apart from that, the library does nothing. :-)

To compile libffidemo for Pharo's use:

  $ gcc -shared -m32 -o libffidemo.so libffidemo.c

I wrote these to figure out how to port NBSQLite3 from NativeBoost to the new
FFI. I hope others will find them helpful too. 

Pierce
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: