Merge branch 'master' into wasix-core-changes

This commit is contained in:
ptitSeb
2023-01-16 09:39:08 +01:00
committed by GitHub
10 changed files with 62 additions and 29 deletions

View File

@@ -638,18 +638,15 @@ impl Module {
/// Following the WebAssembly spec, one name can have multiple
/// custom sections. That's why an iterator (rather than one element)
/// is returned.
pub fn custom_sections<'a>(&'a self, _name: &'a str) -> impl Iterator<Item = Box<[u8]>> + 'a {
// TODO: implement on JavaScript
DefaultCustomSectionsIterator {}
}
}
pub struct DefaultCustomSectionsIterator {}
impl Iterator for DefaultCustomSectionsIterator {
type Item = Box<[u8]>;
fn next(&mut self) -> Option<Self::Item> {
None
pub fn custom_sections<'a>(&'a self, name: &'a str) -> impl Iterator<Item = Box<[u8]>> + 'a {
WebAssembly::Module::custom_sections(&self.module, name)
.iter()
.map(move |(buf_val)| {
let typebuf: js_sys::Uint8Array = js_sys::Uint8Array::new(&buf_val);
typebuf.to_vec().into_boxed_slice()
})
.collect::<Vec<Box<[u8]>>>()
.into_iter()
}
}