aboutsummaryrefslogtreecommitdiff
path: root/docs/api/ffi.md
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-09-07 10:09:09 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-07 10:09:09 -0700
commit5424ea3403df9cd4672290865f12b6f5b01cf2d0 (patch)
tree27e19a70fba49ffdd944c190163f5e8322d7a32f /docs/api/ffi.md
parent4b63ced72dc1b304e737d9ea055c8b6e75f46119 (diff)
downloadbun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.tar.gz
bun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.tar.zst
bun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.zip
Doc updates for v1.0 (#4485)
* Remove v0.x messages * Add windows section to Installatino * update * update * Update * Comment out windows
Diffstat (limited to 'docs/api/ffi.md')
-rw-r--r--docs/api/ffi.md21
1 files changed, 12 insertions, 9 deletions
diff --git a/docs/api/ffi.md b/docs/api/ffi.md
index d6ed23f47..0beae1744 100644
--- a/docs/api/ffi.md
+++ b/docs/api/ffi.md
@@ -229,7 +229,11 @@ const lib = linkSymbols({
},
});
-const [major, minor, patch] = [lib.symbols.getMajor(), lib.symbols.getMinor(), lib.symbols.getPatch()];
+const [major, minor, patch] = [
+ lib.symbols.getMajor(),
+ lib.symbols.getMinor(),
+ lib.symbols.getPatch(),
+];
```
## Callbacks
@@ -249,10 +253,13 @@ const {
},
});
-const searchIterator = new JSCallback((ptr, length) => /hello/.test(new CString(ptr, length)), {
- returns: "bool",
- args: ["ptr", "usize"],
-});
+const searchIterator = new JSCallback(
+ (ptr, length) => /hello/.test(new CString(ptr, length)),
+ {
+ returns: "bool",
+ args: ["ptr", "usize"],
+ },
+);
const str = Buffer.from("wwutwutwutwutwutwutwutwutwutwutut\0", "utf8");
if (search(ptr(str), searchIterator)) {
@@ -376,10 +383,6 @@ If you want to track when a `TypedArray` is no longer in use from JavaScript, yo
#### From C, Rust, Zig, etc
-{% callout %}
-**Note** — Available in Bun v0.1.8 and later.
-{% /callout %}
-
If you want to track when a `TypedArray` is no longer in use from C or FFI, you can pass a callback and an optional context pointer to `toArrayBuffer` or `toBuffer`. This function is called at some point later, once the garbage collector frees the underlying `ArrayBuffer` JavaScript object.
The expected signature is the same as in [JavaScriptCore's C API](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc):