Embind and the WebIDL binder are separate tools. They don't have any special support for mixing between them.
The WebIDL binder doesn't have direct support for copying data from JS into wasm. You can do it manually though, without the WebIDL binder, by malloc()ing some room, copying the data (all in JS, just a copy from the JS data into HEAP8 for example), then you can pass the malloc()ed pointer as a parameter to the compiled code (with the WebIDL binder, passing it as a void* would work, or an int). On Wed, Jul 8, 2020 at 12:34 PM キャロウ マーク <[email protected]> wrote: > Can anyone here explain, or point me at an example, of how to move large > data, e.g an image, between JS memory and wasm memory using a function > defined with WebIDL binder? > > In embind for moving data from JS to wasm, I use an emscripten::val > parameter to pass in the JS handle then emscripten::val::module_property to > get a handle to the wasm memory on which I make a memory view to which the > data is copied. > > To move data from wasm to JS I use emscripten::val::get_typed_memory_view > to create a view onto the item in wasm memory and return the view via a > emscripten::val. > > I tried to use emscripten::val with WebIDL binder but I could not get it > to compile. There is a short section in the WebIDL docs "Pointers, > References, Value types (Ref and Value)”, which is not very illuminating, > but does suggest that emscripten::val is not the right way to move data > with WebIDL binder. > > I’d prefer to use WebIDL binder because in order to document my previous > embind wrappers I ended up writing what looked very much like web IDL > because it seems the best way to tie all the pieces together. > > Regards > > -Mark > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/005C24B2-1D79-47CC-A291-D7A6B749582F%40callow.im > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpTgyrmUFDs_1B0CtJyvcEAZUuk9v9Oed5H6hAeTOQ1DEQ%40mail.gmail.com.
