[M3devel] Interfacing to OSX Core Foundation classes

Darko darko at darko.org
Sun Mar 17 16:05:57 CET 2013


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/bc73f8b1/attachment-0001.html>


More information about the M3devel mailing list