Commits

Ronald Oussoren  committed a9fbdd6

CFTypeRef tweaks

* CF classes are seen in ObjC as subclasses of NSCFType on older OSX releases,
and of a number of those classes on OSX 10.8.

Adjust the code for calculating the __name__ of CF class proxies and
the testsuite for this.

  • Participants
  • Parent commits a056ecd

Comments (0)

Files changed (2)

File pyobjc-core/Lib/PyObjCTools/TestSupport.py

     return onlyIf(os_release() <= release)
 
 _poolclass = objc.lookUpClass('NSAutoreleasePool')
-_nscftype = objc.lookUpClass('NSCFType')
+
+# NOTE: On at least OSX 10.8 there are multiple proxy classes for CFTypeRef...
+_nscftype = tuple(cls for cls in objc.getClassList() if 'NSCFType' in cls.__name__)
 
 _typealias = {}
 

File pyobjc-core/Modules/objc/objc-class.m

 
 	if (cls) {
 		const char* nm = class_getName(cls);
-		if (strcmp(nm, "NSCFType") == 0) {
+		if (strstr(nm, "NSCFType") != NULL) {
 			return PyText_FromFormat(
 				"<core-foundation class %s at %p>", 
 				((PyTypeObject*)obj)->tp_name, (void*)cls);
 		return PyText_FromString("objc.objc_class");
 	} else {
 		const char* nm = class_getName(cls);
-		if (strcmp(nm, "NSCFType") == 0) {
+		if (strstr(nm, "NSCFType") != NULL) {
 			return PyText_FromString(((PyTypeObject*)self)->tp_name);
 		} else {
 			return PyText_FromString(nm);