FFI external data
Alexander Lazarević
Alexander at Lazarevic.de
Sun Jan 11 12:27:58 UTC 2004
I'm calling a function in a shared library using FFI. One of the parameters
needs to be a pointer to an array of floats. The code below works, but I
think I missed to find something more handy to create/fill an array and get a
pointer to it?
| ctrlpoints addr data |
ctrlpoints := { -4.0. -4.0. 0.0.
-2.0. 4.0. 0.0.
2.0. -4.0. 0.0.
4.0. 4.0. 0.0 }.
data := ByteArray new: ctrlpoints size * ExternalType float byteSize.
1 to: ctrlpoints size do: [:i|
data
floatAt: ((i-1)*ExternalType float byteSize + 1)
put: (ctrlpoints at: i)].
addr := ExternalData fromHandle: data type: ExternalType float.
[...]
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 155 bytes
Desc: signature
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040111/c582154d/attachment.pgp
More information about the Squeak-dev
mailing list
|