1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 10:09:20 -05:00
denoland-deno/test_ffi/tests
Aapo Alasuutari af125c8e70
feat(unstable): Improve FFI types (#20215)
Few improvements to FFI types:
1. Export `PointerObject` for convenience. It's fairly commonly used in
library code and thus should be exported.
2. Fix various comments around `PointerValue` and `UnsafePointer` and
expand upon them to better reflect reality.
3. Instead of using a `Record<"value", type>[T]` for determining the
type of an FFI symbol parameter use direct `T extends "value" ? type :
never` comparison.

The last part enables smuggling extra information into the parameter and
return value string declarations at the type level. eg. Instead of just
`"u8"` the parameter can be `"u8" & { [brand]: T }` for some `T extends
number`. That `T` can then be extracted from the parameter to form the
TypeScript function's parameter or return value type. Essentially, this
enables type-safe FFI!

The foremost use-cases for this are enums and pointer safety. These are
implemented in the second commit which should enable, in a backwards
compatible way, for pointer parameters to declare what sort of pointer
they mean, functions to declare what the API definition of the native
function is, and for numbers to declare what Enum they stand for (if
any).
2023-08-21 13:36:26 +05:30
..
bench.js feat(ext/ffi): Make External pointers keep reference to V8 buffer (#17955) 2023-03-05 08:01:23 +00:00
event_loop_integration.ts test(ext/ffi): Increase timeout value in event loop integration test callback (#18394) 2023-03-25 09:18:41 +02:00
ffi_types.ts feat(unstable): Improve FFI types (#20215) 2023-08-21 13:36:26 +05:30
integration_tests.rs fix(test_ffi): thread_safe_callback is flaky (#19640) 2023-06-28 14:41:59 -06:00
test.js feat(ext/ffi): support marking symbols as optional (#18529) 2023-04-03 21:32:21 +03:00
thread_safe_test.js chore: update to Rust 1.71 (#19822) 2023-07-13 15:16:24 -06:00
thread_safe_test_worker.js fix(test_ffi): thread_safe_callback is flaky (#19640) 2023-06-28 14:41:59 -06:00