feat(ext/ffi): Callbacks (#14663)

This commit adds support for unstable FFI
callbacks. A callback is registered using
the `Deno.UnsafeCallback` API.

The backing memory for the callback can 
be disposed of using `Deno.UnsafeCallback#close`.
It is not safe to pass the callback after calling
close.

Callbacks from other than the isolate thread
are not supported.

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
Aapo Alasuutari 2022-06-20 14:06:04 +03:00 committed by GitHub
parent 60869c2598
commit 3d6fa64f19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 2351 additions and 508 deletions

View file

@ -139,6 +139,7 @@
createHttpClient: __bootstrap.fetch.createHttpClient,
http: __bootstrap.http,
dlopen: __bootstrap.ffi.dlopen,
UnsafeCallback: __bootstrap.ffi.UnsafeCallback,
UnsafePointer: __bootstrap.ffi.UnsafePointer,
UnsafePointerView: __bootstrap.ffi.UnsafePointerView,
UnsafeFnPointer: __bootstrap.ffi.UnsafeFnPointer,