[M3devel] Interfacing to OSX Core Foundation classes
Dragiša Durić
dragisha at m3w.org
Sun Mar 17 16:24:55 CET 2013
My problem did not involve Objective-C, just C API's, CoreFoundation and Security were involved. I took only what I needed.
Your Carbon interface is welcome - I would like to learn more about topic, as I never know when I will need it. I like to be prepared! :)
Thanks in advance,
dd
--
Divided by a common language
Dragiša Durić
dragisha at m3w.org
On Mar 17, 2013, at 4:05 PM, Darko wrote:
> But what about creating objects and calling methods, or whatever they're called in Objective-C?
>
> Also be aware if you want to use any structures from the older interfaces and Carbon they have byte alignment and must be declared specially. I have an interface file for most Carbon stuff, but it's a bit large at 3.2MB (~500KB compressed). I can mail it if you need it.
>
>
> On Mar 17, 2013, at 7:12 AM, Dragiša Durić wrote:
>
>> After a hint from Anthony, and a share of mining, mostly due to being first-time OSX Doc Miner :), here comes result. Example code:
>>
>> == CoureFoundation.i3 ==
>> INTERFACE CoreFoundation;
>>
>> IMPORT Ctypes;
>>
>> TYPE
>> TypeRef = ADDRESS;
>> DataRef = ADDRESS;
>> AllocatorRef = ADDRESS;
>> Index = Ctypes.long_int;
>>
>> <* EXTERNAL CFRelease *>
>> PROCEDURE Release(cf: TypeRef);
>>
>> <* EXTERNAL CFDataCreate *>
>> PROCEDURE DataCreate(allocator: AllocatorRef; bytes: Ctypes.void_star; length: Index): DataRef;
>>
>> (* Not exactly CF, but I can split later, if need be to grow this
>> *)
>>
>> END CoreFoundation.
>> == m3makefile ==
>> …
>> proc use_framework(FW) is
>> configure_c_compiler()
>> SYSTEM_CC = SYSTEM_CC & " -framework " & FW
>> end
>>
>> if equal(TARGET, "AMD64_DARWIN")
>> use_framework("CoreFoundation")
>> use_framework("Security")
>> ...
>> ===
>>
>> I named things like this so I can "IMPORT CoreFoundation AS CF" later and use names like CF.Release().
>>
>> Hope it saves few hours to somebody else :).
>> --
>> Divided by a common language
>>
>> Dragiša Durić
>> dragisha at m3w.org
>>
>>
>>
>>
>> On Mar 17, 2013, at 3:37 AM, Antony Hosking wrote:
>>
>>> Should be simple addresses.
>>>
>>>
>>> On Mar 16, 2013, at 6:34 PM, Dragiša Durić <dragisha at m3w.org> wrote:
>>>
>>>> To resolve an issue with a project, I need to wrap few functions from Security framework on OSX Lion. I have no experience on this level with OSX programming.
>>>>
>>>> I did a lot of such work on Linux and Windows, and all I needed there is to match signatures of functions, structure of types, and refer m3makefile to right libraries. Also, I did similar work for various non-framework libraries on OSX, and it is Unix all the way.
>>>>
>>>> Anyone with CF/framework related experience? Do I need some special voodoo for handling various CF opaque objects or they are simple addresses?
>>>>
>>>> TIA,
>>>> dd
>>>>
>>>> --
>>>> Divided by a common language
>>>>
>>>> Dragiša Durić
>>>> dragisha at m3w.org
>>>>
>>>>
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130317/68577763/attachment-0002.html>
More information about the M3devel
mailing list