-
Notifications
You must be signed in to change notification settings - Fork 56
Added two methods for loading embedded .wasm and .wat #13
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
Added two methods for loading embedded .wasm and .wat #13
Conversation
|
Hi @redradist. Thank you for the pull request! I'm not entirely convinced that these methods are needed in the Wasmtime API. Could you explain a little more about your use case? I feel like the Additionally, calling If we do decide it makes sense to include these methods, we will need some unit tests implemented that covers them. |
The reason I need them because I want to store in my Xamarin application *.wasm *.wat files and then during startup or by some event to load the module |
True, it will not work with them directly, but I don't see why it need to when you can load the data yourself and then call the existing overloads of However, I can get behind overloads for If that works, would you also mind adding a test or two of calling the new overloads? I can help write the tests if you're unfamiliar with xunit. |
Yes, I agree, it would be possible to load bytes externally and provide this data of bytes to either If you agree I will add unittests and update pull-request ... |
|
@peterhuene Could you support ? |
|
Hi @redradist. Sorry for the delayed response. It appears there's an upstream bug in Wasmtime that is causing the CI failure. I have identified the bug and have a fix. When that fix is merged, CI should automatically be fixed once rerun. |
|
peterhuene
Okay, thanks for response !! Any suggestion where to put tests for this functionality ? |
|
@peterhuene |
|
We're still waiting on upstream Wasmtime PR to address the failure (bytecodealliance/wasmtime#1600). Regarding this PR, I would still prefer not to have the resource loading code in the |
peterhuene
left a comment
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 don't think we want any embedded resource loading code in the Wasmtime assembly itself; to allow for generic loading from byte streams, can we instead change this PR to add Stream based overloads to LoadModule and LoadModuleText?
You mean to add the following methods ?: public Module LoadModule(Stream stream)
{
// ...
}
public Module LoadEmbeddedModule(Stream stream)
{
// ...
}Actually I like this even more 'cause it more flexible solution )) Okay, I will change implementation to |
|
Hi @redradist. That's correct, except it would be |
I did it, but the method become such simple: public Module LoadModuleText(string moduleName, Stream moduleStream)
{
using (StreamReader reader = new StreamReader(moduleStream))
{
return LoadModuleText(moduleName, reader.ReadToEnd());
}
}
public Module LoadModule(string moduleName, Stream moduleStream)
{
using (StreamReader reader = new StreamReader(moduleStream))
{
using (MemoryStream ms = new MemoryStream())
{
reader.BaseStream.CopyTo(ms);
return LoadModule(moduleName, ms.ToArray());
}
}
}that I do not know actually if it is needed at all |
|
While the methods are simple, it's good to have |
|
@peterhuene |
6228a55 to
e361d2e
Compare
|
@redradist I've rebased your branch to be the latest from the new default You'll want to rebase your local branch from your origin's branch: The commit I added was just a little cleanup up the two new methods you added, plus a test case that loads a wasm and wat file as an embedded resource, per your use case of these methods. Once the CI goes green, I'll merge this. |
A minor cleanup to the new overloads of `LoadModule` and `LoadModuleText`. Added test cases to cover loading a module from an embedded resource stream.
e361d2e to
cea0d9f
Compare
|
@redradist Thanks very much for both your work on this as well as your patience getting this merged! |
|
Oh, I plan on releasing a new version of the NuGet package with these changes soon, once I update the API to address #9. |
No description provided.