-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Create a WitInterface
trait to allow creating of WIT interface snippets
#1902
Conversation
66372fb
to
26cfc5f
Compare
std::borrow::Cow::Borrowed(" "), | ||
#wit_name.into(), | ||
": func(".into(), | ||
#( #parameters, #commas )* | ||
")".into(), | ||
#( #output, )* | ||
";".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused: Somehow I expected this would be a string literal, but it doesn't create any quotes ("
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the question 😅 This creates a String
object, using the slice::join
method applied to strings. This is very similar to concat!
, but some WitType
s might need to build String
objects, so this concatenates a list of Cow<'static, str>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, and wit_name
and parameters
are string literals, of course. 👍
Representation of a type that can be written as a WIT interface.
Prepare to allow the code used to generate `WitInterface` implementations to access helper types used by the `wit_import` and `wit_export` macros.
Implement the code to generate `WitInterface` implementations, so that it can be used by the `wit_export` and `wit_import` macros.
Prepare to access the `AttributeParameters` when generating code later.
Implement `WitInterface` for the type generated by the `wit_import` macro, so that the `trait` can be used to obtain its expected WIT interface.
Implement `WitInterface` for the type the `wit_export` macro is applied to, so that the `impl` block can be used to obtain its exported WIT interface.
Asserts if the WIT type dependencies for a type that implements `WitInterface` are the expected types.
Asserts if the WIT function declarations of a type that implements `WitInterface` matches the expected declarations.
Ensure all the methods return the expected WIT snippets.
Ensure all the methods return the expected WIT snippets.
Ensure all the methods of the types used in the reentrancy tests return the expected WIT snippets.
Ensure all the `WitInterface` methods return the expected WIT snippets.
Follow the Rust convention for function documentation. Co-authored-by: Andreas Fackler <[email protected]> Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
Fix typo in the word "function". Co-authored-by: Andreas Fackler <[email protected]> Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
Fix typo in the word "function". Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
c21b271
to
bb9d66d
Compare
std::borrow::Cow::Borrowed(" "), | ||
#wit_name.into(), | ||
": func(".into(), | ||
#( #parameters, #commas )* | ||
")".into(), | ||
#( #output, )* | ||
";".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, and wit_name
and parameters
are string literals, of course. 👍
Motivation
Witty will allow generating WIT files from Rust items. To achieve that goal, it needs to generate WIT interfaces.
Proposal
Create a
WitInterface
trait that provides the WIT snippets and type dependencies necessary for the interface. Automatically generate the implementation of this trait from#[wit_export]
and#[wit_import]
macros.Test Plan
The expected snippets are now checked in the integration tests.
Release Plan
Only affects Witty, so nothing needed.
Links