[fix] Problem with ByteArray and FFI??

Michael van der Gulik mikevdg at hetnet.nl
Sat Apr 26 10:46:02 UTC 2003


Michael van der Gulik wrote:

> I found and fixed my first bug!! :-). Squeak is kind of addictive, 
> isn't it. I'll work out how to submit things properly later.
>
> "MaFilename>>upTo:" appends the pathDelimiter (see the source) too 
> early. If you only specify the filename without a path, it 
> automatically prefixes a "/" to the filename, which is wrong.

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.

Michael.





More information about the Squeak-dev mailing list