I am new to Javascript and V8 library. My requirement is call a C++ function and return a C struct back to Javascript module.
struct empDetails {
int empNo;
string empName;
};
v8::Handle<v8::Value> getDetails(const v8::Arguments &args) {
if ((args.Length() != 1) || !args[0]->IsUint32()) {
return v8::ThrowException(v8::Exception::Error
(v8::String::New("Invalid> arguments.")));
}
uint32_t userId = args[0]->ToUint32()->Value();
empDetails e;
company::GetEmpdetails(userId, e); // other static function in my project
return e;
}
At return statement, I am getting error. Could anyone tell me how to return a struct from V8 C++ function.
{empNo:1,empName:"John Doe"}?