[squeak-dev] FFI type for 'char[12]'?

Beckmann, Tom Tom.Beckmann at student.hpi.uni-potsdam.de
Sat Sep 19 06:15:05 UTC 2020


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 <squeak-dev-bounces at lists.squeakfoundation.org> on behalf of Eliot Miranda <eliot.miranda at gmail.com>
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 <Tom.Beckmann at student.hpi.uni-potsdam.de<mailto:Tom.Beckmann at student.hpi.uni-potsdam.de>> 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 <squeak-dev-bounces at lists.squeakfoundation.org<mailto:squeak-dev-bounces at lists.squeakfoundation.org>> 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 <tonyg at leastfixedpoint.com<mailto:tonyg at leastfixedpoint.com>>:

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FFIExternalArrayType.1.cs
Type: text/x-csharp
Size: 4076 bytes
Desc: FFIExternalArrayType.1.cs
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200919/66f4b15e/attachment.bin>


More information about the Squeak-dev mailing list