2011/10/16 Schwab,Wilhelm K <
[hidden email]>:
> Hello all,
>
> I have some classes that started out as place holders to allow me to load code I wrote for Dolphin, and over time, have become almost useful :) One thing I really needed was a contiguous array of doubles; there is a LOT of code that uses them. Enter ExternalArray with many subclasses, most of which translate #at: and #at:put: into appropriate methods of ByteArray (#doubleAt:put:, etc.).
>
> The numbers end up being stored in a byte array, so the indexing looks at position and element size. Access is very slow, but most of the time, I simply allocate a block of memory (e.g. create a byte array, which is fast) and then pass it to an external C/C++ function to do the real work.
>
> The passing is the subject of this message. I end up (for FFI) describing the arguments as void*, passing the byte array to the function. Is there a way to tell FFI that an instance of DOUBLEArray can be treated as a double*?
>
> Bill
>
>
>
>
Just a warning: beware of alignment. ByteArray are 4-byte aligned,
some libraries might require double * to be 8-byte aligned.
See
http://smallissimo.blogspot.com/2011/08/smallapack-progress-on-squeak.htmlOtherwise, there is no problem for declaring a double * or a float *,
see how it is used in
http://www.squeaksource.com/SmallapackThe problem I did not resolve is to pass an array of structures other
than with void *...
Nicolas