Add support for nullability to the header postprocessing
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Feb 2015 16:36:39 +0000 (16:36 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Feb 2015 16:36:39 +0000 (16:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141573

Reviewed by Darin Adler.

* Shared/API/Cocoa/WKFoundation.h:
* UIProcess/API/Cocoa/WKBackForwardList.h:
* mac/postprocess-framework-headers.sh:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/WebKit.xcconfig
Source/WebKit2/Shared/API/Cocoa/WKFoundation.h
Source/WebKit2/UIProcess/API/Cocoa/WKBackForwardList.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/mac/postprocess-framework-headers.sh

index f9a3b6e..468dcf4 100644 (file)
@@ -1,3 +1,14 @@
+2015-02-13  Anders Carlsson  <andersca@apple.com>
+
+        Add support for nullability to the header postprocessing
+        https://bugs.webkit.org/show_bug.cgi?id=141573
+
+        Reviewed by Darin Adler.
+
+        * Shared/API/Cocoa/WKFoundation.h:
+        * UIProcess/API/Cocoa/WKBackForwardList.h:
+        * mac/postprocess-framework-headers.sh:
+
 2015-02-16  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
 
         [EFL] Rename WebContextEfl to WebProcessPoolEfl
index f268055..4699a47 100644 (file)
@@ -48,8 +48,9 @@ EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *.pdf WKActionMenuController.* com.app
 
 INSTALLHDRS_SCRIPT_PHASE = YES;
 
-WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED[sdk=iphone*] = YES;
-WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED = $(WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED_$(PLATFORM_NAME)_$(MAC_OS_X_VERSION_MAJOR));
-WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED_macosx_1090 = NO;
-WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED_macosx_101000 = NO;
-WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED_macosx_101100 = YES;
+WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED[sdk=iphoneos8.*] = YES;
+WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED[sdk=iphonesimulator8.*] = YES;
+
+WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED[sdk=macosx*] = $(WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED_macosx_$(MAC_OS_X_VERSION_MAJOR));
+WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED_macosx_1090 = YES;
+WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED_macosx_101000 = YES;
index a4e3872..fcbd7ca 100644 (file)
 #define WK_UNAVAILABLE
 #endif
 
+#ifndef NS_ASSUME_NONNULL_BEGIN
+#define WK_ASSUME_NONNULL_BEGIN
+#else
+#define WK_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
+#endif
+
+#ifndef NS_ASSUME_NONNULL_END
+#define WK_ASSUME_NONNULL_END
+#else
+#define WK_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
+#endif
+
+// We check for the "noescape" attribute here since it was added in the same version of clang
+// that added nullability qualifiers.
+#if !__has_attribute(noescape)
+#define WK_NULLABLE
+#define WK_NULL_UNSPECIFIED
+#define WK_NULLABLE_PROPERTY
+#else
+#define WK_NULLABLE nullable
+#define WK_NULL_UNSPECIFIED null_unspecified
+#define WK_NULLABLE_PROPERTY nullable,
+#endif
+
 #if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
 typedef NSUInteger NSEventModifierFlags;
 #endif
 
 #endif
 
-#endif // !defined(WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED)
+#endif
index a8c249e..27f2015 100644 (file)
 /*! @abstract A WKBackForwardList object is a list of webpages previously
  visited in a web view that can be reached by going back or forward.
  */
+WK_ASSUME_NONNULL_BEGIN
+
 WK_CLASS_AVAILABLE(10_10, 8_0)
 @interface WKBackForwardList : NSObject
 
 /*! @abstract The current item.
  */
-@property (nonatomic, readonly, strong) WKBackForwardListItem *currentItem;
+@property (WK_NULLABLE_PROPERTY nonatomic, readonly, strong) WKBackForwardListItem *currentItem;
 
 /*! @abstract The item immediately preceding the current item, or nil
 if there isn't one.
  */
-@property (nonatomic, readonly, strong) WKBackForwardListItem *backItem;
+@property (WK_NULLABLE_PROPERTY nonatomic, readonly, strong) WKBackForwardListItem *backItem;
 
 /*! @abstract The item immediately following the current item, or nil
 if there isn't one.
  */
-@property (nonatomic, readonly, strong) WKBackForwardListItem *forwardItem;
+@property (WK_NULLABLE_PROPERTY nonatomic, readonly, strong) WKBackForwardListItem *forwardItem;
 
 /*! @abstract Returns the item at a specified distance from the current
  item.
@@ -57,7 +59,7 @@ if there isn't one.
  @result The item at the specified distance from the current item, or nil
  if the index parameter exceeds the limits of the list.
  */
-- (WKBackForwardListItem *)itemAtIndex:(NSInteger)index;
+- (WK_NULLABLE WKBackForwardListItem *)itemAtIndex:(NSInteger)index;
 
 /*! @abstract The portion of the list preceding the current item.
  @discussion The items are in the order in which they were originally
@@ -73,4 +75,6 @@ if there isn't one.
 
 @end
 
+WK_ASSUME_NONNULL_END
+
 #endif
index 35efbfb..8ec2fdc 100644 (file)
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "WKFOUNDATION_H=${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/WKFoundation.h\n\nif [[ ${WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED} == \"YES\" ]]; then\n    UNIFDEF_OPTIONS=\"-DWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED\";\nelse\n    UNIFDEF_OPTIONS=\"-UWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED\";\nfi\n\nunifdef -B ${UNIFDEF_OPTIONS} -o ${WKFOUNDATION_H}.unifdef ${WKFOUNDATION_H}\n\ncase $? in\n0)\n    rm ${WKFOUNDATION_H}.unifdef\n    ;;\n1)\n    mv ${WKFOUNDATION_H}{.unifdef,}\n    ;;\n*)\n    exit 1\nesac\n";
+                       shellScript = "WKFOUNDATION_H=${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/WKFoundation.h\n\nif [[ \"${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}\" == \"YES\" ]]; then\n    UNIFDEF_OPTIONS=\"-UWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED\";\nelse\n    UNIFDEF_OPTIONS=\"-DWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED\";\nfi\n\nunifdef -B ${UNIFDEF_OPTIONS} -o ${WKFOUNDATION_H}.unifdef ${WKFOUNDATION_H}\n\ncase $? in\n0)\n    rm ${WKFOUNDATION_H}.unifdef\n    ;;\n1)\n    mv ${WKFOUNDATION_H}{.unifdef,}\n    ;;\n*)\n    exit 1\nesac\n";
                };
                1ADAE12C1919A43F00F48E21 /* Migrate Headers to WebKit2 */ = {
                        isa = PBXShellScriptBuildPhase;
index 5823311..f29ffdd 100755 (executable)
@@ -24,7 +24,7 @@
 # THE POSSIBILITY OF SUCH DAMAGE.
 #
 
-if [[ ${WK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED} == "NO" ]]; then
+if [[ "${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
     exit 0;
 fi
 
@@ -45,7 +45,7 @@ function rewrite_headers () {
 
     for HEADER_PATH in $1/*.h; do
         if [[ $HEADER_PATH -nt $TIMESTAMP_PATH ]]; then
-            sed -e s/WK_MAC_TBA/${OSX_VERSION}/ -e s/WK_IOS_TBA/${IOS_VERSION}/ -e s/^WK_CLASS_AVAILABLE/NS_CLASS_AVAILABLE/ -e s/WK_AVAILABLE/NS_AVAILABLE/ -e s/WK_DEPRECATED/NS_DEPRECATED/ -e s/WK_DESIGNATED_INITIALIZER/NS_DESIGNATED_INITIALIZER/ -e s/WK_ENUM_AVAILABLE/NS_ENUM_AVAILABLE/ -e s/WK_UNAVAILABLE/NS_UNAVAILABLE/ -e s/WK_NULLABLE_PROPERTY/nullable,/ ${HEADER_PATH} > ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} || exit $_;
+            sed -e s/WK_MAC_TBA/${OSX_VERSION}/ -e s/WK_IOS_TBA/${IOS_VERSION}/ -e s/^WK_CLASS_AVAILABLE/NS_CLASS_AVAILABLE/ -e s/WK_AVAILABLE/NS_AVAILABLE/ -e s/WK_DEPRECATED/NS_DEPRECATED/ -e s/WK_DESIGNATED_INITIALIZER/NS_DESIGNATED_INITIALIZER/ -e s/WK_ENUM_AVAILABLE/NS_ENUM_AVAILABLE/ -e s/WK_UNAVAILABLE/NS_UNAVAILABLE/ -e s/WK_ASSUME_NONNULL_BEGIN/NS_ASSUME_NONNULL_BEGIN/ -e s/WK_ASSUME_NONNULL_END/NS_ASSUME_NONNULL_END/ -e s/WK_NULLABLE_PROPERTY/nullable,/ -e s/WK_NULLABLE/nullable/ -e s/WK_NULL_UNSPECIFIED/null_unspecified/ ${HEADER_PATH} > ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} || exit $_;
             mv ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} $HEADER_PATH;
         fi
     done