From 9c594de0ff7cf363816cda0d31b777f4607299a1 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 5 Aug 2022 19:27:12 +0300 Subject: feat(ext/ffi): Add static method variants to Deno.UnsafePointerView (#15146) --- ext/ffi/00_ffi.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'ext') 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 { -- cgit v1.2.3