void ConsoleLog(const FunctionCallbackInfo& args) { for (int i = 0; i < args.Length(); i++) { String::Utf8Value str(args[i]); printf("%s ", *str); } printf("\n"); }
void Sum(const FunctionCallbackInfoThese examples use the V8 engine for C++ language and its FunctionCallbackInfo class to handle arguments and return values for custom JavaScript functions. The package library is the V8 engine itself.& args) { if (args.Length() != 2) { isolate->ThrowException(Exception::TypeError( String::NewFromUtf8(isolate, "Invalid arguments"))); return; } if (!args[0]->IsNumber() || !args[1]->IsNumber()) { isolate->ThrowException(Exception::TypeError( String::NewFromUtf8(isolate, "Arguments must be numbers"))); return; } double x = args[0]->NumberValue(); double y = args[1]->NumberValue(); double sum = add(x, y); args.GetReturnValue().Set(Number::New(isolate, sum)); }