Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Serialize and JSON serialization support to the exported structs …
…in wit-parser (#1203) * add serialize to all the exported structs Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * rustfmt Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * simplify the JSON output 1. serialize the Arena fields of Resolve as arrays, instead of an object with arena_id 2. serialize world items with kebab indexed 3. remove arena_id Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * wit-parser: add implementation of id_arena::ArenaBehavior for serde support * wit-parser: rename world arg to world_id * wit-parser: use InterfaceId and WorldId types * wit-parser: skip serialization of package name index * wit-parser: additional Serialize implementations * wit-parser: use derived Serialize for more types * wit-parser: change Params type from an alias to a single-value tuple with Deref/MutDeref This allows us to implement Serialize on the Params type. * wit-parser: cleanup on aisle params * wit-parser: lowercase serialization for enums Might change this? * wit-parser: implement Serialize in a function This should allow wit-parser to serialize without the upstream patch to id_arena. * wit-parser: remove dependency on fork of id-arena crate * wit-parser: remove custom Serialize impl for Function * wit-parser: remove custom Serialize impl for Docs * wit-parser: custom Serialize implementation for Handle and TypeOwner * wit-parser: custom Serialize impl for WorldItem * wit-parser: Serialize enums with less code * wit-parser: implement lowercase derived impl Serialize for FunctionKind * wit-parser: serialize WIT types in JSON in their lowercase form * wit-component, wit-parser: remove custom Params type Handle serialization using existing type alias to not break existing public API. * wit-parser: remove commented-out serialize fn * wit-parser: remove custom Serialize impl for Results * wit-parser: remove custom ArenaBehavior in favor of serialize_\* functions * wit-component: revert unnecessary line change * wit-parser: revert unrelated change * wit-parser: remove Serialize impl from Int * wit-parser: remove From<Int> for String * wit-parser: remove Serialize impl from FlagsRepr Not needed? * fixed the tests and run rustfmt Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * add serde_json to component feature Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * modified the tests to generate json for each valid WIT package. This uses the "BLESS=1" env var to tell `cargo test` to force to write to files. Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * delete the unit tests in resolve.rs Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> * wit-parser: remove Serialize from IncludeName PR feedback on wasm-tools#177 * wit-parser: skip serializing Docs if empty PR feedback on wasm-tools#177 * wit-parser: commit blessed JSON output with empty Docs skipped * wit-parser: remove SerializableVersion This doesn’t seem to be necessary? * wit-parser: revert formatting changes PR feedback on wasm-tools#1177 * wit-parser: rustfmt --------- Signed-off-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com> Co-authored-by: Jiaxiao Zhou (Mossaka) <duibao55328@gmail.com>
- Loading branch information