blob: 3c4112a47333bb51fcf7911928c416c260e0bd54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
"use strict";
((window) => {
const core = window.Deno.core;
class DynamicLibrary {
#rid;
symbols = {};
constructor(path, symbols) {
this.#rid = core.opSync("op_ffi_load", { path, symbols });
for (const symbol in symbols) {
this.symbols[symbol] = (...parameters) =>
core.opSync("op_ffi_call", { rid: this.#rid, symbol, parameters });
}
}
close() {
core.close(this.#rid);
}
}
function dlopen(path, symbols) {
return new DynamicLibrary(path, symbols);
}
window.__bootstrap.ffi = { dlopen };
})(this);
|