Remove checks for Leopard-only Objective-C APIs
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2011 22:41:11 +0000 (22:41 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2011 22:41:11 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68579

Reviewed by Sam Weinig.

We can always assume that OBJC_API_VERSION is at least 2, it's been 2 since Leopard.

../WebCore:

* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):
* bridge/objc/objc_instance.mm:
(allocateAutoReleasePool):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcField::ObjcField):
* page/mac/EventHandlerMac.mm:

../WebKit/mac:

* Misc/WebNSObjectExtras.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95675 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bridge/objc/objc_class.mm
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebNSObjectExtras.h

index 18274e8..fa4eb8a 100644 (file)
@@ -1,5 +1,23 @@
 2011-09-21  Anders Carlsson  <andersca@apple.com>
 
+        Remove checks for Leopard-only Objective-C APIs
+        https://bugs.webkit.org/show_bug.cgi?id=68579
+
+        Reviewed by Sam Weinig.
+
+        We can always assume that OBJC_API_VERSION is at least 2, it's been 2 since Leopard.
+
+        * bridge/objc/objc_class.mm:
+        (JSC::Bindings::ObjcClass::methodsNamed):
+        (JSC::Bindings::ObjcClass::fieldNamed):
+        * bridge/objc/objc_instance.mm:
+        (allocateAutoReleasePool):
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::ObjcField::ObjcField):
+        * page/mac/EventHandlerMac.mm:
+
+2011-09-21  Anders Carlsson  <andersca@apple.com>
+
         Remove Widget::beforeMouseDown and Widget::afterMouseDown
         https://bugs.webkit.org/show_bug.cgi?id=68570
 
index e4a336a..a23a06c 100644 (file)
@@ -96,51 +96,34 @@ MethodList ObjcClass::methodsNamed(const Identifier& identifier, Instance*) cons
 
     ClassStructPtr thisClass = _isa;
     while (thisClass && methodList.isEmpty()) {
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
         unsigned numMethodsInClass = 0;
         MethodStructPtr* objcMethodList = class_copyMethodList(thisClass, &numMethodsInClass);
-#else
-        void* iterator = 0;
-        struct objc_method_list* objcMethodList;
-        while ((objcMethodList = class_nextMethodList(thisClass, &iterator))) {
-            unsigned numMethodsInClass = objcMethodList->method_count;
-#endif
-            for (unsigned i = 0; i < numMethodsInClass; i++) {
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
-                MethodStructPtr objcMethod = objcMethodList[i];
-                SEL objcMethodSelector = method_getName(objcMethod);
-#else
-                struct objc_method* objcMethod = &objcMethodList->method_list[i];
-                SEL objcMethodSelector = objcMethod->method_name;
-#endif
-                const char* objcMethodSelectorName = sel_getName(objcMethodSelector);
-                NSString* mappedName = nil;
+        for (unsigned i = 0; i < numMethodsInClass; i++) {
+            MethodStructPtr objcMethod = objcMethodList[i];
+            SEL objcMethodSelector = method_getName(objcMethod);
+            const char* objcMethodSelectorName = sel_getName(objcMethodSelector);
+            NSString* mappedName = nil;
 
-                // See if the class wants to exclude the selector from visibility in JavaScript.
-                if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)])
-                    if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector])
-                        continue;
+            // See if the class wants to exclude the selector from visibility in JavaScript.
+            if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)])
+                if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector])
+                    continue;
 
-                // See if the class want to provide a different name for the selector in JavaScript.
-                // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
-                // of the class.
-                if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)])
-                    mappedName = [thisClass webScriptNameForSelector:objcMethodSelector];
+            // See if the class want to provide a different name for the selector in JavaScript.
+            // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
+            // of the class.
+            if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)])
+                mappedName = [thisClass webScriptNameForSelector:objcMethodSelector];
 
-                if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) {
-                    Method* aMethod = new ObjcMethod(thisClass, objcMethodSelector); // deleted when the dictionary is destroyed
-                    CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod);
-                    methodList.append(aMethod);
-                    break;
-                }
+            if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) {
+                Method* aMethod = new ObjcMethod(thisClass, objcMethodSelector); // deleted when the dictionary is destroyed
+                CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod);
+                methodList.append(aMethod);
+                break;
             }
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
-            thisClass = class_getSuperclass(thisClass);
-            free(objcMethodList);
-#else
         }
-        thisClass = thisClass->super_class;
-#endif
+        thisClass = class_getSuperclass(thisClass);
+        free(objcMethodList);
     }
 
     if (buffer != fixedSizeBuffer)
