JSObject.makeTypedArrayWithBytesNoCopy constructor

JSObject.makeTypedArrayWithBytesNoCopy(
  1. JSContext context,
  2. JSTypedArrayType arrayType,
  3. Bytes bytes,
  4. Pointer<NativeFunction<JSTypedArrayBytesDeallocator>>? bytesDeallocator,
  5. Pointer<NativeType> deallocatorContext, {
  6. JSValuePointer? exception,
})

Creates a JavaScript Typed Array object from an existing pointer. If an exception is thrown during this function the bytesDeallocator will always be called. arrayType A value JSTypedArrayType identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. bytes (void*) A pointer to the byte buffer to be used as the backing store of the Typed Array object. byteLength The number of bytes pointed to by the parameter bytes. bytesDeallocator (JSTypedArrayBytesDeallocator) The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated. deallocatorContext (void*) A pointer to pass back to the deallocator. exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.

Implementation

JSObject.makeTypedArrayWithBytesNoCopy(
  this.context,
  JSTypedArrayType arrayType,
  Bytes bytes,
  Pointer<NativeFunction<JSBase.JSTypedArrayBytesDeallocator>>?
      bytesDeallocator,
  Pointer deallocatorContext, {
  JSValuePointer? exception,
}) : this.pointer = JSTypedArray.jSObjectMakeTypedArrayWithBytesNoCopy(
          context.pointer,
          JSValue.jSTypedArrayTypeToCEnum(arrayType),
          bytes.pointer,
          bytes.length,
          bytesDeallocator ?? nullptr,
          deallocatorContext,
          (exception ?? JSValuePointer(nullptr)).pointer);