Title: [235432] trunk/Source/_javascript_Core
Revision
235432
Author
keith_mil...@apple.com
Date
2018-08-28 11:11:23 -0700 (Tue, 28 Aug 2018)

Log Message

Add nullablity attributes to JSValue
https://bugs.webkit.org/show_bug.cgi?id=189047

Reviewed by Geoffrey Garen.

* API/JSValue.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSValue.h (235431 => 235432)


--- trunk/Source/_javascript_Core/API/JSValue.h	2018-08-28 18:04:54 UTC (rev 235431)
+++ trunk/Source/_javascript_Core/API/JSValue.h	2018-08-28 18:11:23 UTC (rev 235432)
@@ -48,9 +48,9 @@
 @interface JSValue : NSObject
 
 #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < JSC_MAC_VERSION_TBA) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < JSC_IOS_VERSION_TBA)
-typedef NSString *JSValueProperty;
+typedef NSString * _Nonnull JSValueProperty;
 #else
-typedef id JSValueProperty;
+typedef id _Nullable JSValueProperty;
 #endif
 
 /*!
@@ -57,7 +57,7 @@
 @property
 @abstract The JSContext that this value originates from.
 */
-@property (readonly, strong) JSContext *context;
+@property (readonly, strong, nonnull) JSContext *context;
 
 /*!
 @methodgroup Creating _javascript_ Values
@@ -69,7 +69,7 @@
 @param value The Objective-C object to be converted.
 @result The new JSValue.
 */
-+ (JSValue *)valueWithObject:(id)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithObject:(nullable id)value inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -77,7 +77,7 @@
 @param context The JSContext in which the resulting JSValue will be created.
 @result The new JSValue representing the equivalent boolean value.
 */
-+ (JSValue *)valueWithBool:(BOOL)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithBool:(BOOL)value inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -85,7 +85,7 @@
 @param context The JSContext in which the resulting JSValue will be created.
 @result The new JSValue representing the equivalent boolean value.
 */
-+ (JSValue *)valueWithDouble:(double)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithDouble:(double)value inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -93,7 +93,7 @@
 @param context The JSContext in which the resulting JSValue will be created.
 @result The new JSValue representing the equivalent boolean value.
 */
-+ (JSValue *)valueWithInt32:(int32_t)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithInt32:(int32_t)value inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -101,7 +101,7 @@
 @param context The JSContext in which the resulting JSValue will be created.
 @result The new JSValue representing the equivalent boolean value.
 */
-+ (JSValue *)valueWithUInt32:(uint32_t)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithUInt32:(uint32_t)value inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -109,7 +109,7 @@
 @param context The JSContext in which the resulting object will be created.
 @result The new _javascript_ object.
 */
-+ (JSValue *)valueWithNewObjectInContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithNewObjectInContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -117,7 +117,7 @@
 @param context The JSContext in which the resulting array will be created.
 @result The new _javascript_ array.
 */
-+ (JSValue *)valueWithNewArrayInContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithNewArrayInContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -127,7 +127,7 @@
 @param context The JSContext in which the resulting regular _expression_ object will be created.
 @result The new _javascript_ regular _expression_ object.
 */
-+ (JSValue *)valueWithNewRegularExpressionFromPattern:(NSString *)pattern flags:(NSString *)flags inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithNewRegularExpressionFromPattern:(nonnull NSString *)pattern flags:(nonnull NSString *)flags inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -136,7 +136,7 @@
 @param context The JSContext in which the resulting error object will be created.
 @result The new _javascript_ error object.
 */
-+ (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithNewErrorFromMessage:(nonnull NSString *)message inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -144,7 +144,7 @@
 @param context The JSContext to which the resulting JSValue belongs.
 @result The JSValue representing the _javascript_ value <code>null</code>.
 */
-+ (JSValue *)valueWithNullInContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithNullInContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -152,7 +152,7 @@
 @param context The JSContext to which the resulting JSValue belongs.
 @result The JSValue representing the _javascript_ value <code>undefined</code>.
 */
-+ (JSValue *)valueWithUndefinedInContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithUndefinedInContext:(nonnull JSContext *)context;
 
 /*!
  @method
@@ -161,7 +161,7 @@
  @param context The JSContext to which the resulting JSValue belongs.
  @result The JSValue representing a unique _javascript_ value with type symbol.
  */
-+ (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));
++ (nonnull JSValue *)valueWithNewSymbolFromDescription:(nonnull NSString *)description inContext:(nonnull JSContext *)context JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));
 
 /*!
 @methodgroup Converting to Objective-C Types
@@ -216,7 +216,7 @@
  to the conversion rules specified above.
 @result The Objective-C representation of this JSValue.
 */
-- (id)toObject;
+- (nullable id)toObject;
 
 /*!
 @method
@@ -225,7 +225,7 @@
  If the result is not of the specified Class then <code>nil</code> will be returned.
 @result An Objective-C object of the specified Class or <code>nil</code>.
 */
-- (id)toObjectOfClass:(Class)expectedClass;
+- (nullable id)toObjectOfClass:(nonnull Class)expectedClass;
 
 /*!
 @method
@@ -271,7 +271,7 @@
  to the rules specified by the _javascript_ language.
 @result The NSNumber result of the conversion.
 */
-- (NSNumber *)toNumber;
+- (nullable NSNumber *)toNumber;
 
 /*!
 @method
@@ -280,7 +280,7 @@
  by the _javascript_ language.
 @result The NSString containing the result of the conversion.
 */
-- (NSString *)toString;
+- (nullable NSString *)toString;
 
 /*!
 @method
@@ -289,7 +289,7 @@
  since 1970 which is then used to create a new NSDate instance.
 @result The NSDate created using the converted time interval.
 */
-- (NSDate *)toDate;
+- (nullable NSDate *)toDate;
 
 /*!
 @method
@@ -303,7 +303,7 @@
 @result The NSArray containing the recursively converted contents of the 
  converted _javascript_ array.
 */
-- (NSArray *)toArray;
+- (nullable NSArray *)toArray;
 
 /*!
 @method
@@ -315,7 +315,7 @@
 @result The NSDictionary containing the recursively converted contents of
  the converted _javascript_ object.
 */
-- (NSDictionary *)toDictionary;
+- (nullable NSDictionary *)toDictionary;
 
 /*!
 @methodgroup Accessing Properties
@@ -328,7 +328,7 @@
  if the property does not exist.
 @discussion Corresponds to the _javascript_ operation <code>object[property]</code>. After macOS TBA and iOS TBA, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS TBA and iOS TBA, 'property' was expected to be an NSString *.
 */
-- (JSValue *)valueForProperty:(JSValueProperty)property;
+- (nonnull JSValue *)valueForProperty:(JSValueProperty)property;
 
 /*!
 @method
@@ -335,7 +335,7 @@
 @abstract Set a property on a JSValue.
 @discussion Corresponds to the _javascript_ operation <code>object[property] = value</code>. After macOS TBA and iOS TBA, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS TBA and iOS TBA, 'property' was expected to be an NSString *.
 */
-- (void)setValue:(id)value forProperty:(JSValueProperty)property;
+- (void)setValue:(nullable id)value forProperty:(JSValueProperty)property;
 
 /*!
 @method
@@ -360,7 +360,7 @@
 @discussion This method may be used to create a data or accessor property on an object.
  This method operates in accordance with the Object.defineProperty method in the _javascript_ language. After macOS TBA and iOS TBA, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS TBA and iOS TBA, 'property' was expected to be an NSString *.
 */
-- (void)defineProperty:(JSValueProperty)property descriptor:(id)descriptor;
+- (void)defineProperty:(JSValueProperty)property descriptor:(nullable id)descriptor;
 
 /*!
 @method
@@ -368,7 +368,7 @@
 @result The JSValue for the property at the specified index. 
  Returns the _javascript_ value <code>undefined</code> if no property exists at that index. 
 */
-- (JSValue *)valueAtIndex:(NSUInteger)index;
+- (nonnull JSValue *)valueAtIndex:(NSUInteger)index;
 
 /*!
 @method
@@ -376,7 +376,7 @@
 @discussion For JSValues that are _javascript_ arrays, indices greater than 
  UINT_MAX - 1 will not affect the length of the array.
 */
-- (void)setValue:(id)value atIndex:(NSUInteger)index;
+- (void)setValue:(nullable id)value atIndex:(NSUInteger)index;
 
 /*!
 @functiongroup Checking _javascript_ Types
@@ -443,13 +443,13 @@
 @method
 @abstract Compare two JSValues using _javascript_'s <code>===</code> operator.
 */
-- (BOOL)isEqualToObject:(id)value;
+- (BOOL)isEqualToObject:(nullable id)value;
 
 /*!
 @method
 @abstract Compare two JSValues using _javascript_'s <code>==</code> operator.
 */
-- (BOOL)isEqualWithTypeCoercionToObject:(id)value;
+- (BOOL)isEqualWithTypeCoercionToObject:(nullable id)value;
 
 /*!
 @method
@@ -458,7 +458,7 @@
  If an object other than a JSValue is passed, it will first be converted according to
  the aforementioned rules.
 */
-- (BOOL)isInstanceOf:(id)value;
+- (BOOL)isInstanceOf:(nullable id)value;
 
 /*!
 @methodgroup Calling Functions and Constructors
@@ -471,7 +471,7 @@
 @param arguments The arguments to pass to the function.
 @result The return value of the function call. 
 */
