gnustep-dev
[Top][All Lists]
Advanced

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

Re: Changes in base


From: Stef Bidi
Subject: Re: Changes in base
Date: Sat, 13 Mar 2010 12:58:35 -0600

 I really was missing that point, most because I did not know that was the case!  Let me make sure I got this right, are all non-toll-free bridged CF classes also a __NSCFType?  If that's the case, it works for me.

I guess that patch is invalid.

Stefan

On Sat, Mar 13, 2010 at 12:22 PM, David Chisnall <address@hidden> wrote:
Hi Stef,

I believe you are missing something important here.  Although some CoreFoundation types are not toll-free bridged with specific Objective-C classes, they are all __attribute__((NSObject)) and all implement (at least some of) the NSObject protocol.  You can send -retain / -release to all of them, including things like CFSocket that are not toll-free bridged:

$ cat cf.m
#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>

int main(void)
{
       CFSocketRef s = CFSocketCreate(NULL, 0, 0, 0, 0, 0, 0);
       printf("%d\n", (int)CFGetRetainCount(s));
       [(id)s retain];
       printf("%d\n", (int)CFGetRetainCount(s));
       printf("%d\n", (int)[(id)s retainCount]);
       NSLog(@"%@", s);
       NSLog(@"%@", [(id)s class]);
       return 0;
}
Liberator:tmp theraven$ gcc -framework Cocoa cf.m && ./a.out
2
3
3
2010-03-13 18:20:07.933 a.out[44021:903] <CFSocket 0x100111290 [0x7fff704fbf20]>{valid = Yes, type = 1, socket = 3, socket set count = 0,
   callback types = 0x0, callout = ??? (0x0), source = 0x0,
   run loops = <CFArray 0x100111360 [0x7fff704fbf20]>{type = mutable-small, count = 0, values = ()},
   context = <CFSocket context 0x0>}
2010-03-13 18:20:07.978 a.out[44021:903] __NSCFType


As you can see, the object responds to -retainCount, -retain, -description and -class.  It will also respond to things like -hash - you can store all CoreFoundation types in Objective-C collection classes (they are also Core Foundation collection types) transparently, for example.

David

reply via email to

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