diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 39 | ||||
-rw-r--r-- | cli/tests/unit/ffi_test.ts | 5 |
2 files changed, 14 insertions, 30 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 3482d1c80..389d08f9f 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -390,17 +390,14 @@ declare namespace Deno { ? void : T extends StaticNativeBigIntType ? bigint : T extends StaticNativeNumberType ? number - : T extends "pointer" ? UnsafePointer + : T extends "pointer" ? bigint : never; type StaticForeignFunctionParameter<T> = T extends "void" ? void : T extends StaticNativeNumberType | StaticNativeBigIntType ? number | bigint - : T extends "pointer" ? UnsafePointer | TypedArray | null - : T extends NativeCallbackType< - infer U extends readonly NativeType[], - infer V extends NativeParameterType - > ? UnsafeCallback<U, V> | UnsafePointer | null + : T extends "pointer" ? bigint | TypedArray | null + : T extends NativeCallbackType ? bigint | null : unknown; /** Infers a foreign function parameter list. */ @@ -449,19 +446,10 @@ declare namespace Deno { * An unsafe pointer to a memory location for passing and returning pointers to and from the ffi */ export class UnsafePointer { - constructor(value: bigint); - - value: bigint; - /** * Return the direct memory pointer to the typed array in memory */ - static of(typedArray: TypedArray): UnsafePointer; - - /** - * Returns the value of the pointer which is useful in certain scenarios. - */ - valueOf(): bigint; + static of(value: Deno.UnsafeCallback | TypedArray): bigint; } /** **UNSTABLE**: Unsafe and new API, beware! @@ -472,9 +460,9 @@ declare namespace Deno { * (numbers, strings and raw bytes). */ export class UnsafePointerView { - constructor(pointer: UnsafePointer); + constructor(pointer: bigint); - pointer: UnsafePointer; + pointer: bigint; /** Gets an unsigned 8-bit integer at the specified byte offset from the pointer. */ getUint8(offset?: number): number; @@ -511,10 +499,10 @@ declare namespace Deno { * present as symbols. */ export class UnsafeFnPointer<Fn extends ForeignFunction> { - pointer: UnsafePointer; + pointer: bigint; definition: Fn; - constructor(pointer: UnsafePointer, definition: Fn); + constructor(pointer: bigint, definition: Fn); call( ...args: StaticForeignFunctionParameters<Fn["parameters"]> @@ -552,18 +540,15 @@ declare namespace Deno { type UnsafeCallbackParameter<T extends NativeType> = T extends StaticNativeBigIntType ? bigint : T extends StaticNativeNumberType ? number - : T extends "pointer" ? UnsafePointer + : T extends "pointer" ? bigint : never; type UnsafeCallbackResult<T extends NativeParameterType> = T extends "void" ? void : T extends StaticNativeBigIntType ? number | bigint : T extends StaticNativeNumberType ? number - : T extends "pointer" ? UnsafePointer | TypedArray | null - : T extends NativeCallbackType< - infer U extends readonly NativeType[], - infer V extends NativeParameterType - > ? UnsafeCallback<U, V> | UnsafePointer | null + : T extends "pointer" ? bigint | TypedArray | null + : T extends NativeCallbackType ? bigint | null : never; type UnsafeCallbackFunction< @@ -594,7 +579,7 @@ declare namespace Deno { callback: UnsafeCallbackFunction<Parameters, Result>, ); - pointer: UnsafePointer; + pointer: bigint; definition: UnsafeCallbackDefinition<Parameters, Result>; callback: UnsafeCallbackFunction<Parameters, Result>; diff --git a/cli/tests/unit/ffi_test.ts b/cli/tests/unit/ffi_test.ts index 22da88d27..18b831137 100644 --- a/cli/tests/unit/ffi_test.ts +++ b/cli/tests/unit/ffi_test.ts @@ -28,9 +28,8 @@ Deno.test({ permissions: { ffi: false } }, function ffiPermissionDenied() { assertThrows(() => { Deno.dlopen("/usr/lib/libc.so.6", {}); }, Deno.errors.PermissionDenied); - const ptr = new Deno.UnsafePointer(0n); const fnptr = new Deno.UnsafeFnPointer( - ptr, + 0n, { parameters: ["u32", "pointer"], result: "void", @@ -42,7 +41,7 @@ Deno.test({ permissions: { ffi: false } }, function ffiPermissionDenied() { assertThrows(() => { Deno.UnsafePointer.of(new Uint8Array(0)); }, Deno.errors.PermissionDenied); - const ptrView = new Deno.UnsafePointerView(ptr); + const ptrView = new Deno.UnsafePointerView(0n); assertThrows(() => { ptrView.copyInto(new Uint8Array(0)); }, Deno.errors.PermissionDenied); |