Re: getting data back to javascript from a webassembly function.

2020-02-24 Thread Floh
PS: here is a "real-world-example" of what I wrote above in a WIP WebGPU wrapper. Most initialization functions in WebGPU are asynchronous, and it's much easier to do this stuff in JS than C, and when all the promises have resolved, a C function is called (emsc_device_ready()) with the multiple

Re: getting data back to javascript from a webassembly function.

2020-02-24 Thread Floh
> At the moment, I am implementing the solution by having the WebAssembly code call back to javascript with the answer. But that feels wrong in many ways. This is exactly what I'm doing in my C code (no fancy "embind", but I like it that way because there's less "magic" involved"). I basicall

Re: getting data back to javascript from a webassembly function.

2020-02-21 Thread Alon Zakai
I think there are multiple ways to do this. Embind is one option as Shachar suggested. Another is to use a little shared buffer as you mentioned - to avoid memory allocations, you can just allocate one such singleton buffer at the beginning of the program, and keep reusing it for all calls to that

Re: getting data back to javascript from a webassembly function.

2020-02-20 Thread Shachar Langbeheim
You need to use embind to define the return type and the function. https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html On Fri, 21 Feb 2020 at 06:44, Shawn Riordan wrote: > I am new at this, so don't laugh. > > I am able to make C/C++ functions that javascript can call.

getting data back to javascript from a webassembly function.

2020-02-20 Thread Shawn Riordan
I am new at this, so don't laugh. I am able to make C/C++ functions that javascript can call. When the parameters are out only. Can I make them return parameters? Lets say I want to return a point. Two values, x and y. In C/C++ I would make my function look like: void getFoo( float &x, float