简体   繁体   中英

How can I get a v8 function to return a c++ object?

I'm currently trying to update a C++ library wrapper for Node.js. Currently it uses Nan 1.0 and I need to convert it to use the latest version, Nan 2.0. However, I have run into an interesting problem. I have these two lines:

Local<Object> obj;
obj = Nan::Get(result_object, conns[i].from_neuron).As<Object>();

When compiled using node-gyp, I receive the error

../src/fann-accs.cc:286:59: error: ‘Nan::MaybeLocal<v8::Value>’ has no member named ‘As’
   obj = Nan::Get(result_object, conns[i].from_neuron).As<Object>();

How can I get the Nan::Get function to return a c++ object?

Fixed by changing the line from

obj = Nan::Get(result_object, conns[i].from_neuron).As<Object>();

to

obj = result_object->Get(conns[i].from_neuron).As<Object>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM