Title: [246265] trunk/Source/_javascript_Core
Revision
246265
Author
[email protected]
Date
2019-06-10 09:35:00 -0700 (Mon, 10 Jun 2019)

Log Message

Make new Symbol/Promise API public
https://bugs.webkit.org/show_bug.cgi?id=198709

Reviewed by Saam Barati.

We also need to #ifdef some tests when building for older
platforms because the signatures for some methods are outdated on
those platforms.

* API/JSObjectRef.h:
* API/JSObjectRefPrivate.h:
* API/JSValue.h:
* API/JSValuePrivate.h:
* API/JSValueRef.h:
* API/tests/testapi.mm:
(testObjectiveCAPIMain):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSObjectRef.h (246264 => 246265)


--- trunk/Source/_javascript_Core/API/JSObjectRef.h	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/JSObjectRef.h	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Kelvin W Sherlock ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -477,6 +477,17 @@
 JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
 
 /*!
+ @function
+ @abstract Creates a _javascript_ promise object by invoking the provided executor.
+ @param ctx The execution context to use.
+ @param resolve A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
+ @param reject A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
+ @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
+ @result A JSObject that is a promise or NULL if an exception occurred.
+ */
+JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
 @function
 @abstract Creates a function with a given script as its body.
 @param ctx The execution context to use.
@@ -554,6 +565,54 @@
 JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
 
 /*!
+ @function
+ @abstract Tests whether an object has a given property using a JSValueRef as the property key.
+ @param object The JSObject to test.
+ @param propertyKey A JSValueRef containing the property key to use when looking up the property.
+ @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
+ @result true if the object has a property whose name matches propertyKey, otherwise false.
+ @discussion This function is the same as performing "propertyKey in object" from _javascript_.
+ */
+JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+ @function
+ @abstract Gets a property from an object using a JSValueRef as the property key.
+ @param ctx The execution context to use.
+ @param object The JSObject whose property you want to get.
+ @param propertyKey A JSValueRef containing the property key to use when looking up the property.
+ @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
+ @result The property's value if object has the property key, otherwise the undefined value.
+ @discussion This function is the same as performing "object[propertyKey]" from _javascript_.
+ */
+JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+ @function
+ @abstract Sets a property on an object using a JSValueRef as the property key.
+ @param ctx The execution context to use.
+ @param object The JSObject whose property you want to set.
+ @param propertyKey A JSValueRef containing the property key to use when looking up the property.
+ @param value A JSValueRef to use as the property's value.
+ @param attributes A logically ORed set of JSPropertyAttributes to give to the property.
+ @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
+ @discussion This function is the same as performing "object[propertyKey] = value" from _javascript_.
+ */
+JS_EXPORT void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+ @function
+ @abstract Deletes a property from an object using a JSValueRef as the property key.
+ @param ctx The execution context to use.
+ @param object The JSObject whose property you want to delete.
+ @param propertyKey A JSValueRef containing the property key to use when looking up the property.
+ @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
+ @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
+ @discussion This function is the same as performing "delete object[propertyKey]" from _javascript_.
+ */
+JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
 @function
 @abstract Gets a property from an object by numeric index.
 @param ctx The execution context to use.

Modified: trunk/Source/_javascript_Core/API/JSObjectRefPrivate.h (246264 => 246265)


--- trunk/Source/_javascript_Core/API/JSObjectRefPrivate.h	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/JSObjectRefPrivate.h	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -71,83 +71,6 @@
 
 JS_EXPORT JSGlobalContextRef JSObjectGetGlobalContext(JSObjectRef object);
 
-/*!
- @function
- @abstract Creates a _javascript_ promise object by invoking the provided executor.
- @param ctx The execution context to use.
- @param resolve A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
- @param reject A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
- @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
- @result A JSObject that is a promise or NULL if an exception occurred.
- */
-JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract Tests whether an object has a given property using a JSValueRef as the property key.
- @param object The JSObject to test.
- @param propertyKey A JSValueRef containing the property key to use when looking up the property.
- @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
- @result true if the object has a property whose name matches propertyKey, otherwise false.
- @discussion This function is the same as performing "propertyKey in object" from _javascript_.
- */
-JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract Gets a property from an object using a JSValueRef as the property key.
- @param ctx The execution context to use.
- @param object The JSObject whose property you want to get.
- @param propertyKey A JSValueRef containing the property key to use when looking up the property.
- @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
- @result The property's value if object has the property key, otherwise the undefined value.
- @discussion This function is the same as performing "object[propertyKey]" from _javascript_.
- */
-JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract Sets a property on an object using a JSValueRef as the property key.
- @param ctx The execution context to use.
- @param object The JSObject whose property you want to set.
- @param propertyKey A JSValueRef containing the property key to use when looking up the property.
- @param value A JSValueRef to use as the property's value.
- @param attributes A logically ORed set of JSPropertyAttributes to give to the property.
- @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
- @discussion This function is the same as performing "object[propertyKey] = value" from _javascript_.
- */
-JS_EXPORT void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract Deletes a property from an object using a JSValueRef as the property key.
- @param ctx The execution context to use.
- @param object The JSObject whose property you want to delete.
- @param propertyKey A JSValueRef containing the property key to use when looking up the property.
- @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
- @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
- @discussion This function is the same as performing "delete object[propertyKey]" from _javascript_.
- */
-JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract            Creates a _javascript_ value of the symbol type.
- @param ctx           The execution context to use.
- @param description   A description of the newly created symbol value.
- @result              A unique JSValue of the symbol type, whose description matches the one provided.
- */
-JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @function
- @abstract       Tests whether a _javascript_ value's type is the symbol type.
- @param ctx      The execution context to use.
- @param value    The JSValue to test.
- @result         true if value's type is the symbol type, otherwise false.
- */
-JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/_javascript_Core/API/JSValue.h (246264 => 246265)


