-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate WIT type declarations #1704
Merged
Merged
Conversation
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
14 tasks
jvff
force-pushed
the
generate-wit-type-declarations
branch
from
March 1, 2024 12:29
cf533b5
to
13c3be8
Compare
I think architecturally I would prefer that we went via a Wit AST rather than directly to string — but that's a slightly larger change, and I don't want to block this PR on it :) |
Twey
approved these changes
Mar 6, 2024
Returns the type name to use in the WIT file.
They incorrectly referenced the `WitLoad` trait instead of the correct `WitType` trait.
Generate a static string with the kebab-case name of the type.
Generate the WIT snippet to declare the type.
Prepare to use them when generating the WIT declaration snippets of fields.
Allow iterating over the `Type`s of the (non-skipped) fields.
Generate the code with the method to print out a WIT snippet with the type declaration.
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.
List other WIT types that need to be declared in order for the type's declaration to be valid.
Ensure that all indirect dependencies are registered to generate WIT type declarations in a WIT snippet.
Ensure derived `WitType` implementations list their WIT type dependencies.
Update the `WitType` unit tests to check that the generated WIT snippets are correct.
jvff
force-pushed
the
generate-wit-type-declarations
branch
from
March 7, 2024 02:23
13c3be8
to
764d80e
Compare
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.
Motivation
One of the goals of Witty is to allow the Rust code to be the source of truth. Therefore, the Rust code should be able to generate WIT files.
Proposal
This is the first step to generate WIT files. This only allows types that implement
WitType
to be able to generate WIT snippets with the necessary type declarations.Test Plan
Unit tests were updated to check the generated WIT snippets and the derived WIT snippet generators.
Release Plan
Nothing needed.
Links
This is a part of #906, but does not close it.