Reputation: 41
I am trying to cast the arguments passed to my C++ addon into arrays but I am running into the error in the title. This is my code:
#include "node.h"
#include "node_buffer.h"
#include "v8.h"
using namespace v8;
using namespace std;
namespace water{
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Number;
using v8::Value;
using v8::Array;
void water(const FunctionCallbackInfo<Value> &args)
{
if(args[0]->IsArray())
{
Local<Array> a = Array::Cast(*args[0]);
Local<Array> b = Array::Cast(*args[1]);
}
args.GetReturnValue().Set(20);
}
}
This is my error no suitable constructor exists to convert from “v8::Array *” to “v8::Local<v8::Array>”
In other words, I am looking to pass in arrays to my method from a NodeJs program using node-gyp but I can't seem to do so.
Upvotes: 1
Views: 352
Reputation: 30937
Reading the documentation, I think it should be
Local<Array> a = args[0].As<Array>();
Upvotes: 2