Changeset 95675 in webkit


Ignore:
Timestamp:
Sep 21, 2011 3:41:11 PM (13 years ago)
Author:
andersca@apple.com
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:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95673 r95675  
     12011-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
    1192011-09-21  Anders Carlsson  <andersca@apple.com>
    220
  • trunk/Source/WebCore/bridge/objc/objc_class.mm

    r91903 r95675  
    9797    ClassStructPtr thisClass = _isa;
    9898    while (thisClass && methodList.isEmpty()) {
    99 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
    10099        unsigned numMethodsInClass = 0;
    101100        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;
    136123            }
    137 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
    138             thisClass = class_getSuperclass(thisClass);
    139             free(objcMethodList);
    140 #else
    141124        }
    142         thisClass = thisClass->super_class;
    143 #endif
     125        thisClass = class_getSuperclass(thisClass);
     126        free(objcMethodList);
    144127    }
    145128
     
    192175
    193176        while (thisClass) {
    194 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
    195177            unsigned numFieldsInClass = 0;
    196178            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;
    228200                }
    229 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
     201            }
     202
    230203            thisClass = class_getSuperclass(thisClass);
    231204            free(ivarsInClass);
    232 #else
    233             }
    234             thisClass = thisClass->super_class;
    235 #endif
    236205        }
    237206    }
  • trunk/Source/WebCore/bridge/objc/objc_instance.mm

    r95250 r95675  
    131131static NSAutoreleasePool* allocateAutoReleasePool()
    132132{
    133 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
    134133    // If GC is enabled an autorelease pool is unnecessary, and the
    135134    // pool cannot be protected from GC so may be collected leading
     
    137136    if (objc_collectingEnabled())
    138137        return nil;
    139 #endif
     138
    140139    return [[NSAutoreleasePool alloc] init];
    141140}
  • trunk/Source/WebCore/bridge/objc/objc_runtime.mm

    r94875 r95675  
    7777ObjcField::ObjcField(Ivar ivar)
    7878    : _ivar(ivar)
    79 #if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
    8079    , _name(AdoptCF, CFStringCreateWithCString(0, ivar_getName(_ivar), kCFStringEncodingASCII))
    81 #else
    82     , _name(AdoptCF, CFStringCreateWithCString(0, _ivar->ivar_name, kCFStringEncodingASCII))
    83 #endif
    8480{
    8581}
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r95673 r95675  
    5252#include <wtf/MainThread.h>
    5353#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 #endif
    6354
    6455namespace WebCore {
  • trunk/Source/WebKit/mac/ChangeLog

    r95604 r95675  
     12011-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
    1122011-09-21  Andras Becsi  <andras.becsi@nokia.com>
    213
  • trunk/Source/WebKit/mac/Misc/WebNSObjectExtras.h

    r62872 r95675  
    4343}
    4444
    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 #endif
    55 
    5645@interface NSObject (WebNSObjectExtras)
    5746+ (id)_webkit_invokeOnMainThread;
Note: See TracChangeset for help on using the changeset viewer.