summaryrefslogtreecommitdiff
path: root/ext/ffi/00_ffi.js
diff options
context:
space:
mode:
authorDj <43033058+DjDeveloperr@users.noreply.github.com>2023-04-04 00:02:21 +0530
committerGitHub <noreply@github.com>2023-04-03 21:32:21 +0300
commit62c566469710ba610df764df0ee6560295532e4b (patch)
tree5abd4547b40fa9b2fa89afe4a057a9c556759005 /ext/ffi/00_ffi.js
parent51d3fb78ad2453e649d01bcc833ecfec1a05d685 (diff)
feat(ext/ffi): support marking symbols as optional (#18529)
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r--ext/ffi/00_ffi.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index ea75df65c..a8f05dfca 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -443,6 +443,12 @@ class DynamicLibrary {
continue;
}
+ // Symbol was marked as optional, and not found.
+ // In that case, we set its value to null in Rust-side.
+ if (symbols[symbol] === null) {
+ continue;
+ }
+
if (ReflectHas(symbols[symbol], "type")) {
const type = symbols[symbol].type;
if (type === "void") {
@@ -456,6 +462,7 @@ class DynamicLibrary {
this.#rid,
name,
type,
+ symbols[symbol].optional,
);
ObjectDefineProperty(
this.symbols,