-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add more types to polyfill wasmtime in js #3
Conversation
Hello, has a lot of feature at once, I think I will "split" it into separate code changes and push them one at a time.
|
Thanks for the write up. I removed the lifetime from So to use this pattern, the WASM module need to export two functions, one for memory alloc & one for memory free. So I need to store the typed functions of them somewhere. If the lifetime exists, it could barely be done because it's not Untyped functions are related to the plugin system I'm making. Since it is a plugin system, a plugin could provide APIs which are dynamic and not known at compile time. |
Yea that's true. I want to use this for plugins as well, and when one plugin wants to call a custom function from another plugin, there is no getting around dynamic values at that point.
Great. I have already implemented that, you can look here I think I will re-implement all the features, since I will always be adding a failing tests first. That means you will not be in the git history, is that ok? |
It’s fine. |
@@ -7,7 +7,7 @@ use crate::*; | |||
pub(crate) type MakeClosure<T> = Box<dyn Fn(DataHandle<T>) -> (JsValue, DropHandler)>; | |||
|
|||
pub trait IntoMakeClosure<T, Params, Results> { | |||
fn into_make_closure(self) -> MakeClosure<T>; | |||
fn into_make_closure(self, engine: Engine) -> MakeClosure<T>; |
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.
It is probably more "correct" to "propagate" the same engine into the Caller
like this, but the Engine
struct is completely unused and is only there for compatibility with wasmtime, so I think it would just needlessly bloat the code.
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.
Engine is used to construct the store in caller, which leads to impl AsContext and AsContextMut for Caller
Ok @zimond , I think I have implemented all the changes. You can clone the repo at the current commit, or use a git dependency to verify. If there are any holes/mistakes, let me know. |
Most of there changes are from this PR: #3
Hey I came across this project and I really like the idea. Here are some rough code I wrote to polyfill more wasmtime types and logic in
wasm-bridge
. Feel free to use or discard them or discuss the concept with me.The main change to your design is that
Caller
now stores aStore
so it could impl theAsContext / AsContextMut
traits.Have a nice day, friend.