0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

feat(unstable): Support file URLs in Deno.dlopen() (#11658)

This commit is contained in:
Nayeem Rahman 2021-08-24 14:09:00 +01:00 committed by GitHub
parent 8c57a6b7e3
commit 1b7848c4a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -142,7 +142,7 @@ declare namespace Deno {
* Opens a dynamic library and registers symbols * Opens a dynamic library and registers symbols
*/ */
export function dlopen<S extends Record<string, ForeignFunction>>( export function dlopen<S extends Record<string, ForeignFunction>>(
filename: string, filename: string | URL,
symbols: S, symbols: S,
): DynamicLibrary<S>; ): DynamicLibrary<S>;

View file

@ -3,6 +3,7 @@
((window) => { ((window) => {
const core = window.Deno.core; const core = window.Deno.core;
const __bootstrap = window.__bootstrap;
class DynamicLibrary { class DynamicLibrary {
#rid; #rid;
@ -23,7 +24,9 @@
} }
function dlopen(path, symbols) { function dlopen(path, symbols) {
return new DynamicLibrary(path, symbols); // URL support is progressively enhanced by util in `runtime/js`.
const pathFromURL = __bootstrap.util.pathFromURL ?? ((p) => p);
return new DynamicLibrary(pathFromURL(path), symbols);
} }
window.__bootstrap.ffi = { dlopen }; window.__bootstrap.ffi = { dlopen };