JSObject.makeTypedArrayWithArrayBuffer constructor
JSObject.makeTypedArrayWithArrayBuffer(
- JSContext context, {
- required JSTypedArrayType arrayType,
- required JSObject buffer,
- bool autoDispose = true,
Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object.
arrayType
A value JSTypedArrayType identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
buffer
An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
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.makeTypedArrayWithArrayBuffer(
this.context, {
required JSTypedArrayType arrayType,
required JSObject buffer,
bool autoDispose = true,
}) {
final JSException exception = JSException.create(context);
_ref = JSObjectMakeTypedArrayWithArrayBuffer(
context.ref,
JSTypedArrayType.values.indexOf(arrayType),
buffer.ref,
exception.ref,
);
if (exception.shouldThrow) throw exception.error;
attach(calloc.nativeFree, _ref.cast(), autoDispose: autoDispose);
}