WebKit Bugzilla
Attachment 371731 Details for
Bug 198709
: Make new Symbol/Promise API public
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198709-20190610113131.patch (text/plain), 31.59 KB, created by
Keith Miller
on 2019-06-10 02:31:32 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Keith Miller
Created:
2019-06-10 02:31:32 PDT
Size:
31.59 KB
patch
obsolete
>Subversion Revision: 246255 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 0aff93f5605e0ca7d66004e91bca6f86f473771f..23800c87ce57cda51e013a094a13bb76b46fa055 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-06-10 Keith Miller <keith_miller@apple.com> >+ >+ Make new Symbol/Promise API public >+ https://bugs.webkit.org/show_bug.cgi?id=198709 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 <commit-queue@webkit.org> > > Unreviewed, rolling out r246150, r246160, and r246166. >diff --git a/Source/JavaScriptCore/API/JSObjectRef.h b/Source/JavaScriptCore/API/JSObjectRef.h >index 412fbe9ea6aff2498939af8a19033ac3b5f3b49b..b0dbd78288b6263da28fb674b3318788419dc4ea 100644 >--- a/Source/JavaScriptCore/API/JSObjectRef.h >+++ b/Source/JavaScriptCore/API/JSObjectRef.h >@@ -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 (ksherlock@gmail.com) > * > * Redistribution and use in source and binary forms, with or without >@@ -476,6 +476,17 @@ JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, > */ > 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. >@@ -553,6 +564,54 @@ JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStrin > */ > 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. >diff --git a/Source/JavaScriptCore/API/JSObjectRefPrivate.h b/Source/JavaScriptCore/API/JSObjectRefPrivate.h >index 432637234c28ee21968cf3759ed53a2cb5eecae0..6e32612e38acdfb77527c0ec5724607dec6163c8 100644 >--- a/Source/JavaScriptCore/API/JSObjectRefPrivate.h >+++ b/Source/JavaScriptCore/API/JSObjectRefPrivate.h >@@ -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 JSObjectRef JSObjectGetProxyTarget(JSObjectRef); > > 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 >diff --git a/Source/JavaScriptCore/API/JSValue.h b/Source/JavaScriptCore/API/JSValue.h >index 8fe5291aabf8960887cf2c738adebf954190f687..1b5845e9bdea2c266340591a48a9a03834a49842 100644 >--- a/Source/JavaScriptCore/API/JSValue.h >+++ b/Source/JavaScriptCore/API/JSValue.h >@@ -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 >@@ -132,6 +132,45 @@ NS_CLASS_AVAILABLE(10_9, 7_0) > */ > + (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context; > >+/*! >+@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>. >@@ -357,6 +396,12 @@ NS_CLASS_AVAILABLE(10_9, 7_0) > */ > @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,43 +549,52 @@ Create a JSValue from a CGRect. > */ > @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 > @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 @@ Create a JSValue from a CGRect. > @/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 >diff --git a/Source/JavaScriptCore/API/JSValuePrivate.h b/Source/JavaScriptCore/API/JSValuePrivate.h >index b31574f28ecc172c81fe6175d9839675ba9a94f2..35d3d10003140a180e94d3e82f0bc2ac8a8a9919 100644 >--- a/Source/JavaScriptCore/API/JSValuePrivate.h >+++ b/Source/JavaScriptCore/API/JSValuePrivate.h >@@ -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,132 +29,7 @@ > > @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 >- >-/*! >- @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; >+// Currently empty. May be used again in the future. > > @end > >diff --git a/Source/JavaScriptCore/API/JSValueRef.h b/Source/JavaScriptCore/API/JSValueRef.h >index f09cc7a3a37baa95bc9906bc2cf978b856906d34..911b4bfc4df19a047dcea0848d4d52c28e7787df 100644 >--- a/Source/JavaScriptCore/API/JSValueRef.h >+++ b/Source/JavaScriptCore/API/JSValueRef.h >@@ -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 @@ typedef enum { > 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; > > /*! >@@ -142,6 +142,15 @@ JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); > */ > JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); > >+/*! >+@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. >@@ -270,6 +279,15 @@ JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); > */ > 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 */ > > /*! >diff --git a/Source/JavaScriptCore/API/tests/testapi.mm b/Source/JavaScriptCore/API/tests/testapi.mm >index 6ce80f0e012a8c2ab763cd760e4d671e08b11248..06e8d2b78164133acb8d97e89a3eaac60f351416 100644 >--- a/Source/JavaScriptCore/API/tests/testapi.mm >+++ b/Source/JavaScriptCore/API/tests/testapi.mm >@@ -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 @@ static void testObjectiveCAPIMain() > 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 @@ static void testObjectiveCAPIMain() > checkResult(@"iteration count should be 1", [count toUInt32] == 1); > } > >+#endif >+ > @autoreleasepool { > JSCollection* myPrivateProperties = [[JSCollection alloc] init]; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198709
:
371730
| 371731