[Cocoa] Actually use Objective-C lightweight generics when the compiler supports...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Jun 2015 03:27:20 +0000 (03:27 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Jun 2015 03:27:20 +0000 (03:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146183

Reviewed by Sam Weinig.

* Shared/API/Cocoa/WKFoundation.h: When the compiler supports Objective-C generics, define
WK_ARRAY and WK_SET to use them. Also added a definition of WK_DICTIONARY.

* UIProcess/API/Cocoa/WKWebViewPrivate.h: Use WK_DICTIONARY for the options dictionary of
-_loadRequest:withOptions:.

* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore fetchDataRecordsOfTypes:completionHandler:]): Made the completion
halder type match the declaration, now that NSArray and WK_ARRAY(WKWebsiteDataRecord *) are
not the same.

* mac/postprocess-framework-headers.sh: Also rewrite WK_DICTIONARY.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKFoundation.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit2/mac/postprocess-framework-headers.sh

index 22e1c69..79a7ef4 100644 (file)
@@ -1,3 +1,23 @@
+2015-06-20  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Actually use Objective-C lightweight generics when the compiler supports them
+        https://bugs.webkit.org/show_bug.cgi?id=146183
+
+        Reviewed by Sam Weinig.
+
+        * Shared/API/Cocoa/WKFoundation.h: When the compiler supports Objective-C generics, define
+        WK_ARRAY and WK_SET to use them. Also added a definition of WK_DICTIONARY.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Use WK_DICTIONARY for the options dictionary of
+        -_loadRequest:withOptions:.
+
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (-[WKWebsiteDataStore fetchDataRecordsOfTypes:completionHandler:]): Made the completion
+        halder type match the declaration, now that NSArray and WK_ARRAY(WKWebsiteDataRecord *) are
+        not the same.
+
+        * mac/postprocess-framework-headers.sh: Also rewrite WK_DICTIONARY.
+
 2015-06-20  Chris Dumez  <cdumez@apple.com>
 
         [WK2][iOS] Avoid synchronous IPC on view state change when the content is not visible
index 7397e07..6a396d5 100644 (file)
 #define WK_ENUM_AVAILABLE(_mac, _ios)
 #define WK_ENUM_AVAILABLE_IOS(_ios)
 
+#if __has_feature(objc_generics)
+
+#define WK_ARRAY(_objectType) NSArray<_objectType>
+#define WK_DICTIONARY(_keyType, _valueType) NSDictionary<_keyType, _valueType>
+#define WK_SET(_objectType) NSSet<_objectType>
+
+#else
+
 #define WK_ARRAY(...) NSArray
+#define WK_DICTIONARY(...) NSDictionary
 #define WK_SET(...) NSSet
 
+#endif
+
 #ifndef __NSi_8_3
 #define __NSi_8_3 introduced=8.3
 #endif
index 447d089..0b02f17 100644 (file)
@@ -205,7 +205,7 @@ WK_EXTERN NSString * const _WKShouldOpenExternalURLsKey WK_AVAILABLE(WK_MAC_TBA,
 @property (nonatomic, setter=_setScrollPerformanceDataCollectionEnabled:) BOOL _scrollPerformanceDataCollectionEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 @property (nonatomic, readonly) NSArray *_scrollPerformanceData WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
-- (WKNavigation *)_loadRequest:(NSURLRequest *)request withOptions:(NSDictionary *)loadOptions WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+- (WKNavigation *)_loadRequest:(NSURLRequest *)request withOptions:(WK_DICTIONARY(NSString *, id) *)loadOptions WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
 @end
 
index 6d935a2..ec8328e 100644 (file)
@@ -74,7 +74,7 @@ static std::chrono::system_clock::time_point toSystemClockTime(NSDate *date)
     return system_clock::time_point(duration_cast<system_clock::duration>(duration<double>(date.timeIntervalSince1970)));
 }
 
-- (void)fetchDataRecordsOfTypes:(NSSet *)dataTypes completionHandler:(void (^)(NSArray *))completionHandler
+- (void)fetchDataRecordsOfTypes:(NSSet *)dataTypes completionHandler:(void (^)(WK_ARRAY(WKWebsiteDataRecord *) *))completionHandler
 {
     auto completionHandlerCopy = Block_copy(completionHandler);
 
index a4986d5..6436488 100755 (executable)
@@ -59,6 +59,7 @@ function rewrite_headers () {
 
     SED_OPTIONS=(
         -e 's/WK_ARRAY\(([^\)]+)\)/NSArray<\1>/g'
+        -e 's/WK_DICTIONARY\(([^\)]+)\)/NSDictionary<\1>/g'
         -e 's/WK_SET\(([^\)]+)\)/NSSet<\1>/g'
         -e s/WK_ASSUME_NONNULL_BEGIN/NS_ASSUME_NONNULL_BEGIN/
         -e s/WK_ASSUME_NONNULL_END/NS_ASSUME_NONNULL_END/