docs
Loading...
Searching...
No Matches
Param

#include <Ultralight/js/API.h>

Overview

A parameter name for a registration (shown in API::schema() and in error messages).

API::Bind(), API::DefineEvent(), ClassBuilder::Method(), and ClassBuilder::StaticMethod() accept these after the callable. Name every parameter (except a CallInfo or js::Resolver) or none. The text is read during the call, so it doesn't need to outlive it.

api.Bind("setConfig", [](double volume, bool muted) { ... },
js::Param("volume"), js::Param("muted"));
A parameter name for a registration (shown in API::schema() and in error messages).
Definition API.h:199

A wrong call from the page then reports the names:

myApp.setConfig('loud', true);
// TypeError: myApp.setConfig(volume: number, muted: boolean): argument 1 (volume):
// expected number, got 'loud'
Note
The assignment form (api["x"] = fn) takes no annotations. Use Bind() to add them.
Note
Don't confuse this with js::Arg, which is an argument value a callback reads.
See also
js::Doc

Public Member Functions

constexpr Param (const char *declared_name)
 Create a parameter name annotation.

Public Attributes

const char * name
 The parameter name.

Constructor & Destructor Documentation

◆ Param()

Param ( const char * declared_name)
inlineexplicitconstexpr

Create a parameter name annotation.

Parameters
declared_nameThe parameter name (NULL becomes an empty name).

Member Data Documentation

◆ name

const char* name

The parameter name.


The documentation for this struct was generated from the following file: