[squeak-dev] Re: FFI to call Mac Carbon functions
Bert Freudenberg
bert at freudenbergs.de
Fri May 20 14:10:03 UTC 2011
On 20.05.2011, at 10:09, Igor Stasenko wrote:
> On 20 May 2011 02:26, Sean P. DeNigris <sean at clipperadams.com> wrote:
>>
>> Levente Uzonyi-2 wrote:
>>>
>>> You don't have to implement C structs which you won't use in Squeak, just
>>> pass around various C functions. In this case you can declare them as
>>> void* and their class will be ExternalData.
>>>
>>
>> Thanks Levente. I tried the above with a Foundation function, with no
>> success:
>>
>> After I put a link to the Foundation lib in the VM's Resources folder, I
>> compiled:
>>
>> CarbonFunctions>>NSMakeRectWithX: xFloat y: yFloat w: widthFloat h: hFloat
>> <apicall: void* 'NSMakeRect' (float float float float) module:
>> 'Foundation'>
>> ^self externalCallFailed
>>
>> DoIt:
>> CarbonFunctions
>> NSMakeRectWithX: 0.0
>> y: 0.0
>> w: 100.0
>> h: 100.0.
>>
>> Error: Unable to find function address
Seems broken. On the interpreter VM (4.2.5) I can't even call libc functions. 2 of the FFI tests fail.
On Cog (r2348), all tests are green, libc examples work, and I can call some Carbon functions (from the 'ApplicationServices' module, no linking necessary. Not sure if NS* functions are supposed to work.
> Btw, make sure that the lib you are using is 32bit.
MacOS uses fat binaries, so that's no problem:
cd /System/Library/Frameworks/Foundation.framework
file Foundation
Foundation: Mach-O universal binary with 3 architectures
Foundation (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
Foundation (for architecture i386): Mach-O dynamically linked shared library i386
Foundation (for architecture ppc7400): Mach-O dynamically linked shared library ppc
- Bert -
More information about the Squeak-dev
mailing list
|