[squeak-dev] FFI | How to declare pointer to external structure in #fields?
Tobias Pape
Das.Linux at gmx.de
Tue May 19 08:43:53 UTC 2020
> On 19.05.2020, at 10:24, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
>
> > 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. :-)
only if you name it struct tho…
% c99 -o ms.o -c ms.c
ms.c:2:2: error: must use 'struct' tag to refer to type 'MyStruct'
MyStruct *foobar;
^
struct
;P
But actually, yes, you're right.
But are you sure about the thing 'mystruct' is? I assume #( (other 'struct MyStruct*') ) is nothing FFI is fond of, is it?
Best regards
-Tobias
>
> 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
>> >> >
>> >> >
>> >>
>> >
>>
>>
>>
>
More information about the Squeak-dev
mailing list
|