| 530 | |
| 531 | Valdi::JSValueRef JavaScriptCoreContext::newArrayBuffer(const Valdi::BytesView& buffer, |
| 532 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 533 | auto context = getJSGlobalContext(); |
| 534 | JSValueRef exception = nullptr; |
| 535 | JSObjectRef arrayBuffer = nullptr; |
| 536 | if (buffer.empty()) { |
| 537 | arrayBuffer = _emptyArrayBuffer; |
| 538 | } else { |
| 539 | arrayBuffer = JSObjectMakeArrayBufferWithBytesNoCopy(context, |
| 540 | const_cast<Valdi::Byte*>(buffer.data()), |
| 541 | buffer.size(), |
| 542 | &bufferDeallocator, |
| 543 | Valdi::unsafeBridgeRetain(buffer.getSource().get()), |
| 544 | &exception); |
| 545 | if (exception != nullptr) { |
| 546 | // The bufferDeallocator will always be called if an exception is thrown |
| 547 | // No need to worry about deleting the buffer here |
| 548 | return checkCallAndGetValue(exceptionTracker, arrayBuffer, exception); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | return returnJSValueRef(arrayBuffer, kJSTypeObject); |
| 553 | } |
| 554 | |
| 555 | Valdi::JSValueRef JavaScriptCoreContext::newTypedArrayFromArrayBuffer(const Valdi::TypedArrayType& type, |
nothing calls this directly
no test coverage detected