docs
Loading...
Searching...
No Matches
CallInfo

#include <Ultralight/js/CallInfo.h>

Overview

Details of a call to a bound function: the context, this, and the raw arguments.

Add a CallInfo parameter to a bound function to receive it, either first or after the other parameters. It isn't a JavaScript argument, so the other parameters still convert from the page's arguments as usual:

api["inspect"] = [](std::string name, js::CallInfo info) {
return (double)info.arg_count(); // `name` still converts from argument 1
};
Details of a call to a bound function: the context, this, and the raw arguments.
Definition CallInfo.h:41

Declare only one. With a trailing js::Resolver the order is (arguments..., CallInfo, Resolver).

Note
A CallInfo and the js::Arg values it gives you are valid only during the call (in a js::Task, until the Task finishes). Use Arg::ToValue() to keep an argument. You can keep the Context that context() returns.
Note
A function that takes a CallInfo receives every argument the page passes, so Strict diagnostics don't reject extra arguments for it (see js::Diagnostics).

Public Member Functions

Context context () const
 Get the calling context, to create values in it or to keep it after the call:
Arg this_value () const
 Get the call's this value.
size_t arg_count () const
 Get the number of arguments the page passed.
Arg arg (size_t index) const
 Get an argument.

Member Function Documentation

◆ arg()

Arg arg ( size_t index) const
inline

Get an argument.

Parameters
indexThe zero-based argument position.
Returns
Returns the argument (an empty Arg if index is out of range).

◆ arg_count()

size_t arg_count ( ) const
inline

Get the number of arguments the page passed.

◆ context()

Context context ( ) const
inline

Get the calling context, to create values in it or to keep it after the call:

api["build"] = [](js::CallInfo info) {
return info.context().Make(std::vector<double> { 1, 2, 3 });
};
Returns
Returns a new reference to the context.
Note
Requires <Ultralight/js/Context.h> (or <Ultralight/JS.h>).

◆ this_value()

Arg this_value ( ) const
inline

Get the call's this value.


The documentation for this class was generated from the following files: