Skip to content

C: render an object's exported traits (v0.11.0-kixelated.8+v0.32.2) - #7

Open
kixelated wants to merge 2 commits into
kixelated/uniffi-0.32from
kixelated/c-object-traits
Open

kixelated wants to merge 2 commits into
kixelated/uniffi-0.32from
kixelated/c-object-traits

Conversation

@kixelated

Copy link
Copy Markdown
Owner

The C backend renders an object's exported traits instead of refusing them, so moq-ffi's MoqInstance (an opaque instance that compares by value) reaches the generated C. Pinned by moq-dev/moq#8366.

C

  • Display, Debug, Eq, Hash, and Ord on an object become <object>_to_string, <object>_to_debug_string, <object>_eq / <object>_ne, <object>_hash, and <object>_cmp, named like the C++ binding's methods and calling them through the existing callable renderer (null checks, owned string returns).
  • Two handles are distinct pointers even to equal objects, so the README tells callers to compare with <object>_eq.
  • Records and enums still refuse exported traits (other than Display on errors).

Tests

  • c_api fixture: CapiTag, an object exporting all five traits. The C test checks each function, including that two handles to equal objects are distinct pointers but _eq, with matching hashes.

Run locally: the full ctest suite (35 tests) on Linux with GCC 16, cargo fmt --check, and cargo clippy (no warnings). moq's just c check passes against this build.

Release

Tagged v0.11.0-kixelated.8+v0.32.2 at this branch's head, which moq-dev/moq#8366 pins; merging this PR is left to the maintainer.

(Written by Claude Opus 5.5 with high)

kixelated and others added 2 commits November 9, 2026 06:23
Display, Debug, Eq, Hash, and Ord on an object become <object>_to_string,
_to_debug_string, _eq/_ne, _hash, and _cmp, calling the C++ binding's
method of the same name. Records and enums still refuse them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant