Title: [95675] trunk/Source
Revision
95675
Author
ander...@apple.com
Date
2011-09-21 15:41:11 -0700 (Wed, 21 Sep 2011)

Log Message

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.

../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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (95674 => 95675)


--- trunk/Source/WebCore/ChangeLog	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebCore/ChangeLog	2011-09-21 22:41:11 UTC (rev 95675)
@@ -1,5 +1,23 @@
 2011-09-21  Anders Carlsson  <ander...@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  <ander...@apple.com>
+
         Remove Widget::beforeMouseDown and Widget::afterMouseDown
         https://bugs.webkit.org/show_bug.cgi?id=68570
 

Modified: trunk/Source/WebCore/bridge/objc/objc_class.mm (95674 => 95675)


--- trunk/Source/WebCore/bridge/objc/objc_class.mm	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebCore/bridge/objc/objc_class.mm	2011-09-21 22:41:11 UTC (rev 95675)
@@ -96,51 +96,34 @@
 
     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 @@
         // 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;
+            for (unsigned i = 0; i < numFieldsInClass; i++) {
+                IvarStructPtr objcIVar = ivarsInClass[i];
+                const char* objcIvarName = ivar_getName(objcIVar);
+                NSString* mappedName = 0;
 
-                    // 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];
+                // See if the class wants to exclude the selector from visibility in _javascript_.
+                if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)])
+                    if ([thisClass isKeyExcludedFromWebScript:objcIvarName])
+                        continue;
 
-                    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;
-                    }
+                // 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
         }
     }
 

Modified: trunk/Source/WebCore/bridge/objc/objc_instance.mm (95674 => 95675)


--- trunk/Source/WebCore/bridge/objc/objc_instance.mm	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.mm	2011-09-21 22:41:11 UTC (rev 95675)
@@ -130,13 +130,12 @@
 
 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];
 }
 

Modified: trunk/Source/WebCore/bridge/objc/objc_runtime.mm (95674 => 95675)


--- trunk/Source/WebCore/bridge/objc/objc_runtime.mm	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebCore/bridge/objc/objc_runtime.mm	2011-09-21 22:41:11 UTC (rev 95675)
@@ -76,11 +76,7 @@
 
 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
 {
 }
 

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (95674 => 95675)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2011-09-21 22:41:11 UTC (rev 95675)
@@ -52,15 +52,6 @@
 #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)

Modified: trunk/Source/WebKit/mac/ChangeLog (95674 => 95675)


--- trunk/Source/WebKit/mac/ChangeLog	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-09-21 22:41:11 UTC (rev 95675)
@@ -1,3 +1,14 @@
+2011-09-21  Anders Carlsson  <ander...@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.be...@nokia.com>
 
         [Qt] Remove Qt specific code from css/SelectorChecker.cpp

Modified: trunk/Source/WebKit/mac/Misc/WebNSObjectExtras.h (95674 => 95675)


--- trunk/Source/WebKit/mac/Misc/WebNSObjectExtras.h	2011-09-21 22:33:21 UTC (rev 95674)
+++ trunk/Source/WebKit/mac/Misc/WebNSObjectExtras.h	2011-09-21 22:41:11 UTC (rev 95675)
@@ -42,17 +42,6 @@
     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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to