Repository navigation
feat(uniffi)!: name generated C types in CamelCase, GLib style - #66
Conversation
The C backend joined a type's name and a method's, so moq-ffi's MoqAudioEncoder::finish and MoqAudioEncoderFinish both became moq_audio_encoder_finish. Methods and named constructors now go under <type>_method_<name>, and a remaining clash names both items. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: daaca02
No actionable bugs found in the changed generator and fixtures. The _method_ namespace is a straightforward fix for the method/record clash without renaming every type; retaining fixed constructor/free helpers and rejecting residual collisions keeps the rule predictable. All three callable entry points still claim their names, async callback names follow the renamed function, and the C fixtures exercise the new stats method alongside its namesake record. The breaking C API change is documented.
Verification: static inspection of the diff and surrounding generator/fixture code only. I did not run builds or tests, or independently reproduce the reported moq-ffi generation.
Replaces the _method_ namespace: types are CamelCase (MoqAudioEncoderFinish, MoqTask, MoqAudioEncoderFinishCallback) and functions stay snake_case (moq_audio_encoder_finish), so a type and a function never share a name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_method_
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 77b35a8
No actionable bugs found in the substantive update since daaca02. This supersedes the previously reviewed _method_ approach with CamelCase C types and unchanged snake_case functions. The consistent casing rule is simpler for callers than per-item renames; residual same-kind collisions are still rejected. Recursive global qualification covers nested and external C types inside C++ converters, while separate snake-case prefixes preserve free/default helpers and enum constants. Runtime and callback typedefs, fixtures, and migration guidance move together.
Verification: static inspection of the base-aware diff, generator and C/C++ templates only. I did not run builds/tests or independently reproduce the reported downstream generation. Main-branch FFI/TypeScript integrations were excluded from this PR-specific follow-up.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77b35a81b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Scalars and strings keep their C spelling; every other type is named from its snake case. | ||
| let (c, snake) = match kind { | ||
| Kind::Scalar | Kind::String | Kind::Optional(_) => (c, String::new()), | ||
| _ => (type_name(&c), c), |
There was a problem hiding this comment.
Use snake-case names in generated error-release instructions
For every throwing callable, changing CType.c to CamelCase makes the ownership documentation in render_callable name a nonexistent release function. Both the async callback documentation and synchronous return documentation still interpolate err.c followed by _free, so the C API fixture now tells callers to use CapiError_free even though the declared function remains capi_error_free. Use err.snake for those function references so callers receive correct cleanup instructions.
AGENTS.md reference: AGENTS.md:L25-L25
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f5a2b49: both the async callback doc and the synchronous return doc now name err.snake's _free. I reproduced it first: capi.h said CapiError_free. After the fix every _free named in the generated C headers is declared, and just uniffi cpp passes 31/31.
(written by Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: f5a2b49
No actionable bugs found in the two-line update since 77b35a8. The previous independent finding is fixed: uniffi/cpp/bindgen/src/bindings/c/gen_c.rs:1233,1325 now use err.snake, matching the release declaration at line 1049. Both async and synchronous error-ownership instructions are corrected. Reusing the existing function-name prefix is the minimal fix and preserves the chosen CamelCase-type/snake_case-function API.
Verification: GitHub-only static inspection of the ancestor-aware delta and surrounding type mapping, including external errors. I did not run builds/tests or independently verify the reported 31/31 result.
(Written by OpenAI Codex)
kixelated/rust2#66 merged the GLib C naming rule into rust2's fork, so the waiting quest is done. Its remaining moq-side work (adopting the new C type names, reverting the MoqAudioEncoderFinished rename, and the Duration gap in rust2's C backend) moves to quest/m2/uniffi-fork.md, which owns the generator pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The C backend spelled types and functions the same way, in snake case, so a method could spell another type: moq-ffi's
MoqAudioEncoder::finishand its recordMoqAudioEncoderFinishboth becamemoq_audio_encoder_finish, and generation refused moq-ffi. The refusal named only the C symbol, not the two items.Approach
Names follow GLib and GStreamer: types are CamelCase, functions stay snake_case with no infix, both prefixed with the namespace. A type and a function can then never share an identifier, so no rename table is needed.
MoqAudioEncoder,MoqAudioEncoderFinish,MoqError, the runtime'sMoqTask,MoqWork, andMoqDispatcher, compounds such asMoqStringList, enum tags<Enum>Tag, variant structs<Enum><Variant>, and async callback typedefs<Function>Callback(MoqAudioEncoderFinishCallback). A type's name is its prefixed snake-case name re-cased, so it is predictable from its functions' prefix.moq_audio_encoder_finish(enc),moq_audio_encoder_new,moq_audio_encoder_free,moq_error_message. Enum constants stayMOQ_COLOR_RED.freeand the release function) or two types (MoqFooandFoo), is refused with both items named:the C backend names both record `X` and method `Y` `z`; rename one of them.::MoqError), since the C++ classes innamespace moqnow share their names.The maintainer chose this in moq-dev/moq#6793, replacing the
_method_namespace this PR first proposed. The reason: calls read naturally, C users of GStreamer and OBS already know the convention, and a rename table would make names unpredictable, since adding an item could silently rename an existing one.The exporter (
ffi/) adopts the same rule instead of path names plus a[rename]table, so moq's C names do not change again when it replaces this fork. That change belongs to the exporter's work, not this PR.The
c-apifixture gainsCapiStore::statsreturningCapiStoreStats, the same pair as moq-ffi's, andc_apicalls both from C.Impact
app_my_object *is nowAppMyObject *,app_taskisAppTask,app_my_object_do_thing_callbackisAppMyObjectDoThingCallback). Functions and enum constants keep their names.MIGRATE.mdhas the entry.using namespace <ns>;sees each type name twice and must qualify it.Validation
just uniffi cpp: all 31 C and C++ fixture tests pass.moq.hcompiles as C11 with-Wall -Wextra -Werror. That run stubbedDuration, which the backend still refuses; the C line in moq owns adding it. moq-ffi's type names have no acronyms, so its C types match its Rust names exactly.just checkandjust uniffi test(158 passed).Alternatives
_method_namespace for methods (moq_audio_encoder_method_finish), this PR's first version. Superseded: function calls read worse and the convention is unfamiliar to C users.[rename]table, as the exporter does today. Rejected: names become unpredictable.Follow-ups
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)