Changeset 180481 in webkit


Ignore:
Timestamp:
Feb 21, 2015 1:49:57 PM (9 years ago)
Author:
ddkilzer@apple.com
Message:

Add SOFT_LINK_CONSTANT_SOURCE() cross-platform macro and start using it
<http://webkit.org/b/141816>

Reviewed by Alexey Proskuryakov.

  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • Remove CoreMediaSoftLinking.h.
  • platform/cf/CoreMediaSoftLink.cpp:
  • Add kCMTimeZero constant.
  • platform/cf/CoreMediaSoftLink.h:
  • Add SOFT_LINK_FRAMEWORK_HEADER() macro for CoreMedia.
  • Add kCMTimeZero constant.
  • platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h: Remove.
  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
  • Remove reference to CoreMediaSoftLinking.h and update comment.

(WebCore::MediaPlayerPrivateAVFoundationCF::isAvailable):

  • Switch to using new method to check if a framework is available.
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
  • Remove all local soft-linking macros for CoreMedia. CoreMediaSoftLink.h handles everything now.

(WebCore::MediaPlayerPrivateAVFoundationObjC::isAvailable):

  • Switch to using new method to check if a framework is available.
  • platform/mac/SoftLinking.h:

(SOFT_LINK_FRAMEWORK_HEADER): Add. Defines
is_Name_FrameworkAvailable() macro.
(SOFT_LINK_FRAMEWORK_SOURCE): Update to make it work with
optional framework checks without a separate macro.
(SOFT_LINK_CONSTANT_HEADER): Add.
(SOFT_LINK_CONSTANT_SOURCE): Add.

  • Support soft-links to constants.
  • platform/win/SoftLinking.h:

(SOFT_LINK_FRAMEWORK_HELPER): Add. Copied from
SOFT_LINK_LIBRARY_HELPER, with addition of namespace and
non-static function.
(SOFT_LINK_FRAMEWORK): Add. Copied from SOFT_LINK_LIBRARY.
(SOFT_LINK_DEBUG_FRAMEWORK): Add. Copied from
SOFT_LINK_DEBUG_LIBRARY.
(SOFT_LINK_FRAMEWORK_HEADER): Add. Defines
is_Name_FrameworkAvailable() macro.
(SOFT_LINK_FRAMEWORK_SOURCE): Redefine in terms of
SOFT_LINK_FRAMEWORK/SOFT_LINK_DEBUG_FRAMEWORK.
(SOFT_LINK_CONSTANT_HEADER): Add.
(SOFT_LINK_CONSTANT_SOURCE): Add.

  • Support soft-links to constants.
