mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
Added support for Wasm Module custom sections in js
This commit is contained in:
@@ -566,17 +566,15 @@ impl Module {
|
||||
/// 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
|
||||
WebAssembly::Module::custom_sections(&self.module, name)
|
||||
.iter()
|
||||
.map(move |(buf_val)| {
|
||||
// assert!(buf_val.is_instance_of::<ArrayBuffer>());
|
||||
let typebuf: js_sys::Uint8Array = js_sys::Uint8Array::new(&buf_val);
|
||||
typebuf.to_vec().into_boxed_slice()
|
||||
})
|
||||
.collect::<Vec<Box<[u8]>>>()
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user