Using a c struct with FFI

Ivo Rössling iroess at cs.uni-magdeburg.de
Wed May 21 14:47:27 UTC 2003


Hi, Emeric!

> However, we need to use external c structures. We tried to make 
> subclasses
> of ExternalStructure as in X11 exemples provided by FFI but we didn't
> manage to do it. Can someone help us and give us the correct syntax ? 

I'd suggest you to have a look closer look into the category FFI-FFI-Plugin.

There you'll find for example the classes FFITestPoint2 and FFITestPoint4
- which are test-classes representing 2- & 4-dimensional points. Both
classes
are derived from ExternalStructure.

All you have to do for your subclass is to define fields the same way it is
done there:
---------- snip ----------
fields
    "FFITestPoint2 defineFields"
    ^ #(#(#x 'long') #(#y 'long') )
---------- snap ----------

Another small example can be found at the bottom of the "How To Use FFI"
at http://minnow.cc.gatech.edu/squeak/2426.

Cheers,
Ivo.

P.S.: If you want to test those FFI-Classes declared in category
FFI-FFI-Plugin,
or in one of the FFI-FFI-Examples-[...] categories, you might also need the
SqueakFFIPrims.so for your respective platform in addition to the libffi
which
you already should have installed...
Have a look at: http://wwwisg.cs.uni-magdeburg.de/~raab/squeak/FFI/







More information about the Squeak-dev mailing list