pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
898 stars 120 forks source link

How to use ArrayBuffer with v8pp::class_ ? #59

Closed pkhach closed 6 years ago

pkhach commented 7 years ago

Hello,

I would like to pass binary data to JavaScript and process them as ArrayBuffer (Uint8Array) in script.

How can I do this with v8pp?

struct X
{
    unsigned char* buffer;
};

// bind class
v8pp::class_<X> X_class(isolate);
X_class
    .set("buffer", ??????);

Thanks!

pmed commented 6 years ago

Hi @pkhach, You could try to write a v8pp::convert<X> specialization that uses v8::ArrayBuffer for X::buffer