[Ann] DemoFFI

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

[Ann] DemoFFI

Pierce Ng-3
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

Reply | Threaded
Open this post in threaded view
|

Re: [Ann] DemoFFI

Stephan Eggermont-3
On 08-03-16 15:20, Pierce Ng wrote:
> I wrote these to figure out how to port NBSQLite3 from NativeBoost to the new
> FFI. I hope others will find them helpful too.
Thanks, Pierce. I find this kind of demos very helpful.

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: [Ann] DemoFFI

stepharo
In reply to this post by Pierce Ng-3
Thanks.
It would be good to use that in the documentation that esteban started
to write.

Stef

Le 8/3/16 15:20, Pierce Ng a écrit :

> 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