--- trunk/Source/_javascript_Core/API/JSValue.h	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/JSValue.h	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -134,6 +134,45 @@
 
 /*!
 @method
+@abstract Create a new promise object using the provided executor callback.
+@param callback A callback block invoked while the promise object is being initialized. The resolve and reject parameters are functions that can be called to notify any pending reactions about the state of the new promise object.
+@param context The JSContext to which the resulting JSValue belongs.
+@result The JSValue representing a new promise _javascript_ object.
+@discussion This method is equivalent to calling the Promise constructor in _javascript_. the resolve and reject callbacks each normally take a single value, which they forward to all relevent pending reactions. While inside the executor callback context will act as if it were in any other callback, except calleeFunction will be <code>nil</code>. This also means means the new promise object may be accessed via <code>[context thisValue]</code>.
+*/
++ (JSValue *)valueWithNewPromiseInContext:(JSContext *)context fromExecutor:(void (^)(JSValue *resolve, JSValue *reject))callback JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+@method
+@abstract Create a new resolved promise object with the provided value.
+@param result The result value to be passed to any reactions.
+@param context The JSContext to which the resulting JSValue belongs.
+@result The JSValue representing a new promise _javascript_ object.
+@discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [resolve callWithArguments:@[result]]; } inContext:context]</code>
+*/
++ (JSValue *)valueWithNewPromiseResolvedWithResult:(id)result inContext:(JSContext *)context JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+@method
+@abstract Create a new rejected promise object with the provided value.
+@param reason The result value to be passed to any reactions.
+@param context The JSContext to which the resulting JSValue belongs.
+@result The JSValue representing a new promise _javascript_ object.
+@discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [reject callWithArguments:@[reason]]; } inContext:context]</code>
+*/
++ (JSValue *)valueWithNewPromiseRejectedWithReason:(id)reason inContext:(JSContext *)context JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+@method
+@abstract Create a new, unique, symbol object.
+@param description The description of the symbol object being created.
+@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(macos(10.15), ios(13.0));
+
+/*!
+@method
 @abstract Create the _javascript_ value <code>null</code>.
 @param context The JSContext to which the resulting JSValue belongs.
 @result The JSValue representing the _javascript_ value <code>null</code>.
@@ -358,6 +397,12 @@
 @property (readonly) BOOL isDate JSC_API_AVAILABLE(macos(10.11), ios(9.0));
 
 /*!
+ @property
+ @abstract Check if a JSValue is a symbol.
+ */
+@property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
 @method
 @abstract Compare two JSValues using _javascript_'s <code>===</code> operator.
 */
@@ -504,26 +549,35 @@
  */
 @interface JSValue (PropertyAccess)
 
+#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000)
+typedef NSString *JSValueProperty;
+#else
+typedef id JSValueProperty;
+#endif
+
 /*!
  @method
  @abstract Access a property of a JSValue.
  @result The JSValue for the requested property or the JSValue <code>undefined</code>
  if the property does not exist.
+ @discussion Corresponds to the _javascript_ operation <code>object[property]</code>. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
  */
-- (JSValue *)valueForProperty:(NSString *)property;
+- (JSValue *)valueForProperty:(JSValueProperty)property;
 
 /*!
  @method
  @abstract Set a property on a JSValue.
+ @discussion Corresponds to the _javascript_ operation <code>object[property] = value</code>. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
  */
-- (void)setValue:(id)value forProperty:(NSString *)property;
+- (void)setValue:(id)value forProperty:(JSValueProperty)property;
 
 /*!
  @method
  @abstract Delete a property from a JSValue.
  @result YES if deletion is successful, NO otherwise.
+ @discussion Corresponds to the _javascript_ operation <code>delete object[property]</code>. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
  */
