-
Notifications
You must be signed in to change notification settings - Fork 176
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
Implement WitType
, WitLoad
and WitStore
for pointer types
#3063
base: main
Are you sure you want to change the base?
Conversation
type Dependencies = T::Dependencies; | ||
|
||
fn wit_type_name() -> ::std::borrow::Cow<'static, str> { | ||
T::wit_type_name() |
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.
Why not show the wrapper as well ($wrapper<T::wit_type_name()>
)?
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.
Because the wrapper types aren't part of the WIT standard :/
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.
Hmm, but that leads me to a different thought. This should be empty, and the T
should be a dependency 🤔 I'll fix it, thanks!
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.
Nope, I was wrong. The problem is that if I do that, then the same wit_type_name
is used for two different types (T
and Box<T>
), and they end up having different wit_type_declaration
s, which is a problem when generating the .wit
files. So I had to revert to make Box<T>
identical to T
for it to work.
Prepare to reuse code to implement the traits for smart pointer types.
Ensure values in the heap can be copied to and from guest Wasm modules.
Prepare to test more things in the helper function.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the fields are handled as if the field was not boxed.
Ensure that the fields are handled as if the field was not boxed.
Ensure that the fields are handled as if the field was not boxed.
Ensure values in the heap can be copied to and from guest Wasm modules.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the fields are handled as if the field was not boxed.
Ensure values in the heap can be copied to and from guest Wasm modules.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the type is treated exactly the same as if the type was not wrapped.
Ensure that the fields are handled as if the field was not boxed.
b69c53c
to
532da70
Compare
I updated the PR to add tests, but I'll add wrapped slices support in a separate PR because it will also require a few new tests. |
Motivation
It's not uncommon to want to store some values in the heap, but still be able to copy them to and from guest Wasm modules. For that to work, heap smart pointer types should implement the
WitType
,WitLoad
andWitStore
traits.Proposal
Create a new macro with the code to delegate implement the traits by delegating the items to the wrapped type, and use the macro to implement the traits for
Box
,Rc
, andArc
.Test Plan
Unit tests were modified to wrap all tested types in
Arc
,Rc
andBox
containers and check that it doesn't affect the loading and storing of the types.Unit tests were added to check derived
WitType
,WitLoad
andWitStore
implementations for types that haveArc
,Rc
andBox
fields.Release Plan
Links