Current section

Files

Jump to
gossamer src gossamer typed_array.ffi.mjs
Raw

src/gossamer/typed_array.ffi.mjs

// src/gossamer/typed_array.ffi.ts
import * as $typedArray from "./typed_array.mjs";
function unwrap(typed) {
if ($typedArray.TypedArray$isInt8(typed)) {
return $typedArray.TypedArray$Int8$0(typed);
}
if ($typedArray.TypedArray$isUint8(typed)) {
return $typedArray.TypedArray$Uint8$0(typed);
}
if ($typedArray.TypedArray$isUint8Clamped(typed)) {
return $typedArray.TypedArray$Uint8Clamped$0(typed);
}
if ($typedArray.TypedArray$isInt16(typed)) {
return $typedArray.TypedArray$Int16$0(typed);
}
if ($typedArray.TypedArray$isUint16(typed)) {
return $typedArray.TypedArray$Uint16$0(typed);
}
if ($typedArray.TypedArray$isInt32(typed)) {
return $typedArray.TypedArray$Int32$0(typed);
}
if ($typedArray.TypedArray$isUint32(typed)) {
return $typedArray.TypedArray$Uint32$0(typed);
}
if ($typedArray.TypedArray$isFloat16(typed)) {
return $typedArray.TypedArray$Float16$0(typed);
}
if ($typedArray.TypedArray$isFloat32(typed)) {
return $typedArray.TypedArray$Float32$0(typed);
}
if ($typedArray.TypedArray$isFloat64(typed)) {
return $typedArray.TypedArray$Float64$0(typed);
}
if ($typedArray.TypedArray$isBigInt64(typed)) {
return $typedArray.TypedArray$BigInt64$0(typed);
}
return $typedArray.TypedArray$BigUint64$0(typed);
}
function wrap(arr) {
if (arr instanceof Int8Array) return $typedArray.TypedArray$Int8(arr);
if (arr instanceof Uint8ClampedArray) {
return $typedArray.TypedArray$Uint8Clamped(arr);
}
if (arr instanceof Uint8Array) return $typedArray.TypedArray$Uint8(arr);
if (arr instanceof Int16Array) return $typedArray.TypedArray$Int16(arr);
if (arr instanceof Uint16Array) return $typedArray.TypedArray$Uint16(arr);
if (arr instanceof Int32Array) return $typedArray.TypedArray$Int32(arr);
if (arr instanceof Uint32Array) return $typedArray.TypedArray$Uint32(arr);
if (arr instanceof Float16Array) return $typedArray.TypedArray$Float16(arr);
if (arr instanceof Float32Array) return $typedArray.TypedArray$Float32(arr);
if (arr instanceof Float64Array) return $typedArray.TypedArray$Float64(arr);
if (arr instanceof BigInt64Array) return $typedArray.TypedArray$BigInt64(arr);
return $typedArray.TypedArray$BigUint64(arr);
}
var length = (typed) => unwrap(typed).length;
var byte_length = (typed) => unwrap(typed).byteLength;
var byte_offset = (typed) => unwrap(typed).byteOffset;
var buffer = (typed) => unwrap(typed).buffer;
export {
buffer,
byte_length,
byte_offset,
length,
unwrap,
wrap
};