-- (JSValue *)callWithArguments:(NSArray *)arguments;
+- (nonnull JSValue *)callWithArguments:(nullable NSArray *)arguments;
 
 /*!
 @method
@@ -480,7 +480,7 @@
 @param arguments The arguments to pass to the constructor.
 @result The return value of the constructor call.
 */
-- (JSValue *)constructWithArguments:(NSArray *)arguments;
+- (nonnull JSValue *)constructWithArguments:(nullable NSArray *)arguments;
 
 /*!
 @method
@@ -492,7 +492,7 @@
 @param arguments The arguments to pass to the method.
 @result The return value of the method call.
 */
-- (JSValue *)invokeMethod:(NSString *)method withArguments:(NSArray *)arguments;
+- (nonnull JSValue *)invokeMethod:(nonnull NSString *)method withArguments:(nullable NSArray *)arguments;
 
 @end
 
@@ -515,7 +515,7 @@
 @result A newly allocated _javascript_ object containing properties
  named <code>x</code> and <code>y</code>, with values from the CGPoint.
 */
-+ (JSValue *)valueWithPoint:(CGPoint)point inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithPoint:(CGPoint)point inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -523,7 +523,7 @@
 @result A newly allocated _javascript_ object containing properties
  named <code>location</code> and <code>length</code>, with values from the NSRange.
 */
-+ (JSValue *)valueWithRange:(NSRange)range inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithRange:(NSRange)range inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -532,7 +532,7 @@
 @result A newly allocated _javascript_ object containing properties
  named <code>x</code>, <code>y</code>, <code>width</code>, and <code>height</code>, with values from the CGRect.
 */
-+ (JSValue *)valueWithRect:(CGRect)rect inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithRect:(CGRect)rect inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -540,7 +540,7 @@
 @result A newly allocated _javascript_ object containing properties
  named <code>width</code> and <code>height</code>, with values from the CGSize.
 */
-+ (JSValue *)valueWithSize:(CGSize)size inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithSize:(CGSize)size inContext:(nonnull JSContext *)context;
 
 /*!
 @method
@@ -601,10 +601,10 @@
 */
 @interface JSValue (SubscriptSupport)
 
-- (JSValue *)objectForKeyedSubscript:(JSValueProperty)key;
-- (JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
-- (void)setObject:(id)object forKeyedSubscript:(JSValueProperty)key;
-- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;
+- (nonnull JSValue *)objectForKeyedSubscript:(JSValueProperty)key;
+- (nonnull JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
+- (void)setObject:(nullable id)object forKeyedSubscript:(JSValueProperty)key;
+- (void)setObject:(nullable id)object atIndexedSubscript:(NSUInteger)index;
 
 @end
 
@@ -619,7 +619,7 @@
 @abstract Creates a JSValue, wrapping its C API counterpart.
 @result The Objective-C API equivalent of the specified JSValueRef.
 */
-+ (JSValue *)valueWithJSValueRef:(JSValueRef)value inContext:(JSContext *)context;
++ (nonnull JSValue *)valueWithJSValueRef:(nonnull JSValueRef)value inContext:(nonnull JSContext *)context;
 
 /*!
 @property
@@ -626,7 +626,7 @@
 @abstract Returns the C API counterpart wrapped by a JSContext.
 @result The C API equivalent of this JSValue.
 */
-@property (readonly) JSValueRef JSValueRef;
+@property (readonly, nonnull) JSValueRef JSValueRef;
 @end
 
 #ifdef __cplusplus
@@ -665,27 +665,27 @@
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorWritableKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorWritableKey;
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorEnumerableKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorEnumerableKey;
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorConfigurableKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorConfigurableKey;
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorValueKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorValueKey;
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorGetKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorGetKey;
 /*!
 @const 
 */
-JS_EXPORT extern NSString * const JSPropertyDescriptorSetKey;
+JS_EXPORT extern NSString * const _Nonnull JSPropertyDescriptorSetKey;
 
 #ifdef __cplusplus
 } // extern "C"

Modified: trunk/Source/_javascript_Core/ChangeLog (235431 => 235432)


--- trunk/Source/_javascript_Core/ChangeLog	2018-08-28 18:04:54 UTC (rev 235431)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-08-28 18:11:23 UTC (rev 235432)
@@ -1,3 +1,12 @@
+2018-08-28  Keith Miller  <keith_mil...@apple.com>
+
+        Add nullablity attributes to JSValue
+        https://bugs.webkit.org/show_bug.cgi?id=189047
+
+        Reviewed by Geoffrey Garen.
+
+        * API/JSValue.h:
+
 2018-08-27  Yusuke Suzuki  <yusukesuz...@slowstart.org>
 
         [WebAssembly] Parse wasm modules in a streaming fashion
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to