Re: [Pyobjc-dev] Bridging NS and CF classes
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-01-10 04:18:47
|
On Thursday, Jan 9, 2003, at 17:24 US/Eastern, Jack Jansen wrote: > But that doesn't really matter: the PyObjC code could look at the type > of the Python object and pass any CoreFoundation object as the > corresponding NS object still. Ideally, we could automatically determine that there is a representation of the given object / type ref on the other side of the bridge. Two separate problems -- end result, a single message to return the 'other' type. Two slightly different problems, I think. I have asked if there is a transparent way of determining if a particular type/object is bridged on cocoa-dev. Hopefully, someone there will cough up a clean and easy solution. :-) NS -> CF: NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSArray array]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSDictionary dictionary]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSMutableArray array]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSBundle mainBundle]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSUserDefaults standardUserDefaults]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([[NSObject alloc] init]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([[NSSet alloc] init]))); NSLog(@"%@", CFCopyTypeIDDescription(CFGetTypeID([NSNotificationCenter defaultCenter]))); ... spews ... 2003-01-09 22:17:26.077 asdfasdf[1835] CFArray 2003-01-09 22:17:26.079 asdfasdf[1835] CFDictionary 2003-01-09 22:17:26.079 asdfasdf[1835] CFArray 2003-01-09 22:17:26.142 asdfasdf[1835] CFType 2003-01-09 22:17:26.143 asdfasdf[1835] CFType 2003-01-09 22:17:26.143 asdfasdf[1835] CFType 2003-01-09 22:17:26.143 asdfasdf[1835] CFSet 2003-01-09 22:17:26.143 asdfasdf[1835] CFType ... and, as such, it appears that there is some potential to automate the test. The 'conversion' method doesn't do any converting. It simply does: - (CFTypeRef) cfTypeRef { if (.. test encapsulated object for CFness ..) return encapsulatedObject; else return nil; } I'm not going to pretend to speak for Ronald regarding adding a method to all Python encapsulated ObjC objects.... CF -> NS: Jack covered this in his message -- if all CF types inherit from a common base, then implementing a method that returns ref or nil, depending on if it is bridged. b.bum |