Changeset 236520 in webkit
- Timestamp:
- Sep 26, 2018, 1:04:27 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
-
API/JSObjectRef.h (modified) (1 diff)
-
API/JSObjectRefPrivate.h (modified) (1 diff)
-
API/JSValue.h (modified) (6 diffs)
-
API/JSValuePrivate.h (modified) (2 diffs)
-
API/JSValueRef.h (modified) (1 diff)
-
ChangeLog (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSObjectRef.h
r234381 r236520 556 556 /*! 557 557 @function 558 @abstract Tests whether an object has a given property using a JSValueRef as the property key.559 @param object The JSObject to test.560 @param propertyKey A JSValueRef containing the property key to use when looking up the property.561 @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.562 @result true if the object has a property whose name matches propertyKey, otherwise false.563 @discussion This function is the same as performing "propertyKey in object" from JavaScript.564 */565 JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));566 567 /*!568 @function569 @abstract Gets a property from an object using a JSValueRef as the property key.570 @param ctx The execution context to use.571 @param object The JSObject whose property you want to get.572 @param propertyKey A JSValueRef containing the property key to use when looking up the property.573 @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.574 @result The property's value if object has the property key, otherwise the undefined value.575 @discussion This function is the same as performing "object[propertyKey]" from JavaScript.576 */577 JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));578 579 /*!580 @function581 @abstract Sets a property on an object using a JSValueRef as the property key.582 @param ctx The execution context to use.583 @param object The JSObject whose property you want to set.584 @param propertyKey A JSValueRef containing the property key to use when looking up the property.585 @param value A JSValueRef to use as the property's value.586 @param attributes A logically ORed set of JSPropertyAttributes to give to the property.587 @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.588 @discussion This function is the same as performing "object[propertyKey] = value" from JavaScript.589 */590 JS_EXPORT void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));591 592 /*!593 @function594 @abstract Deletes a property from an object using a JSValueRef as the property key.595 @param ctx The execution context to use.596 @param object The JSObject whose property you want to delete.597 @param propertyKey A JSValueRef containing the property key to use when looking up 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 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).600 @discussion This function is the same as performing "delete object[propertyKey]" from JavaScript.601 */602 JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));603 604 /*!605 @function606 558 @abstract Gets a property from an object by numeric index. 607 559 @param ctx The execution context to use. -
trunk/Source/JavaScriptCore/API/JSObjectRefPrivate.h
r236372 r236520 82 82 */ 83 83 JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 84 84 85 /*! 86 @function 87 @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(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 95 96 /*! 97 @function 98 @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(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 107 108 /*! 109 @function 110 @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(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 120 121 /*! 122 @function 123 @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(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 132 133 /*! 134 @function 135 @abstract Tests whether a JavaScript value's type is the symbol type. 136 @param ctx The execution context to use. 137 @param value The JSValue to test. 138 @result true if value's type is the symbol type, otherwise false. 139 */ 140 JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 141 85 142 #ifdef __cplusplus 86 143 } -
trunk/Source/JavaScriptCore/API/JSValue.h
r235465 r236520 48 48 @interface JSValue : NSObject 49 49 50 #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)51 typedef NSString *JSValueProperty;52 #else53 typedef id JSValueProperty;54 #endif55 56 50 /*! 57 51 @property … … 154 148 */ 155 149 + (JSValue *)valueWithUndefinedInContext:(JSContext *)context; 156 157 /*!158 @method159 @abstract Create a new, unique, symbol object.160 @param description The description of the symbol object being created.161 @param context The JSContext to which the resulting JSValue belongs.162 @result The JSValue representing a unique JavaScript value with type symbol.163 */164 + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));165 150 166 151 /*! … … 319 304 320 305 /*! 321 @methodgroup Accessing Properties322 */323 324 /*!325 @method326 @abstract Access a property of a JSValue.327 @result The JSValue for the requested property or the JSValue <code>undefined</code>328 if the property does not exist.329 @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 *.330 */331 - (JSValue *)valueForProperty:(JSValueProperty)property;332 333 /*!334 @method335 @abstract Set a property on a JSValue.336 @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 *.337 */338 - (void)setValue:(id)value forProperty:(JSValueProperty)property;339 340 /*!341 @method342 @abstract Delete a property from a JSValue.343 @result YES if deletion is successful, NO otherwise.344 @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 *.345 */346 - (BOOL)deleteProperty:(JSValueProperty)property;347 348 /*!349 @method350 @abstract Check if a JSValue has a property.351 @discussion This method has the same function as the JavaScript operator <code>in</code>.352 @result Returns YES if property is present on the value.353 @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 *.354 */355 - (BOOL)hasProperty:(JSValueProperty)property;356 357 /*!358 @method359 @abstract Define properties with custom descriptors on JSValues.360 @discussion This method may be used to create a data or accessor property on an object.361 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 *.362 */363 - (void)defineProperty:(JSValueProperty)property descriptor:(id)descriptor;364 365 /*!366 @method367 @abstract Access an indexed (numerical) property on a JSValue.368 @result The JSValue for the property at the specified index.369 Returns the JavaScript value <code>undefined</code> if no property exists at that index.370 */371 - (JSValue *)valueAtIndex:(NSUInteger)index;372 373 /*!374 @method375 @abstract Set an indexed (numerical) property on a JSValue.376 @discussion For JSValues that are JavaScript arrays, indices greater than377 UINT_MAX - 1 will not affect the length of the array.378 */379 - (void)setValue:(id)value atIndex:(NSUInteger)index;380 381 /*!382 306 @functiongroup Checking JavaScript Types 383 307 */ … … 421 345 */ 422 346 @property (readonly) BOOL isObject; 423 424 /*!425 @property426 @abstract Check if a JSValue is a symbol.427 */428 @property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));429 347 430 348 /*! … … 582 500 583 501 /*! 502 @category 503 @discussion These methods enable querying properties on a JSValue. 504 */ 505 @interface JSValue (PropertyAccess) 506 507 /*! 508 @method 509 @abstract Access a property of a JSValue. 510 @result The JSValue for the requested property or the JSValue <code>undefined</code> 511 if the property does not exist. 512 */ 513 - (JSValue *)valueForProperty:(NSString *)property; 514 515 /*! 516 @method 517 @abstract Set a property on a JSValue. 518 */ 519 - (void)setValue:(id)value forProperty:(NSString *)property; 520 521 /*! 522 @method 523 @abstract Delete a property from a JSValue. 524 @result YES if deletion is successful, NO otherwise. 525 */ 526 - (BOOL)deleteProperty:(NSString *)property; 527 528 /*! 529 @method 530 @abstract Check if a JSValue has a property. 531 @discussion This method has the same function as the JavaScript operator <code>in</code>. 532 @result Returns YES if property is present on the value. 533 */ 534 - (BOOL)hasProperty:(NSString *)property; 535 536 /*! 537 @method 538 @abstract Define properties with custom descriptors on JSValues. 539 @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; 544 545 /*! 546 @method 547 @abstract Access an indexed (numerical) property on a JSValue. 548 @result The JSValue for the property at the specified index. 549 Returns the JavaScript value <code>undefined</code> if no property exists at that index. 550 */ 551 - (JSValue *)valueAtIndex:(NSUInteger)index; 552 553 /*! 554 @method 555 @abstract Set an indexed (numerical) property on a JSValue. 556 @discussion For JSValues that are JavaScript arrays, indices greater than 557 UINT_MAX - 1 will not affect the length of the array. 558 */ 559 - (void)setValue:(id)value atIndex:(NSUInteger)index; 560 561 @end 562 563 /*! 584 564 @category 585 565 @discussion Instances of JSValue implement the following methods in order to enable … … 595 575 596 576 An object key passed as a subscript will be converted to a JavaScript value, 597 and then the value using the same rules as <code>valueWithObject:inContext:</code>. In macOS 598 TBA and iOS TBA and below, the <code>key</code> argument of 599 <code>setObject:object forKeyedSubscript:key</code> was restricted to an 600 <code>NSString <NSCopying> *</code> but that restriction was never used. 577 and then the value converted to a string used as a property name. 601 578 */ 602 579 @interface JSValue (SubscriptSupport) 603 580 604 - (JSValue *)objectForKeyedSubscript:( JSValueProperty)key;581 - (JSValue *)objectForKeyedSubscript:(id)key; 605 582 - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index; 606 - (void)setObject:(id)object forKeyedSubscript:( JSValueProperty)key;583 - (void)setObject:(id)object forKeyedSubscript:(NSObject <NSCopying> *)key; 607 584 - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index; 608 585 -
trunk/Source/JavaScriptCore/API/JSValuePrivate.h
r236372 r236520 29 29 30 30 @interface JSValue(JSPrivate) 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(macosx(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(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 31 93 32 94 /*! … … 69 131 @end 70 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; 158 159 @end 160 71 161 #endif // JSC_OBJC_API_ENABLED -
trunk/Source/JavaScriptCore/API/JSValueRef.h
r234858 r236520 152 152 JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); 153 153 154 /*!155 @function156 @abstract Tests whether a JavaScript value's type is the symbol type.157 @param ctx The execution context to use.158 @param value The JSValue to test.159 @result true if value's type is the symbol type, otherwise false.160 */161 JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA));162 163 154 164 155 /*! -
trunk/Source/JavaScriptCore/ChangeLog
r236514 r236520 1 2018-09-25 Keith Miller <keith_miller@apple.com> 2 3 Move Symbol API to SPI 4 https://bugs.webkit.org/show_bug.cgi?id=189946 5 6 Reviewed by Michael Saboff. 7 8 Some of the property access methods on JSValue needed to be moved 9 to a category so that SPI overloads don't result in a compiler 10 error for internal users. 11 12 Additionally, this patch does not move the new enum entry for 13 Symbols in the JSType enumeration. 14 15 * API/JSObjectRef.h: 16 * API/JSObjectRefPrivate.h: 17 * API/JSValue.h: 18 * API/JSValuePrivate.h: 19 * API/JSValueRef.h: 20 1 21 2018-09-26 Keith Miller <keith_miller@apple.com> 2 22
Note:
See TracChangeset
for help on using the changeset viewer.