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

Marcel Taeumel marcel.taeumel at hpi.de
Tue May 19 08:24:06 UTC 2020


> If you have control over the source, try this:

Well, that recursive definition through pointers still valid in C, right? So it should be supported in Squeak's FFI. :-)

Best,
Marcel
Am 19.05.2020 09:52:57 schrieb Tobias Pape <das.linux at gmx.de>:

> On 19.05.2020, at 08:46, Marcel Taeumel wrote:
>
> Hi Levente.
>
> > Does MyStruct exist when you're writing this method?
>
> Yes.
>
> > If yes, is there a refence to that class in ExternalType's StructTypes class variable?
>
> Yes.
>
> **
>
> The issue was that I wanted to make a pointer to the struct I am currently (re-)defining:
>

> struct MyStruct {
> MyStruct *foobar;
> };

If you have control over the source, try this:

typedef struct s_MyStruct MyStruct;
typedef MyStruct* pMyStruct;
struct s_MyStruct {
pMyStruct *foobar;
};

-t


>
> Works fine when pointing to other structs. Should code generation work for this case? :-)
>
> Best,
> Marcel
>> Am 18.05.2020 21:28:49 schrieb Levente Uzonyi :
>>
>> 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
>>
>> >
>> > Third, this gives me a debugger:
>> > ^ #( (other MyStruct *) )
>> >
>> > :-)
>> >
>> > Best,
>> > Marcel
>> >
>> >
>>
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200519/84d837fd/attachment-0001.html>


More information about the Squeak-dev mailing list