diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-07-24 13:41:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 16:11:11 +0530 |
commit | f8fee6cd21cce82d6c34e539d39da86df7b036f7 (patch) | |
tree | 8099527951e4b532934a00c25797758aeb496ab6 /cli/dts/lib.deno.unstable.d.ts | |
parent | e1cbd2364f536a1cef817961967e1738b89be734 (diff) |
feat(ext/ffi): Safe number pointers (#15173)
Diffstat (limited to 'cli/dts/lib.deno.unstable.d.ts')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 50749e1d6..037dbe2c1 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -366,9 +366,9 @@ declare namespace Deno { type ToNativeTypeMap = & Record<NativeNumberType, number> - & Record<NativeBigIntType, bigint | number> - & Record<NativePointerType, TypedArray | bigint | null> - & Record<NativeFunctionType, bigint | null>; + & Record<NativeBigIntType, PointerValue> + & Record<NativePointerType, TypedArray | PointerValue | null> + & Record<NativeFunctionType, PointerValue | null>; /** Type conversion for foreign symbol parameters and unsafe callback return types */ type ToNativeType<T extends NativeType = NativeType> = ToNativeTypeMap[T]; @@ -391,9 +391,9 @@ declare namespace Deno { type FromNativeTypeMap = & Record<NativeNumberType, number> - & Record<NativeBigIntType, bigint> - & Record<NativePointerType, bigint> - & Record<NativeFunctionType, bigint>; + & Record<NativeBigIntType, PointerValue> + & Record<NativePointerType, PointerValue> + & Record<NativeFunctionType, PointerValue>; /** Type conversion for foreign symbol return types and unsafe callback parameters */ type FromNativeType<T extends NativeType = NativeType> = FromNativeTypeMap[T]; @@ -481,6 +481,15 @@ declare namespace Deno { | BigInt64Array | BigUint64Array; + /** + * Pointer type depends on the architecture and actual pointer value. + * + * On a 32 bit system all pointer values are plain numbers. On a 64 bit + * system pointer values are represented as numbers if the value is below + * `Number.MAX_SAFE_INTEGER`. + */ + export type PointerValue = number | bigint; + /** **UNSTABLE**: Unsafe and new API, beware! * * An unsafe pointer to a memory location for passing and returning pointers to and from the ffi @@ -489,7 +498,7 @@ declare namespace Deno { /** * Return the direct memory pointer to the typed array in memory */ - static of(value: Deno.UnsafeCallback | TypedArray): bigint; + static of(value: Deno.UnsafeCallback | TypedArray): PointerValue; } /** **UNSTABLE**: Unsafe and new API, beware! @@ -517,9 +526,9 @@ declare namespace Deno { /** Gets a signed 32-bit integer at the specified byte offset from the pointer. */ getInt32(offset?: number): number; /** Gets an unsigned 64-bit integer at the specified byte offset from the pointer. */ - getBigUint64(offset?: number): bigint; + getBigUint64(offset?: number): PointerValue; /** Gets a signed 64-bit integer at the specified byte offset from the pointer. */ - getBigInt64(offset?: number): bigint; + getBigInt64(offset?: number): PointerValue; /** Gets a signed 32-bit float at the specified byte offset from the pointer. */ getFloat32(offset?: number): number; /** Gets a signed 64-bit float at the specified byte offset from the pointer. */ |