[M3devel] Interfacing to OSX Core Foundation classes
Dragiša Durić
dragisha at m3w.org
Sun Mar 17 15:12:07 CET 2013
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/501fc274/attachment-0002.html>
More information about the M3devel
mailing list