diff --git a/quest/m2/c/README.md b/quest/m2/c/README.md index 37a02e4d863..b8d303197dd 100644 --- a/quest/m2/c/README.md +++ b/quest/m2/c/README.md @@ -13,7 +13,9 @@ scope; they already sit on moq-ffi through the generated C++. Decided 2026-10-25 (maintainer): this line ships after the cut, once moq builds its bindings from rust2's UniFFI fork. The hand-written crate ships at the cut with [parity](/quest/m1/c/README.md) instead. The generator fix for the C name -clash lands in rust2, not in a `kixelated/uniffi-bindgen-cpp` release. +clash landed in rust2's fork +([kixelated/rust2#66](https://github.com/kixelated/rust2/pull/66)), not in a +`kixelated/uniffi-bindgen-cpp` release, and reaches moq with the switch. Decided earlier, still standing: @@ -35,10 +37,11 @@ Decided earlier, still standing: bullet carries the move for the package's `MIGRATE.md`. The `moq-c` package (`c/moq`, `just c check`) builds the generated header and -its probe in CI, so drift fails loud. Until name-clash lands, it renames the -record `MoqAudioEncoderFinish` to `MoqAudioEncoderFinished` so the current -generator emits the header; the generator fix can revert that rename. No -`c-v*` tag ships before the cut. +its probe in CI, so drift fails loud. moq-ffi's record +`MoqAudioEncoderFinished` was renamed from `MoqAudioEncoderFinish` so moq's +current generator emits the header; +[the switch](/quest/m2/uniffi-fork.md) reverts that rename. No `c-v*` tag ships +before the cut. The line owns the pre-publication check: every `doc/lib/c` sample and the C interop client build and run against the built release archive. @@ -48,6 +51,5 @@ publication; [old-crate retirement](/quest/m2/release/c-retire.md) follows. ## Required - [Switch to rust2's UniFFI](/quest/m2/uniffi-fork.md) - the C generator comes from rust2's fork -- [One C name per moq-ffi item](/quest/m2/c/name-clash.md) - rust2's C generator names types in CamelCase and functions in snake_case, so the record `MoqAudioEncoderFinish` and the method `moq_audio_encoder_finish` never share a name - [C consumers](/quest/m2/c/consumers.md) - the C interop client and `doc/lib/c` samples move onto the generated API - [Async failure contract](/quest/m2/c/async-failure-contract.md) - every generated async call returns a task and calls back exactly once, cancelled when its task was freed first diff --git a/quest/m2/c/name-clash.md b/quest/m2/c/name-clash.md deleted file mode 100644 index 90add9c3895..00000000000 --- a/quest/m2/c/name-clash.md +++ /dev/null @@ -1,64 +0,0 @@ -# [XS] One C name per moq-ffi item - -## Goal - -The generated C header gives every moq-ffi item its own name. Under the current -generator the method `MoqAudioEncoder::finish` and the record -`MoqAudioEncoderFinish` both map to `moq_audio_encoder_finish`, so -[moq-dev/moq#6052](https://github.com/moq-dev/moq/pull/6052) renamed the record -to `MoqAudioEncoderFinished`; revert that rename once the fix reaches moq's -generator pin. Waiting on -[kixelated/rust2#66](https://github.com/kixelated/rust2/pull/66), which -implements the rule below; delete this quest once it merges. - -## Plan - -Decided with the maintainer on 2026-10-24: fix the C generator, not moq-ffi, so -no moq-ffi item is renamed. Decided 2026-10-25: the fix lands in rust2's UniFFI -fork (`uniffi/cpp/bindgen/src/bindings/c/gen_c.rs`), not in a -`kixelated/uniffi-bindgen-cpp` release. - -The naming rule (maintainer, 2026-10-25): - -- ✅ GLib/GStreamer style: CamelCase types, snake_case functions -- Explicit method namespace (`moq_audio_encoder_method_finish`), chosen first - the same day and then superseded by the GLib rule -- Uniform type naming change while keeping short function names -- Path names plus a `[rename]` table - -Why: function calls read naturally (`moq_audio_encoder_finish(enc)`), C users -of GStreamer and OBS already know the convention, and a type can never share an -identifier with a function, so no rename table is needed. A rename table would -make names unpredictable: adding an item could silently rename an existing one. - -The rule: - -- Types are CamelCase with the namespace prefix: `MoqAudioEncoder`, - `MoqAudioEncoderFinish`, `MoqError`, `MoqTask`, compounds such as - `MoqStringList`, enum tags `Tag`, variant structs ``, - and async callback typedefs `Callback` - (`MoqAudioEncoderFinishCallback`). A type's name is its prefixed snake-case - name re-cased, so it is predictable from its functions' prefix. -- Functions stay snake_case with no infix: `moq_audio_encoder_finish`, - `moq_audio_encoder_new`, `moq_audio_encoder_free`, `moq_error_message`. Enum - constants stay `MOQ__`. -- Any clash that remains (two functions with one name, such as a method `free` - and the release function, or `MoqFoo` and `Foo`) is refused at generation - with both items named, and the Rust author renames one. - -rust2's own exporter (`ffi/`), which replaces the fork, adopts the same rule -instead of path names plus a `[rename]` table, so moq's C names do not change -again when it lands. - -Under the old rule moq-ffi had exactly the one clash; under this rule it has -none, and its header compiles as C11. That check stubbed `Duration`, which -moq-ffi now uses and the C backend still refuses, another drift the generated C -line must close. - -moq still builds C++ from `kixelated/uniffi-bindgen-cpp`; the rule reaches -moq's build through [Switch to rust2's UniFFI](/quest/m2/uniffi-fork.md), which -owns the pin, and `just c check` builds the header. The generated `moq-c` -package (`c/moq`) adopts these names then. - -Public API: generated C type names become CamelCase; function names are -unchanged. Wire: none. diff --git a/quest/m2/uniffi-fork.md b/quest/m2/uniffi-fork.md index f5b22b3dca9..babe42a4326 100644 --- a/quest/m2/uniffi-fork.md +++ b/quest/m2/uniffi-fork.md @@ -9,7 +9,8 @@ input. `rs/uniffi-bindgen`, `nix/uniffi-dart-*`, and the per-generator pins are deleted, and the three `kixelated/uniffi-*` generator forks are archived. The browser's TypeScript, generated through ubrn's `wasm2` flavour, still generates against the fork. Generated bindings are unchanged by the switch -itself. +itself, except C's type names and the one record rename the C name rule +undoes. ## Plan @@ -48,7 +49,23 @@ which publishes `rust2-uniffi`, `rust2-uniffi-core`, `rust2-uniffi-macros`, and - **Generated code stays identical**: Kotlin package names, library symbol prefixes, and every wrapper's API do not change. Diff the regenerated bindings for every language against `main`'s, and run each wrapper's check - plus `just test interop --all`. + plus `just test interop --all`. The C names below are the only expected + differences. +- **C names** (maintainer, 2026-10-24 and 2026-10-25): rust2's C generator + names in GLib style + ([kixelated/rust2#66](https://github.com/kixelated/rust2/pull/66)). + Types are CamelCase with the namespace prefix (`MoqError`, `MoqStringList`, + enum tags `Tag`, async callbacks `Callback`), functions and + enum constants keep their names, and any remaining clash fails generation + with both items named. `c/moq` (its probe, `shutdown.c`, and docs) moves to + the new type names. moq-ffi's record `MoqAudioEncoderFinished` returns to + `MoqAudioEncoderFinish`, its name before + [moq-dev/moq#6052](https://github.com/moq-dev/moq/pull/6052) worked around + the old clash with `moq_audio_encoder_finish`; every wrapper's + `EncoderFinish` alias follows, so wrapper APIs do not change. +- rust2's C backend still refuses `Duration`, which moq-ffi's audio configs + use (moq's current generator accepts it), so the fork must accept it before + the switch can generate C. - **One pin**: rust2 becomes a flake input, and `flake.nix`, the release workflows, `rs/moq-ffi/build.sh`, and `sh/` read the generators from it. Delete `rs/uniffi-bindgen`, the "five places" comments in `flake.nix`, and the @@ -69,7 +86,10 @@ which publishes `rust2-uniffi`, `rust2-uniffi-core`, `rust2-uniffi-macros`, and ([Generated C bindings](/quest/m2/c/README.md)) to point at rust2, then archive the three forks. -Public API: none; moq-ffi's dependency names change. Wire: none. +Public API: moq-ffi's dependency names change, generated C type names become +CamelCase, and the generated record `MoqAudioEncoderFinished` becomes +`MoqAudioEncoderFinish` in every language; wrapper APIs do not change. Wire: +none. ## Required