add-ffi-binding
/add-ffi-binding
Dodaje lub zmienia wiązania do bibliotek systemowych, np. libc, X11, AppKit czy Win32, z asercjami układu pamięci i źródłami.
- Autor
- jabbott-iii ↗
- Repozytorium
- Tidepool ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 12.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 12.11.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Dodaje lub zmienia wiązania do bibliotek systemowych, np. libc, X11, AppKit czy Win32, z asercjami układu pamięci i źródłami.
Argumenty
/add-ffi-binding <linux|macos|windows> <API or functions needed>
Oryginalny opis (EN)
Use whenever adding or changing OS bindings (libc, X11, Objective-C/AppKit/CoreGraphics, Win32, ConPTY). Declares items in tidepool-sys with layout assertions and source citations, then wraps them safely in tidepool-platform.
Jak działa
- 1. Scope it
- 2. Declare in tidepool-sys
- 3. Wrap safely in tidepool-platform
- 4. Test
- 5. Report
Podgląd SKILL.md
---
name: add-ffi-binding
description: Use whenever adding or changing OS bindings (libc, X11, Objective-C/AppKit/CoreGraphics, Win32, ConPTY). Declares items in tidepool-sys with layout assertions and source citations, then wraps them safely in tidepool-platform.
argument-hint: "<linux|macos|windows> <API or functions needed>"
---
# Add an FFI binding
Request: `$ARGUMENTS`
We use no binding crates (ADR-0001), so correctness depends on following
this procedure exactly. Nadir (same owner) uses the same procedure; check
whether it already declares what you need and port it with a note.
## 1. Scope it
- List the exact functions, types, constants or selectors the feature
calls. **Declare nothing else.**
- For each item, find the authoritative source:
- Linux: glibc headers (`/usr/include/*.h`, `sys/*.h`), X11 headers
(`/usr/include/X11/*.h`), kernel uapi headers (`linux/inotify.h`)
- macOS: SDK framework headers or Apple's developer documentation
- Windows: Windows SDK headers (`um/*.h`) or Microsoft Learn
- If the header isn't available in this session, use the official
documentation and mark the values "verify on <OS>".
## 2. Declare in `tidepool-sys`
- File: `crates/sys/src/<os>/<module>.rs`. Every item carries a doc comment
or a `// source:` comment naming the header and declaration.
- Functions: `unsafe extern "system" { ... }` for Win32, `unsafe extern "C"
{ ... }` elsewhere. Libraries we `dlopen` (libX11) use the `dynlib!`
macro, which reports every missing symbol by name.
- Types: `#[repr(C)]`, fields in header order with exact widths (`long` is
`i64` on LP64 Linux and macOS, `i32` on Windows; objc `BOOL` is `bool` on
arm64, `i8` on x86_64).
- Layout assertions for every struct, with numbers from the header or docs
(never from the Rust struct you just wrote):
```rust
const _: () = assert!(core::mem::size_of::<XEvent>() == 192);
const _: () = assert!(core::mem::align_of::<XEvent>() == 8);
const _: () = assert!(core::mem::offset_of!(XKeyEvent, keycode) == 84);
```
Gate per target with `#[cfg(...)]` when values differ.
- Constants: the header's type and spelling (hex stays hex).
- Objective-C: cache selectors once; every `msg_send!` spells the full
signature; `_stret` for big struct returns on x86_64; runtime-created
classes list ivars and methods with type encodings in one place.
## 3. Wrap safely in `tidepool-platform`
- Safe API: owned RAII types for handles, `&str`/`&Path` instead of raw
strings, our error enums instead of codes.
- One unsafe operation per block, each preceded by `// SAFETY:`.
- Document ownership (who frees what, with which call) and main-thread-only
requirements; make main-thread types `!Send`.
- Convert every failure path into an error with context.
## 4. Test
- Layout assertions compile on the OS they target: say which OS builds you
actually ran.
- Unit tests for wrapper logic that doesn't need the OS (key mapping
tables, string conversion).
- Behavior tests under Xvfb on Linux where a display is needed.
- Run `cargo xtask unsafe-audit` and
`cargo clippy -p <crate> --all-targets -- -D warnings`.
- Ask `security-reviewer` to review.
## 5. Report
- Each declared item and its source.
- Which layout assertions compiled on which OS in this session.
- Which items still need verification on another OS (also add a `⏳` note
to the roadmap task).
Wersje
W bazie nie ma innych skilli o nazwie add-ffi-binding.
Migawka bazy z 13.11.2026 · wersja paczki 688c996e964a (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100rs-unsafe
Przegląda kod unsafe w Rust i FFI: wskaźniki surowe, transmute, union, układ pamięci, komentarze SAFETY i niezdefiniowane zachowanie. - 100rust-ffi
Wywołuje biblioteki C z Rust i odwrotnie: generuje wiązania bindgen i cbindgen, pisze bezpieczne opakowania nad unsafe i linkuje biblioteki. - 100ffi-code-review
Przegląda kod Rust FFI pod kątem bezpieczeństwa typów, układu pamięci, obsługi stringów, callbacków i poprawności granicy unsafe przy wywołaniach bibliotek C i C++. - 100rust-system-calls
Podpowiada, jak wykonywać wywołania systemowe i operacje na plikach w Rust przez bun_sys zamiast std::fs lub libc. - 90desktop-appkit
Pomaga w tworzeniu aplikacji macOS w AppKit i Cocoa, w tym w Swift AppKit i architekturze natywnych aplikacji Mac. - 100dart-use-ffigen
Prowadzi przez użycie package:ffigen do automatycznego generowania wiązań FFI zamiast pisania ich ręcznie, także dla integracji C, Objective-C i Swift.