Simon,

Thank you so much for your answer!
That makes perfect sense

On Sun, Sep 1, 2019 at 10:31 PM 'Simon Zünd' via v8-users <
v8-users@googlegroups.com> wrote:

> Hey,
>
> You are not accessing the "size" property, but treat "args[0]" as if it
> were a number (which it is not, it's a ArrayBuffer). Since you have
> established that args[0] is an ArrayBuffer, you can use cast, which would
> look roughly like this:
>
> Local<ArrayBuffer> array_buffer = Local<ArrayBuffer>::cast(args[0]);
> size_t size = array_buffer->ByteLength();
>
>
> On Mon, Sep 2, 2019 at 12:50 AM Jonathan Doster <jbdos...@gmail.com>
> wrote:
>
>> Hey everyone!
>>
>> I am trying to pass an ArrayBuffer from JS to C++, and when I debug the
>> "size" variable is 0.
>> I do not understand what I am doing wrong, ultimately my goal is to be
>> able to read and write the buffer, copy, etc.
>> Thank you!!
>>
>> var api = require('../src/public/api')
>> api.Method(new ArrayBuffer([1, 2, 3, 4]))
>>
>> void Method(const v8::FunctionCallbackInfo<v8::Value> &args)
>> {
>> CHECK_ARGS(args, args[0]->IsArrayBuffer());
>> uint32_t size = args[0]->Uint32Value();
>> }
>>
>>
>> --
>> --
>> v8-users mailing list
>> v8-users@googlegroups.com
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to v8-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-users/ed43b406-af94-49f1-94c2-47c09673379d%40googlegroups.com
>> <https://groups.google.com/d/msgid/v8-users/ed43b406-af94-49f1-94c2-47c09673379d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-users/CACswSC1LA6dT66X12EOTNTrG29St8tnnHYp8uqhwARtid4ijcA%40mail.gmail.com
> <https://groups.google.com/d/msgid/v8-users/CACswSC1LA6dT66X12EOTNTrG29St8tnnHYp8uqhwARtid4ijcA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Jonathan Doster 909.839.3432 jbdos...@gmail.com Please disregard any
spelling errors, this message was sent via mobile.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAPcdUY%2BFKic66ioqYcqbHC4cziMs5Ez796HArVNgqVTFePyxXA%40mail.gmail.com.

Reply via email to