@@ -191,48 +174,34 @@ Field* ObjcClass::fieldNamed(const Identifier& identifier, Instance* instance) c
         // introspection.
 
         while (thisClass) {
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
             unsigned numFieldsInClass = 0;
             IvarStructPtr* ivarsInClass = class_copyIvarList(thisClass, &numFieldsInClass);
-#else
-            struct objc_ivar_list* fieldsInClass = thisClass->ivars;
-            if (fieldsInClass) {
-                unsigned numFieldsInClass = fieldsInClass->ivar_count;
-#endif
-                for (unsigned i = 0; i < numFieldsInClass; i++) {
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
-                    IvarStructPtr objcIVar = ivarsInClass[i];
-                    const char* objcIvarName = ivar_getName(objcIVar);
-#else
-                    IvarStructPtr objcIVar = &fieldsInClass->ivar_list[i];
-                    const char* objcIvarName = objcIVar->ivar_name;
-#endif
-                    NSString* mappedName = 0;
-
-                    // See if the class wants to exclude the selector from visibility in JavaScript.
-                    if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)])
-                        if ([thisClass isKeyExcludedFromWebScript:objcIvarName])
-                            continue;
-
-                    // See if the class want to provide a different name for the selector in JavaScript.
-                    // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
-                    // of the class.
-                    if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)])
-                        mappedName = [thisClass webScriptNameForKey:objcIvarName];
-
-                    if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, jsName.data()) == 0) {
-                        aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed
-                        CFDictionaryAddValue(_fields.get(), fieldName.get(), aField);
-                        break;
-                    }
+
+            for (unsigned i = 0; i < numFieldsInClass; i++) {
+                IvarStructPtr objcIVar = ivarsInClass[i];
+                const char* objcIvarName = ivar_getName(objcIVar);
+                NSString* mappedName = 0;
+
+                // See if the class wants to exclude the selector from visibility in JavaScript.
+                if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)])
+                    if ([thisClass isKeyExcludedFromWebScript:objcIvarName])
+                        continue;
+
+                // See if the class want to provide a different name for the selector in JavaScript.
+                // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
+                // of the class.
+                if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)])
+                    mappedName = [thisClass webScriptNameForKey:objcIvarName];
+
+                if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, jsName.data()) == 0) {
+                    aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed
+                    CFDictionaryAddValue(_fields.get(), fieldName.get(), aField);
+                    break;
                 }
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+            }
+
             thisClass = class_getSuperclass(thisClass);
             free(ivarsInClass);
-#else
-            }
-            thisClass = thisClass->super_class;
-#endif
         }
     }
 
index 5422e63..a31af91 100644 (file)
@@ -130,13 +130,12 @@ ObjcInstance::~ObjcInstance()
 
 static NSAutoreleasePool* allocateAutoReleasePool()
 {
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
     // If GC is enabled an autorelease pool is unnecessary, and the
     // pool cannot be protected from GC so may be collected leading
     // to a crash when we try to drain the release pool.
     if (objc_collectingEnabled())
         return nil;
-#endif
+
     return [[NSAutoreleasePool alloc] init];
 }
 
index 32c16be..c03f28f 100644 (file)
@@ -76,11 +76,7 @@ NSMethodSignature* ObjcMethod::getMethodSignature() const
 
 ObjcField::ObjcField(Ivar ivar) 
     : _ivar(ivar)
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
     , _name(AdoptCF, CFStringCreateWithCString(0, ivar_getName(_ivar), kCFStringEncodingASCII))
-#else
-    , _name(AdoptCF, CFStringCreateWithCString(0, _ivar->ivar_name, kCFStringEncodingASCII))
-#endif
 {
 }
 
index 06ec153..71546a4 100644 (file)
 #include <wtf/MainThread.h>
 #include <wtf/StdLibExtras.h>
 
-#if !(defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0)
-static inline IMP method_setImplementation(Method m, IMP i)
-{
-    IMP oi = m->method_imp;
-    m->method_imp = i;
-    return oi;
-}
-#endif
-
 namespace WebCore {
 
 #if ENABLE(DRAG_SUPPORT)
index 7e54d68..bae88ea 100644 (file)
@@ -1,3 +1,14 @@
+2011-09-21  Anders Carlsson  <andersca@apple.com>
+
+        Remove checks for Leopard-only Objective-C APIs
+        https://bugs.webkit.org/show_bug.cgi?id=68579
+
+        Reviewed by Sam Weinig.
+
+        We can always assume that OBJC_API_VERSION is at least 2, it's been 2 since Leopard.
+
+        * Misc/WebNSObjectExtras.h:
+
 2011-09-21  Andras Becsi  <andras.becsi@nokia.com>
 
         [Qt] Remove Qt specific code from css/SelectorChecker.cpp
index 0114bcc..b76e913 100644 (file)
@@ -42,17 +42,6 @@ static inline id WebCFAutorelease(CFTypeRef obj)
     return (id)obj;
 }
 
-#if !(defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0)
-
-static inline IMP method_setImplementation(Method m, IMP i)
-{
-    IMP oi = m->method_imp;
-    m->method_imp = i;
-    return oi;
-}
-
-#endif
-
 @interface NSObject (WebNSObjectExtras)
 + (id)_webkit_invokeOnMainThread;
 - (id)_webkit_invokeOnMainThread;