From 3d6fa64f19e74924813ece5e5fbd53023342bac8 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Mon, 20 Jun 2022 14:06:04 +0300 Subject: 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 Co-authored-by: Bert Belder --- test_ffi/tests/integration_tests.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test_ffi/tests/integration_tests.rs') diff --git a/test_ffi/tests/integration_tests.rs b/test_ffi/tests/integration_tests.rs index 5b9bb2fc2..93f368787 100644 --- a/test_ffi/tests/integration_tests.rs +++ b/test_ffi/tests/integration_tests.rs @@ -65,11 +65,27 @@ fn basic() { -8589934590n\n\ 579.9119873046875\n\ 579.912\n\ + 579\n\ + 8589934590n\n\ + -8589934590n\n\ + 8589934590n\n\ + -8589934590n\n\ + 579.9119873046875\n\ + 579.912\n\ After sleep_blocking\n\ true\n\ Before\n\ true\n\ + logCallback\n\ + 1 -1 2 -2 3 -3 4n -4n 0.5 -0.5 1 2 3 4 5 6 7 8\n\ + u8: 8\n\ + buf: [1, 2, 3, 4, 5, 6, 7, 8]\n\ + logCallback\n\ + 30\n\ + STORED_FUNCTION cleared\n\ + STORED_FUNCTION_2 cleared\n\ Static u32: 42\n\ + Static i64: -1242464576485n\n\ Static ptr: true\n\ Static ptr value: 42\n\ After\n\ -- cgit v1.2.3