I am using FFI in MacOSX, I simple create a framework in XCode then move the framework xxx.framework to /System/Library/Frameworks , this is a workaround because the other more correct locations: /Library/Frameworks or ~/Library/Frameworks are not working with the current VM.
In Squeak you define (for example):
macCallWith: ba with: res <cdecl: long 'testVF' (VFExternalStructure* VFExternalStructure*) module:'vftest.framework'> ^self externalCallFailed
Where VFExternalStructure is for example a subclass of ExternalData (or the other classes defined in FFI-Kernel).
Then call with (more examples): ba _ ByteArray new: 3456 withAll: 0. res _ ByteArray new: 2800 withAll: 0. [init data, etc...] pba _ VFExternalStructure fromHandle: ba type: ExternalType char. pres _ VFExternalStructure fromHandle: res type: ExternalType char. pBuff _ self macCallWith: pba with: pres.
This example is using ByteArrays (char* in C) you need to change with the other types of (external) data.
On 10/06/2004, at 11:02, Diego Tiscornia wrote:
John M McIntosh writes:
I'm sure I read somewhere is that the function call we make to get the address for a function name doesn't care if it's a bundle or dylib, or something. It does the right thing to resolve the address.
On Jun 9, 2004, at 10:28 PM, diego bart wrote:
In order to test I wrote a small example and compiled it both .bundle and .dylib following apple examples. I get the message "cannot find function address".I can use them from C via the NS way (bundle) and linking to a dylib, but cant get sq to find the symbols :(
Hi thank you for answering.
I already had SqueakFFIPrims.bundle. I think it came with the Carbon version, and the FFI examples work, but I can't get anything else to work with it :( I think I would get the "no function callout mechanism available" (or similar) exception hadn't I gotten the lib, at least this is what happens when you delete it.
Anyway I just in case downloaded the version you mentioned, but it doesnt work either :(
Javier Diaz-Reinoso Web: http://homepage.mac.com/javier_diaz_r/