Changeset 246265 in webkit
- Timestamp:
- Jun 10, 2019 9:35:00 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSObjectRef.h
r243376 r246265 1 1 /* 2 * Copyright (C) 2006 , 2007Apple Inc. All rights reserved.2 * Copyright (C) 2006-2019 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) 4 4 * … … 478 478 479 479 /*! 480 @function 481 @abstract Creates a JavaScript promise object by invoking the provided executor. 482 @param ctx The execution context to use. 483 @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. 484 @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. 485 @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. 486 @result A JSObject that is a promise or NULL if an exception occurred. 487 */ 488 JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 489 490 /*! 480 491 @function 481 492 @abstract Creates a function with a given script as its body. … … 555 566 556 567 /*! 568 @function 569 @abstract Tests whether an object has a given property using a JSValueRef as the property key. 570 @param object The JSObject to test. 571 @param propertyKey A JSValueRef containing the property key to use when looking up the property. 572 @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. 573 @result true if the object has a property whose name matches propertyKey, otherwise false. 574 @discussion This function is the same as performing "propertyKey in object" from JavaScript. 575 */ 576 JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 577 578 /*! 579 @function 580 @abstract Gets a property from an object using a JSValueRef as the property key. 581 @param ctx The execution context to use. 582 @param object The JSObject whose property you want to get. 583 @param propertyKey A JSValueRef containing the property key to use when looking up the property. 584 @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. 585 @result The property's value if object has the property key, otherwise the undefined value. 586 @discussion This function is the same as performing "object[propertyKey]" from JavaScript. 587 */ 588 JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 589 590 /*! 591 @function 592 @abstract Sets a property on an object using a JSValueRef as the property key. 593 @param ctx The execution context to use. 594 @param object The JSObject whose property you want to set. 595 @param propertyKey A JSValueRef containing the property key to use when looking up the property. 596 @param value A JSValueRef to use as the property's value. 597 @param attributes A logically ORed set of JSPropertyAttributes to give to the property. 598 @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. 599 @discussion This function is the same as performing "object[propertyKey] = value" from JavaScript. 600 */ 601 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)); 602 603 /*! 604 @function 605 @abstract Deletes a property from an object using a JSValueRef as the property key. 606 @param ctx The execution context to use. 607 @param object The JSObject whose property you want to delete. 608 @param propertyKey A JSValueRef containing the property key to use when looking up the property. 609 @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. 610 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). 611 @discussion This function is the same as performing "delete object[propertyKey]" from JavaScript. 612 */ 613 JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 614 615 /*! 557 616 @function 558 617 @abstract Gets a property from an object by numeric index. -
trunk/Source/JavaScriptCore/API/JSObjectRefPrivate.h
r243376 r246265 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 72 72 JS_EXPORT JSGlobalContextRef JSObjectGetGlobalContext(JSObjectRef object); 73 73 74 /*!75 @function76 @abstract Creates a JavaScript promise object by invoking the provided executor.77 @param ctx The execution context to use.78 @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.79 @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.80 @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.81 @result A JSObject that is a promise or NULL if an exception occurred.82 */83 JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));84 85 /*!86 @function87 @abstract Tests whether an object has a given property using a JSValueRef as the property key.88 @param object The JSObject to test.89 @param propertyKey A JSValueRef containing the property key to use when looking up the property.90 @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.91 @result true if the object has a property whose name matches propertyKey, otherwise false.92 @discussion This function is the same as performing "propertyKey in object" from JavaScript.93 */94 JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));95 96 /*!97 @function98 @abstract Gets a property from an object using a JSValueRef as the property key.99 @param ctx The execution context to use.100 @param object The JSObject whose property you want to get.101 @param propertyKey A JSValueRef containing the property key to use when looking up the property.102 @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.103 @result The property's value if object has the property key, otherwise the undefined value.104 @discussion This function is the same as performing "object[propertyKey]" from JavaScript.105 */106 JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));107 108 /*!109 @function110 @abstract Sets a property on an object using a JSValueRef as the property key.111 @param ctx The execution context to use.112 @param object The JSObject whose property you want to set.113 @param propertyKey A JSValueRef containing the property key to use when looking up the property.114 @param value A JSValueRef to use as the property's value.115 @param attributes A logically ORed set of JSPropertyAttributes to give to the property.116 @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.117 @discussion This function is the same as performing "object[propertyKey] = value" from JavaScript.118 */119 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));120 121 /*!122 @function123 @abstract Deletes a property from an object using a JSValueRef as the property key.124 @param ctx The execution context to use.125 @param object The JSObject whose property you want to delete.126 @param propertyKey A JSValueRef containing the property key to use when looking up the property.127 @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.128 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).129 @discussion This function is the same as performing "delete object[propertyKey]" from JavaScript.130 */131 JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));132 133 /*!134 @function135 @abstract Creates a JavaScript value of the symbol type.136 @param ctx The execution context to use.137 @param description A description of the newly created symbol value.138 @result A unique JSValue of the symbol type, whose description matches the one provided.139 */140 JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));141 142 /*!143 @function144 @abstract Tests whether a JavaScript value's type is the symbol type.145 @param ctx The execution context to use.146 @param value The JSValue to test.147 @result true if value's type is the symbol type, otherwise false.148 */149 JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA));150 151 74 #ifdef __cplusplus 152 75 } -
trunk/Source/JavaScriptCore/API/JSValue.h
r243376 r246265 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 135 135 /*! 136 136 @method 137 @abstract Create a new promise object using the provided executor callback. 138 @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. 139 @param context The JSContext to which the resulting JSValue belongs. 140 @result The JSValue representing a new promise JavaScript object. 141 @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>. 142 */ 143 + (JSValue *)valueWithNewPromiseInContext:(JSContext *)context fromExecutor:(void (^)(JSValue *resolve, JSValue *reject))callback JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 144 145 /*! 146 @method 147 @abstract Create a new resolved promise object with the provided value. 148 @param result The result value to be passed to any reactions. 149 @param context The JSContext to which the resulting JSValue belongs. 150 @result The JSValue representing a new promise JavaScript object. 151 @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [resolve callWithArguments:@[result]]; } inContext:context]</code> 152 */ 153 + (JSValue *)valueWithNewPromiseResolvedWithResult:(id)result inContext:(JSContext *)context JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 154 155 /*! 156 @method 157 @abstract Create a new rejected promise object with the provided value. 158 @param reason The result value to be passed to any reactions. 159 @param context The JSContext to which the resulting JSValue belongs. 160 @result The JSValue representing a new promise JavaScript object. 161 @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [reject callWithArguments:@[reason]]; } inContext:context]</code> 162 */ 163 + (JSValue *)valueWithNewPromiseRejectedWithReason:(id)reason inContext:(JSContext *)context JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 164 165 /*! 166 @method 167 @abstract Create a new, unique, symbol object. 168 @param description The description of the symbol object being created. 169 @param context The JSContext to which the resulting JSValue belongs. 170 @result The JSValue representing a unique JavaScript value with type symbol. 171 */ 172 + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 173 174 /*! 175 @method 137 176 @abstract Create the JavaScript value <code>null</code>. 138 177 @param context The JSContext to which the resulting JSValue belongs. … … 359 398 360 399 /*! 400 @property 401 @abstract Check if a JSValue is a symbol. 402 */ 403 @property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 404 405 /*! 361 406 @method 362 407 @abstract Compare two JSValues using JavaScript's <code>===</code> operator. … … 505 550 @interface JSValue (PropertyAccess) 506 551 552 #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) 553 typedef NSString *JSValueProperty; 554 #else 555 typedef id JSValueProperty; 556 #endif 557 507 558 /*! 508 559 @method … … 510 561 @result The JSValue for the requested property or the JSValue <code>undefined</code> 511 562 if the property does not exist. 512 */ 513 - (JSValue *)valueForProperty:(NSString *)property; 563 @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 *. 564 */ 565 - (JSValue *)valueForProperty:(JSValueProperty)property; 514 566 515 567 /*! 516 568 @method 517 569 @abstract Set a property on a JSValue. 518 */ 519 - (void)setValue:(id)value forProperty:(NSString *)property; 570 @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 *. 571 */ 572 - (void)setValue:(id)value forProperty:(JSValueProperty)property; 520 573 521 574 /*! … … 523 576 @abstract Delete a property from a JSValue. 524 577 @result YES if deletion is successful, NO otherwise. 525 */ 526 - (BOOL)deleteProperty:(NSString *)property; 578 @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 *. 579 */ 580 - (BOOL)deleteProperty:(JSValueProperty)property; 527 581 528 582 /*! … … 531 585 @discussion This method has the same function as the JavaScript operator <code>in</code>. 532 586 @result Returns YES if property is present on the value. 533 */ 534 - (BOOL)hasProperty:(NSString *)property; 587 @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 *. 588 */ 589 - (BOOL)hasProperty:(JSValueProperty)property; 535 590 536 591 /*! … … 538 593 @abstract Define properties with custom descriptors on JSValues. 539 594 @discussion This method may be used to create a data or accessor property on an object. 540 This method operates in accordance with the Object.defineProperty method in the 541 JavaScript language. 542 */ 543 - (void)defineProperty:(NSString *)property descriptor:(id)descriptor; 595 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 *. 596 */ 597 - (void)defineProperty:(JSValueProperty)property descriptor:(id)descriptor; 544 598 545 599 /*! … … 575 629 576 630 An object key passed as a subscript will be converted to a JavaScript value, 577 and then the value converted to a string used as a property name. 631 and then the value using the same rules as <code>valueWithObject:inContext:</code>. In macOS 632 10.14 and iOS 12 and below, the <code>key</code> argument of 633 <code>setObject:object forKeyedSubscript:key</code> was restricted to an 634 <code>NSObject <NSCopying> *</code> but that restriction was never used internally. 578 635 */ 579 636 @interface JSValue (SubscriptSupport) … … 581 638 - (JSValue *)objectForKeyedSubscript:(id)key; 582 639 - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index; 583 - (void)setObject:(id)object forKeyedSubscript:( NSObject <NSCopying> *)key;640 - (void)setObject:(id)object forKeyedSubscript:(id)key; 584 641 - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index; 585 642 -
trunk/Source/JavaScriptCore/API/JSValuePrivate.h
r243376 r246265 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 @interface JSValue(JSPrivate) 31 31 32 #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) 33 typedef NSString *JSValueProperty; 34 #else 35 typedef id JSValueProperty; 36 #endif 37 38 /*! 39 @method 40 @abstract Create a new, unique, symbol object. 41 @param description The description of the symbol object being created. 42 @param context The JSContext to which the resulting JSValue belongs. 43 @result The JSValue representing a unique JavaScript value with type symbol. 44 */ 45 + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 46 47 /*! 48 @method 49 @abstract Access a property of a JSValue. 50 @result The JSValue for the requested property or the JSValue <code>undefined</code> 51 if the property does not exist. 52 @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 *. 53 */ 54 - (JSValue *)valueForProperty:(JSValueProperty)property; 55 56 /*! 57 @method 58 @abstract Set a property on a JSValue. 59 @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 *. 60 */ 61 - (void)setValue:(id)value forProperty:(JSValueProperty)property; 62 63 /*! 64 @method 65 @abstract Delete a property from a JSValue. 66 @result YES if deletion is successful, NO otherwise. 67 @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 *. 68 */ 69 - (BOOL)deleteProperty:(JSValueProperty)property; 70 71 /*! 72 @method 73 @abstract Check if a JSValue has a property. 74 @discussion This method has the same function as the JavaScript operator <code>in</code>. 75 @result Returns YES if property is present on the value. 76 @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 *. 77 */ 78 - (BOOL)hasProperty:(JSValueProperty)property; 79 80 /*! 81 @method 82 @abstract Define properties with custom descriptors on JSValues. 83 @discussion This method may be used to create a data or accessor property on an object. 84 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 *. 85 */ 86 - (void)defineProperty:(JSValueProperty)property descriptor:(id)descriptor; 87 88 /*! 89 @property 90 @abstract Check if a JSValue is a symbol. 91 */ 92 @property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 93 94 /*! 95 @method 96 @abstract Create a new promise object using the provided executor callback. 97 @param callback A callback block invoked while the promise object is 98 being initialized. The resolve and reject parameters are functions that 99 can be called to notify any pending reactions about the state of the 100 new promise object. 101 @param context The JSContext to which the resulting JSValue belongs. 102 @result The JSValue representing a new promise JavaScript object. 103 @discussion This method is equivalent to calling the Promise constructor in JavaScript. 104 the resolve and reject callbacks each normally take a single value, which they 105 forward to all relevent pending reactions. While inside the executor callback context will act 106 as if it were in any other callback, except calleeFunction will be <code>nil</code>. This also means 107 means the new promise object may be accessed via <code>[context thisValue]</code>. 108 */ 109 + (JSValue *)valueWithNewPromiseInContext:(JSContext *)context fromExecutor:(void (^)(JSValue *resolve, JSValue *reject))callback JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 110 111 /*! 112 @method 113 @abstract Create a new resolved promise object with the provided value. 114 @param result The result value to be passed to any reactions. 115 @param context The JSContext to which the resulting JSValue belongs. 116 @result The JSValue representing a new promise JavaScript object. 117 @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [resolve callWithArguments:@[result]]; } inContext:context]</code> 118 */ 119 + (JSValue *)valueWithNewPromiseResolvedWithResult:(id)result inContext:(JSContext *)context JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 120 121 /*! 122 @method 123 @abstract Create a new rejected promise object with the provided value. 124 @param reason The result value to be passed to any reactions. 125 @param context The JSContext to which the resulting JSValue belongs. 126 @result The JSValue representing a new promise JavaScript object. 127 @discussion This method is equivalent to calling <code>[JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [reject callWithArguments:@[reason]]; } inContext:context]</code> 128 */ 129 + (JSValue *)valueWithNewPromiseRejectedWithReason:(id)reason inContext:(JSContext *)context JSC_API_AVAILABLE(macos(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 130 131 @end 132 133 /*! 134 @category 135 @discussion Instances of JSValue implement the following methods in order to enable 136 support for subscript access by key and index, for example: 137 138 @textblock 139 JSValue *objectA, *objectB; 140 JSValue *v1 = object[@"X"]; // Get value for property "X" from 'object'. 141 JSValue *v2 = object[42]; // Get value for index 42 from 'object'. 142 object[@"Y"] = v1; // Assign 'v1' to property "Y" of 'object'. 143 object[101] = v2; // Assign 'v2' to index 101 of 'object'. 144 @/textblock 145 146 An object key passed as a subscript will be converted to a JavaScript value, 147 and then the value using the same rules as <code>valueWithObject:inContext:</code>. In macOS 148 TBA and iOS TBA and below, the <code>key</code> argument of 149 <code>setObject:object forKeyedSubscript:key</code> was restricted to an 150 <code>NSString <NSCopying> *</code> but that restriction was never used. 151 */ 152 @interface JSValue (SubscriptSupportPrivate) 153 154 - (JSValue *)objectForKeyedSubscript:(JSValueProperty)key; 155 - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index; 156 - (void)setObject:(id)object forKeyedSubscript:(JSValueProperty)key; 157 - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index; 32 // Currently empty. May be used again in the future. 158 33 159 34 @end -
trunk/Source/JavaScriptCore/API/JSValueRef.h
r243376 r246265 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 52 52 kJSTypeString, 53 53 kJSTypeObject, 54 kJSTypeSymbol JSC_API_AVAILABLE(macos( JSC_MAC_TBA), ios(JSC_IOS_TBA))54 kJSTypeSymbol JSC_API_AVAILABLE(macos(10.15), ios(13.0)) 55 55 } JSType; 56 56 … … 145 145 /*! 146 146 @function 147 @abstract Tests whether a JavaScript value's type is the symbol type. 148 @param ctx The execution context to use. 149 @param value The JSValue to test. 150 @result true if value's type is the symbol type, otherwise false. 151 */ 152 JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 153 154 /*! 155 @function 147 156 @abstract Tests whether a JavaScript value's type is the object type. 148 157 @param ctx The execution context to use. … … 270 279 */ 271 280 JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); 281 282 /*! 283 @function 284 @abstract Creates a JavaScript value of the symbol type. 285 @param ctx The execution context to use. 286 @param description A description of the newly created symbol value. 287 @result A unique JSValue of the symbol type, whose description matches the one provided. 288 */ 289 JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(10.15), ios(13.0)); 272 290 273 291 /* Converting to and from JSON formatted strings */ -
trunk/Source/JavaScriptCore/API/tests/testapi.mm
r246060 r246265 1 1 /* 2 * Copyright (C) 2013-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 650 650 } 651 651 652 // Older platforms ifdef the type of some selectors so these tests don't work. 653 // FIXME: Remove this when we stop building for macOS 10.14/iOS 12. 654 #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) 655 652 656 @autoreleasepool { 653 657 JSContext *context = [[JSContext alloc] init]; … … 734 738 checkResult(@"iteration count should be 1", [count toUInt32] == 1); 735 739 } 740 741 #endif 736 742 737 743 @autoreleasepool { -
trunk/Source/JavaScriptCore/ChangeLog
r246240 r246265 1 2019-06-10 Keith Miller <keith_miller@apple.com> 2 3 Make new Symbol/Promise API public 4 https://bugs.webkit.org/show_bug.cgi?id=198709 5 6 Reviewed by Saam Barati. 7 8 We also need to #ifdef some tests when building for older 9 platforms because the signatures for some methods are outdated on 10 those platforms. 11 12 * API/JSObjectRef.h: 13 * API/JSObjectRefPrivate.h: 14 * API/JSValue.h: 15 * API/JSValuePrivate.h: 16 * API/JSValueRef.h: 17 * API/tests/testapi.mm: 18 (testObjectiveCAPIMain): 19 1 20 2019-06-09 Commit Queue <commit-queue@webkit.org> 2 21
Note: See TracChangeset
for help on using the changeset viewer.