Shaka Player Embedded
|
Typedefs | |
template<size_t I, typename... Choices> | |
using | get_type_at_t = typename get_type_at< I, Choices... >::type |
template<size_t I, typename... Choices> | |
using | get_const_reference_at_t = typename std::add_lvalue_reference< typename std::add_const< typename get_type_at< I, Choices... >::type >::type >::type |
template<typename Func > | |
using | RetOf = typename std::result_of< Func()>::type |
template<typename T > | |
using | RawType = typename std::remove_cv< typename std::remove_reference< T >::type >::type |
Functions | |
bool | ConstructWrapperObject (const CallbackArguments &arguments, BackingObject *that) |
template<typename T , typename Arg > | |
ReturnVal< JsValue > | CreateInternalData (T **extra_data, Arg &&arg) |
template<typename Func > | |
ReturnVal< JsFunction > | CreateJsFunctionFromCallback (const std::string &target, const std::string &name, Func &&callback, bool is_member_func) |
Variables | |
constexpr const char * | kHiddenPropertyName = "$__shaka_extra_data" |
using shaka::impl::get_const_reference_at_t = typedef typename std::add_lvalue_reference<typename std::add_const< typename get_type_at<I, Choices...>::type>::type>::type |
using shaka::impl::get_type_at_t = typedef typename get_type_at<I, Choices...>::type |
using shaka::impl::RawType = typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type |
Careful, thar be magic here. Only read if you are familiar with template metaprogramming.
This file defines several functions that are used to convert a C++ function to a V8 function. A V8 function accepts a single argument that defines the array of arguments, some internal state, and the return value. This is not convenient with C++ code that accepts positional arguments and returns the value.
First, this checks each argument that is passed in. It tries to convert the argument to the expected type, throwing a JavaScript exception if it cannot do so. Then it calls the C++ function. Finally, if needed, converts the return value and passes back to JavaScript.
These methods all return a boolean. They should return |true| when JavaScript returns normally, or |false| if an exception is thrown.
Definition at line 70 of file register_member.h.
using shaka::impl::RetOf = typedef typename std::result_of<Func()>::type |
Definition at line 47 of file task_runner.h.
bool shaka::impl::ConstructWrapperObject | ( | const CallbackArguments & | arguments, |
BackingObject * | that | ||
) |
This is called when defining a JavaScript constructor. This sets up the resulting JavaScript object and links it to the given backing object.
In V8, the JavaScript object is already created for us (stored in |arguments.This()|). All we need to do is connect it to the backing object by setting its internal fields.
In JSC, this creates a new JavaScript object using |This| to get the correct type. This method then sets the return value of the JavaScript function so the object is passed to JavaScript.
arguments | The arguments (including |this| and the return value) to the JavaScript function. |
that | The backing object to wrap. |
Definition at line 23 of file register_member.cc.
ReturnVal<JsValue> shaka::impl::CreateInternalData | ( | T ** | extra_data, |
Arg && | arg | ||
) |
Creates extra data of the given type that will be passed to the callbacks when it is called. This allows us to pass internal data to specific function objects.
Definition at line 351 of file register_member.h.
ReturnVal<JsFunction> shaka::impl::CreateJsFunctionFromCallback | ( | const std::string & | target, |
const std::string & | name, | ||
Func && | callback, | ||
bool | is_member_func | ||
) |
Definition at line 557 of file register_member.h.
constexpr const char* shaka::impl::kHiddenPropertyName = "$__shaka_extra_data" |
Definition at line 319 of file register_member.h.