News for hackers. Stuff that matters.
Re:Type conversions from JavaScript to C++ in V8 by megalodon on Sunday April 03, 2016 @02:22PM (#11417025)
Somewhat related: You can also read and manipulate the contents of JavaScript typed arrays in V8:

    // js
    var x = new Float64Array([1, 2, 3]);
    binding(x);

    // c++
    void binding(const v8::FunctionCallbackInfo<v8::Value>& info) {
        void *data = info[0].As<v8::Float64Array>()->Buffer()->GetContents().Data();
        double *x = reinterpret_cast<double*>(data);

        // do whatever, e.g.
        x[0] = 0;
    }
Re:Type conversions from JavaScript to C++ in V8 by dkopi on Sunday April 03, 2016 @03:00PM (#11417165)
Be ultra careful when doing this. First of all - make sure to get, validate and store the buffer's length (ByteLength())

Secondly - GetContents() is only for temporary access to a buffer. if you store that pointer and use it later (//do whatever), there's a great chance it will get garbage collected. Make sure to Externalize() the array if you intend on keeping the pointer for later.

Re:Type conversions from JavaScript to C++ in V8 by zbjornson on Sunday April 03, 2016 @07:24PM (#11418332)
Or use the relatively new NaN helper TypedArrayContents:

https://github.com/nodejs/nan/blob/master/doc/v8_misc.md#api...