[squeak-dev] FFI | How to declare pointer to external structure in #fields?

Vanessa Freudenberg vanessa at codefrau.net
Mon May 18 21:45:28 UTC 2020


On Mon, May 18, 2020 at 12:28 PM Levente Uzonyi <leves at caesar.elte.hu>
wrote:

> Hi Marcel,
>
> On Mon, 18 May 2020, Marcel Taeumel wrote:
>
> > Hi, there!
> >
> > In the #fields method of a new ExternalStructure, how can I express a
> pointer to another external structure?
> >
> > First, non-pointer works as expected:
> > ^ #( (other MyStruct) )
> >
> > Second, this just treats it as a void*, which returns a generic
> ExternalData:
> > ^ #( (other 'MyStruct*') )
>
> This is how it should be written. Does MyStruct exist when you're writing
> this method? If yes, is there a refence to that class in ExternalType's
> StructTypes class variable?
>
> Levente
>


This is the correct answer. I missed the 'treats it as a void*' part.

The current FFI is very low-level. It tries to do as little magic as
possible, meaning it may be necessary to still manually write a lot of the
necessary accessors.

Also, we do not have a good story for 32/64 bits yet, I think. The same FFI
code is unlikely to work on both.

- Vanessa -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200518/010899b8/attachment.html>


More information about the Squeak-dev mailing list