[squeak-dev] Questions regarding FFI
Mariano Martinez Peck
marianopeck at gmail.com
Wed May 13 13:48:23 UTC 2009
> 2) To finalize objects the OpenCV library defines some functions such
> as cvReleaseImage, cvReleaseMat, etc. As far as I can tell, these functions
> receive a pointer-to-pointer as argument. How can I declare such a method in
> Squeak? Having one object, how can I get the pointer to that object? Should
> I use the #getHandle method?
>
In OpenDBX we have a functions like this for example:
long odbx_init(odbx_t**, char*, char*, char*)
This is how I declare it:
apiInitialize: handle backend: backend host: host port: port
<cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'>
^self externalCallFailed
Remember a pinter to a pointer is a long :)
And then in the code I do something like this:
handleArray := WordArray with: 0.
err := OpenDBX current
apiInitialize: handleArray
backend: self backend
host: aConnection settings host
port: aConnection settings port.
Notice the WordArray.
I have no idea of 1) and 3) sorry.
I hope this helps. If this do help, perhaps we can put it in FFI wiki page.
Cheers,
Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090513/2cff5251/attachment.htm
More information about the Squeak-dev
mailing list
|