[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreFoundation

From: Richard Frith-Macdonald
Subject: Re: CoreFoundation
Date: Sat, 24 Oct 2009 07:22:22 +0100

On 24 Oct 2009, at 02:14, Stef Bidi wrote:

On Fri, Oct 23, 2009 at 4:34 PM, David Chisnall <address@hidden> wrote:
Hi Stef,

Having an implementation of Core Foundation would be nice, but I believe your approach is wrong.

Unless you want to use CF for some very low-level stuff, then there is really no point in copying this.  You can just:

1) Define Objective-C classes that implement the CF types (many of these already exist in GNUstep).
2) Write wrapper functions that call the ObjC methods.
3) Return the address of the class as the isa pointer.

This will then work with all code that uses CF types unless they either rely on the TypeID < 2^16 thing or uses CF functions in +load or __attribute__((constructor)) functions.

Most of the CF equivalents of class methods take a CFAllocator.  You can declare this as a typedef from NSZone; they are functionally equivalent.  For a first pass, you can just implement most of the CF functions as trivial Objective-C functions, for example:

typedef NSArray *CFArrayRef;
typedef NSZone *CFAllocatorRef;

And here's where I ran into some problems... apparently, CFAllocatorRef is considered a class (responds to CFGetTypeID()), but isn't one in GNUstep.  Also, it allows users to define they're own with CFAllocatorCreate(), which takes a CFAllocatorContext.  I might just have to not allow that if this is the case.

Don't think that you have to build on top of base while leaving base untouched ... writing CF on top of base is the right thing to do, but that doesn't mean you can't modify base to make it easier ... in this case there's no reason you can't change NSZone to actually be a class rather than a struct.  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]