-- (BOOL)deleteProperty:(NSString *)property;
+- (BOOL)deleteProperty:(JSValueProperty)property;
 
 /*!
  @method
@@ -530,17 +584,17 @@
  @abstract Check if a JSValue has a property.
  @discussion This method has the same function as the _javascript_ operator <code>in</code>.
  @result Returns YES if property is present on the value.
+ @discussion Corresponds to the _javascript_ operation <code>property in object</code>. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
  */
-- (BOOL)hasProperty:(NSString *)property;
+- (BOOL)hasProperty:(JSValueProperty)property;
 
 /*!
  @method
  @abstract Define properties with custom descriptors on JSValues.
  @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.
+ This method operates in accordance with the Object.defineProperty method in the _javascript_ language. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of <code>valueWithObject:inContext:</code>. Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
  */
-- (void)defineProperty:(NSString *)property descriptor:(id)descriptor;
+- (void)defineProperty:(JSValueProperty)property descriptor:(id)descriptor;
 
 /*!
  @method
@@ -574,13 +628,16 @@
 @/textblock
 
  An object key passed as a subscript will be converted to a _javascript_ value,
- and then the value converted to a string used as a property name.
+ and then the value using the same rules as <code>valueWithObject:inContext:</code>. In macOS
+ 10.14 and iOS 12 and below, the <code>key</code> argument of
+ <code>setObject:object forKeyedSubscript:key</code> was restricted to an
+ <code>NSObject <NSCopying> *</code> but that restriction was never used internally.
 */
 @interface JSValue (SubscriptSupport)
 
 - (JSValue *)objectForKeyedSubscript:(id)key;
 - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
-- (void)setObject:(id)object forKeyedSubscript:(NSObject <NSCopying> *)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
 - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;
 
 @end

Modified: trunk/Source/_javascript_Core/API/JSValuePrivate.h (246264 => 246265)


--- trunk/Source/_javascript_Core/API/JSValuePrivate.h	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/JSValuePrivate.h	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,133 +29,8 @@
 
 @interface JSValue(JSPrivate)
 
-#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;
-#else
-typedef id JSValueProperty;
-#endif
+// Currently empty. May be used again in the future.
 
-/*!
- @method
- @abstract Create a new, unique, symbol object.
- @param description The description of the symbol object being created.
- @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(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @method
- @abstract Access a property of a JSValue.
- @result The JSValue for the requested property or the JSValue <code>undefined</code>
- 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;
-
-/*!
- @method
- @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;
-
-/*!
- @method
- @abstract Delete a property from a JSValue.
- @result YES if deletion is successful, NO otherwise.
- @discussion Corresponds to the _javascript_ operation <code>delete 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 *.
- */
-- (BOOL)deleteProperty:(JSValueProperty)property;
-
-/*!
- @method
- @abstract Check if a JSValue has a property.
- @discussion This method has the same function as the _javascript_ operator <code>in</code>.
- @result Returns YES if property is present on the value.
- @discussion Corresponds to the _javascript_ operation <code>property in object</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 *.
- */
-- (BOOL)hasProperty:(JSValueProperty)property;
-
-/*!
- @method
- @abstract Define properties with custom descriptors on JSValues.
- @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;
-
-/*!
- @property
- @abstract Check if a JSValue is a symbol.
- */
-@property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @method
- @abstract Create a new promise object using the provided executor callback.
- @param callback A callback block invoked while the promise object is
- being initialized. The resolve and reject parameters are functions that
- can be called to notify any pending reactions about the state of the
- new promise object.
- @param context The JSContext to which the resulting JSValue belongs.
- @result The JSValue representing a new promise _javascript_ object.
- @discussion This method is equivalent to calling the Promise constructor in _javascript_.
- the resolve and reject callbacks each normally take a single value, which they
- forward to all relevent pending reactions. While inside the executor callback context will act
- as if it were in any other callback, except calleeFunction will be <code>nil</code>. This also means
- means the new promise object may be accessed via <code>[context thisValue]</code>.
- */
-+ (JSValue *)valueWithNewPromiseInContext:(JSContext *)context fromExecutor:(void (^)(JSValue *resolve, JSValue *reject))callback JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @method
- @abstract Create a new resolved promise object with the provided value.
- @param result The result value to be passed to any reactions.
- @param context The JSContext to which the resulting JSValue belongs.
- @result The JSValue representing a new promise _javascript_ object.
- @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [resolve callWithArguments:@[result]]; } inContext:context]</code>
- */
-+ (JSValue *)valueWithNewPromiseResolvedWithResult:(id)result inContext:(JSContext *)context JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
-/*!
- @method
- @abstract Create a new rejected promise object with the provided value.
- @param reason The result value to be passed to any reactions.
- @param context The JSContext to which the resulting JSValue belongs.
- @result The JSValue representing a new promise _javascript_ object.
- @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [reject callWithArguments:@[reason]]; } inContext:context]</code>
- */
-+ (JSValue *)valueWithNewPromiseRejectedWithReason:(id)reason inContext:(JSContext *)context JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));
-
 @end
 
