[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Implementing CFSTR() in corebase
From: |
Vincent R. |
Subject: |
Re: Implementing CFSTR() in corebase |
Date: |
Fri, 22 Jan 2010 23:26:34 +0100 |
User-agent: |
RoundCube Webmail/0.2 |
On Fri, 22 Jan 2010 13:26:00 -0700, Eric Wasylishen
<address@hidden>
wrote:
> On 2010-01-22, at 9:53 AM, David Chisnall wrote:
>
>> Hi Stef,
>>
>> I had this discussion with Eric yesterday, so good timing...
>>
>> On OS X, CSTR() calls one of two functions.
>>
>
> Hi,
> On a related note, regarding Opal, David and I decided that Opal should
> just use Foundation directly (internally). The main reasons are:
>
> - There is no way (with the public API of CoreFoundation) to create new
> CoreFoundation types . The CG objects need to respond to -[retain] and
> -[release], as well as CFRetain(), and the other CF functions available
for
> all CF types, so they really have to be instances of NSObject
subclasses.
> - We need constant Obj-C/CF strings - it sounds like it is best to just
> use @"...".
>
> Initially I was interested in making Opal independent of Foundation, and
> able to work with Apple's CF or CFLite, but now I think it's not worth
the
> effort.
>
Hum Wait. This is exactly what I am working on windows. I have compiled
CoreFoundationLite and now I implement
CoreGraphics with openVG/cairo backend.
First idea was also to be able to use Objective-C but when I read all your
stuff I think it's far too complicated
so I am happy to have a CoreFoundation/Coregraphics writtent in plain C.
However I don't understand your sentence : "There is no way (with the
public API of CoreFoundation) to create new
CoreFoundation types"...
What do you mean ?
For instance my CGContext is implemented as shown below :
static CFRuntimeClass CGContextClass =
{
0, // version
"CGContext", // className
0, // init
0, // copy
CGContextFinalize, // finalize
0, // equal
0, // hash
0, // copyFormattingDesc
0 // copyDebugDesc
};
CFTypeID __kCGContextID = _kCFRuntimeNotATypeID;
CFTypeID CGContextGetTypeID(void)
{
return CGTypeRegisterWithCallbacks(&__kCGContextID, &CGContextClass);
}
CFTypeID CGTypeRegisterWithCallbacks(CFTypeID* typeID, CFRuntimeClass*
rtclass)
{
CFTypeID id;
if (*typeID != _kCFRuntimeNotATypeID) { return *typeID; }
id = _CFRuntimeRegisterClass(rtclass);
*typeID = id;
return id;
}
CFTypeRef CGTypeCreateInstance(CFTypeID id, CFIndex size)
{
return CGTypeCreateInstanceWithAllocator(0, id, size);
}
CFTypeRef CGTypeCreateInstanceWithAllocator(CFAllocatorRef allocator,
CFTypeID id, CFIndex size)
{
CFTypeRef type;
CFRuntimeClass* rtc;
char* ptr;
/* Create the CFType */
//
type = _CFRuntimeCreateInstance(allocator, id, size, NULL);
CHK(type);
///* Init with zero values all fields except our base object */
ptr = (char*)type;
memset((void*)(ptr + sizeof(CFRuntimeBase)), 0, size);
return type;
Cleanup:
return NULL;
}
Re: Implementing CFSTR() in corebase, Richard Frith-Macdonald, 2010/01/22