Changeset 234227 in webkit
- Timestamp:
- Jul 25, 2018, 7:32:25 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 1 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/APICast.h
r233765 r234227 31 31 #include "JSCJSValueInlines.h" 32 32 #include "JSGlobalObject.h" 33 #include "HeapCellInlines.h" 33 34 34 35 namespace JSC { -
trunk/Source/JavaScriptCore/API/JSBasePrivate.h
r165676 r234227 44 44 region. 45 45 */ 46 JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) CF_AVAILABLE(10_6, 7_0);46 JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 47 47 48 48 JS_EXPORT void JSDisableGCTimer(void); -
trunk/Source/JavaScriptCore/API/JSContext.h
r207542 r234227 79 79 @result The last value generated by the script. 80 80 */ 81 - (JSValue *)evaluateScript:(NSString *)script withSourceURL:(NSURL *)sourceURL NS_AVAILABLE(10_10, 8_0);81 - (JSValue *)evaluateScript:(NSString *)script withSourceURL:(NSURL *)sourceURL JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 82 82 83 83 /*! … … 102 102 @result The currently executing JavaScript function or nil if there isn't one. 103 103 */ 104 + (JSValue *)currentCallee NS_AVAILABLE(10_10, 8_0);104 + (JSValue *)currentCallee JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 105 105 106 106 /*! … … 177 177 @discussion Name of the JSContext. Exposed when remote debugging the context. 178 178 */ 179 @property (copy) NSString *name NS_AVAILABLE(10_10, 8_0);179 @property (copy) NSString *name JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 180 180 181 181 @end -
trunk/Source/JavaScriptCore/API/JSContextPrivate.h
r170589 r234227 37 37 @discussion Remote inspection setting of the JSContext. Default value is YES. 38 38 */ 39 @property (setter=_setRemoteInspectionEnabled:) BOOL _remoteInspectionEnabled NS_AVAILABLE(10_10, 8_0);39 @property (setter=_setRemoteInspectionEnabled:) BOOL _remoteInspectionEnabled JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 40 40 41 41 /*! … … 43 43 @discussion Set whether or not the native call stack is included when reporting exceptions. Default value is YES. 44 44 */ 45 @property (setter=_setIncludesNativeCallStackWhenReportingExceptions:) BOOL _includesNativeCallStackWhenReportingExceptions NS_AVAILABLE(10_10, 8_0);45 @property (setter=_setIncludesNativeCallStackWhenReportingExceptions:) BOOL _includesNativeCallStackWhenReportingExceptions JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 46 46 47 47 /*! … … 49 49 @discussion Set the run loop the Web Inspector debugger should use when evaluating JavaScript in the JSContext. 50 50 */ 51 @property (setter=_setDebuggerRunLoop:) CFRunLoopRef _debuggerRunLoop NS_AVAILABLE(10_10, 8_0);51 @property (setter=_setDebuggerRunLoop:) CFRunLoopRef _debuggerRunLoop JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 52 52 53 53 @end -
trunk/Source/JavaScriptCore/API/JSContextRef.h
r230961 r234227 54 54 @result The created JSContextGroup. 55 55 */ 56 JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) CF_AVAILABLE(10_6, 7_0);56 JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 57 57 58 58 /*! … … 62 62 @result A JSContextGroup that is the same as group. 63 63 */ 64 JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0);64 JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 65 65 66 66 /*! … … 69 69 @param group The JSContextGroup to release. 70 70 */ 71 JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0);71 JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 72 72 73 73 /*! … … 84 84 @result A JSGlobalContext with a global object of class globalObjectClass. 85 85 */ 86 JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) CF_AVAILABLE(10_5, 7_0);86 JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) JSC_API_AVAILABLE(macosx(10.5), ios(7.0)); 87 87 88 88 /*! … … 98 98 group equal to group. 99 99 */ 100 JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) CF_AVAILABLE(10_6, 7_0);100 JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 101 101 102 102 /*! … … 129 129 @result ctx's group. 130 130 */ 131 JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) CF_AVAILABLE(10_6, 7_0);131 JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 132 132 133 133 /*! … … 137 137 @result ctx's global context. 138 138 */ 139 JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAILABLE(10_7, 7_0);139 JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) JSC_API_AVAILABLE(macosx(10.7), ios(7.0)); 140 140 141 141 /*! … … 147 147 easier to identify the context you would like to attach to. 148 148 */ 149 JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);149 JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 150 150 151 151 /*! … … 155 155 @param name The remote debugging name to set on ctx. 156 156 */ 157 JS_EXPORT void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) CF_AVAILABLE(10_10, 8_0);157 JS_EXPORT void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 158 158 159 159 #ifdef __cplusplus -
trunk/Source/JavaScriptCore/API/JSContextRefInternal.h
r207542 r234227 43 43 @param ctx The JSGlobalContext whose setting you want to get. 44 44 */ 45 JS_EXPORT CFRunLoopRef JSGlobalContextGetDebuggerRunLoop(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);45 JS_EXPORT CFRunLoopRef JSGlobalContextGetDebuggerRunLoop(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 46 46 47 47 /*! … … 51 51 @param runLoop The new value of the setting for the context. 52 52 */ 53 JS_EXPORT void JSGlobalContextSetDebuggerRunLoop(JSGlobalContextRef ctx, CFRunLoopRef runLoop) CF_AVAILABLE(10_10, 8_0);53 JS_EXPORT void JSGlobalContextSetDebuggerRunLoop(JSGlobalContextRef ctx, CFRunLoopRef runLoop) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 54 54 #endif 55 55 -
trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h
r207542 r234227 45 45 @result A string containing the backtrace 46 46 */ 47 JS_EXPORT JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) CF_AVAILABLE(10_6, 7_0);47 JS_EXPORT JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 48 48 49 49 … … 86 86 any scripts. 87 87 */ 88 JS_EXPORT void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef group, double limit, JSShouldTerminateCallback callback, void* context) CF_AVAILABLE(10_6, 7_0);88 JS_EXPORT void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef group, double limit, JSShouldTerminateCallback callback, void* context) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 89 89 90 90 /*! … … 93 93 @param group The JavaScript context group that the time limit is cleared on. 94 94 */ 95 JS_EXPORT void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0);95 JS_EXPORT void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef group) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 96 96 97 97 /*! … … 102 102 @discussion Remote inspection is true by default. 103 103 */ 104 JS_EXPORT bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);104 JS_EXPORT bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 105 105 106 106 /*! … … 110 110 @param enabled The new remote inspection enabled setting for the context. 111 111 */ 112 JS_EXPORT void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled) CF_AVAILABLE(10_10, 8_0);112 JS_EXPORT void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 113 113 114 114 /*! … … 119 119 @discussion This setting is true by default. 120 120 */ 121 JS_EXPORT bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);121 JS_EXPORT bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 122 122 123 123 /*! … … 127 127 @param includesNativeCallStack The new value of the setting for the context. 128 128 */ 129 JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) CF_AVAILABLE(10_10, 8_0);129 JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 130 130 131 131 #ifdef __cplusplus -
trunk/Source/JavaScriptCore/API/JSManagedValue.h
r207542 r234227 58 58 */ 59 59 + (JSManagedValue *)managedValueWithValue:(JSValue *)value; 60 + (JSManagedValue *)managedValueWithValue:(JSValue *)value andOwner:(id)owner NS_AVAILABLE(10_10, 8_0);60 + (JSManagedValue *)managedValueWithValue:(JSValue *)value andOwner:(id)owner JSC_API_AVAILABLE(macosx(10.10), ios(8.0)); 61 61 62 62 /*! -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r233245 r234227 367 367 } 368 368 369 bool JSObjectHasPropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef key, JSValueRef* exception) 370 { 371 if (!ctx) { 372 ASSERT_NOT_REACHED(); 373 return false; 374 } 375 ExecState* exec = toJS(ctx); 376 VM& vm = exec->vm(); 377 JSLockHolder locker(vm); 378 auto scope = DECLARE_CATCH_SCOPE(vm); 379 380 JSObject* jsObject = toJS(object); 381 Identifier ident = toJS(exec, key).toPropertyKey(exec); 382 if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow) 383 return false; 384 385 bool result = jsObject->hasProperty(exec, ident); 386 handleExceptionIfNeeded(scope, exec, exception); 387 return result; 388 } 389 390 JSValueRef JSObjectGetPropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef key, JSValueRef* exception) 391 { 392 if (!ctx) { 393 ASSERT_NOT_REACHED(); 394 return nullptr; 395 } 396 ExecState* exec = toJS(ctx); 397 VM& vm = exec->vm(); 398 JSLockHolder locker(vm); 399 auto scope = DECLARE_CATCH_SCOPE(vm); 400 401 JSObject* jsObject = toJS(object); 402 Identifier ident = toJS(exec, key).toPropertyKey(exec); 403 if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow) 404 return nullptr; 405 406 JSValue jsValue = jsObject->get(exec, ident); 407 handleExceptionIfNeeded(scope, exec, exception); 408 return toRef(exec, jsValue); 409 } 410 411 void JSObjectSetPropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef key, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) 412 { 413 if (!ctx) { 414 ASSERT_NOT_REACHED(); 415 return; 416 } 417 ExecState* exec = toJS(ctx); 418 VM& vm = exec->vm(); 419 JSLockHolder locker(vm); 420 auto scope = DECLARE_CATCH_SCOPE(vm); 421 422 JSObject* jsObject = toJS(object); 423 JSValue jsValue = toJS(exec, value); 424 425 Identifier ident = toJS(exec, key).toPropertyKey(exec); 426 if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow) 427 return; 428 429 bool doesNotHaveProperty = attributes && !jsObject->hasProperty(exec, ident); 430 if (LIKELY(!scope.exception())) { 431 if (doesNotHaveProperty) { 432 PropertyDescriptor desc(jsValue, attributes); 433 jsObject->methodTable(vm)->defineOwnProperty(jsObject, exec, ident, desc, false); 434 } else { 435 PutPropertySlot slot(jsObject); 436 jsObject->methodTable(vm)->put(jsObject, exec, ident, jsValue, slot); 437 } 438 } 439 handleExceptionIfNeeded(scope, exec, exception); 440 } 441 442 bool JSObjectDeletePropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef key, JSValueRef* exception) 443 { 444 if (!ctx) { 445 ASSERT_NOT_REACHED(); 446 return false; 447 } 448 ExecState* exec = toJS(ctx); 449 VM& vm = exec->vm(); 450 JSLockHolder locker(vm); 451 auto scope = DECLARE_CATCH_SCOPE(vm); 452 453 JSObject* jsObject = toJS(object); 454 Identifier ident = toJS(exec, key).toPropertyKey(exec); 455 if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow) 456 return false; 457 458 bool result = jsObject->methodTable(vm)->deleteProperty(jsObject, exec, ident); 459 handleExceptionIfNeeded(scope, exec, exception); 460 return result; 461 } 462 369 463 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) 370 464 { -
trunk/Source/JavaScriptCore/API/JSObjectRef.h
r207542 r234227 442 442 is supplied, this function returns an array with one element. 443 443 */ 444 JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);444 JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 445 445 446 446 /*! … … 453 453 @result A JSObject that is a Date. 454 454 */ 455 JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);455 JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 456 456 457 457 /*! … … 464 464 @result A JSObject that is a Error. 465 465 */ 466 JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);466 JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 467 467 468 468 /*! … … 475 475 @result A JSObject that is a RegExp. 476 476 */ 477 JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);477 JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.6), ios(7.0)); 478 478 479 479 /*! … … 537 537 @param object The JSObject whose property you want to set. 538 538 @param propertyName A JSString containing the property's name. 539 @param value A JSValue to use as the property's value. 540 @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. 539 @param value A JSValueRef to use as the property's value. 541 540 @param attributes A logically ORed set of JSPropertyAttributes to give to the property. 541 @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. 542 542 */ 543 543 JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception); … … 553 553 */ 554 554 JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 555 556 /*! 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 JSObjectHasPropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 566 567 /*! 568 @function 569 @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 JSObjectGetPropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 578 579 /*! 580 @function 581 @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 JSObjectSetPropertyKey(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 @function 594 @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 JSObjectDeletePropertyKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 555 603 556 604 /*! -
trunk/Source/JavaScriptCore/API/JSRemoteInspector.h
r222309 r234227 41 41 #endif 42 42 43 JS_EXPORT void JSRemoteInspectorDisableAutoStart(void) CF_AVAILABLE(10_11, 9_0);44 JS_EXPORT void JSRemoteInspectorStart(void) CF_AVAILABLE(10_11, 9_0);45 JS_EXPORT void JSRemoteInspectorSetParentProcessInformation(JSProcessID, const uint8_t* auditData, size_t auditLength) CF_AVAILABLE(10_11, 9_0);43 JS_EXPORT void JSRemoteInspectorDisableAutoStart(void) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 44 JS_EXPORT void JSRemoteInspectorStart(void) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 45 JS_EXPORT void JSRemoteInspectorSetParentProcessInformation(JSProcessID, const uint8_t* auditData, size_t auditLength) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 46 46 47 JS_EXPORT void JSRemoteInspectorSetLogToSystemConsole(bool) CF_AVAILABLE(10_11, 9_0);47 JS_EXPORT void JSRemoteInspectorSetLogToSystemConsole(bool) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 48 48 49 JS_EXPORT bool JSRemoteInspectorGetInspectionEnabledByDefault(void) CF_AVAILABLE(10_11, 9_0);50 JS_EXPORT void JSRemoteInspectorSetInspectionEnabledByDefault(bool) CF_AVAILABLE(10_11, 9_0);49 JS_EXPORT bool JSRemoteInspectorGetInspectionEnabledByDefault(void) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 50 JS_EXPORT void JSRemoteInspectorSetInspectionEnabledByDefault(bool) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 51 51 52 52 #ifdef __cplusplus -
trunk/Source/JavaScriptCore/API/JSTypedArray.h
r207542 r234227 46 46 @result A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error. 47 47 */ 48 JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);48 JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t length, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 49 49 50 50 /*! … … 61 61 @discussion If an exception is thrown during this function the bytesDeallocator will always be called. 62 62 */ 63 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);63 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 64 64 65 65 /*! … … 72 72 @result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer. 73 73 */ 74 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);74 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 75 75 76 76 /*! … … 85 85 @result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer. 86 86 */ 87 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, size_t byteOffset, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);87 JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, size_t byteOffset, size_t length, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 88 88 89 89 /*! … … 96 96 @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls. 97 97 */ 98 JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);98 JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 99 99 100 100 /*! … … 106 106 @result The length of the Typed Array object or 0 if the object is not a Typed Array object. 107 107 */ 108 JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);108 JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 109 109 110 110 /*! … … 116 116 @result The byte length of the Typed Array object or 0 if the object is not a Typed Array object. 117 117 */ 118 JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);118 JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 119 119 120 120 /*! … … 126 126 @result The byte offset of the Typed Array object or 0 if the object is not a Typed Array object. 127 127 */ 128 JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);128 JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 129 129 130 130 /*! … … 136 136 @result A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array. 137 137 */ 138 JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);138 JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 139 139 140 140 // ------------- Array Buffer functions ------------- … … 152 152 @discussion If an exception is thrown during this function the bytesDeallocator will always be called. 153 153 */ 154 JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);154 JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 155 155 156 156 /*! … … 162 162 @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls. 163 163 */ 164 JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);164 JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 165 165 166 166 /*! … … 172 172 @result The number of bytes stored in the data object. 173 173 */ 174 JS_EXPORT size_t JSObjectGetArrayBufferByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);174 JS_EXPORT size_t JSObjectGetArrayBufferByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 175 175 176 176 #ifdef __cplusplus -
trunk/Source/JavaScriptCore/API/JSValue.h
r207542 r234227 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 *JSValuePropertyKeyType; 52 #else 53 typedef id JSValuePropertyKeyType; 54 #endif 55 50 56 /*! 51 57 @property … … 148 154 */ 149 155 + (JSValue *)valueWithUndefinedInContext:(JSContext *)context; 156 157 /*! 158 @method 159 @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)); 150 165 151 166 /*! … … 306 321 @methodgroup Accessing Properties 307 322 */ 323 308 324 /*! 309 325 @method … … 311 327 @result The JSValue for the requested property or the JSValue <code>undefined</code> 312 328 if the property does not exist. 313 */ 314 - (JSValue *)valueForProperty:(NSString *)property; 329 @discussion Corresponds to the JavaScript operation <code>object[property]</code>. Pass an NSString * to access a named property. Other valid properties include symbols, numbers, and stringifiable objects. In macOS 10.13 and iOS 11 and below, 'property' was an NSString *. 330 */ 331 - (JSValue *)valueForProperty:(JSValuePropertyKeyType)property; 315 332 316 333 /*! 317 334 @method 318 335 @abstract Set a property on a JSValue. 319 */ 320 - (void)setValue:(id)value forProperty:(NSString *)property; 336 @discussion Corresponds to the JavaScript operation <code>object[property] = value</code>. Pass an NSString * to access a named property. Other valid properties include symbols, numbers, and stringifiable objects. In macOS 10.13 and iOS 11 and below, 'property' was an NSString *. 337 */ 338 - (void)setValue:(id)value forProperty:(JSValuePropertyKeyType)property; 321 339 322 340 /*! … … 324 342 @abstract Delete a property from a JSValue. 325 343 @result YES if deletion is successful, NO otherwise. 326 */ 327 - (BOOL)deleteProperty:(NSString *)property; 344 @discussion Corresponds to the JavaScript operation <code>delete object[property]</code>. Pass an NSString * to access a named property. Other valid properties include symbols, numbers, and stringifiable objects. In macOS 10.13 and iOS 11 and below, 'property' was an NSString *. 345 */ 346 - (BOOL)deleteProperty:(JSValuePropertyKeyType)property; 328 347 329 348 /*! … … 332 351 @discussion This method has the same function as the JavaScript operator <code>in</code>. 333 352 @result Returns YES if property is present on the value. 334 */ 335 - (BOOL)hasProperty:(NSString *)property; 353 @discussion Corresponds to the JavaScript operation <code>property in object</code>. Pass an NSString * to access a named property. Other valid properties include symbols, numbers, and stringifiable objects. In macOS 10.13 and iOS 11 and below, 'property' was an NSString *. 354 */ 355 - (BOOL)hasProperty:(JSValuePropertyKeyType)property; 336 356 337 357 /*! … … 340 360 @discussion This method may be used to create a data or accessor property on an object. 341 361 This method operates in accordance with the Object.defineProperty method in the 342 JavaScript language. 343 */ 344 - (void)defineProperty:( NSString *)property descriptor:(id)descriptor;362 JavaScript language. Pass an NSString * to access a named property. Other valid properties include symbols, numbers, and stringifiable objects. In macOS 10.13 and iOS 11 and below, 'property' was an NSString *. 363 */ 364 - (void)defineProperty:(JSValuePropertyKeyType)property descriptor:(id)descriptor; 345 365 346 366 /*! … … 405 425 /*! 406 426 @property 427 @abstract Check if a JSValue is a symbol. 428 */ 429 @property (readonly) BOOL isSymbol JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)); 430 431 /*! 432 @property 407 433 @abstract Check if a JSValue is an array. 408 434 */ 409 @property (readonly) BOOL isArray NS_AVAILABLE(10_11, 9_0);435 @property (readonly) BOOL isArray JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 410 436 411 437 /*! … … 413 439 @abstract Check if a JSValue is a date. 414 440 */ 415 @property (readonly) BOOL isDate NS_AVAILABLE(10_11, 9_0);441 @property (readonly) BOOL isDate JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 416 442 417 443 /*! … … 570 596 571 597 An object key passed as a subscript will be converted to a JavaScript value, 572 and then the value converted to a string used as a property name. 598 and then the value converted to a string used as a property name. In macOS 599 10.13 and iOS 11 and below, the <code>key</code> argument of 600 <code>setObject:object forKeyedSubscript:key</code> was restricted to an 601 <code>NSString <NSCopying> *</code> but that restriction was never used. 573 602 */ 574 603 @interface JSValue (SubscriptSupport) 575 604 576 - (JSValue *)objectForKeyedSubscript:( id)key;605 - (JSValue *)objectForKeyedSubscript:(JSValuePropertyKeyType)key; 577 606 - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index; 578 - (void)setObject:(id)object forKeyedSubscript:( NSObject <NSCopying> *)key;607 - (void)setObject:(id)object forKeyedSubscript:(JSValuePropertyKeyType)key; 579 608 - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index; 580 609 -
trunk/Source/JavaScriptCore/API/JSValue.mm
r233409 r234227 40 40 #import "Strong.h" 41 41 #import "StrongInlines.h" 42 #import <wtf/Expected.h> 42 43 #import <wtf/HashMap.h> 43 44 #import <wtf/HashSet.h> … … 152 153 } 153 154 155 + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context 156 { 157 JSStringRef string = JSStringCreateWithCFString(reinterpret_cast<CFStringRef>(description)); 158 return [JSValue valueWithJSValueRef:JSValueMakeSymbol([context JSGlobalContextRef], string) inContext:context]; 159 } 160 161 154 162 - (id)toObject 155 163 { … … 235 243 } 236 244 237 - (JSValue *)valueForProperty:(NSString *)propertyName 238 { 245 template<typename Result, typename NSStringFunction, typename JSValueFunction, typename... Types> 246 inline Expected<Result, JSValueRef> performPropertyOperation(NSStringFunction stringFunction, JSValueFunction jsFunction, JSValue* value, id propertyKey, Types... arguments) 247 { 248 JSContext* context = [value context]; 249 JSValueRef exception = nullptr; 250 JSObjectRef object = JSValueToObject([context JSGlobalContextRef], [value JSValueRef], &exception); 251 if (exception) 252 return Unexpected<JSValueRef>(exception); 253 254 Result result; 255 // If it's a NSString already, reduce indirection and just pass the NSString. 256 if ([propertyKey isKindOfClass:[NSString class]]) { 257 JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyKey); 258 result = stringFunction([context JSGlobalContextRef], object, name, arguments..., &exception); 259 JSStringRelease(name); 260 } else 261 result = jsFunction([context JSGlobalContextRef], object, [[JSValue valueWithObject:propertyKey inContext:context] JSValueRef], arguments..., &exception); 262 return Expected<Result, JSValueRef>(result); 263 } 264 265 - (JSValue *)valueForProperty:(id)key 266 { 267 auto result = performPropertyOperation<JSValueRef>(JSObjectGetProperty, JSObjectGetPropertyKey, self, key); 268 if (!result) 269 return [_context valueFromNotifyException:result.error()]; 270 271 return [JSValue valueWithJSValueRef:result.value() inContext:_context]; 272 } 273 274 275 - (void)setValue:(id)value forProperty:(JSValuePropertyKeyType)key 276 { 277 // We need Unit business because void can't be assigned to in performPropertyOperation and I don't want to duplicate the code... 278 using Unit = std::tuple<>; 279 auto stringSetProperty = [] (auto... args) -> Unit { 280 JSObjectSetProperty(args...); 281 return { }; 282 }; 283 284 auto jsValueSetProperty = [] (auto... args) -> Unit { 285 JSObjectSetPropertyKey(args...); 286 return { }; 287 }; 288 289 auto result = performPropertyOperation<Unit>(stringSetProperty, jsValueSetProperty, self, key, objectToValue(_context, value), kJSPropertyAttributeNone); 290 if (!result) { 291 [_context notifyException:result.error()]; 292 return; 293 } 294 } 295 296 - (BOOL)deleteProperty:(JSValuePropertyKeyType)key 297 { 298 Expected<BOOL, JSValueRef> result = performPropertyOperation<BOOL>(JSObjectDeleteProperty, JSObjectDeletePropertyKey, self, key); 299 if (!result) 300 return [_context boolFromNotifyException:result.error()]; 301 return result.value(); 302 } 303 304 - (BOOL)hasProperty:(JSValuePropertyKeyType)key 305 { 306 // The C-api doesn't return an exception value for the string version of has property. 307 auto stringHasProperty = [] (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef*) -> BOOL { 308 return JSObjectHasProperty(ctx, object, propertyName); 309 }; 310 311 Expected<BOOL, JSValueRef> result = performPropertyOperation<BOOL>(stringHasProperty, JSObjectHasPropertyKey, self, key); 312 if (!result) 313 return [_context boolFromNotifyException:result.error()]; 314 return result.value(); 315 } 316 317 - (void)defineProperty:(JSValuePropertyKeyType)key descriptor:(id)descriptor 318 { 319 [[_context globalObject][@"Object"] invokeMethod:@"defineProperty" withArguments:@[ self, key, descriptor ]]; 320 } 321 322 - (JSValue *)valueAtIndex:(NSUInteger)index 323 { 324 // Properties that are higher than an unsigned value can hold are converted to a double then inserted as a normal property. 325 // Indices that are bigger than the max allowed index size (UINT_MAX - 1) will be handled internally in get(). 326 if (index != (unsigned)index) 327 return [self valueForProperty:[[JSValue valueWithDouble:index inContext:_context] toString]]; 328 239 329 JSValueRef exception = 0; 240 330 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception); … … 242 332 return [_context valueFromNotifyException:exception]; 243 333 244 JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName); 245 JSValueRef result = JSObjectGetProperty([_context JSGlobalContextRef], object, name, &exception); 246 JSStringRelease(name); 334 JSValueRef result = JSObjectGetPropertyAtIndex([_context JSGlobalContextRef], object, (unsigned)index, &exception); 247 335 if (exception) 248 336 return [_context valueFromNotifyException:exception]; … … 251 339 } 252 340 253 - (void)setValue:(id)value forProperty:(NSString *)propertyName 254 { 341 - (void)setValue:(id)value atIndex:(NSUInteger)index 342 { 343 // Properties that are higher than an unsigned value can hold are converted to a double, then inserted as a normal property. 344 // Indices that are bigger than the max allowed index size (UINT_MAX - 1) will be handled internally in putByIndex(). 345 if (index != (unsigned)index) 346 return [self setValue:value forProperty:[[JSValue valueWithDouble:index inContext:_context] toString]]; 347 255 348 JSValueRef exception = 0; 256 349 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception); … … 260 353 } 261 354 262 JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);263 JSObjectSetProperty([_context JSGlobalContextRef], object, name, objectToValue(_context, value), 0, &exception);264 JSStringRelease(name);265 if (exception) {266 [_context notifyException:exception];267 return;268 }269 }270 271 - (BOOL)deleteProperty:(NSString *)propertyName272 {273 JSValueRef exception = 0;274 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception);275 if (exception)276 return [_context boolFromNotifyException:exception];277 278 JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);279 BOOL result = JSObjectDeleteProperty([_context JSGlobalContextRef], object, name, &exception);280 JSStringRelease(name);281 if (exception)282 return [_context boolFromNotifyException:exception];283 284 return result;285 }286 287 - (BOOL)hasProperty:(NSString *)propertyName288 {289 JSValueRef exception = 0;290 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception);291 if (exception)292 return [_context boolFromNotifyException:exception];293 294 JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);295 BOOL result = JSObjectHasProperty([_context JSGlobalContextRef], object, name);296 JSStringRelease(name);297 return result;298 }299 300 - (void)defineProperty:(NSString *)property descriptor:(id)descriptor301 {302 [[_context globalObject][@"Object"] invokeMethod:@"defineProperty" withArguments:@[ self, property, descriptor ]];303 }304 305 - (JSValue *)valueAtIndex:(NSUInteger)index306 {307 // Properties that are higher than an unsigned value can hold are converted to a double then inserted as a normal property.308 // Indices that are bigger than the max allowed index size (UINT_MAX - 1) will be handled internally in get().309 if (index != (unsigned)index)310 return [self valueForProperty:[[JSValue valueWithDouble:index inContext:_context] toString]];311 312 JSValueRef exception = 0;313 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception);314 if (exception)315 return [_context valueFromNotifyException:exception];316 317 JSValueRef result = JSObjectGetPropertyAtIndex([_context JSGlobalContextRef], object, (unsigned)index, &exception);318 if (exception)319 return [_context valueFromNotifyException:exception];320 321 return [JSValue valueWithJSValueRef:result inContext:_context];322 }323 324 - (void)setValue:(id)value atIndex:(NSUInteger)index325 {326 // Properties that are higher than an unsigned value can hold are converted to a double, then inserted as a normal property.327 // Indices that are bigger than the max allowed index size (UINT_MAX - 1) will be handled internally in putByIndex().328 if (index != (unsigned)index)329 return [self setValue:value forProperty:[[JSValue valueWithDouble:index inContext:_context] toString]];330 331 JSValueRef exception = 0;332 JSObjectRef object = JSValueToObject([_context JSGlobalContextRef], m_value, &exception);333 if (exception) {334 [_context notifyException:exception];335 return;336 }337 338 355 JSObjectSetPropertyAtIndex([_context JSGlobalContextRef], object, (unsigned)index, objectToValue(_context, value), &exception); 339 356 if (exception) { … … 371 388 { 372 389 return JSValueIsObject([_context JSGlobalContextRef], m_value); 390 } 391 392 - (BOOL)isSymbol 393 { 394 return JSValueIsSymbol([_context JSGlobalContextRef], m_value); 373 395 } 374 396 … … 555 577 - (JSValue *)objectForKeyedSubscript:(id)key 556 578 { 557 if (![key isKindOfClass:[NSString class]]) { 558 key = [[JSValue valueWithObject:key inContext:_context] toString]; 559 if (!key) 560 return [JSValue valueWithUndefinedInContext:_context]; 561 } 562 563 return [self valueForProperty:(NSString *)key]; 579 return [self valueForProperty:key]; 564 580 } 565 581 … … 569 585 } 570 586 571 - (void)setObject:(id)object forKeyedSubscript:(NSObject <NSCopying> *)key 572 { 573 if (![key isKindOfClass:[NSString class]]) { 574 key = [[JSValue valueWithObject:key inContext:_context] toString]; 575 if (!key) 576 return; 577 } 578 579 [self setValue:object forProperty:(NSString *)key]; 587 - (void)setObject:(id)object forKeyedSubscript:(id)key 588 { 589 [self setValue:object forProperty:key]; 580 590 } 581 591 -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r232337 r234227 87 87 if (jsValue.isString()) 88 88 return kJSTypeString; 89 if (jsValue.isSymbol()) 90 return kJSTypeSymbol; 89 91 ASSERT(jsValue.isObject()); 90 92 return kJSTypeObject; … … 161 163 162 164 return toJS(exec, value).isObject(); 165 } 166 167 bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) 168 { 169 if (!ctx) { 170 ASSERT_NOT_REACHED(); 171 return false; 172 } 173 ExecState* exec = toJS(ctx); 174 JSLockHolder locker(exec); 175 176 return toJS(exec, value).isSymbol(); 163 177 } 164 178 … … 321 335 } 322 336 337 JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) 338 { 339 if (!ctx) { 340 ASSERT_NOT_REACHED(); 341 return nullptr; 342 } 343 ExecState* exec = toJS(ctx); 344 JSLockHolder locker(exec); 345 auto scope = DECLARE_CATCH_SCOPE(exec->vm()); 346 347 JSString* jsDescription = jsString(exec, description ? description->string() : String()); 348 RETURN_IF_EXCEPTION(scope, nullptr); 349 350 return toRef(exec, Symbol::create(exec, jsDescription)); 351 } 352 323 353 JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) 324 354 { -
trunk/Source/JavaScriptCore/API/JSValueRef.h
r207542 r234227 43 43 @constant kJSTypeString A primitive string value. 44 44 @constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). 45 @constant kJSTypeSymbol A primitive symbol value. 45 46 */ 46 47 typedef enum { … … 50 51 kJSTypeNumber, 51 52 kJSTypeString, 52 kJSTypeObject 53 kJSTypeObject, 54 kJSTypeSymbol JSC_API_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)) 53 55 } JSType; 54 56 … … 81 83 kJSTypedArrayTypeArrayBuffer, 82 84 kJSTypedArrayTypeNone, 83 } JSTypedArrayType CF_ENUM_AVAILABLE(10_12, 10_0);85 } JSTypedArrayType JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 84 86 85 87 #ifdef __cplusplus … … 149 151 */ 150 152 JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); 153 154 /*! 155 @function 156 @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 151 163 152 164 /*! … … 167 179 @result true if value is an array, otherwise false. 168 180 */ 169 JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0);181 JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 170 182 171 183 /*! … … 176 188 @result true if value is a date, otherwise false. 177 189 */ 178 JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0);190 JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macosx(10.11), ios(9.0)); 179 191 180 192 /*! … … 186 198 @result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object. 187 199 */ 188 JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);200 JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.12), ios(10.0)); 189 201 190 202 /* Comparing values */ … … 257 269 */ 258 270 JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); 271 272 /*! 273 @function 274 @abstract Creates a JavaScript value of the symbol type. 275 @param ctx The execution context to use. 276 @param description A description of the newly created symbol value. 277 @result A unique JSValue of the symbol type, whose description matches the one provided. 278 */ 279 JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description); 259 280 260 281 /*! … … 277 298 @result A JSValue containing the parsed value, or NULL if the input is invalid. 278 299 */ 279 JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) CF_AVAILABLE(10_7, 7_0);300 JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) JSC_API_AVAILABLE(macosx(10.7), ios(7.0)); 280 301 281 302 /*! … … 288 309 @result A JSString with the result of serialization, or NULL if an exception is thrown. 289 310 */ 290 JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) CF_AVAILABLE(10_7, 7_0);311 JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) JSC_API_AVAILABLE(macosx(10.7), ios(7.0)); 291 312 292 313 /* Converting to primitive values */ -
trunk/Source/JavaScriptCore/API/WebKitAvailability.h
r219050 r234227 70 70 71 71 #if defined(BUILDING_GTK__) 72 #undef CF_AVAILABLE 73 #define CF_AVAILABLE(_mac, _ios) 74 #undef CF_ENUM_AVAILABLE 75 #define CF_ENUM_AVAILABLE(_mac, _ios) 72 #undef JSC_API_AVAILABLE 73 #define JSC_API_AVAILABLE(...) 76 74 #endif 77 75 78 76 #else 79 #define CF_AVAILABLE(_mac, _ios) 80 #define CF_ENUM_AVAILABLE(_mac, _ios) 77 #define JSC_API_AVAILABLE(...) 81 78 #endif 82 79 -
trunk/Source/JavaScriptCore/API/tests/CurrentThisInsideBlockGetterTest.mm
r221097 r234227 24 24 */ 25 25 26 #include "config.h" 26 27 #include "CurrentThisInsideBlockGetterTest.h" 27 28 -
trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c
r222175 r234227 24 24 */ 25 25 26 #include "config.h" 26 27 #include "CustomGlobalObjectClassTest.h" 27 28 -
trunk/Source/JavaScriptCore/API/tests/DateTests.mm
r217182 r234227 24 24 */ 25 25 26 #import "config.h" 26 27 #import "DateTests.h" 27 28 #import <Foundation/Foundation.h> -
trunk/Source/JavaScriptCore/API/tests/JSExportTests.mm
r218316 r234227 24 24 */ 25 25 26 #import "config.h" 26 27 #import "JSExportTests.h" 27 28 -
trunk/Source/JavaScriptCore/API/tests/JSNode.c
r165676 r234227 24 24 */ 25 25 26 #include <wtf/Platform.h>26 #include "config.h" 27 27 28 28 #include "JSNode.h" -
trunk/Source/JavaScriptCore/API/tests/JSNodeList.c
r165676 r234227 24 24 */ 25 25 26 #include <wtf/Platform.h>26 #include "config.h" 27 27 28 28 #include "JSNode.h" -
trunk/Source/JavaScriptCore/API/tests/Node.c
r165676 r234227 24 24 */ 25 25 26 #include "config.h" 26 27 #include "Node.h" 28 27 29 #include <stddef.h> 28 30 #include <stdlib.h> -
trunk/Source/JavaScriptCore/API/tests/NodeList.c
r165676 r234227 24 24 */ 25 25 26 #include "config.h" 26 27 #include "NodeList.h" 27 28 -
trunk/Source/JavaScriptCore/API/tests/minidom.c
r165676 r234227 25 25 */ 26 26 27 #include <wtf/Platform.h>27 #include "config.h" 28 28 29 29 #include "JSContextRef.h" -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r221546 r234227 24 24 */ 25 25 26 #include <wtf/Platform.h> 26 #define ASSERT_DISABLED 0 27 #include "config.h" 27 28 28 29 #if USE(CF) … … 45 46 #include <string.h> 46 47 #include <time.h> 47 #define ASSERT_DISABLED 048 48 #include <wtf/Assertions.h> 49 49 … … 66 66 void testObjectiveCAPI(void); 67 67 #endif 68 69 int testCAPIViaCpp(void); 68 70 69 71 bool assertTrue(bool value, const char* message); … … 1362 1364 testObjectiveCAPI(); 1363 1365 #endif 1366 RELEASE_ASSERT(!testCAPIViaCpp()); 1364 1367 1365 1368 const char *scriptPath = "testapi.js"; -
trunk/Source/JavaScriptCore/API/tests/testapi.mm
r234180 r234227 24 24 */ 25 25 26 #import "config.h" 26 27 #import "JSExportMacros.h" 27 28 #import <JavaScriptCore/JavaScriptCore.h> … … 43 44 #import <wtf/MemoryFootprint.h> 44 45 #import <wtf/Optional.h> 46 #import <wtf/DataLog.h> 45 47 46 48 extern "C" void JSSynchronousGarbageCollectForDebugging(JSContextRef); … … 628 630 629 631 @autoreleasepool { 632 JSContext *context = [[JSContext alloc] init]; 633 JSValue *symbol = [context evaluateScript:@"Symbol('dope');"]; 634 JSValue *notSymbol = [context evaluateScript:@"'dope'"]; 635 checkResult(@"Should be a symbol value", symbol.isSymbol); 636 checkResult(@"Should not be a symbol value", !notSymbol.isSymbol); 637 } 638 639 @autoreleasepool { 640 JSContext *context = [[JSContext alloc] init]; 641 JSValue *symbol = [JSValue valueWithNewSymbolFromDescription:@"dope" inContext:context]; 642 checkResult(@"Should be a created from Obj-C", symbol.isSymbol); 643 } 644 645 @autoreleasepool { 646 JSContext *context = [[JSContext alloc] init]; 647 JSValue *arrayIterator = [context evaluateScript:@"Array.prototype[Symbol.iterator]"]; 648 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 649 JSValue *array = [JSValue valueWithNewArrayInContext:context]; 650 checkResult(@"Looking up by subscript with symbol should work", [array[iteratorSymbol] isEqual:arrayIterator]); 651 checkResult(@"Looking up by method with symbol should work", [[array valueForProperty:iteratorSymbol] isEqual:arrayIterator]); 652 } 653 654 @autoreleasepool { 655 JSContext *context = [[JSContext alloc] init]; 656 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 657 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 658 JSValue *theAnswer = [JSValue valueWithUInt32:42 inContext:context]; 659 object[iteratorSymbol] = theAnswer; 660 checkResult(@"Setting by subscript with symbol should work", [object[iteratorSymbol] isEqual:theAnswer]); 661 } 662 663 @autoreleasepool { 664 JSContext *context = [[JSContext alloc] init]; 665 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 666 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 667 JSValue *theAnswer = [JSValue valueWithUInt32:42 inContext:context]; 668 [object setValue:theAnswer forProperty:iteratorSymbol]; 669 checkResult(@"Setting by method with symbol should work", [object[iteratorSymbol] isEqual:theAnswer]); 670 } 671 672 @autoreleasepool { 673 JSContext *context = [[JSContext alloc] init]; 674 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 675 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 676 JSValue *theAnswer = [JSValue valueWithUInt32:42 inContext:context]; 677 object[iteratorSymbol] = theAnswer; 678 checkResult(@"has property with symbol should work", [object hasProperty:iteratorSymbol]); 679 } 680 681 @autoreleasepool { 682 JSContext *context = [[JSContext alloc] init]; 683 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 684 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 685 JSValue *theAnswer = [JSValue valueWithUInt32:42 inContext:context]; 686 checkResult(@"delete property with symbol should work without property", [object deleteProperty:iteratorSymbol]); 687 object[iteratorSymbol] = theAnswer; 688 checkResult(@"delete property with symbol should work with property", [object deleteProperty:iteratorSymbol]); 689 checkResult(@"delete should be false with non-configurable property", ![context[@"Array"] deleteProperty:@"prototype"]); 690 } 691 692 @autoreleasepool { 693 JSContext *context = [[JSContext alloc] init]; 694 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 695 NSObject *objCObject = [[NSObject alloc] init]; 696 JSValue *result = object[objCObject]; 697 checkResult(@"getting a non-convertable object should return undefined", [result isUndefined]); 698 object[objCObject] = @(1); 699 result = object[objCObject]; 700 checkResult(@"getting a non-convertable object should return the stored value", [result toUInt32] == 1); 701 } 702 703 @autoreleasepool { 704 JSContext *context = [[JSContext alloc] init]; 705 JSValue *object = [JSValue valueWithNewObjectInContext:context]; 706 JSValue *iteratorSymbol = context[@"Symbol"][@"iterator"]; 707 object[@"value"] = @(1); 708 context[@"object"] = object; 709 710 object[iteratorSymbol] = ^{ 711 JSValue *result = [JSValue valueWithNewObjectInContext:context]; 712 result[@"object"] = [JSContext currentThis]; 713 result[@"next"] = ^{ 714 JSValue *result = [JSValue valueWithNewObjectInContext:context]; 715 JSValue *value = [JSContext currentThis][@"object"][@"value"]; 716 [[JSContext currentThis][@"object"] deleteProperty:@"value"]; 717 result[@"value"] = value; 718 result[@"done"] = [JSValue valueWithBool:[value isUndefined] inContext:context]; 719 return result; 720 }; 721 return result; 722 }; 723 724 725 JSValue *count = [context evaluateScript:@"let count = 0; for (let v of object) { if (v !== 1) throw new Error(); count++; } count;"]; 726 checkResult(@"iterator should not throw", ![context exception]); 727 checkResult(@"iteration count should be 1", [count toUInt32] == 1); 728 } 729 730 @autoreleasepool { 630 731 JSCollection* myPrivateProperties = [[JSCollection alloc] init]; 631 732 -
trunk/Source/JavaScriptCore/ChangeLog
r234207 r234227 1 2018-07-25 Keith Miller <keith_miller@apple.com> 2 3 [JSC API] We should support the symbol type in our C/Obj-C API 4 https://bugs.webkit.org/show_bug.cgi?id=175836 5 6 Reviewed by Filip Pizlo. 7 8 This patch makes the following API additions: 9 1) Test if a JSValue/JSValueRef is a symbol via any of the methods API are able to test for the types of other JSValues. 10 2) Create a symbol on both APIs. 11 3) Get/Set/Delete/Define property now take ids in the Obj-C API. 12 4) Add Get/Set/Delete in the C API. 13 14 We can do 3 because it is both binary and source compatable with 15 the existing API. I added (4) because the current property access 16 APIs only have the ability to get Strings. It was possible to 17 merge symbols into JSStringRef but that felt confusing and exposes 18 implementation details of our engine. The new functions match the 19 same meaning that they have in JS, thus should be forward 20 compatible with any future language extensions. 21 22 Lastly, this patch adds the same availability preproccessing phase 23 in WebCore to JavaScriptCore, which enables TBA features for 24 testing on previous releases. 25 26 * API/APICast.h: 27 * API/JSBasePrivate.h: 28 * API/JSContext.h: 29 * API/JSContextPrivate.h: 30 * API/JSContextRef.h: 31 * API/JSContextRefInternal.h: 32 * API/JSContextRefPrivate.h: 33 * API/JSManagedValue.h: 34 * API/JSObjectRef.cpp: 35 (JSObjectHasPropertyKey): 36 (JSObjectGetPropertyKey): 37 (JSObjectSetPropertyKey): 38 (JSObjectDeletePropertyKey): 39 * API/JSObjectRef.h: 40 * API/JSRemoteInspector.h: 41 * API/JSTypedArray.h: 42 * API/JSValue.h: 43 * API/JSValue.mm: 44 (+[JSValue valueWithNewSymbolFromDescription:inContext:]): 45 (performPropertyOperation): 46 (-[JSValue valueForProperty:valueForProperty:]): 47 (-[JSValue setValue:forProperty:setValue:forProperty:]): 48 (-[JSValue deleteProperty:deleteProperty:]): 49 (-[JSValue hasProperty:hasProperty:]): 50 (-[JSValue defineProperty:descriptor:defineProperty:descriptor:]): 51 (-[JSValue isSymbol]): 52 (-[JSValue objectForKeyedSubscript:]): 53 (-[JSValue setObject:forKeyedSubscript:]): 54 (-[JSValue valueForProperty:]): Deleted. 55 (-[JSValue setValue:forProperty:]): Deleted. 56 (-[JSValue deleteProperty:]): Deleted. 57 (-[JSValue hasProperty:]): Deleted. 58 (-[JSValue defineProperty:descriptor:]): Deleted. 59 * API/JSValueRef.cpp: 60 (JSValueGetType): 61 (JSValueIsSymbol): 62 (JSValueMakeSymbol): 63 * API/JSValueRef.h: 64 * API/WebKitAvailability.h: 65 * API/tests/CurrentThisInsideBlockGetterTest.mm: 66 * API/tests/CustomGlobalObjectClassTest.c: 67 * API/tests/DateTests.mm: 68 * API/tests/JSExportTests.mm: 69 * API/tests/JSNode.c: 70 * API/tests/JSNodeList.c: 71 * API/tests/Node.c: 72 * API/tests/NodeList.c: 73 * API/tests/minidom.c: 74 * API/tests/testapi.c: 75 (main): 76 * API/tests/testapi.cpp: Added. 77 (APIString::APIString): 78 (APIString::~APIString): 79 (APIString::operator JSStringRef): 80 (APIContext::APIContext): 81 (APIContext::~APIContext): 82 (APIContext::operator JSGlobalContextRef): 83 (APIVector::APIVector): 84 (APIVector::~APIVector): 85 (APIVector::append): 86 (testCAPIViaCpp): 87 (TestAPI::evaluateScript): 88 (TestAPI::callFunction): 89 (TestAPI::functionReturnsTrue): 90 (TestAPI::check): 91 (TestAPI::checkJSAndAPIMatch): 92 (TestAPI::interestingObjects): 93 (TestAPI::interestingKeys): 94 (TestAPI::run): 95 * API/tests/testapi.mm: 96 (testObjectiveCAPIMain): 97 * JavaScriptCore.xcodeproj/project.pbxproj: 98 * config.h: 99 * postprocess-headers.sh: 100 * shell/CMakeLists.txt: 101 * testmem/testmem.mm: 102 1 103 2018-07-25 Andy VanWagoner <andy@vanwagoner.family> 2 104 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r234127 r234227 1041 1041 53E9E0AC1EAE83DF00FEE251 /* WasmMachineThreads.h in Headers */ = {isa = PBXBuildFile; fileRef = 53E9E0AA1EAE83DE00FEE251 /* WasmMachineThreads.h */; }; 1042 1042 53E9E0AF1EAEC45700FEE251 /* WasmTierUpCount.h in Headers */ = {isa = PBXBuildFile; fileRef = 53E9E0AE1EAEC45700FEE251 /* WasmTierUpCount.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1043 53F11F41209138D700E411A7 /* JSImmutableButterfly.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F11F40209138D700E411A7 /* JSImmutableButterfly.h */; }; 1044 53F40E851D58F9770099A1B6 /* WasmSections.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E841D58F9770099A1B6 /* WasmSections.h */; }; 1043 53F11F41209138D700E411A7 /* JSImmutableButterfly.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F11F40209138D700E411A7 /* JSImmutableButterfly.h */; }; 1044 53EAFE2F208DFAB4007D524B /* testapi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 531D4E191F59CDD200EC836C /* testapi.cpp */; }; 1045 53F40E851D58F9770099A1B6 /* WasmSections.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E841D58F9770099A1B6 /* WasmSections.h */; }; 1045 1046 53F40E8B1D5901BB0099A1B6 /* WasmFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */; }; 1046 1047 53F40E8D1D5901F20099A1B6 /* WasmParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8C1D5901F20099A1B6 /* WasmParser.h */; }; … … 3306 3307 531374BC1D5CE67600AF7A0B /* WasmPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmPlan.h; sourceTree = "<group>"; }; 3307 3308 531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPlan.cpp; sourceTree = "<group>"; }; 3309 531D4E191F59CDD200EC836C /* testapi.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = testapi.cpp; path = API/tests/testapi.cpp; sourceTree = "<group>"; }; 3308 3310 533B15DE1DC7F463004D500A /* WasmOps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmOps.h; sourceTree = "<group>"; }; 3309 3311 5341FC6F1DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3WasmBoundsCheckValue.cpp; path = b3/B3WasmBoundsCheckValue.cpp; sourceTree = "<group>"; }; … … 3476 3478 53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArrayViewPrototype.h; sourceTree = "<group>"; }; 3477 3479 53917E831B791CB8000EBD33 /* TypedArrayPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = TypedArrayPrototype.js; path = builtins/TypedArrayPrototype.js; sourceTree = SOURCE_ROOT; }; 3478 539EB0711D553DF800C82EF7 /* testWasm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testWasm.cpp; sourceTree = "<group>"; };3479 3480 539FB8B91C99DA7C00940FA1 /* JSArrayInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayInlines.h; sourceTree = "<group>"; }; 3480 3481 53B0BE331E561AC900A8FC29 /* GetterSetterAccessCase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetterSetterAccessCase.cpp; sourceTree = "<group>"; }; … … 5468 5469 FECB8B291D25CABB006F2463 /* testapi-function-overrides.js */, 5469 5470 14BD5A2D0A3E91F600BAF59C /* testapi.c */, 5471 531D4E191F59CDD200EC836C /* testapi.cpp */, 5470 5472 14D857740A4696C80032146C /* testapi.js */, 5471 5473 86D22219167EF9440024C804 /* testapi.mm */, 5472 5474 651122E5140469BA002B101D /* testRegExp.cpp */, 5473 539EB0711D553DF800C82EF7 /* testWasm.cpp */,5474 5475 534902821C7242C80012BCB8 /* TypedArrayCTest.cpp */, 5475 5476 534902831C7242C80012BCB8 /* TypedArrayCTest.h */, … … 8983 8984 0FB467811FDDA6F7003FCB09 /* IsoCellSetInlines.h in Headers */, 8984 8985 0FDCE12D1FAFB4E5006F3901 /* IsoSubspace.h in Headers */, 8985 8986 8986 0FD2FD9520B52BE200F09441 /* IsoSubspaceInlines.h in Headers */, 8987 0F5E0FE72086AD480097F0DE /* IsoSubspacePerVM.h in Headers */, 8987 8988 8B9F6D561D5912FA001C739F /* IterationKind.h in Headers */, 8988 8989 FE4D55B81AE716CA0052E459 /* IterationStatus.h in Headers */, … … 10204 10205 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */, 10205 10206 1440F6100A4F85670005F061 /* testapi.c in Sources */, 10207 53EAFE2F208DFAB4007D524B /* testapi.cpp in Sources */, 10206 10208 86D2221A167EF9440024C804 /* testapi.mm in Sources */, 10207 10209 534902851C7276B70012BCB8 /* TypedArrayCTest.cpp in Sources */, … … 10671 10673 baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */; 10672 10674 buildSettings = { 10675 HEADER_SEARCH_PATHS = ( 10676 "\"$(JAVASCRIPTCORE_FRAMEWORKS_DIR)/JavaScriptCore.framework/PrivateHeaders\"", 10677 "$(inherited)", 10678 ); 10673 10679 }; 10674 10680 name = Debug; … … 10678 10684 baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */; 10679 10685 buildSettings = { 10686 HEADER_SEARCH_PATHS = ( 10687 "\"$(JAVASCRIPTCORE_FRAMEWORKS_DIR)/JavaScriptCore.framework/PrivateHeaders\"", 10688 "$(inherited)", 10689 ); 10680 10690 }; 10681 10691 name = Release; … … 10685 10695 baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */; 10686 10696 buildSettings = { 10697 HEADER_SEARCH_PATHS = ( 10698 "\"$(JAVASCRIPTCORE_FRAMEWORKS_DIR)/JavaScriptCore.framework/PrivateHeaders\"", 10699 "$(inherited)", 10700 ); 10687 10701 }; 10688 10702 name = Production; … … 11009 11023 baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */; 11010 11024 buildSettings = { 11025 HEADER_SEARCH_PATHS = ( 11026 "\"$(JAVASCRIPTCORE_FRAMEWORKS_DIR)/JavaScriptCore.framework/PrivateHeaders\"", 11027 "$(inherited)", 11028 ); 11011 11029 }; 11012 11030 name = Profiling; -
trunk/Source/JavaScriptCore/config.h
r224277 r234227 24 24 #endif 25 25 26 #define JSC_API_AVAILABLE(...) 27 // Use zero since it will be less than any possible version number. 28 #define JSC_MAC_VERSION_TBA 0 29 #define JSC_IOS_VERSION_TBA 0 30 26 31 #include "JSExportMacros.h" 27 32 -
trunk/Source/JavaScriptCore/postprocess-headers.sh
r194821 r234227 1 cd "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}" 1 #!/bin/sh 2 # 3 # Copyright (C) 2014-2018 Apple Inc. All rights reserved. 4 # 5 # Redistribution and use in source and binary forms, with or without 6 # modification, are permitted provided that the following conditions 7 # are met: 8 # 1. Redistributions of source code must retain the above copyright 9 # notice, this list of conditions and the following disclaimer. 10 # 2. Redistributions in binary form must reproduce the above copyright 11 # notice, this list of conditions and the following disclaimer in the 12 # documentation and/or other materials provided with the distribution. 13 # 14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 # THE POSSIBILITY OF SUCH DAMAGE. 25 # 2 26 3 UNIFDEF_OPTIONS="-D__MAC_OS_X_VERSION_MIN_REQUIRED=${TARGET_MAC_OS_X_VERSION_MAJOR}" 27 if [[ "${JSC_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then 28 exit 0; 29 fi 4 30 5 for ((i = 0; i < ${SCRIPT_INPUT_FILE_COUNT}; ++i)); do 6 eval HEADER=\${SCRIPT_INPUT_FILE_${i}}; 7 unifdef -B ${UNIFDEF_OPTIONS} -o "${HEADER}".unifdef "${HEADER}" 8 case $? in 9 0) 10 rm "${HEADER}".unifdef 11 ;; 12 1) 13 mv "${HEADER}"{.unifdef,} 14 ;; 15 *) 16 exit 1 17 esac 18 done 31 TIMESTAMP_PATH=${TARGET_TEMP_DIR}/${0##*/} 32 33 if [[ -e $TIMESTAMP_PATH && $0 -nt $TIMESTAMP_PATH ]]; then 34 rm "${TIMESTAMP_PATH}"; 35 fi 36 37 function process_definitions () { 38 local DEFINITIONS_FILE=$1 39 40 if [[ ! -f "${DEFINITIONS_FILE}" ]]; then 41 return 1 42 fi 43 44 if [[ -e $TIMESTAMP_PATH && "${DEFINITIONS_FILE}" -nt $TIMESTAMP_PATH ]]; then 45 rm "${TIMESTAMP_PATH}"; 46 fi 47 48 source "${DEFINITIONS_FILE}" 49 } 50 51 function rewrite_headers () { 52 if [[ "${PLATFORM_NAME}" == "macosx" ]]; then 53 [[ -n ${OSX_VERSION} ]] || OSX_VERSION=${MACOSX_DEPLOYMENT_TARGET} 54 [[ -n ${IOS_VERSION} ]] || IOS_VERSION="NA" 55 [[ -n ${OSX_VERSION_NUMBER} ]] || OSX_VERSION_NUMBER=${TARGET_MAC_OS_X_VERSION_MAJOR} 56 [[ -n ${IOS_VERSION_NUMBER} ]] || IOS_VERSION_NUMBER="0" 57 elif [[ "${PLATFORM_NAME}" =~ "iphone" ]]; then 58 [[ -n ${IOS_VERSION} ]] || IOS_VERSION=${IPHONEOS_DEPLOYMENT_TARGET} 59 [[ -n ${OSX_VERSION} ]] || OSX_VERSION="NA" 60 [[ -n ${OSX_VERSION_NUMBER} ]] || OSX_VERSION_NUMBER="0" 61 [[ -n ${IOS_VERSION_NUMBER} ]] || IOS_VERSION_NUMBER=${SDK_VERSION_MAJOR} 62 fi 63 64 SED_OPTIONS=( 65 ) 66 67 if [[ -n "$OSX_VERSION" && -n "$IOS_VERSION" ]]; then 68 SED_OPTIONS+=( 69 -e s/JSC_MAC_TBA/${OSX_VERSION}/g 70 -e s/JSC_IOS_TBA/${IOS_VERSION}/g 71 -e s/JSC_MAC_VERSION_TBA/${OSX_VERSION_NUMBER}/g 72 -e s/JSC_IOS_VERSION_TBA/${IOS_VERSION_NUMBER}/g 73 -e s/JSC_API_AVAILABLE/API_AVAILABLE/ 74 -e s/JSC_API_DEPRECATED/API_DEPRECATED/ 75 -e "s/^JSC_CLASS_AVAILABLE/JSC_EXTERN API_AVAILABLE/" 76 -e "s/^JSC_CLASS_DEPRECATED/JSC_EXTERN API_DEPRECATED/" 77 ) 78 else 79 SED_OPTIONS+=(-e 's/JSC_(API_|CLASS_)AVAILABLE\(.*\)\s*\)//g' -e 's/JSC_(API_|CLASS_)DEPRECATED(_WITH_REPLACEMENT)?\(.*\)\s*\)//g') 80 fi 81 82 SED_OPTIONS+=(${OTHER_SED_OPTIONS[*]}) 83 84 for HEADER_PATH in "${1}/"*.h; do 85 if [[ "$HEADER_PATH" -nt $TIMESTAMP_PATH ]]; then 86 ditto "${HEADER_PATH}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" 87 sed -i .tmp -E "${SED_OPTIONS[@]}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" || exit $? 88 mv "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" "$HEADER_PATH" 89 fi 90 done 91 } 92 93 DEFINITIONS_PATH=usr/local/include/WebKitAdditions/Scripts/postprocess-framework-headers-definitions 94 95 process_definitions "${BUILT_PRODUCTS_DIR}/${DEFINITIONS_PATH}" || process_definitions "${SDKROOT}/${DEFINITIONS_PATH}" 96 97 rewrite_headers "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}" 98 rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}" 99 100 touch ${TIMESTAMP_PATH} -
trunk/Source/JavaScriptCore/shell/CMakeLists.txt
r227952 r234227 29 29 ../API/tests/TypedArrayCTest.cpp 30 30 ../API/tests/testapi.c 31 ../API/tests/testapi.cpp 31 32 ) 32 33 -
trunk/Source/JavaScriptCore/testmem/testmem.mm
r232193 r234227 24 24 */ 25 25 26 #import "config.h" 26 27 #import <JavaScriptCore/JavaScriptCore.h> 27 28 #import <inttypes.h>
Note:
See TracChangeset
for help on using the changeset viewer.