From 16a6b86122b742ba48637d58379d1c401ea206b7 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 21 Oct 2022 06:46:57 +0300 Subject: fix(ext/ffi): Use BufferSource for FFI buffer types (#16355) Potential fix for type-code mismatch in FFI buffer types. The code supports ArrayBuffers, but types only reflect TypedArray support. There's also an existing type for this sort of stuff: `BufferSource`. (Although, it uses `ArrayBufferView` which doesn't actually connect with the TypedArray interfaces specifically, but it's just a type inheritance difference and nothing more.) --- cli/dts/lib.deno.unstable.d.ts | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'cli/dts') diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 1feb11e97..466e72c8f 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -480,7 +480,7 @@ declare namespace Deno { & Record & Record & Record - & Record; + & Record; /** **UNSTABLE**: New API, yet to be vetted. * @@ -660,23 +660,6 @@ declare namespace Deno { [K in keyof T]: StaticForeignSymbol; }; - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category FFI - */ - type TypedArray = - | Int8Array - | Uint8Array - | Int16Array - | Uint16Array - | Int32Array - | Uint32Array - | Uint8ClampedArray - | Float32Array - | Float64Array - | BigInt64Array - | BigUint64Array; - /** **UNSTABLE**: New API, yet to be vetted. * * Pointer type depends on the architecture and actual pointer value. @@ -700,7 +683,7 @@ declare namespace Deno { /** * Return the direct memory pointer to the typed array in memory */ - static of(value: Deno.UnsafeCallback | TypedArray): PointerValue; + static of(value: Deno.UnsafeCallback | BufferSource): PointerValue; } /** **UNSTABLE**: New API, yet to be vetted. @@ -752,11 +735,11 @@ declare namespace Deno { offset?: number, ): ArrayBuffer; /** Copies the memory of the pointer into a typed array. Length is determined from the typed array's `byteLength`. Also takes optional byte offset from the pointer. */ - copyInto(destination: TypedArray, offset?: number): void; + copyInto(destination: BufferSource, offset?: number): void; /** Copies the memory of the specified pointer into a typed array. Length is determined from the typed array's `byteLength`. Also takes optional byte offset from the pointer. */ static copyInto( pointer: PointerValue, - destination: TypedArray, + destination: BufferSource, offset?: number, ): void; } -- cgit v1.2.3