I am trying to write a native C++ module to include in a Node.js project -- I followed the guide here and have things setup pretty well.
The general idea is that I want to pass an array of integers to my C++ module to be sorted; the module then returns the sorted array.
However, I cannot compile using node-gyp build
because I hit the following error:
error: no viable conversion from 'Local' to 'int *'
It is complaining about this code in my C++:
void Method(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
int* inputArray = args[0]; // <-- ERROR!
sort(inputArray, 0, sizeof(inputArray) - 1);
args.GetReturnValue().Set(inputArray);
}
This all makes conceptual sense to me -- the compiler can't magically cast arg[0]
(presumably of type v8::Local
) to an int*
. Having said that, I cannot seem to find any way to get my argument successfully cast into a C++ integer array.
It should be known that my C++ is rather rusty, and I know next-to-nothing about V8. Can anyone point me in the right direction?