Shaka Player Embedded
Public Member Functions | Static Public Member Functions | List of all members
shaka::Callback Class Reference

#include <callback.h>

Inheritance diagram for shaka::Callback:
shaka::GenericConverter shaka::memory::Traceable

Public Member Functions

 Callback ()
 
 ~Callback () override
 
 Callback (const Callback &)
 
 Callback (Callback &&)
 
Callbackoperator= (const Callback &)
 
Callbackoperator= (Callback &&)
 
bool empty () const
 
bool operator== (const Callback &other) const
 
bool operator!= (const Callback &other) const
 
template<typename... Args>
void operator() (Args &&... args) const
 
template<typename T , typename... Args>
MUST_USE_RESULT ExceptionOr< void > CallWithThis (T &&that, Args &&... args) const
 
bool TryConvert (Handle< JsValue > given) override
 
ReturnVal< JsValue > ToJsValue () const override
 
void Trace (memory::HeapTracer *tracer) const override
 
- Public Member Functions inherited from shaka::GenericConverter
virtual ~GenericConverter ()
 
- Public Member Functions inherited from shaka::memory::Traceable
virtual ~Traceable ()
 
virtual bool IsRootedAlive () const
 
virtual bool IsShortLived () const
 

Static Public Member Functions

static std::string name ()
 

Additional Inherited Members

- Static Public Attributes inherited from shaka::memory::Traceable
static constexpr const uint64_t kShortLiveDurationMs = 5000
 

Detailed Description

Defines a helper type that is used to store and call JavaScript functions.

This defines a call operator that will call the function and swallow exceptions, printing the stack trace in the debug log if one is thrown. This also defines a named function to call the JavaScript function and return any exception instead.

Definition at line 38 of file callback.h.

Constructor & Destructor Documentation

§ Callback() [1/3]

shaka::Callback::Callback ( )

Definition at line 21 of file callback.cc.

§ ~Callback()

shaka::Callback::~Callback ( )
override

Definition at line 22 of file callback.cc.

§ Callback() [2/3]

shaka::Callback::Callback ( const Callback )
default

§ Callback() [3/3]

shaka::Callback::Callback ( Callback &&  )
default

Member Function Documentation

§ CallWithThis()

template<typename T , typename... Args>
MUST_USE_RESULT ExceptionOr<void> shaka::Callback::CallWithThis ( T &&  that,
Args &&...  args 
) const
inline

Definition at line 74 of file callback.h.

§ empty()

bool shaka::Callback::empty ( ) const
inline

Definition at line 52 of file callback.h.

§ name()

static std::string shaka::Callback::name ( )
inlinestatic

Definition at line 40 of file callback.h.

§ operator!=()

bool shaka::Callback::operator!= ( const Callback other) const
inline

Definition at line 59 of file callback.h.

§ operator()()

template<typename... Args>
void shaka::Callback::operator() ( Args &&...  args) const
inline

Definition at line 64 of file callback.h.

§ operator=() [1/2]

Callback & shaka::Callback::operator= ( const Callback )
default

§ operator=() [2/2]

Callback & shaka::Callback::operator= ( Callback &&  )
default

§ operator==()

bool shaka::Callback::operator== ( const Callback other) const
inline

Definition at line 56 of file callback.h.

§ ToJsValue()

ReturnVal< JsValue > shaka::Callback::ToJsValue ( ) const
overridevirtual

Converts the current value into a JavaScript value.

Implements shaka::GenericConverter.

Definition at line 36 of file callback.cc.

§ Trace()

void shaka::Callback::Trace ( memory::HeapTracer tracer) const
overridevirtual

Called during a GC run. This should call HeapTracer::Trace on all Traceable members. Be sure to call the base method when overriding.

Implements shaka::memory::Traceable.

Definition at line 40 of file callback.cc.

§ TryConvert()

bool shaka::Callback::TryConvert ( Handle< JsValue >  value)
overridevirtual

Tries to convert the given value into the required type, populating the members of this object as needed.

Returns
True on success, false on error.

Implements shaka::GenericConverter.

Definition at line 29 of file callback.cc.


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