-/*!
- @category
- @discussion Instances of JSValue implement the following methods in order to enable
- support for subscript access by key and index, for example:
-
- @textblock
- JSValue *objectA, *objectB;
- JSValue *v1 = object[@"X"]; // Get value for property "X" from 'object'.
- JSValue *v2 = object[42];   // Get value for index 42 from 'object'.
- object[@"Y"] = v1;          // Assign 'v1' to property "Y" of 'object'.
- object[101] = v2;           // Assign 'v2' to index 101 of 'object'.
- @/textblock
-
- An object key passed as a subscript will be converted to a _javascript_ value,
- and then the value using the same rules as <code>valueWithObject:inContext:</code>. In macOS
- TBA and iOS TBA and below, the <code>key</code> argument of
- <code>setObject:object forKeyedSubscript:key</code> was restricted to an
- <code>NSString <NSCopying> *</code> but that restriction was never used.
- */
-@interface JSValue (SubscriptSupportPrivate)
-
-- (JSValue *)objectForKeyedSubscript:(JSValueProperty)key;
-- (JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
-- (void)setObject:(id)object forKeyedSubscript:(JSValueProperty)key;
-- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;
-
-@end
-
 #endif // JSC_OBJC_API_ENABLED

Modified: trunk/Source/_javascript_Core/API/JSValueRef.h (246264 => 246265)


--- trunk/Source/_javascript_Core/API/JSValueRef.h	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/JSValueRef.h	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2019 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -51,7 +51,7 @@
     kJSTypeNumber,
     kJSTypeString,
     kJSTypeObject,
-    kJSTypeSymbol JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA))
+    kJSTypeSymbol JSC_API_AVAILABLE(macos(10.15), ios(13.0))
 } JSType;
 
 /*!
@@ -144,6 +144,15 @@
 
 /*!
 @function
+@abstract       Tests whether a _javascript_ value's type is the symbol type.
+@param ctx      The execution context to use.
+@param value    The JSValue to test.
+@result         true if value's type is the symbol type, otherwise false.
+*/
+JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
+/*!
+@function
 @abstract       Tests whether a _javascript_ value's type is the object type.
 @param ctx  The execution context to use.
 @param value    The JSValue to test.
@@ -270,6 +279,15 @@
 */
 JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string);
 
+/*!
+ @function
+ @abstract            Creates a _javascript_ value of the symbol type.
+ @param ctx           The execution context to use.
+ @param description   A description of the newly created symbol value.
+ @result              A unique JSValue of the symbol type, whose description matches the one provided.
+ */
+JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
+
 /* Converting to and from JSON formatted strings */
 
 /*!

Modified: trunk/Source/_javascript_Core/API/tests/testapi.mm (246264 => 246265)


--- trunk/Source/_javascript_Core/API/tests/testapi.mm	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/API/tests/testapi.mm	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -649,6 +649,10 @@
         checkResult(@"Should be a created from Obj-C", symbol.isSymbol);
     }
 
+// Older platforms ifdef the type of some selectors so these tests don't work.
+// FIXME: Remove this when we stop building for macOS 10.14/iOS 12.
+#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
+
     @autoreleasepool {
         JSContext *context = [[JSContext alloc] init];
         JSValue *arrayIterator = [context evaluateScript:@"Array.prototype[Symbol.iterator]"];
@@ -734,6 +738,8 @@
         checkResult(@"iteration count should be 1", [count toUInt32] == 1);
     }
 
+#endif
+
     @autoreleasepool {
         JSCollection* myPrivateProperties = [[JSCollection alloc] init];
 

Modified: trunk/Source/_javascript_Core/ChangeLog (246264 => 246265)


--- trunk/Source/_javascript_Core/ChangeLog	2019-06-10 16:16:52 UTC (rev 246264)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-06-10 16:35:00 UTC (rev 246265)
@@ -1,3 +1,22 @@
+2019-06-10  Keith Miller  <[email protected]>
+
+        Make new Symbol/Promise API public
+        https://bugs.webkit.org/show_bug.cgi?id=198709
+
+        Reviewed by Saam Barati.
+
+        We also need to #ifdef some tests when building for older
+        platforms because the signatures for some methods are outdated on
+        those platforms.
+
+        * API/JSObjectRef.h:
+        * API/JSObjectRefPrivate.h:
+        * API/JSValue.h:
+        * API/JSValuePrivate.h:
+        * API/JSValueRef.h:
+        * API/tests/testapi.mm:
+        (testObjectiveCAPIMain):
+
 2019-06-09  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r246150, r246160, and r246166.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to