Sending doubles and long doubles to Slate.

Pupeno pupeno at pupeno.com
Fri Nov 19 22:14:03 PST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Slaters,
As some of you may know, I'm writting an FFI for Slate. I'm based on Ken 
Causey's FFI (that was very simplistic) and Lee Salsman's ExternalLibray[1].
I've managed to call functions (without any parameter) and succesfully get the 
returning value to Slate for the following types: void (well, hehehe), 
unsinged char, signed char, unsinged short, signed short, unsinged int, 
signed int, unsinged long, signed long, float, unsinged int8, signed int8, 
unsinged int16, signed int16, unsinged int32, signed int32, unsinged int64 
and signed int64[2].
I'm having troubles converting doubles and long doubles to Slate object (that 
is, I don't have a clue of how to do it, because for float, I just copied 
Lee's code and doubles and long doubles seems to be very different to 
floats).
The code I'm using is:
return PSObject_asObject((struct Object *) 
PSObjectHeap_newByteArray_from_sized_ (CurrentMemory, FloatProto, (Byte *) 
&result, sizeof(result)));
where result is the float.
Any hints as to where to look next would be appretiated.
Thank you.
- -- 
Pupeno: pupeno at pupeno.com - http://www.pupeno.com

[1] ExternalLibrary has the limitations of not being able to call functions 
with more than 12 parameters. Something that is hardcoded and was 5 before I 
extended to 12. It also can't handle any C type that is not int, float, 
pointer and a special case for pointer that is called bytes.

[2] At list on little endian platforms, extra care may be needed for big 
endian platforms, but for one thing, I only have little endian platforms at 
hand. Anyone wants to send me this: 
http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/72303/wo/vdGGLbQZg27C3BMWFfw1R6gqnVI/3.0.11.1.0.6.3 
so I can code it ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBnuCvfW48a9PWGkURAtLjAJ9D6fFLWBglZDrT/JYzhVTx7jkA0QCffYgQ
IlBQujTYLqyLFnRe0dUkO+g=
=BGz9
-----END PGP SIGNATURE-----




More information about the Slate mailing list