Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
v8::MaybeLocal< T > Class Template Reference

#include <v8-local-handle.h>

Inheritance diagram for v8::MaybeLocal< T >:
[legend]

Public Member Functions

 MaybeLocal ()
 
template<class S >
 MaybeLocal (Local< S > that)
 
bool IsEmpty () const
 
template<class S >
bool ToLocal (Local< S > *out) const
 
Local< T > ToLocalChecked ()
 
template<class S >
Local< S > FromMaybe (Local< S > default_value) const
 
template<class S >
MaybeLocal< S > As () const
 

Static Public Member Functions

template<class S >
static MaybeLocal< T > Cast (MaybeLocal< S > that)
 

Friends

template<typename S >
class MaybeLocal
 

Detailed Description

template<class T>
class v8::MaybeLocal< T >

A MaybeLocal<> is a wrapper around Local<> that enforces a check whether the Local<> is empty before it can be used.

If an API method returns a MaybeLocal<>, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a TerminateExecution exception was thrown. In that case, an empty MaybeLocal is returned.

Examples
process.cc, and shell.cc.

Constructor & Destructor Documentation

◆ MaybeLocal() [1/2]

template<class T >
v8::MaybeLocal< T >::MaybeLocal ( )
inline

◆ MaybeLocal() [2/2]

template<class T >
template<class S >
v8::MaybeLocal< T >::MaybeLocal ( Local< S >  that)
inline

Member Function Documentation

◆ As()

template<class T >
template<class S >
MaybeLocal< S > v8::MaybeLocal< T >::As ( ) const
inline

Calling this is equivalent to MaybeLocal<S>::Cast(). In particular, this is only valid if the handle actually refers to a value of the target type.

Here is the call graph for this function:

◆ Cast()

template<class T >
template<class S >
static MaybeLocal< T > v8::MaybeLocal< T >::Cast ( MaybeLocal< S >  that)
inlinestatic

Cast a handle to a subclass, e.g. MaybeLocal<Value> to MaybeLocal<Object>. This is only valid if the handle actually refers to a value of the target type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromMaybe()

template<class T >
template<class S >
Local< S > v8::MaybeLocal< T >::FromMaybe ( Local< S >  default_value) const
inline

Converts this MaybeLocal<> to a Local<>, using a default value if this MaybeLocal<> is empty.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsEmpty()

template<class T >
bool v8::MaybeLocal< T >::IsEmpty ( ) const
inline
Here is the caller graph for this function:

◆ ToLocal()

template<class T >
template<class S >
bool v8::MaybeLocal< T >::ToLocal ( Local< S > *  out) const
inline

Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, |false| is returned and |out| is assigned with nullptr.

Here is the call graph for this function:

◆ ToLocalChecked()

template<class T >
Local< T > v8::MaybeLocal< T >::ToLocalChecked ( )
inline

Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, V8 will crash the process.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ MaybeLocal

template<class T >
template<typename S >
friend class MaybeLocal
friend

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