-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate WIT type declarations (#1704)
* Add a `WitType::wit_name` associated function Returns the type name to use in the WIT file. * Fix comments in unit tests They incorrectly referenced the `WitLoad` trait instead of the correct `WitType` trait. * Generate `wit_name` when deriving `WitType` Generate a static string with the kebab-case name of the type. * Add `WitType::wit_declaration` method Generate the WIT snippet to declare the type. * Allow retrieving WIT names and types of fields Prepare to use them when generating the WIT declaration snippets of fields. * Add a getter for the types of the fields Allow iterating over the `Type`s of the (non-skipped) fields. * Generate `WitType::wit_type_declaration` methods Generate the code with the method to print out a WIT snippet with the type declaration. * Create a `RegisterWitTypes` helper trait A trait for heterogeneous lists that lists the dependencies of a WIT type. These are other WIT types that should be declared in the same WIT snippet. * Add a `Dependencies` associated type to `WitType` List other WIT types that need to be declared in order for the type's declaration to be valid. * Register dependencies recursively Ensure that all indirect dependencies are registered to generate WIT type declarations in a WIT snippet. * Generate `WitType::Dependencies` associated types Ensure derived `WitType` implementations list their WIT type dependencies. * Test generated WIT type declarations Update the `WitType` unit tests to check that the generated WIT snippets are correct.
- Loading branch information
Showing
19 changed files
with
757 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.