Changeset 95675 in webkit
- Timestamp:
- Sep 21, 2011 3:41:11 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95673 r95675 1 2011-09-21 Anders Carlsson <andersca@apple.com> 2 3 Remove checks for Leopard-only Objective-C APIs 4 https://bugs.webkit.org/show_bug.cgi?id=68579 5 6 Reviewed by Sam Weinig. 7 8 We can always assume that OBJC_API_VERSION is at least 2, it's been 2 since Leopard. 9 10 * bridge/objc/objc_class.mm: 11 (JSC::Bindings::ObjcClass::methodsNamed): 12 (JSC::Bindings::ObjcClass::fieldNamed): 13 * bridge/objc/objc_instance.mm: 14 (allocateAutoReleasePool): 15 * bridge/objc/objc_runtime.mm: 16 (JSC::Bindings::ObjcField::ObjcField): 17 * page/mac/EventHandlerMac.mm: 18 1 19 2011-09-21 Anders Carlsson <andersca@apple.com> 2 20 -
trunk/Source/WebCore/bridge/objc/objc_class.mm
r91903 r95675 97 97 ClassStructPtr thisClass = _isa; 98 98 while (thisClass && methodList.isEmpty()) { 99 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2100 99 unsigned numMethodsInClass = 0; 101 100 MethodStructPtr* objcMethodList = class_copyMethodList(thisClass, &numMethodsInClass); 102 #else 103 void* iterator = 0; 104 struct objc_method_list* objcMethodList; 105 while ((objcMethodList = class_nextMethodList(thisClass, &iterator))) { 106 unsigned numMethodsInClass = objcMethodList->method_count; 107 #endif 108 for (unsigned i = 0; i < numMethodsInClass; i++) { 109 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 110 MethodStructPtr objcMethod = objcMethodList[i]; 111 SEL objcMethodSelector = method_getName(objcMethod); 112 #else 113 struct objc_method* objcMethod = &objcMethodList->method_list[i]; 114 SEL objcMethodSelector = objcMethod->method_name; 115 #endif 116 const char* objcMethodSelectorName = sel_getName(objcMethodSelector); 117 NSString* mappedName = nil; 118 119 // See if the class wants to exclude the selector from visibility in JavaScript. 120 if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)]) 121 if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector]) 122 continue; 123 124 // See if the class want to provide a different name for the selector in JavaScript. 125 // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity 126 // of the class. 127 if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)]) 128 mappedName = [thisClass webScriptNameForSelector:objcMethodSelector]; 129 130 if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) { 131 Method* aMethod = new ObjcMethod(thisClass, objcMethodSelector); // deleted when the dictionary is destroyed 132 CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod); 133 methodList.append(aMethod); 134 break; 135 } 101 for (unsigned i = 0; i < numMethodsInClass; i++) { 102 MethodStructPtr objcMethod = objcMethodList[i]; 103 SEL objcMethodSelector = method_getName(objcMethod); 104 const char* objcMethodSelectorName = sel_getName(objcMethodSelector); 105 NSString* mappedName = nil; 106 107 // See if the class wants to exclude the selector from visibility in JavaScript. 108 if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)]) 109 if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector]) 110 continue; 111 112 // See if the class want to provide a different name for the selector in JavaScript. 113 // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity 114 // of the class. 115 if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)]) 116 mappedName = [thisClass webScriptNameForSelector:objcMethodSelector]; 117 118 if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) { 119 Method* aMethod = new ObjcMethod(thisClass, objcMethodSelector); // deleted when the dictionary is destroyed 120 CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod); 121 methodList.append(aMethod); 122 break; 136 123 } 137 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2138 thisClass = class_getSuperclass(thisClass);139 free(objcMethodList);140 #else141 124 } 142 thisClass = thisClass->super_class;143 #endif 125 thisClass = class_getSuperclass(thisClass); 126 free(objcMethodList); 144 127 } 145 128 … … 192 175 193 176 while (thisClass) { 194 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2195 177 unsigned numFieldsInClass = 0; 196 178 IvarStructPtr* ivarsInClass = class_copyIvarList(thisClass, &numFieldsInClass); 197 #else 198 struct objc_ivar_list* fieldsInClass = thisClass->ivars; 199 if (fieldsInClass) { 200 unsigned numFieldsInClass = fieldsInClass->ivar_count; 201 #endif 202 for (unsigned i = 0; i < numFieldsInClass; i++) { 203 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 204 IvarStructPtr objcIVar = ivarsInClass[i]; 205 const char* objcIvarName = ivar_getName(objcIVar); 206 #else 207 IvarStructPtr objcIVar = &fieldsInClass->ivar_list[i]; 208 const char* objcIvarName = objcIVar->ivar_name; 209 #endif 210 NSString* mappedName = 0; 211 212 // See if the class wants to exclude the selector from visibility in JavaScript. 213 if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)]) 214 if ([thisClass isKeyExcludedFromWebScript:objcIvarName]) 215 continue; 216 217 // See if the class want to provide a different name for the selector in JavaScript. 218 // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity 219 // of the class. 220 if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)]) 221 mappedName = [thisClass webScriptNameForKey:objcIvarName]; 222 223 if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, jsName.data()) == 0) { 224 aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed 225 CFDictionaryAddValue(_fields.get(), fieldName.get(), aField); 226 break; 227 } 179 180 for (unsigned i = 0; i < numFieldsInClass; i++) { 181 IvarStructPtr objcIVar = ivarsInClass[i]; 182 const char* objcIvarName = ivar_getName(objcIVar); 183 NSString* mappedName = 0; 184 185 // See if the class wants to exclude the selector from visibility in JavaScript. 186 if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)]) 187 if ([thisClass isKeyExcludedFromWebScript:objcIvarName]) 188 continue; 189 190 // See if the class want to provide a different name for the selector in JavaScript. 191 // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity 192 // of the class. 193 if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)]) 194 mappedName = [thisClass webScriptNameForKey:objcIvarName]; 195 196 if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, jsName.data()) == 0) { 197 aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed 198 CFDictionaryAddValue(_fields.get(), fieldName.get(), aField); 199 break; 228 200 } 229 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 201 } 202 230 203 thisClass = class_getSuperclass(thisClass); 231 204 free(ivarsInClass); 232 #else233 }234 thisClass = thisClass->super_class;235 #endif236 205 } 237 206 } -
trunk/Source/WebCore/bridge/objc/objc_instance.mm
r95250 r95675 131 131 static NSAutoreleasePool* allocateAutoReleasePool() 132 132 { 133 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2134 133 // If GC is enabled an autorelease pool is unnecessary, and the 135 134 // pool cannot be protected from GC so may be collected leading … … 137 136 if (objc_collectingEnabled()) 138 137 return nil; 139 #endif 138 140 139 return [[NSAutoreleasePool alloc] init]; 141 140 } -
trunk/Source/WebCore/bridge/objc/objc_runtime.mm
r94875 r95675 77 77 ObjcField::ObjcField(Ivar ivar) 78 78 : _ivar(ivar) 79 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 280 79 , _name(AdoptCF, CFStringCreateWithCString(0, ivar_getName(_ivar), kCFStringEncodingASCII)) 81 #else82 , _name(AdoptCF, CFStringCreateWithCString(0, _ivar->ivar_name, kCFStringEncodingASCII))83 #endif84 80 { 85 81 } -
trunk/Source/WebCore/page/mac/EventHandlerMac.mm
r95673 r95675 52 52 #include <wtf/MainThread.h> 53 53 #include <wtf/StdLibExtras.h> 54 55 #if !(defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0)56 static inline IMP method_setImplementation(Method m, IMP i)57 {58 IMP oi = m->method_imp;59 m->method_imp = i;60 return oi;61 }62 #endif63 54 64 55 namespace WebCore { -
trunk/Source/WebKit/mac/ChangeLog
r95604 r95675 1 2011-09-21 Anders Carlsson <andersca@apple.com> 2 3 Remove checks for Leopard-only Objective-C APIs 4 https://bugs.webkit.org/show_bug.cgi?id=68579 5 6 Reviewed by Sam Weinig. 7 8 We can always assume that OBJC_API_VERSION is at least 2, it's been 2 since Leopard. 9 10 * Misc/WebNSObjectExtras.h: 11 1 12 2011-09-21 Andras Becsi <andras.becsi@nokia.com> 2 13 -
trunk/Source/WebKit/mac/Misc/WebNSObjectExtras.h
r62872 r95675 43 43 } 44 44 45 #if !(defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0)46 47 static inline IMP method_setImplementation(Method m, IMP i)48 {49 IMP oi = m->method_imp;50 m->method_imp = i;51 return oi;52 }53 54 #endif55 56 45 @interface NSObject (WebNSObjectExtras) 57 46 + (id)_webkit_invokeOnMainThread;
Note: See TracChangeset
for help on using the changeset viewer.