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 <[email protected]> wrote:

> 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 &y);
>
> and have the implementation fill in the values for those two references.
> The caller could then read the values out of the variables they passed in.
>
> How do I do a similar thing with WebAssembly and javascript?
>
> 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.
>
> Also, allocating a shared buffer to write to, feels wrong in this case.
> Since it happens on mouse move and all those memory allocations seem
> wasteful.
>
> What is the right way to do this?
>
> --
> 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/73244098-e837-46e7-892e-d39346405347%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/73244098-e837-46e7-892e-d39346405347%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CA%2B_KjGY_HnpuvrKd8O%3DFTyXN7%2BSdrDhLZwoT97q%2Bj3Bj7yw3eQ%40mail.gmail.com.

Reply via email to