[fix] Problem with ByteArray and FFI??

Avi Bryant avi at beta4.com
Mon Apr 28 18:16:19 UTC 2003


On Mon, 28 Apr 2003, Chris Muller wrote:

> > 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.
>
> I'd love to see this be made non-platform dependent, and also for it to be
> pluggable with arbitrary bit-sizes, as maUint:at:, and maUint:at:put: are.  If
> this were done, Magma would probably run quite faster.  :-)

I think we've been over this before.  The *point* of those FFI methods is
to be platform dependent.  This is crucial when you are working with data
coming from the host OS, and you don't know whether it's little-endian or
big-endian.  That's why they're in the "external access" category on
ByteArray.  They're generally useless if you're not using FFI, since you
can't predict from platform to platform which endianness they'll use - so
having them in the FFI plugin makes perfect sense.  I'm not sure if he is,
but if Chris is using these to serialize objects then Magma database files
won't work across architectures.

There is a separate "platform independent" category that does not require
FFI, and that lets you explicitly choose whether you want little or big
endian.  This is what you should use for network protocols or
serialization.  The methods are, eg,

#longAt:bigEndian:
#longAt:put:bigEndian:
#shortAt:bigEndian:
etc

Cheers,
Avi



More information about the Squeak-dev mailing list