From b1a6555c0502196174bed1454e446717daf52f12 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 18 Feb 2022 14:21:19 +0200 Subject: feat(ext/ffi): Support read only global statics (#13662) --- cli/dts/lib.deno.unstable.d.ts | 43 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'cli/dts/lib.deno.unstable.d.ts') diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 708eafe6a..08b3ca80c 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -176,9 +176,15 @@ declare namespace Deno { nonblocking?: NonBlocking; } - /** A foreign function interface descriptor */ - export interface ForeignFunctionInterface { - [name: string]: ForeignFunction; + export interface ForeignStatic { + /** Name of the symbol, defaults to the key name in symbols object. */ + name?: string; + type: Exclude; + } + + /** A foreign library interface descriptor */ + export interface ForeignLibraryInterface { + [name: string]: ForeignFunction | ForeignStatic; } /** All possible number types interfacing with foreign functions */ @@ -203,20 +209,23 @@ declare namespace Deno { }, ]; - /** Infers a foreign function */ - type StaticForeignFunction = ( - ...args: StaticForeignFunctionParameters - ) => ConditionalAsync< - T["nonblocking"], - StaticForeignFunctionResult - >; + /** Infers a foreign symbol */ + type StaticForeignSymbol = + T extends ForeignFunction ? ( + ...args: StaticForeignFunctionParameters + ) => ConditionalAsync< + T["nonblocking"], + StaticForeignFunctionResult + > + : T extends ForeignStatic ? StaticForeignFunctionResult + : never; type ConditionalAsync = IsAsync extends true ? Promise : T; - /** Infers a foreign function interface */ - type StaticForeignFunctionInterface = { - [K in keyof T]: StaticForeignFunction; + /** Infers a foreign library interface */ + type StaticForeignLibraryInterface = { + [K in keyof T]: StaticForeignSymbol; }; type TypedArray = @@ -313,9 +322,9 @@ declare namespace Deno { } /** A dynamic library resource */ - export interface DynamicLibrary { - /** All of the registered symbols along with functions for calling them */ - symbols: StaticForeignFunctionInterface; + export interface DynamicLibrary { + /** All of the registered library along with functions for calling them */ + symbols: StaticForeignLibraryInterface; close(): void; } @@ -323,7 +332,7 @@ declare namespace Deno { * * Opens a dynamic library and registers symbols */ - export function dlopen( + export function dlopen( filename: string | URL, symbols: S, ): DynamicLibrary; -- cgit v1.2.3