[squeak-dev] Passing array of float from Squeak to C

Ang Beepeng beepeng86 at yahoo.com
Mon Mar 2 06:58:54 UTC 2009


Thanks for the help. The plugin works fine now. 

Here's another problem I'm facing. How can I get value in double from
ByteArray for the interpreter simulation? ByteArray is referred by
CArrayAccessor.

Here's one thing I learned. We can use 
useBigEndian := SmalltalkImage current isBigEndian.
instead of setting it manually. 

Thank you so much. 

Ang Beepeng



Joshua Gargus-2 wrote:
> 
> You would pass in a ByteArray.  You can populate the ByteArray like this:
> 
> ba := ByteArray new: 8 * 3.  "3 is number of elements"
> useBigEndian := true.  "or false, depending on what kind of machine you
> are on"
> ba doubleAt: 1 put: 1.0 bigEndian: useBigEndian.
> ba doubleAt: 9 put: 4.55555555 bigEndian: useBigEndian.
> ba doubleAt: 17 put: 3.0001 bigEndian: useBigEndian.
> someObj primitiveDoSomethingWithDoubles: ba
> 
> 
> Your primitive would need to get a pointer to the actual data in the
> ByteArray (see senders of #firstIndexableField:), and cast it to
> (double*).
> 
> Hope this helps,
> Josh
> 
> 

-- 
View this message in context: http://www.nabble.com/Passing-array-of-float-from-Squeak-to-C-tp22166581p22283049.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.




More information about the Squeak-dev mailing list