summaryrefslogtreecommitdiff
path: root/ext/ffi/00_ffi.js
diff options
context:
space:
mode:
authorAapo Alasuutari <aapo.alasuutari@gmail.com>2022-07-23 20:11:06 +0300
committerGitHub <noreply@github.com>2022-07-23 22:41:06 +0530
commite1cbd2364f536a1cef817961967e1738b89be734 (patch)
tree5e4c335cab348696a46558a0cd8d2be37160db8a /ext/ffi/00_ffi.js
parent2843160fc79a9651e9b2c2ddc4f834c15e138db6 (diff)
feat(ext/ffi): Add support to get ArrayBuffers from UnsafePointerView (#15143)
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r--ext/ffi/00_ffi.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index cdaf69e0d..ac8dda317 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -10,7 +10,6 @@
ObjectPrototypeIsPrototypeOf,
PromisePrototypeThen,
TypeError,
- Uint8Array,
} = window.__bootstrap.primordials;
function unpackU64([hi, lo]) {
@@ -107,9 +106,11 @@
}
getArrayBuffer(byteLength, offset = 0) {
- const uint8array = new Uint8Array(byteLength);
- this.copyInto(uint8array, offset);
- return uint8array.buffer;
+ return core.opSync(
+ "op_ffi_get_buf",
+ offset ? this.pointer + BigInt(offset) : this.pointer,
+ byteLength,
+ );
}
copyInto(destination, offset = 0) {