Title: [180476] trunk/Source/WebCore
Revision
180476
Author
[email protected]
Date
2015-02-20 20:09:02 -0800 (Fri, 20 Feb 2015)

Log Message

Make namespace configurable for SOFT_LINK_*_{HEADER,SOURCE}() macros
<http://webkit.org/b/141849>

Reviewed by Brent Fulgham.

This patch does the following:
- Add namespace argument to the SOFT_LINK_*_{HEADER,SOURCE}()
  macros for reuse in other projects.
- Adds SOFT_LINK_FRAMEWORK_SOURCE() macro in preparation for Bug
  141816.
- Adds back framework argument to SOFT_LINK_FUNCTION_HEADER()
  and includes framework name in generated function names.  This
  adds more entropy to the names in case there are two functions
  with the same name in different frameworks.

* platform/cf/CoreMediaSoftLink.cpp:
- Add FIXME about USE(COREMEDIA).
- Switch from SOFT_LINK_FRAMEWORK() to
  SOFT_LINK_FRAMEWORK_SOURCE().
* platform/cf/CoreMediaSoftLink.h:
- Add FIXME about USE(COREMEDIA).
- Add back framework argument to SOFT_LINK_FUNCTION_HEADER()
  macros.

* platform/mac/SoftLinking.h:
- Add missing header guards.
- Add pragmas for different macro groups.
(SOFT_LINK_FRAMEWORK_SOURCE): Add.
(SOFT_LINK_FUNCTION_HEADER): Move. Add back framework argument.
(SOFT_LINK_FUNCTION_SOURCE): Move.
- Add framework name to generated function names.
- Incorporates namespace so that it doesn't have to be listed in
  the *SoftLink.{cpp,h} file.

* platform/win/SoftLinking.h:
- Add pragmas for different macro groups.
(SOFT_LINK_FRAMEWORK_SOURCE): Add.
(SOFT_LINK_FUNCTION_HEADER): Move. Add back framework argument.
(SOFT_LINK_FUNCTION_SOURCE): Move.
- Add framework name to generated function names.
- Incorporates namespace so that it doesn't have to be listed in
  the *SoftLink.{cpp,h} file.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (180475 => 180476)


--- trunk/Source/WebCore/ChangeLog	2015-02-21 03:44:33 UTC (rev 180475)
+++ trunk/Source/WebCore/ChangeLog	2015-02-21 04:09:02 UTC (rev 180476)
@@ -1,3 +1,48 @@
+2015-02-20  David Kilzer  <[email protected]>
+
+        Make namespace configurable for SOFT_LINK_*_{HEADER,SOURCE}() macros
+        <http://webkit.org/b/141849>
+
+        Reviewed by Brent Fulgham.
+
+        This patch does the following:
+        - Add namespace argument to the SOFT_LINK_*_{HEADER,SOURCE}()
+          macros for reuse in other projects.
+        - Adds SOFT_LINK_FRAMEWORK_SOURCE() macro in preparation for Bug
+          141816.
+        - Adds back framework argument to SOFT_LINK_FUNCTION_HEADER()
+          and includes framework name in generated function names.  This
+          adds more entropy to the names in case there are two functions
+          with the same name in different frameworks.
+
+        * platform/cf/CoreMediaSoftLink.cpp:
+        - Add FIXME about USE(COREMEDIA).
+        - Switch from SOFT_LINK_FRAMEWORK() to
+          SOFT_LINK_FRAMEWORK_SOURCE().
+        * platform/cf/CoreMediaSoftLink.h:
+        - Add FIXME about USE(COREMEDIA).
+        - Add back framework argument to SOFT_LINK_FUNCTION_HEADER()
+          macros.
+
+        * platform/mac/SoftLinking.h:
+        - Add missing header guards.
+        - Add pragmas for different macro groups.
+        (SOFT_LINK_FRAMEWORK_SOURCE): Add.
+        (SOFT_LINK_FUNCTION_HEADER): Move. Add back framework argument.
+        (SOFT_LINK_FUNCTION_SOURCE): Move.
+        - Add framework name to generated function names.
+        - Incorporates namespace so that it doesn't have to be listed in
+          the *SoftLink.{cpp,h} file.
+
+        * platform/win/SoftLinking.h:
+        - Add pragmas for different macro groups.
+        (SOFT_LINK_FRAMEWORK_SOURCE): Add.
+        (SOFT_LINK_FUNCTION_HEADER): Move. Add back framework argument.
+        (SOFT_LINK_FUNCTION_SOURCE): Move.
+        - Add framework name to generated function names.
+        - Incorporates namespace so that it doesn't have to be listed in
+          the *SoftLink.{cpp,h} file.
+
 2015-02-20  Brent Fulgham  <[email protected]>
 
         [Gtk] Unreviewed build fix.

Modified: trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.cpp (180475 => 180476)


--- trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.cpp	2015-02-21 03:44:33 UTC (rev 180475)
+++ trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.cpp	2015-02-21 04:09:02 UTC (rev 180476)
@@ -25,32 +25,31 @@
 #include "config.h"
 
 #if USE(AVFOUNDATION)
+// FIXME: Should be USE(COREMEDIA), but this isn't currently defined on Windows.
 
 #include "CoreMediaSPI.h"
 #include "SoftLinking.h"
 #include <CoreMedia/CoreMedia.h>
 
-namespace WebCore {
-SOFT_LINK_FRAMEWORK(CoreMedia)
-}
+SOFT_LINK_FRAMEWORK_SOURCE(WebCore, CoreMedia)
 
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
 
 #if PLATFORM(COCOA)
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMNotificationCenterGetDefaultLocalCenter, CMNotificationCenterRef, (void), ());
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMNotificationCenterAddListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object, UInt32 flags), (center, listener, callback, notification, object, flags))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMNotificationCenterRemoveListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object), (center, listener, callback, notification, object))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimebaseGetTime, CMTime, (CMTimebaseRef timebase), (timebase))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeCopyAsDictionary, CFDictionaryRef, (CMTime time, CFAllocatorRef allocator), (time, allocator))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMNotificationCenterGetDefaultLocalCenter, CMNotificationCenterRef, (void), ());
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMNotificationCenterAddListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object, UInt32 flags), (center, listener, callback, notification, object, flags))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMNotificationCenterRemoveListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object), (center, listener, callback, notification, object))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimebaseGetTime, CMTime, (CMTimebaseRef timebase), (timebase))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeCopyAsDictionary, CFDictionaryRef, (CMTime time, CFAllocatorRef allocator), (time, allocator))
 #endif // PLATFORM(COCOA)
 
 #if PLATFORM(WIN)
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeAdd, CMTime, (CMTime addend1, CMTime addend2), (addend1, addend2))
-SOFT_LINK_FUNCTION_SOURCE(CoreMedia, CMTimeMakeFromDictionary, CMTime, (CFDictionaryRef dict), (dict))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeAdd, CMTime, (CMTime addend1, CMTime addend2), (addend1, addend2))
+SOFT_LINK_FUNCTION_SOURCE(WebCore, CoreMedia, CMTimeMakeFromDictionary, CMTime, (CFDictionaryRef dict), (dict))
 #endif // PLATFORM(WIN)
 
 #endif // USE(AVFOUNDATION)

Modified: trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.h (180475 => 180476)


--- trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.h	2015-02-21 03:44:33 UTC (rev 180475)
+++ trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.h	2015-02-21 04:09:02 UTC (rev 180476)
@@ -26,43 +26,44 @@
 #define CoreMediaSoftLink_h
 
 #if USE(AVFOUNDATION)
+// FIXME: Should be USE(COREMEDIA), but this isn't currently defined on Windows.
 
 #include "CoreMediaSPI.h"
 #include "SoftLinking.h"
 #include <CoreMedia/CoreMedia.h>
 
