summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/ffi/00_ffi.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index 4d77449e8..7ba5aadc0 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -121,10 +121,25 @@
);
}
+ static getCString(pointer, offset = 0) {
+ return core.opSync(
+ "op_ffi_cstr_read",
+ offset ? BigInt(pointer) + BigInt(offset) : pointer,
+ );
+ }
+
getArrayBuffer(byteLength, offset = 0) {
return core.opSync(
"op_ffi_get_buf",
- offset ? this.pointer + BigInt(offset) : this.pointer,
+ offset ? BigInt(this.pointer) + BigInt(offset) : this.pointer,
+ byteLength,
+ );
+ }
+
+ static getArrayBuffer(pointer, byteLength, offset = 0) {
+ return core.opSync(
+ "op_ffi_get_buf",
+ offset ? BigInt(pointer) + BigInt(offset) : pointer,
byteLength,
);
}
@@ -137,6 +152,15 @@
destination.byteLength,
);
}
+
+ static copyInto(pointer, destination, offset = 0) {
+ core.opSync(
+ "op_ffi_buf_copy_into",
+ offset ? BigInt(pointer) + BigInt(offset) : pointer,
+ destination,
+ destination.byteLength,
+ );
+ }
}
class UnsafePointer {