feat(c): add map type support#1611
Open
yordis wants to merge 4 commits into
Open
Conversation
Anonymous container types that reference a named type must live in the interface namespace, not the world-level "primitive" namespace. Otherwise the import-side and export-side variants of the named type are forced to share a single C struct whose field type is fixed to one variant, producing a compile error on the other side. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
The flat { entry_t *ptr; size_t len; } shape matches the canonical
ABI's lowered layout for map<K, V>, so reusing the list fast-path
keeps the FFI boundary copy-free and brings C to parity with the
Rust, Go, MoonBit, and C# backends that already ship map support.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Covers the C-side lower/lift boundary behaviorally against the existing Rust/Go/MoonBit suite, so future ABI changes that compile cleanly cannot silently regress map round-trips. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
The earlier is_prim_type change moved every anonymous container of a named-prim-content type out of the world-level dedup namespace, which renamed pre-existing types like runner_tuple2_list_typedef2_list_typedef3_t and broke hand-written runtime tests that depend on the old names. Revert that change and re-add map.wit to the C verify skip list until a non-breaking fix lands. The map ABI implementation itself is unaffected and the map runtime tests still exercise C-side lower/lift end to end with the original world-shared names. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
yordis
commented
May 13, 2026
| config: &crate::config::WitConfig, | ||
| _args: &[String], | ||
| ) -> bool { | ||
| // `map.wit` exercises `tuple<names-by-id, u64>` where `names-by-id` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
{ entry_t *ptr; size_t len; }representation matches the canonical ABI's lowered layout formap<K, V>exactly, so reusing the existing list lower/lift fast-path keeps the FFI boundary copy-free and the implementation stays consistent withcrates/c's existing list/string idiom.TypeDefKind::Map(..) => todo!()arms fromcrates/cand themap.witentry fromcrates/test/src/c.rs'sshould_fail_verifyskip list.