[Cocoa] Add optional variants of SOFT_LINK_CLASS_FOR_SOURCE
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Dec 2018 18:40:31 +0000 (18:40 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Dec 2018 18:40:31 +0000 (18:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192498

Reviewed by Tim Horton.

Added SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL and SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT,
which behave like their non-optional variants but do not require their classes to exist.

* wtf/cocoa/SoftLinking.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238955 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/cocoa/SoftLinking.h

index d493a4e..a21dc56 100644 (file)
@@ -1,3 +1,15 @@
+2018-12-07  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add optional variants of SOFT_LINK_CLASS_FOR_SOURCE
+        https://bugs.webkit.org/show_bug.cgi?id=192498
+
+        Reviewed by Tim Horton.
+
+        Added SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL and SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT,
+        which behave like their non-optional variants but do not require their classes to exist.
+
+        * wtf/cocoa/SoftLinking.h:
+
 2018-12-06  Alexey Proskuryakov  <ap@apple.com>
 
         Move USE_NEW_THEME out of WebCore's config.h
index 6434cbd..1afab5b 100644 (file)
     } \
     }
 
-#define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(functionNamespace, framework, className, export) \
+#define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, assertion) \
     @class className; \
     namespace functionNamespace { \
     static Class init##className(); \
         dispatch_once(&once, ^{ \
             framework##Library(); \
             class##className = objc_getClass(#className); \
-            RELEASE_ASSERT(class##className); \
+            assertion(class##className); \
             get##className##Class = className##Function; \
         }); \
         return class##className; \
     } \
     }
 
+#define NO_ASSERT(assertion) (void(0))
+
+#define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(functionNamespace, framework, className, export) \
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, RELEASE_ASSERT)
+
+#define SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(functionNamespace, framework, className, export) \
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, NO_ASSERT)
+
 #define SOFT_LINK_CLASS_FOR_SOURCE(functionNamespace, framework, className) \
-    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(functionNamespace, framework, className, )
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, , RELEASE_ASSERT)
+
+#define SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL(functionNamespace, framework, className) \
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, , NO_ASSERT)
 
 #define SOFT_LINK_CONSTANT_FOR_HEADER(functionNamespace, framework, variableName, variableType) \
     WTF_EXTERN_C_BEGIN \