Hi Brion,
We are trying to retrieve the C++ Data Type that were previously converted
into an emscripten val.
That is, suppose we had an instance of class X in C++, convert it into
emscripten val using the method you described previously,
how do we retrieve that instance in class X in C++?
It would be super help if you can look into this.
Best,
Peng Hui
On Tuesday, August 18, 2015 at 7:17:40 PM UTC-7, Matthew Tamayo wrote:
>
> Thanks Brion! This is super useful.
>
> -mtr
> ------------------------------
> From: Brion Vibber <javascript:>
> Sent: 8/15/2015 5:53 AM
> To: emscripten Mailing List <javascript:>
> Subject: Re: Marshalling Data From C++ to JS Efficiently
>
> If you declare your C++ function to return an emscripten::val, a memory
> view should correctly marshal out and return a Uint8Array (or whichever
> type you selected).
>
> Here's an example in a getter on a value object, but it should work fine
> on regular object methods too:
>
>
> #include <emscripten/bind.h>
> using namespace emscripten;
>
> ...
>
> struct H264Plane {
> unsigned char *data;
> int stride;
> int height;
> ...
> val data_getter() const;
> void data_setter(val v);
> };
>
> ...
>
> val H264Plane::data_getter() const
> {
> return val(memory_view<unsigned char>(stride * height, (unsigned
> char *)data));
> }
>
> ...
>
> EMSCRIPTEN_BINDINGS(h264_decoder) {
>
> value_object<H264Plane>("H264Plane")
> .field("data", &H264Plane::data_getter,
> &H264Plane::data_setter)
> ...
> ;
> ...
> }
>
> -- brion
>
>
> On Fri, Aug 14, 2015 at 11:22 PM, Matthew Tamayo <[email protected]
> <javascript:>> wrote:
>
>> I've been looking around Emscripten to try and figure out how to marshall
>> large binary objects from C++.
>>
>> We want to:
>>
>> 1. pass binaryArray = (unsigned *)&bigObject as a Uint8Array
>> 2. Use XMLHttpRequest2 to send Uint8Array to server
>> 3. Read in binary data on server (BigObject*) binaryArray in C++
>>
>> The problem we're having is figuring out the most efficient way to get a
>> Uint8Array of emscripten using embind. I've seen some threads that
>> recommend emscripten::memory_view(output_size, output_ptr), but I don't
>> know if it requires passing in a JS function via emscripten::val or if
>> returning a memory view will get correctly marshalled.
>>
>> Does this seem like sane approach? Any easier ways in the most recent
>> version of emscripten?
>>
>> -mtr
>>
>> --
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "emscripten-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/emscripten-discuss/l8GkOxZ79Ks/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
--
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].
For more options, visit https://groups.google.com/d/optout.