Hi all,
Is there some way in the FFI to specify that an ExternalStructure has a member whose type is like 'char x[12]'? Similarly, given some ExternalStructure Foo, can I have another structure that has a member like 'Foo x[5]'? Tony |
Hi Tony, such container types are still work-in-progress. :-/ For char[12], you can either use "string" or "char*", I suppose. "Foo x[5]" can be expressed through ExternalData, too, which would be "Foo*". Best, Marcel
|
Hi,
for ExternalStructure fields definitions I worked around this by exploding the array, as in #((str1 'char') (str2 'char') (str3 'char') (str4 'char') (str5 'char')) The same works for other ExternalTypes like Foo of course. I also have an experimental set of changes that adds an ExternalArrayType to support this, however it still has some untested corner cases. I'll investigate getting it merged to FFI soon. Best, Tom ________________________________________ From: Squeak-dev <[hidden email]> on behalf of Taeumel, Marcel Sent: Wednesday, September 16, 2020 9:58:45 AM To: squeak-dev Subject: Re: [squeak-dev] FFI type for 'char[12]'? Hi Tony, such container types are still work-in-progress. :-/ For char[12], you can either use "string" or "char*", I suppose. "Foo x[5]" can be expressed through ExternalData, too, which would be "Foo*". Best, Marcel Am 16.09.2020 09:49:20 schrieb Tony Garnock-Jones <[hidden email]>: Hi all, Is there some way in the FFI to specify that an ExternalStructure has a member whose type is like 'char x[12]'? Similarly, given some ExternalStructure Foo, can I have another structure that has a member like 'Foo x[5]'? Tony |
Thanks, Tom and Marcel.
On 9/16/20 10:11 AM, Beckmann, Tom wrote: > for ExternalStructure fields definitions I worked around this by exploding the array, as in > #((str1 'char') (str2 'char') (str3 'char') (str4 'char') (str5 'char')) Yes, this occurred to me but I ended up not doing it :-P > I also have an experimental set of changes that adds an ExternalArrayType to support this, however it still has some untested corner cases. I'll investigate getting it merged to FFI soon. The ExternalArrayType idea sounds good! Looking forward to it. For now I've just parsed the structure by hand out of a ByteArray, which works well enough until ExternalArrayType or similar lands. Regards, Tony |
In reply to this post by Beckmann, Tom
Hi Tom, On Wed, Sep 16, 2020 at 1:12 AM Beckmann, Tom <[hidden email]> wrote: Hi, It is much better to have a new facility "out in the wild" available to look at b others and test than it is to sit on something until it is perfect. Please do release it asap. Then we can all collaborate on writing tests for it (we would need tests in the FFI test suite), reviewing the code, etc.
_,,,^..^,,,_ best, Eliot |
Hi Elliot, hi all,
> It is much better to have a new facility "out in the wild" available to look at b others and test than it is to sit on something until it is perfect. Please do release it asap. Then we can all collaborate on writing tests for it (we would need tests in the FFI test suite), reviewing the code, etc. Wholeheartedly agree! The code in question was mixed with a bunch of other experiments for FFI that mostly turned out to not be interesting. I went ahead and isolated it into the attached changeset now. As of right now, it does the bare minimum required to generate accessors for returning appropriately typed ExternalData instances for arrays. It does not support type aliases and I'm sure there are some incorrectly implemented overrides in the ExternalArrayType class. To test, just add a definition like (myArray 'char[12]') to a struct's #fields and try `MyStruct new myArray at: 3`. Please feel free to take this as a base or disregard it completely :) If no one else picks the topic up in the next weeks I'll eventually get time to return to it and investigate adding fixes and tests. Best, Tom ________________________________________ From: Squeak-dev <[hidden email]> on behalf of Eliot Miranda <[hidden email]> Sent: Wednesday, September 16, 2020 5:08:24 PM To: The general-purpose Squeak developers list Subject: Re: [squeak-dev] FFI type for 'char[12]'? Hi Tom, On Wed, Sep 16, 2020 at 1:12 AM Beckmann, Tom <[hidden email]<mailto:[hidden email]>> wrote: Hi, for ExternalStructure fields definitions I worked around this by exploding the array, as in #((str1 'char') (str2 'char') (str3 'char') (str4 'char') (str5 'char')) The same works for other ExternalTypes like Foo of course. I also have an experimental set of changes that adds an ExternalArrayType to support this, however it still has some untested corner cases. I'll investigate getting it merged to FFI soon. It is much better to have a new facility "out in the wild" available to look at b others and test than it is to sit on something until it is perfect. Please do release it asap. Then we can all collaborate on writing tests for it (we would need tests in the FFI test suite), reviewing the code, etc. Best, Tom ________________________________________ From: Squeak-dev <[hidden email]<mailto:[hidden email]>> on behalf of Taeumel, Marcel Sent: Wednesday, September 16, 2020 9:58:45 AM To: squeak-dev Subject: Re: [squeak-dev] FFI type for 'char[12]'? Hi Tony, such container types are still work-in-progress. :-/ For char[12], you can either use "string" or "char*", I suppose. "Foo x[5]" can be expressed through ExternalData, too, which would be "Foo*". Best, Marcel Am 16.09.2020 09:49:20 schrieb Tony Garnock-Jones <[hidden email]<mailto:[hidden email]>>: Hi all, Is there some way in the FFI to specify that an ExternalStructure has a member whose type is like 'char x[12]'? Similarly, given some ExternalStructure Foo, can I have another structure that has a member like 'Foo x[5]'? Tony -- _,,,^..^,,,_ best, Eliot FFIExternalArrayType.1.cs (5K) Download Attachment |
Free forum by Nabble | Edit this page |