Location:
trunk/Source/WebCore
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180476 r180481  
     12015-02-21  David Kilzer  <ddkilzer@apple.com>
     2
     3        Add SOFT_LINK_CONSTANT_SOURCE() cross-platform macro and start using it
     4        <http://webkit.org/b/141816>
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * WebCore.vcxproj/WebCore.vcxproj:
     9        * WebCore.vcxproj/WebCore.vcxproj.filters:
     10        - Remove CoreMediaSoftLinking.h.
     11
     12        * platform/cf/CoreMediaSoftLink.cpp:
     13        - Add kCMTimeZero constant.
     14        * platform/cf/CoreMediaSoftLink.h:
     15        - Add SOFT_LINK_FRAMEWORK_HEADER() macro for CoreMedia.
     16        - Add kCMTimeZero constant.
     17
     18        * platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h: Remove.
     19
     20        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     21        - Remove reference to CoreMediaSoftLinking.h and update comment.
     22        (WebCore::MediaPlayerPrivateAVFoundationCF::isAvailable):
     23        - Switch to using new method to check if a framework is
     24          available.
     25
     26        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     27        - Remove all local soft-linking macros for CoreMedia.
     28          CoreMediaSoftLink.h handles everything now.
     29        (WebCore::MediaPlayerPrivateAVFoundationObjC::isAvailable):
     30        - Switch to using new method to check if a framework is
     31          available.
     32
     33        * platform/mac/SoftLinking.h:
     34        (SOFT_LINK_FRAMEWORK_HEADER): Add.  Defines
     35        is_Name_FrameworkAvailable() macro.
     36        (SOFT_LINK_FRAMEWORK_SOURCE): Update to make it work with
     37        optional framework checks without a separate macro.
     38        (SOFT_LINK_CONSTANT_HEADER): Add.
     39        (SOFT_LINK_CONSTANT_SOURCE): Add.
     40        - Support soft-links to constants.
     41
     42        * platform/win/SoftLinking.h:
     43        (SOFT_LINK_FRAMEWORK_HELPER): Add.  Copied from
     44        SOFT_LINK_LIBRARY_HELPER, with addition of namespace and
     45        non-static function.
     46        (SOFT_LINK_FRAMEWORK): Add.  Copied from SOFT_LINK_LIBRARY.
     47        (SOFT_LINK_DEBUG_FRAMEWORK): Add.  Copied from
     48        SOFT_LINK_DEBUG_LIBRARY.
     49        (SOFT_LINK_FRAMEWORK_HEADER): Add.  Defines
     50        is_Name_FrameworkAvailable() macro.
     51        (SOFT_LINK_FRAMEWORK_SOURCE): Redefine in terms of
     52        SOFT_LINK_FRAMEWORK/SOFT_LINK_DEBUG_FRAMEWORK.
     53        (SOFT_LINK_CONSTANT_HEADER): Add.
     54        (SOFT_LINK_CONSTANT_SOURCE): Add.
     55        - Support soft-links to constants.
     56
    1572015-02-20  David Kilzer  <ddkilzer@apple.com>
    258
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r180294 r180481  
    2000320003    <ClInclude Include="..\platform\graphics\avfoundation\MediaTimeAVFoundation.h" />
    2000420004    <ClInclude Include="..\platform\graphics\avfoundation\cf\AVFoundationCFSoftLinking.h" />
    20005     <ClInclude Include="..\platform\graphics\avfoundation\cf\CoreMediaSoftLinking.h" />
    2000620005    <ClInclude Include="..\platform\graphics\avfoundation\cf\MediaPlayerPrivateAVFoundationCF.h" />
    2000720006    <ClInclude Include="..\platform\network\AuthenticationChallengeBase.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r180366 r180481  
    86928692      <Filter>platform\graphics\avfoundation\cf</Filter>
    86938693    </ClInclude>
    8694     <ClInclude Include="..\platform\graphics\avfoundation\cf\CoreMediaSoftLinking.h">
    8695       <Filter>platform\graphics\avfoundation\cf</Filter>
    8696     </ClInclude>
    86978694    <ClInclude Include="..\platform\graphics\avfoundation\cf\MediaPlayerPrivateAVFoundationCF.h">
    86988695      <Filter>platform\graphics\avfoundation\cf</Filter>
  • trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.cpp

    r180476 r180481  
    4040SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
    4141
     42SOFT_LINK_CONSTANT_SOURCE(WebCore, CoreMedia, kCMTimeZero, CMTime);
     43
    4244#if PLATFORM(COCOA)
    4345SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMNotificationCenterGetDefaultLocalCenter, CMNotificationCenterRef, (void), ());
  • trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.h

    r180476 r180481  
    3333#include <CoreMedia/CoreMedia.h>
    3434
     35SOFT_LINK_FRAMEWORK_HEADER(WebCore, CoreMedia)
     36
    3537SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
    3638#define CMTimeCompare softLink_CoreMedia_CMTimeCompare
     
    4345SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
    4446#define CMTimeRangeGetEnd softLink_CoreMedia_CMTimeRangeGetEnd
     47
     48SOFT_LINK_CONSTANT_HEADER(WebCore, CoreMedia, kCMTimeZero, CMTime);
     49#define kCMTimeZero get_CoreMedia_kCMTimeZero()
    4550
    4651#if PLATFORM(COCOA)
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r180406 r180481  
    7272#include <wtf/StringPrintStream.h>
    7373
    74 // The softlink header files must be included after the AVCF and CoreMedia header files.
     74// Soft-linking headers must be included last since they #define functions, constants, etc.
    7575#include "AVFoundationCFSoftLinking.h"
    7676#include "CoreMediaSoftLink.h"
    77 #include "CoreMediaSoftLinking.h"
    7877
    7978// We don't bother softlinking against libdispatch since it's already been loaded by AAS.
     
    941940bool MediaPlayerPrivateAVFoundationCF::isAvailable()
    942941{
    943     return AVFoundationCFLibrary() && CoreMediaLibrary();
     942    return AVFoundationCFLibrary() && isCoreMediaFrameworkAvailable();
    944943}
    945944
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r180416 r180481  
    3636#import "CDMSessionAVFoundationObjC.h"
    3737#import "Cookie.h"
    38 #import "CoreMediaSoftLink.h"
    3938#import "ExceptionCodePlaceholder.h"
    4039#import "FloatConversion.h"
     
    146145typedef AVMediaSelectionOption AVMediaSelectionOptionType;
    147146
     147#pragma mark - Soft Linking
     148
     149// Soft-linking headers must be included last since they #define functions, constants, etc.
     150#import "CoreMediaSoftLink.h"
     151
    148152SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
    149 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
    150153SOFT_LINK_FRAMEWORK_OPTIONAL(CoreImage)
    151154SOFT_LINK_FRAMEWORK_OPTIONAL(CoreVideo)
     
    196199
    197200SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetClientBundleIdentifierKey, NSString *)
    198 
    199 SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
    200201
    201202#define AVPlayer getAVPlayerClass()
     
    284285#if PLATFORM(IOS)
    285286SOFT_LINK_POINTER(AVFoundation, AVURLAssetBoundNetworkInterfaceName, NSString *)
    286 
    287287#define AVURLAssetBoundNetworkInterfaceName getAVURLAssetBoundNetworkInterfaceName()
    288288#endif
    289 
    290 #define kCMTimeZero getkCMTimeZero()
    291289
    292290using namespace WebCore;
     
    17551753bool MediaPlayerPrivateAVFoundationObjC::isAvailable()
    17561754{
    1757     return AVFoundationLibrary() && CoreMediaLibrary();
     1755    return AVFoundationLibrary() && isCoreMediaFrameworkAvailable();
    17581756}
    17591757
  • trunk/Source/WebCore/platform/mac/SoftLinking.h

    r180476 r180481  
    294294// See Source/WebCore/platform/cf/CoreMediaSoftLink.{cpp,h} for an example implementation.
    295295
     296#define SOFT_LINK_FRAMEWORK_HEADER(functionNamespace, framework) \
     297    namespace functionNamespace { \
     298    extern void* framework##Library(bool isOptional = false); \
     299    bool is##framework##FrameworkAvailable(); \
     300    inline bool is##framework##FrameworkAvailable() { \
     301        return framework##Library(true) != nullptr; \
     302    } \
     303    }
     304
    296305#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
    297306    namespace functionNamespace { \
    298     static void* framework##Library() \
     307    void* framework##Library(bool isOptional = false); \
     308    void* framework##Library(bool isOptional) \
    299309    { \
    300310        static void* frameworkLibrary; \
     
    302312        dispatch_once(&once, ^{ \
    303313            frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
    304             ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
    305314        }); \
    306         return frameworkLibrary; \
     315        ASSERT_WITH_MESSAGE_UNUSED(isOptional, isOptional || frameworkLibrary, "%s", dlerror()); \
     316        return frameworkLibrary; \
     317    } \
     318    }
     319
     320#define SOFT_LINK_CONSTANT_HEADER(functionNamespace, framework, variableName, variableType) \
     321    WTF_EXTERN_C_BEGIN \
     322    extern const variableType variableName; \
     323    WTF_EXTERN_C_END \
     324    namespace functionNamespace { \
     325    const variableType get_##framework##_##variableName(); \
     326    }
     327
     328#define SOFT_LINK_CONSTANT_SOURCE(functionNamespace, framework, variableName, variableType) \
     329    WTF_EXTERN_C_BEGIN \
     330    extern const variableType variableName; \
     331    WTF_EXTERN_C_END \
     332    namespace functionNamespace { \
     333    const variableType get_##framework##_##variableName(); \
     334    const variableType get_##framework##_##variableName() \
     335    { \
     336        static variableType constant##framework##variableName; \
     337        static dispatch_once_t once; \
     338        dispatch_once(&once, ^{ \
     339            void* constant = dlsym(framework##Library(), #variableName); \
     340            ASSERT_WITH_MESSAGE(constant, "%s", dlerror()); \
     341            constant##framework##variableName = *static_cast<variableType*>(constant); \
     342        }); \
     343        return constant##framework##variableName; \
    307344    } \
    308345    }
  • trunk/Source/WebCore/platform/win/SoftLinking.h

    r180476 r180481  
    176176// See Source/WebCore/platform/cf/CoreMediaSoftLink.{cpp,h} for an example implementation.
    177177
     178#define SOFT_LINK_FRAMEWORK_HEADER(functionNamespace, framework) \
     179    namespace functionNamespace { \
     180    extern HMODULE framework##Library(bool isOptional = false); \
     181    bool is##framework##FrameworkAvailable(); \
     182    inline bool is##framework##FrameworkAvailable() { \
     183        return framework##Library(true) != nullptr; \
     184    } \
     185    }
     186
     187#define SOFT_LINK_FRAMEWORK_HELPER(functionNamespace, framework, suffix) \
     188    namespace functionNamespace { \
     189    HMODULE framework##Library(bool isOptional = false); \
     190    HMODULE framework##Library(bool isOptional) \
     191    { \
     192        static HMODULE library = LoadLibraryW(L###framework suffix); \
     193        ASSERT_WITH_MESSAGE_UNUSED(isOptional, isOptional || library, "Could not load %s", L###framework suffix); \
     194        return library; \
     195    } \
     196    }
     197
     198#define SOFT_LINK_FRAMEWORK(functionNamespace, framework) SOFT_LINK_FRAMEWORK_HELPER(functionNamespace, framework, L".dll")
     199#define SOFT_LINK_DEBUG_FRAMEWORK(functionNamespace, framework) SOFT_LINK_FRAMEWORK_HELPER(functionNamespace, framework, L"_debug.dll")
     200
    178201#ifdef DEBUG_ALL
    179 #define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
    180     namespace functionNamespace { \
    181     SOFT_LINK_DEBUG_LIBRARY(framework) \
    182     }
     202#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) SOFT_LINK_DEBUG_FRAMEWORK(functionNamespace, framework)
    183203#else
    184 #define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
    185     namespace functionNamespace { \
    186     SOFT_LINK_LIBRARY(framework) \
    187     }
     204#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) SOFT_LINK_FRAMEWORK(functionNamespace, framework)
    188205#endif
     206
     207#define SOFT_LINK_CONSTANT_HEADER(functionNamespace, framework, variableName, variableType) \
     208    namespace functionNamespace { \
     209    const variableType get_##framework##_##variableName(); \
     210    }
     211
     212#define SOFT_LINK_CONSTANT_SOURCE(functionNamespace, framework, variableName, variableType) \
     213    namespace functionNamespace { \
     214    static void init##framework##variableName(void* context) { \
     215        variableType* ptr = reinterpret_cast<variableType*>(SOFT_LINK_GETPROCADDRESS(framework##Library(), #variableName)); \
     216        ASSERT(ptr); \
     217        *static_cast<variableType*>(context) = *ptr; \
     218    } \
     219    const variableType get_##framework##_##variableName(); \
     220    const variableType get_##framework##_##variableName() \
     221    { \
     222        static variableType constant##framework##variableName; \
     223        static dispatch_once_t once; \
     224        dispatch_once_f(&once, static_cast<void*>(&constant##framework##variableName), init##framework##variableName); \
     225        return constant##framework##variableName; \
     226    } \
     227    }
    189228
    190229#define SOFT_LINK_FUNCTION_HEADER(functionNamespace, framework, functionName, resultType, parameterDeclarations, parameterNames) \
Note: See TracChangeset for help on using the changeset viewer.