⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 238470 in webkit


Ignore:
Timestamp:
Nov 24, 2018, 10:37:14 AM (8 years ago)
Author:
aestes@apple.com
Message:

[Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
https://bugs.webkit.org/show_bug.cgi?id=191899

Reviewed by Dean Jackson.

Source/WebCore:

  • editing/cocoa/DataDetection.mm:
  • editing/cocoa/FontAttributesCocoa.mm:
  • editing/cocoa/FontShadowCocoa.mm:
  • platform/cocoa/DataDetectorsCoreSoftLink.h:
  • platform/graphics/cocoa/ColorCocoa.mm:
  • platform/ios/PlatformScreenIOS.mm:

Source/WebCore/PAL:

  • pal/cocoa/PassKitSoftLink.h:
  • pal/ios/UIKitSoftLink.h:

Source/WebKit:

  • Shared/cocoa/WebCoreArgumentCodersCocoa.mm:
  • UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
  • UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:

Source/WTF:

Currently, SOFT_LINK_CLASS_FOR_HEADER declares a class getter function that includes the
framework name. For example, NSView would have a class getter named
namespace::get_AppKit_NSViewClass().

Including the framework name in the getter is unnecessary. Objective-C classes already exist
in a global namespace, so there is no need to disambiguate class names by framework. This
patch elides the framework name from the getter function. For example, NSView would now have
a getter named namespace::getNSViewClass().

  • wtf/cocoa/SoftLinking.h:
Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r238469 r238470  
     12018-11-24  Andy Estes  <aestes@apple.com>
     2
     3        [Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
     4        https://bugs.webkit.org/show_bug.cgi?id=191899
     5
     6        Reviewed by Dean Jackson.
     7
     8        Currently, SOFT_LINK_CLASS_FOR_HEADER declares a class getter function that includes the
     9        framework name. For example, NSView would have a class getter named
     10        namespace::get_AppKit_NSViewClass().
     11
     12        Including the framework name in the getter is unnecessary. Objective-C classes already exist
     13        in a global namespace, so there is no need to disambiguate class names by framework. This
     14        patch elides the framework name from the getter function. For example, NSView would now have
     15        a getter named namespace::getNSViewClass().
     16
     17        * wtf/cocoa/SoftLinking.h:
     18
    1192018-11-24  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/Source/WTF/wtf/cocoa/SoftLinking.h

    r238434 r238470  
    379379    SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(functionNamespace, framework, )
    380380
    381 #define SOFT_LINK_CLASS_FOR_HEADER(functionNamespace, framework, className) \
     381#define SOFT_LINK_CLASS_FOR_HEADER(functionNamespace, className) \
    382382    @class className; \
    383383    namespace functionNamespace { \
    384     extern Class (*get_##framework##_##className##Class)(); \
     384    extern Class (*get##className##Class)(); \
    385385    className *alloc##className##Instance(); \
    386386    inline className *alloc##className##Instance() \
    387387    { \
    388         return [get_##framework##_##className##Class() alloc]; \
     388        return [get##className##Class() alloc]; \
    389389    } \
    390390    }
     
    394394    namespace functionNamespace { \
    395395    static Class init##className(); \
    396     export Class (*get_##framework##_##className##Class)() = init##className; \
     396    export Class (*get##className##Class)() = init##className; \
    397397    static Class class##className; \
    398398    \
     
    409409            class##className = objc_getClass(#className); \
    410410            RELEASE_ASSERT(class##className); \
    411             get_##framework##_##className##Class = className##Function; \
     411            get##className##Class = className##Function; \
    412412        }); \
    413413        return class##className; \
  • trunk/Source/WebCore/ChangeLog

    r238466 r238470  
     12018-11-24  Andy Estes  <aestes@apple.com>
     2
     3        [Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
     4        https://bugs.webkit.org/show_bug.cgi?id=191899
     5
     6        Reviewed by Dean Jackson.
     7
     8        * editing/cocoa/DataDetection.mm:
     9        * editing/cocoa/FontAttributesCocoa.mm:
     10        * editing/cocoa/FontShadowCocoa.mm:
     11        * platform/cocoa/DataDetectorsCoreSoftLink.h:
     12        * platform/graphics/cocoa/ColorCocoa.mm:
     13        * platform/ios/PlatformScreenIOS.mm:
     14
    1152018-11-23  Jiewen Tan  <jiewen_tan@apple.com>
    216
  • trunk/Source/WebCore/PAL/ChangeLog

    r238461 r238470  
     12018-11-24  Andy Estes  <aestes@apple.com>
     2
     3        [Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
     4        https://bugs.webkit.org/show_bug.cgi?id=191899
     5
     6        Reviewed by Dean Jackson.
     7
     8        * pal/cocoa/PassKitSoftLink.h:
     9        * pal/ios/UIKitSoftLink.h:
     10
    1112018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
    212
  • trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h

    r238434 r238470  
    3333SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, PassKit)
    3434
    35 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKContact)
    36 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPassLibrary)
    37 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPayment)
    38 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentAuthorizationViewController)
    39 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentMethod)
    40 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentMerchantSession)
    41 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentRequest)
    42 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentSummaryItem)
    43 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKShippingMethod)
     35SOFT_LINK_CLASS_FOR_HEADER(PAL, PKContact)
     36SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPassLibrary)
     37SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPayment)
     38SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentAuthorizationViewController)
     39SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentMethod)
     40SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentMerchantSession)
     41SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentRequest)
     42SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentSummaryItem)
     43SOFT_LINK_CLASS_FOR_HEADER(PAL, PKShippingMethod)
    4444
    4545SOFT_LINK_FUNCTION_FOR_HEADER(PAL, PassKit, PKCanMakePaymentsWithMerchantIdentifierAndDomain, void, (NSString *identifier, NSString *domain, PKCanMakePaymentsCompletion completion), (identifier, domain, completion))
     
    4747
    4848#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300)
    49 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentAuthorizationResult)
    50 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentRequestPaymentMethodUpdate)
    51 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentRequestShippingContactUpdate)
    52 SOFT_LINK_CLASS_FOR_HEADER(PAL, PassKit, PKPaymentRequestShippingMethodUpdate)
     49SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentAuthorizationResult)
     50SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentRequestPaymentMethodUpdate)
     51SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentRequestShippingContactUpdate)
     52SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentRequestShippingMethodUpdate)
    5353
    5454SOFT_LINK_CONSTANT_FOR_HEADER(PAL, PassKit, PKContactFieldEmailAddress, PKContactField)
  • trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h

    r237266 r238470  
    3333SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, UIKit)
    3434
    35 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, NSParagraphStyle)
    36 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, NSShadow)
    37 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, NSTextList)
    38 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, UIApplication)
    39 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, UIScreen)
    40 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIKit, UIColor)
     35SOFT_LINK_CLASS_FOR_HEADER(PAL, NSParagraphStyle)
     36SOFT_LINK_CLASS_FOR_HEADER(PAL, NSShadow)
     37SOFT_LINK_CLASS_FOR_HEADER(PAL, NSTextList)
     38SOFT_LINK_CLASS_FOR_HEADER(PAL, UIApplication)
     39SOFT_LINK_CLASS_FOR_HEADER(PAL, UIScreen)
     40SOFT_LINK_CLASS_FOR_HEADER(PAL, UIColor)
    4141SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIAccessibilityIsGrayscaleEnabled, BOOL, (void), ())
    4242SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIAccessibilityIsInvertColorsEnabled, BOOL, (void), ())
  • trunk/Source/WebCore/editing/cocoa/DataDetection.mm

    r238002 r238470  
    644644        lastTextNodeToUpdate->setData(lastNodeContent);
    645645   
    646     return [get_DataDetectorsCore_DDScannerResultClass() resultsFromCoreResults:scannerResults.get()];
     646    return [getDDScannerResultClass() resultsFromCoreResults:scannerResults.get()];
    647647}
    648648
  • trunk/Source/WebCore/editing/cocoa/FontAttributesCocoa.mm

    r237266 r238470  
    7777    Class textListClass = NSTextList.class;
    7878#else
    79     Class textListClass = PAL::get_UIKit_NSTextListClass();
     79    Class textListClass = PAL::getNSTextListClass();
    8080#endif
    8181    auto result = adoptNS([[textListClass alloc] initWithMarkerFormat:cocoaTextListMarkerName(style, ordered) options:0]);
     
    107107    Class paragraphStyleClass = NSParagraphStyle.class;
    108108#else
    109     Class paragraphStyleClass = PAL::get_UIKit_NSParagraphStyleClass();
     109    Class paragraphStyleClass = PAL::getNSParagraphStyleClass();
    110110#endif
    111111    auto style = adoptNS([[paragraphStyleClass defaultParagraphStyle] mutableCopy]);
  • trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm

    r237266 r238470  
    4141    auto shadow = adoptNS([NSShadow new]);
    4242#elif PLATFORM(IOS_FAMILY)
    43     auto shadow = adoptNS([PAL::get_UIKit_NSShadowClass() new]);
     43    auto shadow = adoptNS([PAL::getNSShadowClass() new]);
    4444#endif
    4545    [shadow setShadowColor:platformColor(color)];
  • trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.h

    r237266 r238470  
    3333#if PLATFORM(IOS_FAMILY)
    3434
    35 SOFT_LINK_CLASS_FOR_HEADER(WebCore, DataDetectorsCore, DDScannerResult)
     35SOFT_LINK_CLASS_FOR_HEADER(WebCore, DDScannerResult)
    3636SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDScannerCreate, DDScannerRef, (DDScannerType type, DDScannerOptions options, CFErrorRef * errorRef), (type, options, errorRef))
    3737SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDScannerScanQuery, Boolean, (DDScannerRef scanner, DDScanQueryRef query), (scanner, query))
  • trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.mm

    r237266 r238470  
    4949UIColor *platformColor(const Color& color)
    5050{
    51     return [PAL::get_UIKit_UIColorClass() _disambiguated_due_to_CIImage_colorWithCGColor:cachedCGColor(color)];
     51    return [PAL::getUIColorClass() _disambiguated_due_to_CIImage_colorWithCGColor:cachedCGColor(color)];
    5252}
    5353
  • trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm

    r237266 r238470  
    130130FloatSize screenSize()
    131131{
    132     if (deviceHasIPadCapability() && [[PAL::get_UIKit_UIApplicationClass() sharedApplication] _isClassic])
     132    if (deviceHasIPadCapability() && [[PAL::getUIApplicationClass() sharedApplication] _isClassic])
    133133        return { 320, 480 };
    134     return FloatSize([[PAL::get_UIKit_UIScreenClass() mainScreen] _referenceBounds].size);
     134    return FloatSize([[PAL::getUIScreenClass() mainScreen] _referenceBounds].size);
    135135}
    136136
    137137FloatSize availableScreenSize()
    138138{
    139     if (deviceHasIPadCapability() && [[PAL::get_UIKit_UIApplicationClass() sharedApplication] _isClassic])
     139    if (deviceHasIPadCapability() && [[PAL::getUIApplicationClass() sharedApplication] _isClassic])
    140140        return { 320, 480 };
    141     return FloatSize([PAL::get_UIKit_UIScreenClass() mainScreen].bounds.size);
     141    return FloatSize([PAL::getUIScreenClass() mainScreen].bounds.size);
    142142}
    143143
     
    154154{
    155155    if (!screen)
    156         screen = [PAL::get_UIKit_UIScreenClass() mainScreen];
     156        screen = [PAL::getUIScreenClass() mainScreen];
    157157
    158158    return screen.scale;
  • trunk/Source/WebKit/ChangeLog

    r238468 r238470  
     12018-11-24  Andy Estes  <aestes@apple.com>
     2
     3        [Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
     4        https://bugs.webkit.org/show_bug.cgi?id=191899
     5
     6        Reviewed by Dean Jackson.
     7
     8        * Shared/cocoa/WebCoreArgumentCodersCocoa.mm:
     9        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
     10        * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
     11
    1122018-11-23  Antti Koivisto  <antti@apple.com>
    213
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r238434 r238470  
    5656    auto unarchiver = secureUnarchiverFromData(data.get());
    5757    @try {
    58         PKPayment *pkPayment = [unarchiver decodeObjectOfClass:PAL::get_PassKit_PKPaymentClass() forKey:NSKeyedArchiveRootObjectKey];
     58        PKPayment *pkPayment = [unarchiver decodeObjectOfClass:PAL::getPKPaymentClass() forKey:NSKeyedArchiveRootObjectKey];
    5959        payment = Payment(pkPayment);
    6060    } @catch (NSException *exception) {
     
    107107    auto unarchiver = secureUnarchiverFromData(data.get());
    108108    @try {
    109         PKContact *pkContact = [unarchiver decodeObjectOfClass:PAL::get_PassKit_PKContactClass() forKey:NSKeyedArchiveRootObjectKey];
     109        PKContact *pkContact = [unarchiver decodeObjectOfClass:PAL::getPKContactClass() forKey:NSKeyedArchiveRootObjectKey];
    110110        paymentContact = PaymentContact(pkContact);
    111111    } @catch (NSException *exception) {
     
    164164    auto unarchiver = secureUnarchiverFromData(data.get());
    165165    @try {
    166         PKPaymentMerchantSession *pkPaymentMerchantSession = [unarchiver decodeObjectOfClass:PAL::get_PassKit_PKPaymentMerchantSessionClass() forKey:NSKeyedArchiveRootObjectKey];
     166        PKPaymentMerchantSession *pkPaymentMerchantSession = [unarchiver decodeObjectOfClass:PAL::getPKPaymentMerchantSessionClass() forKey:NSKeyedArchiveRootObjectKey];
    167167        paymentMerchantSession = PaymentMerchantSession(pkPaymentMerchantSession);
    168168    } @catch (NSException *exception) {
     
    194194    auto unarchiver = secureUnarchiverFromData(data.get());
    195195    @try {
    196         PKPaymentMethod *pkPaymentMethod = [unarchiver decodeObjectOfClass:PAL::get_PassKit_PKPaymentMethodClass() forKey:NSKeyedArchiveRootObjectKey];
     196        PKPaymentMethod *pkPaymentMethod = [unarchiver decodeObjectOfClass:PAL::getPKPaymentMethodClass() forKey:NSKeyedArchiveRootObjectKey];
    197197        paymentMethod = PaymentMethod(pkPaymentMethod);
    198198    } @catch (NSException *exception) {
  • trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm

    r238434 r238470  
    8585    _sessionBlock = sessionBlock;
    8686
    87     [PAL::get_PassKit_PKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
     87    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
    8888        if (error)
    8989            LOG_ERROR("PKCanMakePaymentsWithMerchantIdentifierAndDomain error %@", error);
     
    259259bool WebPaymentCoordinatorProxy::platformCanMakePayments()
    260260{
    261     return [PAL::get_PassKit_PKPaymentAuthorizationViewControllerClass() canMakePayments];
     261    return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
    262262}
    263263
     
    351351static RetainPtr<PKPaymentSummaryItem> toPKPaymentSummaryItem(const WebCore::ApplePaySessionPaymentRequest::LineItem& lineItem)
    352352{
    353     return [PAL::get_PassKit_PKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:toDecimalNumber(lineItem.amount) type:toPKPaymentSummaryItemType(lineItem.type)];
     353    return [PAL::getPKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:toDecimalNumber(lineItem.amount) type:toPKPaymentSummaryItemType(lineItem.type)];
    354354}
    355355
     
    410410static RetainPtr<PKShippingMethod> toPKShippingMethod(const WebCore::ApplePaySessionPaymentRequest::ShippingMethod& shippingMethod)
    411411{
    412     RetainPtr<PKShippingMethod> result = [PAL::get_PassKit_PKShippingMethodClass() summaryItemWithLabel:shippingMethod.label amount:toDecimalNumber(shippingMethod.amount)];
     412    RetainPtr<PKShippingMethod> result = [PAL::getPKShippingMethodClass() summaryItemWithLabel:shippingMethod.label amount:toDecimalNumber(shippingMethod.amount)];
    413413    [result setIdentifier:shippingMethod.identifier];
    414414    [result setDetail:shippingMethod.detail];
     
    799799Vector<String> WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks()
    800800{
    801     NSArray<PKPaymentNetwork> *availableNetworks = [PAL::get_PassKit_PKPaymentRequestClass() availableNetworks];
     801    NSArray<PKPaymentNetwork> *availableNetworks = [PAL::getPKPaymentRequestClass() availableNetworks];
    802802    Vector<String> result;
    803803    result.reserveInitialCapacity(availableNetworks.count);
  • trunk/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm

    r238434 r238470  
    4242    auto showPaymentUIRequestSeed = m_showPaymentUIRequestSeed;
    4343    auto weakThis = makeWeakPtr(*this);
    44     [PAL::get_PassKit_PKPaymentAuthorizationViewControllerClass() requestViewControllerWithPaymentRequest:paymentRequest.get() completion:BlockPtr<void(PKPaymentAuthorizationViewController *, NSError *)>::fromCallable([paymentRequest, showPaymentUIRequestSeed, weakThis, completionHandler = WTFMove(completionHandler)](PKPaymentAuthorizationViewController *viewController, NSError *error) {
     44    [PAL::getPKPaymentAuthorizationViewControllerClass() requestViewControllerWithPaymentRequest:paymentRequest.get() completion:BlockPtr<void(PKPaymentAuthorizationViewController *, NSError *)>::fromCallable([paymentRequest, showPaymentUIRequestSeed, weakThis, completionHandler = WTFMove(completionHandler)](PKPaymentAuthorizationViewController *viewController, NSError *error) {
    4545        auto paymentCoordinatorProxy = weakThis.get();
    4646        if (!paymentCoordinatorProxy)
Note: See TracChangeset for help on using the changeset viewer.