-SOFT_LINK_FUNCTION_HEADER(CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
-#define CMTimeCompare softLink_CMTimeCompare
-SOFT_LINK_FUNCTION_HEADER(CMTimeGetSeconds, Float64, (CMTime time), (time))
-#define CMTimeGetSeconds softLink_CMTimeGetSeconds
-SOFT_LINK_FUNCTION_HEADER(CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
-#define CMTimeMake softLink_CMTimeMake
-SOFT_LINK_FUNCTION_HEADER(CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
-#define CMTimeMakeWithSeconds softLink_CMTimeMakeWithSeconds
-SOFT_LINK_FUNCTION_HEADER(CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
-#define CMTimeRangeGetEnd softLink_CMTimeRangeGetEnd
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
+#define CMTimeCompare softLink_CoreMedia_CMTimeCompare
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
+#define CMTimeGetSeconds softLink_CoreMedia_CMTimeGetSeconds
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
+#define CMTimeMake softLink_CoreMedia_CMTimeMake
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
+#define CMTimeMakeWithSeconds softLink_CoreMedia_CMTimeMakeWithSeconds
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
+#define CMTimeRangeGetEnd softLink_CoreMedia_CMTimeRangeGetEnd
 
 #if PLATFORM(COCOA)
 
-SOFT_LINK_FUNCTION_HEADER(CMNotificationCenterGetDefaultLocalCenter, CMNotificationCenterRef, (void), ());
-#define CMNotificationCenterGetDefaultLocalCenter softLink_CMNotificationCenterGetDefaultLocalCenter
-SOFT_LINK_FUNCTION_HEADER(CMNotificationCenterAddListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object, UInt32 flags), (center, listener, callback, notification, object, flags))
-#define CMNotificationCenterAddListener softLink_CMNotificationCenterAddListener
-SOFT_LINK_FUNCTION_HEADER(CMNotificationCenterRemoveListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object), (center, listener, callback, notification, object))
-#define CMNotificationCenterRemoveListener softLink_CMNotificationCenterRemoveListener
-SOFT_LINK_FUNCTION_HEADER(CMTimebaseGetTime, CMTime, (CMTimebaseRef timebase), (timebase))
-#define CMTimebaseGetTime softLink_CMTimebaseGetTime
-SOFT_LINK_FUNCTION_HEADER(CMTimeCopyAsDictionary, CFDictionaryRef, (CMTime time, CFAllocatorRef allocator), (time, allocator))
-#define CMTimeCopyAsDictionary softLink_CMTimeCopyAsDictionary
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMNotificationCenterGetDefaultLocalCenter, CMNotificationCenterRef, (void), ());
+#define CMNotificationCenterGetDefaultLocalCenter softLink_CoreMedia_CMNotificationCenterGetDefaultLocalCenter
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMNotificationCenterAddListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object, UInt32 flags), (center, listener, callback, notification, object, flags))
+#define CMNotificationCenterAddListener softLink_CoreMedia_CMNotificationCenterAddListener
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMNotificationCenterRemoveListener, OSStatus, (CMNotificationCenterRef center, const void* listener, CMNotificationCallback callback, CFStringRef notification, const void* object), (center, listener, callback, notification, object))
+#define CMNotificationCenterRemoveListener softLink_CoreMedia_CMNotificationCenterRemoveListener
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimebaseGetTime, CMTime, (CMTimebaseRef timebase), (timebase))
+#define CMTimebaseGetTime softLink_CoreMedia_CMTimebaseGetTime
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeCopyAsDictionary, CFDictionaryRef, (CMTime time, CFAllocatorRef allocator), (time, allocator))
+#define CMTimeCopyAsDictionary softLink_CoreMedia_CMTimeCopyAsDictionary
 
 #endif // PLATFORM(COCOA)
 
 #if PLATFORM(WIN)
 
-SOFT_LINK_FUNCTION_HEADER(CMTimeAdd, CMTime, (CMTime addend1, CMTime addend2), (addend1, addend2))
-#define CMTimeAdd softLink_CMTimeAdd
-SOFT_LINK_FUNCTION_HEADER(CMTimeMakeFromDictionary, CMTime, (CFDictionaryRef dict), (dict))
-#define CMTimeMakeFromDictionary softLink_CMTimeMakeFromDictionary
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeAdd, CMTime, (CMTime addend1, CMTime addend2), (addend1, addend2))
+#define CMTimeAdd softLink_CoreMedia_CMTimeAdd
+SOFT_LINK_FUNCTION_HEADER(WebCore, CoreMedia, CMTimeMakeFromDictionary, CMTime, (CFDictionaryRef dict), (dict))
+#define CMTimeMakeFromDictionary softLink_CoreMedia_CMTimeMakeFromDictionary
 
 #endif // PLATFORM(WIN)
 

Modified: trunk/Source/WebCore/platform/mac/SoftLinking.h (180475 => 180476)


