Another option is to use the HEAP* typed array views directly. For example, the uint8_t* is, like all pointers, a 32-bit value, as is the len field. So if ptr contains a pointer to a ByteBuffer, you can read the second field with
HEAP32[(ptr + 4) >> 2] // + 4 to get to the "len" element, >> 2 because each HEAP32 element is 4 bytes. On Thu, Sep 29, 2016 at 2:41 PM, Shlomi Fish <[email protected]> wrote: > Hi Reuben, > > On Thu, 29 Sep 2016 14:01:22 -0700 (PDT) > Reuben Scratton <[email protected]> wrote: > > > Say I have a lot of C code that uses variable-length byte buffers with > > something like this: > > > > struct ByteBuffer { > > uint8_t* pData; > > uint32_t len; > > }; > > > > How may I access such a buffer from Javascript? > > > > Please look at Module.getValue() and Module.setValue(). > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > What does “Zionism” mean? - http://shlom.in/def-zionism > > Chuck Norris had a problem so he decided to use regular expressions. Now, > all the World’s problems are solved. > — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > > -- > 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. > -- 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.
