Commit 4975360
Add Serialize and JSON serialization support to the exported structs in wit-parser (bytecodealliance#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>1 parent 3fa59ad commit 4975360
56 files changed
Lines changed: 7123 additions & 39 deletions
File tree
- crates/wit-parser
- src
- tests
- ui
- src
- bin/wasm-tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
0 commit comments