Sorry, I sent it with the wrong subject. Here I go again:<br><br><div class="gmail_quote">On Wed, May 13, 2009 at 3:41 PM, Ricardo Moran <span dir="ltr"><<a href="mailto:richi.moran@gmail.com">richi.moran@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>Thanks for the reply, Mariano! I tried your advice but I ended up with some "Could not coerce arguments" errors and crashing the VM several times :P. </div>
<div>However, I tried something like this:</div>
<div><br></div><div>IplImage>>free</div><div>SqueakCV apiReleaseImage: handle asByteArrayPointer.<br></div><div><br></div><div><div>SqueakCV>>apiReleaseImage: doublePointer </div><div><span style="white-space:pre">        </span><apicall: void 'cvReleaseImage' (byte*) module: 'cxcore110.dll'></div>
<div><span style="white-space:pre">        </span>^ self externalCallFailed</div></div><div><br></div><div><br></div><div>It appears to be working. I don't know if this is the right way to do it, though. I don't know either if overriding #free is ok and it would not bring problems later...</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="font-family:Arial;font-size:16px"><pre style="font-family:monospace;margin-left:3em;font-size:90%">
><i> 2) To finalize objects the OpenCV library defines some functions such
</i>><i> as cvReleaseImage, cvReleaseMat, etc. As far as I can tell, these functions
</i>><i> receive a pointer-to-pointer as argument. How can I declare such a method in
</i>><i> Squeak? Having one object, how can I get the pointer to that object? Should
</i>><i> I use the #getHandle method?
</i>><i>
</i>
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</pre></span></blockquote></div><br>
</blockquote></div><br>