diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-08-05 19:27:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 21:57:12 +0530 |
commit | 9c594de0ff7cf363816cda0d31b777f4607299a1 (patch) | |
tree | 255170ced40116c21307195cc0b26bb1b1a903e6 /ext/ffi/00_ffi.js | |
parent | 569910856e648e8cdaad85916eb82fea3c75ed8b (diff) |
feat(ext/ffi): Add static method variants to Deno.UnsafePointerView (#15146)
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r-- | ext/ffi/00_ffi.js | 26 |
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 { |