0

I'd like to be able to access the Arguments& args of a callback. Right now when I set the C++ function to be called from the JavaScript side it looks like this:

global->Set(String::New("login"), FunctionTemplate::New(Login));

And the prototype of the C++ function is:

Handle<Value> MyClass::Login(const Arguments& args)

How do I access this Arguments& args so that I can pass in a variable when the callback occurs? Thanks for the help.

1 Answer 1

1

v8::Arguments::Length() will return the number of arguments passed from JavaScript. The v8::Arguments& variable is accessed using an array subscript.

for (int32_t index = 0; index < arguments->Length(); ++index) {
  if (arguments[index]->IsString()) {
    ::printf("%s\n", *v8::String::Utf8Value(arguments[index]->ToString()));
  }
}

You will find an online version of the v8::Arguments documentation at http://izs.me/v8-docs/classv8_1_1Arguments.html, however I make no guarantees that it is current or will remain online.

Running the following command from the top of the V8 source tree will generate the documentation locally using doxygen.

$ cd include && doxygen -g && doxygen

If doxygen executes successfully you can access the documentation in include/html/index.html.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.