--- trunk/Source/WebCore/platform/mac/SoftLinking.h	2015-02-21 03:44:33 UTC (rev 180475)
+++ trunk/Source/WebCore/platform/mac/SoftLinking.h	2015-02-21 04:09:02 UTC (rev 180476)
@@ -22,6 +22,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef SoftLinking_h
+#define SoftLinking_h
+
 #import <wtf/Assertions.h>
 #import <dlfcn.h>
 
@@ -29,6 +32,8 @@
 #import <objc/runtime.h>
 #endif
 
+#pragma mark - Soft-link macros for use within a single source file
+
 #define SOFT_LINK_LIBRARY(lib) \
     static void* lib##Library() \
     { \
@@ -109,36 +114,6 @@
         return softLink##functionName parameterNames; \
     }
 
-#define SOFT_LINK_FUNCTION_HEADER(functionName, resultType, parameterDeclarations, parameterNames) \
-    WTF_EXTERN_C_BEGIN \
-    resultType functionName parameterDeclarations; \
-    WTF_EXTERN_C_END \
-    namespace WebCore { \
-    extern resultType (*softLink##functionName) parameterDeclarations; \
-    } \
-    inline resultType softLink_##functionName parameterDeclarations \
-    { \
-        return WebCore::softLink##functionName parameterNames; \
-    }
-
-#define SOFT_LINK_FUNCTION_SOURCE(framework, functionName, resultType, parameterDeclarations, parameterNames) \
-    WTF_EXTERN_C_BEGIN \
-    resultType functionName parameterDeclarations; \
-    WTF_EXTERN_C_END \
-    namespace WebCore { \
-    static resultType init##functionName parameterDeclarations; \
-    resultType (*softLink##functionName) parameterDeclarations = init##functionName; \
-    static resultType init##functionName parameterDeclarations \
-    { \
-        static dispatch_once_t once; \
-        dispatch_once(&once, ^{ \
-            softLink##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \
-            ASSERT_WITH_MESSAGE(softLink##functionName, "%s", dlerror()); \
-        }); \
-        return softLink##functionName parameterNames; \
-    } \
-    }
-
 #define SOFT_LINK_MAY_FAIL(framework, functionName, resultType, parameterDeclarations, parameterNames) \
     WTF_EXTERN_C_BEGIN \
     resultType functionName parameterDeclarations; \
@@ -313,3 +288,53 @@
         get##name = name##Function; \
         return true; \
     }
+
+#pragma mark - Soft-link macros for sharing across multiple source files
+
+// See Source/WebCore/platform/cf/CoreMediaSoftLink.{cpp,h} for an example implementation.
+
+#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
+    namespace functionNamespace { \
+    static void* framework##Library() \
+    { \
+        static void* frameworkLibrary; \
+        static dispatch_once_t once; \
+        dispatch_once(&once, ^{ \
+            frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
+            ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
+        }); \
+        return frameworkLibrary; \
+    } \
+    }
+
+#define SOFT_LINK_FUNCTION_HEADER(functionNamespace, framework, functionName, resultType, parameterDeclarations, parameterNames) \
+    WTF_EXTERN_C_BEGIN \
+    resultType functionName parameterDeclarations; \
+    WTF_EXTERN_C_END \
+    namespace functionNamespace { \
+    extern resultType (*softLink##framework##functionName) parameterDeclarations; \
+    inline resultType softLink_##framework##_##functionName parameterDeclarations \
+    { \
+        return softLink##framework##functionName parameterNames; \
+    } \
+    }
+
+#define SOFT_LINK_FUNCTION_SOURCE(functionNamespace, framework, functionName, resultType, parameterDeclarations, parameterNames) \
+    WTF_EXTERN_C_BEGIN \
+    resultType functionName parameterDeclarations; \
+    WTF_EXTERN_C_END \
+    namespace functionNamespace { \
+    static resultType init##framework##functionName parameterDeclarations; \
+    resultType (*softLink##framework##functionName) parameterDeclarations = init##framework##functionName; \
+    static resultType init##framework##functionName parameterDeclarations \
+    { \
+        static dispatch_once_t once; \
+        dispatch_once(&once, ^{ \
+            softLink##framework##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \
+            ASSERT_WITH_MESSAGE(softLink##framework##functionName, "%s", dlerror()); \
+        }); \
+        return softLink##framework##functionName parameterNames; \
+    } \
+    }
+
+#endif // SoftLinking_h

Modified: trunk/Source/WebCore/platform/win/SoftLinking.h (180475 => 180476)


--- trunk/Source/WebCore/platform/win/SoftLinking.h	2015-02-21 03:44:33 UTC (rev 180475)
+++ trunk/Source/WebCore/platform/win/SoftLinking.h	2015-02-21 04:09:02 UTC (rev 180476)
@@ -28,11 +28,7 @@
 #include <windows.h>
 #include <wtf/Assertions.h>
 
-#ifdef DEBUG_ALL
-#define SOFT_LINK_FRAMEWORK(framework) SOFT_LINK_DEBUG_LIBRARY(framework)
-#else
-#define SOFT_LINK_FRAMEWORK(framework) SOFT_LINK_LIBRARY(framework)
-#endif
+#pragma mark - Soft-link helper macros
 
 #define SOFT_LINK_LIBRARY_HELPER(lib, suffix) \
     static HMODULE lib##Library() \
@@ -45,6 +41,8 @@
 #define SOFT_LINK_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L".dll")
 #define SOFT_LINK_DEBUG_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L"_debug.dll")
 
+#pragma mark - Soft-link macros for use within a single source file
+
 #define SOFT_LINK(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \
     static resultType callingConvention init##functionName parameterDeclarations; \
     static resultType (callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \
@@ -116,27 +114,6 @@
         return softLink##functionName parameterNames; \
     }
 
-#define SOFT_LINK_FUNCTION_HEADER(functionName, resultType, parameterDeclarations, parameterNames) \
-    namespace WebCore { \
-    extern resultType(__cdecl*softLink##functionName) parameterDeclarations; \
-    } \
-    inline resultType softLink_##functionName parameterDeclarations \
-    { \
-        return WebCore::softLink##functionName parameterNames; \
-    }
-
-#define SOFT_LINK_FUNCTION_SOURCE(library, functionName, resultType, parameterDeclarations, parameterNames) \
-    namespace WebCore { \
-    static resultType __cdecl init##functionName parameterDeclarations; \
-    resultType(__cdecl*softLink##functionName) parameterDeclarations = init##functionName; \
-    static resultType __cdecl init##functionName parameterDeclarations \
-    { \
-        softLink##functionName = reinterpret_cast<resultType (__cdecl*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
-        ASSERT(softLink##functionName); \
-        return softLink##functionName parameterNames; \
-    } \
-    }
-
 #define SOFT_LINK_DLL_IMPORT_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \
     typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
     static functionName##PtrType functionName##Ptr() \
@@ -194,4 +171,41 @@
         return *ptr; \
     } \
 
+#pragma mark - Soft-link macros for sharing across multiple source files
+
+// See Source/WebCore/platform/cf/CoreMediaSoftLink.{cpp,h} for an example implementation.
+
+#ifdef DEBUG_ALL
+#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
+    namespace functionNamespace { \
+    SOFT_LINK_DEBUG_LIBRARY(framework) \
+    }
+#else
+#define SOFT_LINK_FRAMEWORK_SOURCE(functionNamespace, framework) \
+    namespace functionNamespace { \
+    SOFT_LINK_LIBRARY(framework) \
+    }
+#endif
+
+#define SOFT_LINK_FUNCTION_HEADER(functionNamespace, framework, functionName, resultType, parameterDeclarations, parameterNames) \
+    namespace functionNamespace { \
+    extern resultType(__cdecl*softLink##framework##functionName) parameterDeclarations; \
+    inline resultType softLink_##framework##_##functionName parameterDeclarations \
+    { \
+        return softLink##framework##functionName parameterNames; \
+    } \
+    }
+
+#define SOFT_LINK_FUNCTION_SOURCE(functionNamespace, framework, functionName, resultType, parameterDeclarations, parameterNames) \
+    namespace functionNamespace { \
+    static resultType __cdecl init##framework##functionName parameterDeclarations; \
+    resultType(__cdecl*softLink##framework##functionName) parameterDeclarations = init##framework##functionName; \
+    static resultType __cdecl init##framework##functionName parameterDeclarations \
+    { \
+        softLink##framework##functionName = reinterpret_cast<resultType (__cdecl*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(framework##Library(), #functionName)); \
+        ASSERT(softLink##framework##functionName); \
+        return softLink##framework##functionName parameterNames; \
+    } \
+    }
+
 #endif // SoftLinking_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to