[fix] Problem with ByteArray and FFI??

David T. Lewis lewis at mail.msen.com
Sat Apr 26 14:36:25 UTC 2003


On Tue, Jan 01, 2002 at 08:49:45PM +0100, Michael van der Gulik wrote:
> Michael van der Gulik wrote:
> 
> Next error: a failed primitive.
> 
> Magma extends the ByteArray class a bit -  maUint:at: and maUint:at:put: 
> fail quite readily. This is because they call 
> ByteArray>>integerAt:put:size:signed: which is a <primitive: 
> 'primitiveFFIIntegerAtPut' module:'SqueakFFIPrims'>. And I don't have a 
> working FFI on my system.
> 
> Luckily, the problem is easy to fix: ByteArray>>maUint:at and 
> maUint:at:put both have handy (big-endian?) alternative implementations 
> at the end of the function. Commenting out the first part of these 
> methods works quite nicely.. I think. Untested, but it doesn't crash and 
> burn this time.
> 
> A question remains: something like ByteArray>>integerAt:.... seems like 
> fairly basic functionality. Why aren't these just "normal" primitives, 
> or at least compiled into core Squeak instead of in the FFI (which I 
> assume to be the Foreign Function Interface). FFI is platform dependant.

Good question. The ByteArray>>integerAt:put:signed: method is one of
several methods in category "external access". These methods are all
dependent on FFI (they are actually part of the FFI support code). This
is probably clear enough to anyone who is writing something in Squeak
that uses these methods, but it's not so clear to a user of the code
when it does not work due to a missing FFI plugin. I don't know the
"right" way to address this but perhaps changing the method category
to something like "external access - FFI" would help to communicate
the intention of these methods.

I suspect that better-informed Squeakers may be able to suggest solutions
involving exception handling or Squeak modularization.

Dave



More information about the Squeak-dev mailing list