v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
v8toolkit Namespace Reference

Namespaces

 literals
 
 v8toolkit
 

Classes

struct  always_false
 
struct  Any
 
struct  AnyBase
 
struct  AnyPtr
 
struct  AnyPtr< T, std::enable_if_t<!std::is_pointer< T >::value &&!std::is_reference< T >::value > >
 
class  ArrayBufferAllocator
 
class  BidirectionalException
 
struct  Bind
 
struct  Bind< R(T::*)(Args...) const >
 
struct  Bind< R(T::*)(Args...) const & >
 
struct  Bind< R(T::*)(Args...)& >
 
struct  Bind< R(T::*)(Args...)>
 
struct  CallCallable
 
struct  CallCallable< func::function< ReturnType(Args...)> >
 
struct  CallCallable< func::function< ReturnType(InitialArg, Args...)>, InitialArg >
 
struct  CallCallable< func::function< void(Args...)> >
 
struct  CallCallable< func::function< void(InitialArg, Args...)>, InitialArg >
 
struct  cast_to_native_no_value
 
struct  cast_to_native_supports_default_value
 
struct  cast_to_native_supports_default_value< T, void_t< std::result_of_t< CastToNative< T >(v8::Isolate *)> > >
 
class  CastException
 
struct  CastToJS
 
struct  CastToJS< eastl::fixed_string< CharType, Length, Overflow, Allocator > >
 
struct  CastToJS< eastl::vector< T, Rest... > >
 
struct  CastToJS< eastl::vector_map< A, B, Rest... > >
 
struct  CastToJS< eastl::vector_multimap< A, B, Rest... > >
 
struct  CastToJS< eastl::vector_set< T, Rest... > >
 
struct  CastToJS< JSWrapper< T > >
 
struct  CastToJS< std::array< T, N > >
 
struct  CastToJS< std::deque< T, Rest... > >
 
struct  CastToJS< std::function< R(Params...)> >
 
struct  CastToJS< std::list< U, Rest... > >
 
struct  CastToJS< std::map< KeyType, ValueType, Rest... > >
 
struct  CastToJS< std::multimap< A, B, Rest... > >
 
struct  CastToJS< std::pair< T1, T2 > >
 
struct  CastToJS< std::set< T, Rest... > >
 
struct  CastToJS< std::shared_ptr< T > >
 
struct  CastToJS< std::tuple< Args... > >
 
struct  CastToJS< std::unique_ptr< T, Rest... > &, std::enable_if_t<!is_wrapped_type_v< std::unique_ptr< T, Rest... > > > >
 
struct  CastToJS< std::unique_ptr< T, Rest... > const &, std::enable_if_t<!is_wrapped_type_v< std::unique_ptr< T, Rest... > const > > >
 
struct  CastToJS< std::unique_ptr< T, Rest... >, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToJS< std::unique_ptr< T, Rest... >, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToJS< std::unordered_map< A, B, Rest... > >
 
struct  CastToJS< std::vector< T, Rest... > >
 
struct  CastToJS< T &&, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToJS< T &, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToJS< T &, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToJS< T ** >
 
struct  CastToJS< T *, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToJS< T *, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToJS< T const, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToJS< T, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToJS< v8::Global< T > >
 
struct  CastToJS< v8::Local< T > >
 
struct  CastToNative
 
struct  CastToNative< char * >
 
struct  CastToNative< const char * >
 
struct  CastToNative< eastl::fixed_string< CharType, Length, Overflow, Allocator > >
 
struct  CastToNative< eastl::vector< T, Args... > >
 
struct  CastToNative< eastl::vector_map< Key, Value, Args... > >
 
struct  CastToNative< eastl::vector_multimap< Key, Value, Args... > >
 
struct  CastToNative< eastl::vector_set< T, Args... > >
 
struct  CastToNative< std::function< ReturnT(Args...)> >
 
struct  CastToNative< std::map< Key, Value, Args... > >
 
struct  CastToNative< std::multimap< Key, Value, Args... > >
 
struct  CastToNative< std::set< T, Rest... >, std::enable_if_t<!is_wrapped_type_v< std::set< T, Rest... > > > >
 
struct  CastToNative< std::tuple< Ts... > >
 
struct  CastToNative< std::unique_ptr< T, Rest... >, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToNative< std::vector< T, Rest... > &&, std::enable_if_t<!is_wrapped_type_v< std::vector< T, Rest... > > > >
 
struct  CastToNative< std::vector< T, Rest... >, std::enable_if_t< std::is_copy_constructible< T >::value > >
 
struct  CastToNative< T &&, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToNative< T &&, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToNative< T &, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToNative< T *, std::enable_if_t< is_wrapped_type_v< T > > >
 
struct  CastToNative< T const &, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToNative< T const, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  CastToNative< T, std::enable_if_t<!std::is_const_v< T > &&std::is_copy_constructible< T >::value &&is_wrapped_type_v< T > > >
 
struct  CastToNative< T, std::enable_if_t<!std::is_copy_constructible< T >::value &&is_wrapped_type_v< T > > >
 
struct  CastToNative< v8::Local< T > >
 
struct  CastToNative< v8::Local< v8::Function > >
 
struct  CastToNative< void >
 
struct  CastTupleToJS
 
struct  CastTupleToJS< 0, std::tuple< Args... > >
 
struct  CastTupleToJS< position, std::tuple< Args... > >
 
class  Context
 
class  CppFactory
 
class  CppFactory< Base, Child, TypeList< FixedParams... >, TypeList< ExternalConstructorParams... >, FactoryBase, Deleter >
 
class  CppFactory< Base, Child, TypeList< ExternalConstructorParams... >, ParentType, FactoryBase >
 
class  DebugContext
 
struct  DestructorBehavior
 
struct  DestructorBehavior_Delete
 
struct  DestructorBehavior_LeaveAlone
 
class  DuplicateNameException
 
class  EmptyFactoryBase
 
struct  enable_if_t< is_wrapped_type_v< T > >>
 
struct  enable_if_t<!is_wrapped_type_v< T > >>
 
struct  enable_if_t<!std::is_reference< std::result_of_t< CastToNative< std::remove_reference_t< Container< const char *, Rest... > > >(v8::Isolate *, v8::Local< v8::Value >) > >::value >
 
struct  enable_if_t<!std::is_reference< std::result_of_t< CastToNative< std::remove_const_t< std::remove_reference_t< Container< char *, Rest... > > > >(v8::Isolate *, v8::Local< v8::Value >)> >::value >
 
class  Factory
 
class  Factory< Base, TypeList< ConstructorArgs... >, FactoryBase, Deleter >
 
class  FlexibleParent
 
struct  function< void(const v8::FunctionCallbackInfo< v8::Value > &)>
 
struct  FunctionTemplateData
 
class  InvalidCallException
 
struct  is_specialization
 
struct  is_specialization< Ref< Args... >, Ref >
 
struct  is_wrapped_type
 
struct  is_wrapped_type< T, std::enable_if_t< std::is_base_of< v8toolkit::WrappedClassBase, T >::value > >
 
class  Isolate
 
class  JSFactory
 
class  JSFactory< Base, JSWrapperClass, TypeList< InternalConstructorParams... >, TypeList< ExternalConstructorParams... >, FactoryBase, Deleter >
 
class  JSWrapper
 
class  JSWrapperBase
 
struct  LTG
 
struct  LTG< T && >
 
struct  MapperHelper
 
struct  MapperHelper< Container< Data, AddParams... >, Callable >
 
struct  MapperHelper< std::map< Key, Value, AddParams... >, Callable >
 
struct  MethodAdderData
 
struct  ParameterBuilder
 
struct  ParameterBuilder< v8::Local< T >, std::enable_if_t< !std::is_pointer_v< v8::Local< T > > && !std::is_reference_v< v8::Local< T > > && !is_wrapped_type_v< v8::Local< T > > > >
 
struct  ParameterBuilder< char * >
 
struct  ParameterBuilder< char const * >
 
struct  ParameterBuilder< const v8::FunctionCallbackInfo< v8::Value > & >
 
struct  ParameterBuilder< T &&, std::enable_if_t<!is_wrapped_type_v< T > > >
 
struct  ParameterBuilder< T &, std::enable_if_t< std::is_same_v< std::remove_const_t< T >, char > &&!is_wrapped_type_v< T > > >
 
struct  ParameterBuilder< T &, std::enable_if_t<!std::is_same_v< std::remove_const_t< T >, char > &&!is_wrapped_type_v< T > > >
 
struct  ParameterBuilder< T, std::enable_if_t< std::is_copy_constructible_v< T > &&is_wrapped_type_v< T > > >
 
struct  ParameterBuilder< T, std::enable_if_t< std::is_reference_v< T > &&is_wrapped_type_v< std::remove_reference_t< T > > > >
 
struct  ParameterBuilder< T, std::enable_if_t<!std::is_pointer_v< T > &&!std::is_reference_v< T > &&!is_wrapped_type_v< T > > >
 
struct  ParameterBuilder< v8::Isolate * >
 
struct  ParameterBuilder< v8::Local< v8::Context > >
 
class  Platform
 
struct  ProxyType
 
struct  ProxyType< T, void_t< typename T::V8TOOLKIT_PROXY_TYPE > >
 
struct  remove_const_from_reference
 
struct  remove_const_from_reference< T const >
 
struct  remove_const_from_reference< T const & >
 
struct  RequireResult
 
class  Script
 
struct  SetWeakCallbackData
 
struct  static_all_of
 
struct  static_all_of< false, tail... >
 
struct  static_all_of< true, tail... >
 
struct  static_all_of<>
 
struct  static_any
 
struct  static_any< false, tail... >
 
struct  static_any< true, tail... >
 
struct  static_any<>
 
struct  Stuff
 
struct  StuffBase
 
struct  TupleForEach
 
struct  TupleForEach< 0, Tuple >
 
struct  TypeChecker
 
struct  TypeChecker< T, TypeList<> >
 
struct  TypeChecker< T, v8toolkit::TypeList< Head, Tail... >, std::enable_if_t< std::is_const< T >::value||!std::is_const< Head >::value > >
 
struct  TypeChecker< T, v8toolkit::TypeList< Head, Tail... >, std::enable_if_t<!std::is_const< T >::value &&std::is_const< Head >::value > >
 
struct  TypeCheckerBase
 
struct  TypeList
 
class  UndefinedPropertyException
 
class  V8AssertionException
 
class  V8ClassWrapper
 
class  V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >
 
class  V8ClassWrapperInstanceRegistry
 
class  V8CompilationException
 
class  V8Exception
 
class  V8ExecutionException
 
struct  value && !is_wrapped_type_v< T > >>
 
class  WebsocketChannel
 
struct  WrapAsMostDerived
 
struct  WrapAsMostDerived< T, TypeList< Head, Tail... >, std::enable_if_t< std::is_const< T >::value &&!std::is_const< Head >::value > >
 
struct  WrapAsMostDerived< T, TypeList< Head, Tail... >, std::enable_if_t<!std::is_const< T >::value||std::is_const< Head >::value > >
 
struct  WrapAsMostDerived< T, TypeList<> >
 
struct  WrapAsMostDerivedBase
 
class  WrappedClassBase
 
struct  WrappedData
 

Typedefs

using ScriptPtr = std::shared_ptr< Script >
 
using ContextPtr = std::shared_ptr< Context >
 
using IsolatePtr = std::shared_ptr< Isolate >
 
using StdFunctionCallbackType = func::function< void(const v8::FunctionCallbackInfo< v8::Value > &info)>
 
template<class T >
using void_t = void
 
template<class T >
using int_t = int
 
template<class T >
using remove_const_from_reference_t = typename remove_const_from_reference< T >::type
 
using json = nlohmann::json
 
typedef std::map< std::string, RequireResultcached_isolate_modules_t
 

Enumerations

enum  { kDebugIdIndex = v8::Context::kDebugIdIndex, kModuleEmbedderDataIndex, kInspectorClientIndex }
 

Functions

template<class T >
std::enable_if_t< std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > safe_get_javascript_object (T *object)
 
template<class T >
std::enable_if_t<!std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > safe_get_javascript_object (T *object)
 
 CAST_TO_NATIVE (bool,{HANDLE_FUNCTION_VALUES;return static_cast< bool >(value->ToBoolean() ->Value());})
 
 CAST_TO_NATIVE (long long,{HANDLE_FUNCTION_VALUES;return static_cast< long long >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (unsigned long long,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long long >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (long,{HANDLE_FUNCTION_VALUES;return static_cast< long >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (unsigned long,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (int,{HANDLE_FUNCTION_VALUES;return static_cast< int >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (unsigned int,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned int >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (short,{HANDLE_FUNCTION_VALUES;return static_cast< short >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (unsigned short,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned short >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (char,{HANDLE_FUNCTION_VALUES;return static_cast< char >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (unsigned char,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned char >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (wchar_t,{HANDLE_FUNCTION_VALUES;return static_cast< wchar_t >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (char16_t,{HANDLE_FUNCTION_VALUES;return static_cast< char16_t >(value->ToInteger() ->Value());})
 
 CAST_TO_NATIVE (char32_t,{HANDLE_FUNCTION_VALUES;return static_cast< char32_t >(value->ToInteger() ->Value());})
 
template<class... Ts, std::size_t... Is>
std::tuple< Ts... > cast_to_native_tuple_helper (v8::Isolate *isolate, v8::Local< v8::Array > array, std::tuple< Ts... >, std::index_sequence< Is... >)
 
template<template< class, class > class ContainerTemplate, class FirstT , class SecondT >
ContainerTemplate< FirstT, SecondT > pair_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value)
 
 CAST_TO_NATIVE (float,{HANDLE_FUNCTION_VALUES;return static_cast< float >(value->ToNumber() ->Value());})
 
 CAST_TO_NATIVE (double,{HANDLE_FUNCTION_VALUES;return static_cast< double >(value->ToNumber() ->Value());})
 
 CAST_TO_NATIVE (long double,{HANDLE_FUNCTION_VALUES;return static_cast< long double >(value->ToNumber() ->Value());})
 
 CAST_TO_NATIVE (std::string,{HANDLE_FUNCTION_VALUES;return std::string(*v8::String::Utf8Value(value));})
 
template<template< class, class... > class VectorTemplate, class T , class... Rest>
auto vector_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) -> VectorTemplate< std::remove_reference_t< std::result_of_t< CastToNative< T >(v8::Isolate *, v8::Local< v8::Value >)>>, Rest... >
 
template<template< class, class... > class SetTemplate, class T , class... Rest>
auto set_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) -> SetTemplate< std::remove_reference_t< std::result_of_t< CastToNative< T >(v8::Isolate *, v8::Local< v8::Value >)>>, Rest... >
 
template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest>
ContainerTemplate< Key, Value, Rest... > map_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value)
 
template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest>
ContainerTemplate< Key, Value, Rest... > multimap_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value)
 
 CAST_TO_JS (bool,{return v8::Boolean::New(isolate, value);})
 
 CAST_TO_JS (char,{return v8::Integer::New(isolate, value);})
 
 CAST_TO_JS (unsigned char,{return v8::Integer::New(isolate, value);})
 
 CAST_TO_JS (wchar_t,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (char16_t,{return v8::Integer::New(isolate, value);})
 
 CAST_TO_JS (char32_t,{return v8::Integer::New(isolate, value);})
 
 CAST_TO_JS (short,{return v8::Integer::New(isolate, value);})
 
 CAST_TO_JS (int,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (unsigned int,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (long,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (long long,{return v8::Number::New(isolate, static_cast< double >(value));})
 
 CAST_TO_JS (unsigned long long,{return v8::Number::New(isolate, static_cast< double >(value));})
 
 CAST_TO_JS (float,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (double,{return v8::Number::New(isolate, value);})
 
 CAST_TO_JS (std::string,{return v8::String::NewFromUtf8(isolate, value.c_str(), v8::String::kNormalString, value.length());})
 
 CAST_TO_JS (char *,{return v8::String::NewFromUtf8(isolate, value);})
 
 CAST_TO_JS (char const *,{return v8::String::NewFromUtf8(isolate, value);})
 
template<template< class, class, class... > class MapTemplate, class KeyType , class ValueType , class ReferenceTypeIndicator , class... Rest>
v8::Local< v8::Value > cast_to_js_map_helper (v8::Isolate *isolate, MapTemplate< KeyType, ValueType, Rest... > const &map)
 
template<template< class... > class VectorTemplate, class ValueType , class... Rest>
v8::Local< v8::Value > cast_to_js_vector_helper (v8::Isolate *isolate, VectorTemplate< std::remove_reference_t< ValueType >, Rest... > const &vector)
 
template<template< class, class, class... > class MultiMapLike, class A , class B , class... Rest>
v8::Local< v8::Object > casttojs_multimaplike (v8::Isolate *isolate, MultiMapLike< A, B, Rest... > const &map)
 
 CAST_TO_NATIVE (eastl::string,{HANDLE_FUNCTION_VALUES;return eastl::string(*v8::String::Utf8Value(value));})
 
 CAST_TO_JS (eastl::string,{return v8::String::NewFromUtf8(isolate, value.c_str());})
 
template<class T , int default_arg_position = -1, class DefaultArgsTuple = std::tuple<>>
T * get_default_parameter (const v8::FunctionCallbackInfo< v8::Value > &info, int &i, std::vector< std::unique_ptr< StuffBase >> &stuff, DefaultArgsTuple &&default_args_tuple)
 
template<class T >
std::string type_details ()
 
template<class T , std::enable_if_t< std::is_pointer< T >::value||std::is_reference< T >::value, int > = 0>
T & get_object_from_embedded_cpp_object (v8::Isolate *isolate, v8::Local< v8::Value > value)
 
template<class MemberT , class ClassT >
constexpr bool get_member_is_readonly (MemberT(ClassT::*member))
 
std::string get_stack_trace_string (v8::Local< v8::StackTrace > stack_trace)
 
template<class ReturnType , class... Args, class... Ts>
auto run_function (func::function< ReturnType(Args...)> &function, const v8::FunctionCallbackInfo< v8::Value > &info, Ts &&...ts) -> ReturnType
 
template<class ReturnType , class... Args, class Callable , class... Ts>
auto run_function (Callable callable, const v8::FunctionCallbackInfo< v8::Value > &info, Ts &&...ts) -> ReturnType
 
void ReportException (v8::Isolate *isolate, v8::TryCatch *try_catch)
 
std::string demangle_typeid_name (const std::string &mangled_name)
 
template<class T >
std::string & demangle ()
 
template<class Destination , class Source , std::enable_if_t< std::is_polymorphic< Source >::value, int > = 0>
Destination safe_dynamic_cast (Source *source)
 
template<class Destination >
Destination * safe_dynamic_cast (Destination *source)
 
template<class T , std::enable_if_t< SAFE_MOVE_CONSTRUCTOR_SFINAE, int > = 0>
std::unique_ptr< T > safe_move_constructor (T &&original)
 
template<class R , class... Ts>
auto get_typelist_for_function (func::function< R(Ts...)>) -> TypeList< Ts... >
 
template<class R , class Head , class... Tail>
auto get_typelist_for_function_strip_first (func::function< R(Head, Tail...)>) -> TypeList< Tail... >
 
template<class... Ts>
auto get_typelist_for_variables (Ts...ts) -> TypeList< Ts... >
 
template<class... Ts>
auto make_tuple_for_variables (Ts &&...ts) -> std::tuple< Ts... >
 
void print_v8_value_details (v8::Local< v8::Value > local_value)
 
int get_array_length (v8::Isolate *isolate, v8::Local< v8::Value > array_value)
 
std::set< std::string > make_set_from_object_keys (v8::Isolate *isolate, v8::Local< v8::Object > &object, bool own_properties_only=true)
 
template<class Callable >
void for_each_value (const v8::Local< v8::Context > context, const v8::Local< v8::Value > value, Callable callable)
 
void set_global_object_alias (v8::Isolate *isolate, const v8::Local< v8::Context > context, std::string alias_name)
 
std::string get_type_string_for_value (v8::Local< v8::Value > value)
 
void process_v8_flags (int &argc, char **argv)
 
void expose_gc ()
 
v8::Local< v8::Value > call_simple_javascript_function (v8::Isolate *isolate, v8::Local< v8::Function > function)
 
template<class T >
void for_each_own_property (const v8::Local< v8::Context > context, const v8::Local< v8::Object > object, T callable)
 
template<class Container , class Callable >
auto mapper (const Container &container, Callable callable) -> decltype(MapperHelper< Container, Callable >()(container, callable))
 
template<class Callable , class Container >
auto reducer (const Container &container, Callable callable) -> std::vector< typename std::result_of< Callable(typename Container::value_type)>::type >
 
template<class T >
v8::Local< T > get_value_as (v8::Local< v8::Value > value)
 
template<class T >
v8::Local< T > get_value_as (v8::Isolate *isolate, v8::Global< v8::Value > &value)
 
template<class T >
v8::Local< T > get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key)
 
template<class T >
v8::Local< T > get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Value > object, std::string key)
 
v8::Local< v8::Value > get_key (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key)
 
v8::Local< v8::Value > get_key (v8::Local< v8::Context > context, v8::Local< v8::Value > value, std::string key)
 
std::string stringify_value (v8::Isolate *isolate, const v8::Local< v8::Value > &value, bool show_all_properties=false, std::vector< v8::Local< v8::Value >> &&processed_values=std::vector< v8::Local< v8::Value >>{})
 
bool global_name_conflicts (const std::string &name)
 
v8::Local< v8::Object > check_value_is_object (v8::Local< v8::Value > value, std::string const &class_name)
 
template<class T >
auto scoped_run (v8::Isolate *isolate, T callable) -> typename std::result_of< T()>::type
 
template<class T >
auto scoped_run (v8::Isolate *isolate, v8::Local< v8::Context > context, T callable) -> typename std::result_of< T()>::type
 
template<class T >
auto scoped_run (v8::Isolate *isolate, const v8::Global< v8::Context > &context, T callable)
 
template<class R , class... Args>
v8::Local< v8::FunctionTemplate > make_function_template (v8::Isolate *isolate, func::function< R(Args...)> f, std::string const &name)
 
template<class R , class CLASS , class... Args>
func::function< R(Args...)> make_std_function_from_callable (R(CLASS::*f)(Args...) const, CLASS callable)
 
template<class R , class... Args>
func::function< R(Args...)> make_std_function_from_callable (R(*callable)(Args...), std::string name)
 
template<class T >
v8::Local< v8::FunctionTemplate > make_function_template (v8::Isolate *isolate, T callable, std::string name)
 
template<class R , class... Args>
v8::Local< v8::FunctionTemplate > make_function_template (v8::Isolate *isolate, R(*f)(Args...), std::string const &name)
 
template<class R , class... Args>
void add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, func::function< R(Args...)> function)
 
template<class T >
void add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T callable)
 
template<class R , class... Args>
void add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, R(*function)(Args...))
 
template<class T >
void add_function (const v8::Local< v8::Context > &context, const v8::Local< v8::Object > &object, const char *name, T callable)
 
void add_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, const v8::Local< v8::Data > value)
 
void add_variable (const v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, const v8::Local< v8::Value > value)
 
void add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, void(*function)(const v8::FunctionCallbackInfo< v8::Value > &))
 
template<class... OriginalTypes, class... Ts>
v8::Local< v8::Value > call_javascript_function_with_vars (const v8::Local< v8::Context > context, const v8::Local< v8::Function > function, const v8::Local< v8::Object > receiver, const TypeList< OriginalTypes... > &type_list, Ts &&...ts)
 
template<class TupleType = std::tuple<>>
v8::Local< v8::Value > call_javascript_function (const v8::Local< v8::Context > context, const v8::Local< v8::Function > function, const v8::Local< v8::Object > receiver, const TupleType &tuple={})
 
template<class TupleType = std::tuple<>>
v8::Local< v8::Value > call_javascript_function (const v8::Local< v8::Context > context, const std::string &function_name, const v8::Local< v8::Object > receiver, const TupleType &tuple={})
 
template<class T >
void _variable_getter (v8::Local< v8::String > property, const v8::PropertyCallbackInfo< v8::Value > &info)
 
template<class T , std::enable_if_t< std::is_const< T >::value, int > = 0>
void _variable_setter (v8::Local< v8::String > property, v8::Local< v8::Value > value, const v8::PropertyCallbackInfo< void > &info)
 
template<class T >
void expose_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable)
 
template<class T , class... Rest>
void expose_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, std::unique_ptr< T, Rest... > &variable)
 
template<class T >
void expose_variable_readonly (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable)
 
template<class T >
void expose_variable (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable)
 
template<class T >
void expose_variable_readonly (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable)
 
SetWeakCallbackDataglobal_set_weak (v8::Isolate *isolate, const v8::Local< v8::Object > &javascript_object, func::function< void(v8::WeakCallbackInfo< SetWeakCallbackData > const &)> callback, bool destructive)
 
std::string _printf_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline)
 
std::vector< v8::Local< v8::Value > > get_all_values (const v8::FunctionCallbackInfo< v8::Value > &args, int depth=1)
 
std::string _print_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline)
 
void add_print (v8::Isolate *isolate, v8::Local< v8::ObjectTemplate > object_template, func::function< void(const std::string &)>=[](const std::string &s){printf("%s", s.c_str());})
 
void add_print (const v8::Local< v8::Context > context, func::function< void(const std::string &)> callback=[](const std::string &s){printf("%s", s.c_str());})
 
void add_assert (v8::Isolate *isolate, v8::Local< v8::ObjectTemplate > object_template)
 
bool compare_contents (v8::Isolate *isolate, const v8::Local< v8::Value > &left, const v8::Local< v8::Value > &right)
 
template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function< R(Args...)> bind (CLASS &object, R(METHOD_CLASS::*method)(Args...))
 
template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function< R(Args...)> bind (CLASS &object, R(METHOD_CLASS::*method)(Args...)&)
 
template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function< R(Args...)> bind (CLASS &object, R(METHOD_CLASS::*method)(Args...) const &)
 
bool get_file_contents (std::string filename, std::string &file_contents, time_t &file_modification_time)
 
bool get_file_contents (std::string filename, std::string &file_contents)
 
void delete_require_cache_for_isolate (v8::Isolate *isolate)
 
void add_require (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &context, const std::vector< std::string > &paths)
 
void add_module_list (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template)
 
bool require (v8::Local< v8::Context > context, std::string filename, v8::Local< v8::Value > &result, const std::vector< std::string > &paths, bool track_modification_times=false, bool use_cache=true, func::function< void(RequireResult const &)> callback=func::function< void(RequireResult const &)>(), func::function< std::string(std::string const &)> resource_name_callback=func::function< std::string(std::string const &)>())
 
void require_directory (v8::Local< v8::Context > context, std::string directory_name)
 
void dump_prototypes (v8::Isolate *isolate, v8::Local< v8::Object > object)
 
std::vector< std::string > get_interesting_properties (v8::Local< v8::Context > context, v8::Local< v8::Object > object)
 
v8::Local< v8::Value > run_script (v8::Local< v8::Context > context, v8::Local< v8::Script > script)
 
void foreach_file (const std::string &directory_name, std::function< void(const std::string &)> const &callback)
 
void foreach_directory (const std::string &directory_name, std::function< void(const std::string &)> const &callback)
 
std::atomic< int > script_id_counter (0)
 
v8::Local< v8::Context > get_debug_context ()
 
 Isolate::operator v8::Local< v8::ObjectTemplate > ()
 
int get_array_length (v8::Isolate *isolate, v8::Local< v8::Array > array)
 
std::string _format_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline)
 
bool _get_modification_time_of_filename (std::string filename, time_t &modification_time)
 
cached_isolate_modules_tget_loaded_modules (v8::Isolate *isolate)
 
bool compile_source (v8::Local< v8::Context > &context, std::string source, v8::Local< v8::Script > &script, v8::Local< v8::Value > &error, v8::ScriptOrigin *script_origin=nullptr)
 
v8::Local< v8::Value > execute_module (v8::Local< v8::Context > context, const std::string module_source, const v8::ScriptOrigin &script_origin, v8::Local< v8::Function > &compiled_function)
 
void foreach_filesystem_helper (const std::string &directory_name, const volatile bool files, const volatile bool directories, std::function< void(const std::string &)> const &callback)
 
 CAST_TO_NATIVE (WrappedString,{return WrappedString(CastToNative< std::string >()(isolate, value));})
 

Variables

template<class T >
constexpr bool always_false_v = always_false<T>::value
 
template<class T >
constexpr bool is_wrapped_type_v = is_wrapped_type<T>::value
 
template<class T >
constexpr bool cast_to_native_supports_default_value_v = cast_to_native_supports_default_value<T>::value
 
template<class T >
constexpr bool is_wrapped_typeish_v
 
boost::uuids::random_generator uuid_generator
 
V8ClassWrapperInstanceRegistry wrapper_registery
 
std::map< v8::Isolate *, std::vector< std::string > > used_constructor_name_list_map
 
template<auto member>
constexpr bool is_pointer_to_const_data_member_v = get_member_is_readonly(member)
 
bool AnybaseDebugPrintFlag = false
 
std::vector< std::string > reserved_global_names
 
std::mutex require_results_mutex
 
static std::map< v8::Isolate *, cached_isolate_modules_trequire_results
 

Detailed Description

This file contains things needed to create "types" and objects in both C++ and javascript and use them in either environment regardless of where they were created. Since C++ types must exist at compile time, types created with these tools cannot create actual C++ types, but instead allow behavior to be overridden on virtual functions

See samples/bidirectional_sample.cpp for examples on how to use this library.

TODO LIST

All includes should be included as #include "v8toolkit/FILENAME.h" instead of just #include "FILENAME.h" Rename javascript.h file to something much better Including "v8toolkit/v8toolkit.h" should include everything, but specific includes should also work for v8helpers.h, <new name for v8toolkit.h>, <new name for javascript.h>


Class Documentation

struct v8toolkit::AnyPtr

template<class T, class = void>
struct v8toolkit::AnyPtr< T, class >

Definition at line 546 of file v8helpers.h.

struct v8toolkit::Bind

template<class>
struct v8toolkit::Bind< class >

Accepts an object and a method on that object to be called later via its operator() Does not require knowledge of how many parameters the method takes or any placeholder arguments Can be wrapped with a func::function

Definition at line 770 of file v8toolkit.h.

struct v8toolkit::CallCallable

template<class Function, class... T>
struct v8toolkit::CallCallable< Function, T >

Definition at line 21 of file call_callable.h.

struct v8toolkit::CastToJS

template<typename T, class = void>
struct v8toolkit::CastToJS< T, class >

Casts from a native type to a boxed Javascript type

Definition at line 507 of file casts.hpp.

struct v8toolkit::CastTupleToJS

template<int position, class T>
struct v8toolkit::CastTupleToJS< position, T >

Definition at line 906 of file casts.hpp.

class v8toolkit::CppFactory

template<class Base, class Child, class ExternalTypeList = TypeList<>, template< class, class... > class ParentType = FlexibleParent, class FactoryBase = EmptyFactoryBase>
class v8toolkit::CppFactory< Base, Child, ExternalTypeList, ParentType, FactoryBase >

Returns a pure-C++ object of type Child which inherits from type Base. It's Base type and ConstructorArgs... must match with the Factory it is associated with. You can have it inherit from a type that inherits from v8toolkit::Factory but v8toolkit::Factory must be in the inheritance chain somewhere

Definition at line 110 of file sample.cpp.

class v8toolkit::EmptyFactoryBase

Class for Factory to inherit from when no other parent is specified Must be empty

Definition at line 63 of file sample2.h.

class v8toolkit::Factory

template<class Base, class = TypeList<>, class FactoryBase = EmptyFactoryBase, class Deleter = std::default_delete<Base>>
class v8toolkit::Factory< Base, class, FactoryBase, Deleter >

Common Factory Inheritance goes: v8toolkit::CppFactory => custom user-defined Factory type for additional data/functions => v8toolkit::Factory => v8toolkit::Factory<BaseType> => Common base type for all factories Internal constructor parameters are parameters only on the Base type constructor that are not specified to each instance of the derived type. The value is fixed across all isntances of the specific derived type.

External constructor parameters are parameers are all the parameters to the derived type (except an optional first parameter of the factory object which will be automatically populated) Base class for a Factory that creates a bidirectional "type" by name. The object returned can be used as a class T regardless of whether it is a pure C++ type or if it has been extended in javascript

Definition at line 159 of file bidirectional.h.

struct v8toolkit::FunctionTemplateData

template<class R, class... Args>
struct v8toolkit::FunctionTemplateData< R, Args >

Struct of data passed down through building the parameters to call the function and actually calling the function

Definition at line 344 of file v8toolkit.h.

Collaboration diagram for v8toolkit::FunctionTemplateData< R, Args >:
Class Members
callable
string name
class v8toolkit::JSFactory

template<class Base, class JSWrapperClass, class Internal, class External, class FactoryBase = Factory<Base, External, EmptyFactoryBase>, class Deleter = std::default_delete<JSWrapperClass>>
class v8toolkit::JSFactory< Base, JSWrapperClass, Internal, External, FactoryBase, Deleter >

Returns a JavaScript-extended object inheriting from Base. It's Base type and *ConstructorParams must match up with the Factory class it is associated

InternalConstructorParams are ones that will be specified in the javascript code declaring the new type

ExternalConstructorParams will be potentially change for each instance of that type

Example of internal vs external parameters: if the base type is "animal" and it takes two parameters "is_mammal" and "name". Whether or not the derived type is a mammal is known when making the derived type so it would be an internal parameter, while the name isn't known until the object is constructed so it would be an external parameter.

Perhaps the order should be swapped to take external first, since that is maybe more common?

Definition at line 290 of file bidirectional.h.

struct v8toolkit::MapperHelper

template<class Container, class Callable>
struct v8toolkit::MapperHelper< Container, Callable >

Takes a container, runs each element through Callable and returns a new container of the same container type but with a data type matching the returned type of the Callable

Definition at line 418 of file v8helpers.h.

struct v8toolkit::ParameterBuilder

template<class T, class = void>
struct v8toolkit::ParameterBuilder< T, class >

Used by CallCallable to build an actual list of values to send to a function. Each call to ParameterBuilder is responsible for one parameter.

If the parameter isn't self contained (like a char *), then the memory allocated for it will be stored in stuff which is automatically cleaned up when the function returns.

If no explicit parameter is provided from JavaScript, a default value may be available in default_args_tuple

Definition at line 35 of file parameter_builder.h.

struct v8toolkit::ProxyType

template<typename T, typename = void>
struct v8toolkit::ProxyType< T, typename >

Definition at line 119 of file v8helpers.h.

Class Members
typedef T PROXY_TYPE
struct v8toolkit::ProxyType< T, void_t< typename T::V8TOOLKIT_PROXY_TYPE > >

template<typename T>
struct v8toolkit::ProxyType< T, void_t< typename T::V8TOOLKIT_PROXY_TYPE > >

Definition at line 124 of file v8helpers.h.

Class Members
typedef typename
V8TOOLKIT_PROXY_TYPE
PROXY_TYPE
struct v8toolkit::remove_const_from_reference

template<class T>
struct v8toolkit::remove_const_from_reference< T >

Definition at line 319 of file v8toolkit.h.

Class Members
typedef T type
struct v8toolkit::remove_const_from_reference< T const >

template<class T>
struct v8toolkit::remove_const_from_reference< T const >

Definition at line 330 of file v8toolkit.h.

Class Members
typedef T type
struct v8toolkit::remove_const_from_reference< T const & >

template<class T>
struct v8toolkit::remove_const_from_reference< T const & >

Definition at line 325 of file v8toolkit.h.

Class Members
typedef T && type
struct v8toolkit::static_all_of

template<bool... b>
struct v8toolkit::static_all_of< b >

Definition at line 275 of file v8helpers.h.

struct v8toolkit::static_any

template<bool... b>
struct v8toolkit::static_any< b >

Definition at line 262 of file v8helpers.h.

struct v8toolkit::TypeChecker

template<class, class, class = void>
struct v8toolkit::TypeChecker< class, class, class >

Definition at line 190 of file v8_class_wrapper.h.

struct v8toolkit::TypeList

template<class...>
struct v8toolkit::TypeList<... >

Definition at line 73 of file sample2.h.

class v8toolkit::V8ClassWrapper

template<class T>
class v8toolkit::V8ClassWrapper< T >

Provides a mechanism for creating javascript-ready objects from an arbitrary C++ class Can provide a JS constructor method or wrap objects created in another c++ function

Const types should not be wrapped directly. Instead, a const version of a non-const type will automatically be created and populated with read-only members and any const-qualified method added to the non-const version.

All members/methods must be added, then finalize() called, then any desired constructors may be created.

Definition at line 16 of file sample2.h.

struct v8toolkit::WrapAsMostDerived

template<class, class, class = void>
struct v8toolkit::WrapAsMostDerived< class, class, class >

Definition at line 160 of file v8_class_wrapper.h.

Typedef Documentation

using v8toolkit::ScriptPtr = typedef std::shared_ptr<Script>

Definition at line 26 of file javascript.h.

using v8toolkit::ContextPtr = typedef std::shared_ptr<Context>

Definition at line 367 of file javascript.h.

using v8toolkit::IsolatePtr = typedef std::shared_ptr<Isolate>

Definition at line 651 of file javascript.h.

using v8toolkit::StdFunctionCallbackType = typedef func::function<void(const v8::FunctionCallbackInfo<v8::Value>& info)>

Definition at line 42 of file v8helpers.h.

template<class T >
using v8toolkit::void_t = typedef void

Definition at line 62 of file v8helpers.h.

template<class T >
using v8toolkit::int_t = typedef int

Definition at line 65 of file v8helpers.h.

template<class T >
using v8toolkit::remove_const_from_reference_t = typedef typename remove_const_from_reference<T>::type

Definition at line 336 of file v8toolkit.h.

using v8toolkit::json = typedef nlohmann::json

Definition at line 16 of file debugger.cpp.

typedef std::map<std::string, RequireResult> v8toolkit::cached_isolate_modules_t

Definition at line 337 of file v8toolkit.cpp.

Enumeration Type Documentation

anonymous enum
Enumerator
kDebugIdIndex 
kModuleEmbedderDataIndex 
kInspectorClientIndex 

Definition at line 263 of file debugger.h.

Function Documentation

template<class T >
std::enable_if_t<std::is_base_of<JSWrapperBase, T>::value, v8::Local<v8::Object> > v8toolkit::safe_get_javascript_object ( T *  object)

Definition at line 89 of file bidirectional.h.

Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::wrap_existing_cpp_object().

Here is the caller graph for this function:

template<class T >
std::enable_if_t<!std::is_base_of<JSWrapperBase, T>::value, v8::Local<v8::Object> > v8toolkit::safe_get_javascript_object ( T *  object)

Definition at line 94 of file bidirectional.h.

v8toolkit::CAST_TO_NATIVE ( bool  ,
{HANDLE_FUNCTION_VALUES;return static_cast< bool >(value->ToBoolean() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( long  long,
{HANDLE_FUNCTION_VALUES;return static_cast< long long >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( unsigned long  long,
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long long >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( long  ,
{HANDLE_FUNCTION_VALUES;return static_cast< long >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( unsigned  long,
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( int  ,
{HANDLE_FUNCTION_VALUES;return static_cast< int >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( unsigned  int,
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned int >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( short  ,
{HANDLE_FUNCTION_VALUES;return static_cast< short >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( unsigned  short,
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned short >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( char  ,
{HANDLE_FUNCTION_VALUES;return static_cast< char >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( unsigned  char,
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned char >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( wchar_t  ,
{HANDLE_FUNCTION_VALUES;return static_cast< wchar_t >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( char16_t  ,
{HANDLE_FUNCTION_VALUES;return static_cast< char16_t >(value->ToInteger() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( char32_t  ,
{HANDLE_FUNCTION_VALUES;return static_cast< char32_t >(value->ToInteger() ->Value());}   
)
template<class... Ts, std::size_t... Is>
std::tuple<Ts...> v8toolkit::cast_to_native_tuple_helper ( v8::Isolate *  isolate,
v8::Local< v8::Array >  array,
std::tuple< Ts... >  ,
std::index_sequence< Is... >   
)

Definition at line 170 of file casts.hpp.

Referenced by v8toolkit::CastToNative< std::tuple< Ts... > >::operator()().

Here is the caller graph for this function:

template<template< class, class > class ContainerTemplate, class FirstT , class SecondT >
ContainerTemplate<FirstT, SecondT> v8toolkit::pair_type_helper ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
)

Definition at line 223 of file casts.hpp.

References get_array_length(), HANDLE_FUNCTION_VALUES, and stringify_value().

Here is the call graph for this function:

v8toolkit::CAST_TO_NATIVE ( float  ,
{HANDLE_FUNCTION_VALUES;return static_cast< float >(value->ToNumber() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( double  ,
{HANDLE_FUNCTION_VALUES;return static_cast< double >(value->ToNumber() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( long  double,
{HANDLE_FUNCTION_VALUES;return static_cast< long double >(value->ToNumber() ->Value());}   
)
v8toolkit::CAST_TO_NATIVE ( std::string  ,
{HANDLE_FUNCTION_VALUES;return std::string(*v8::String::Utf8Value(value));}   
)
template<template< class, class... > class VectorTemplate, class T , class... Rest>
auto v8toolkit::vector_type_helper ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
) -> VectorTemplate<std::remove_reference_t<std::result_of_t<CastToNative<T>(v8::Isolate *, v8::Local<v8::Value>)>>, Rest...>
template<template< class, class... > class SetTemplate, class T , class... Rest>
auto v8toolkit::set_type_helper ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
) -> SetTemplate<std::remove_reference_t<std::result_of_t<CastToNative<T>(v8::Isolate *, v8::Local<v8::Value>)>>, Rest...>

Definition at line 332 of file casts.hpp.

template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest>
ContainerTemplate<Key, Value, Rest...> v8toolkit::map_type_helper ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
)
template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest>
ContainerTemplate<Key, Value, Rest...> v8toolkit::multimap_type_helper ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
)
v8toolkit::CAST_TO_JS ( bool  ,
{return v8::Boolean::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( char  ,
{return v8::Integer::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( unsigned  char,
{return v8::Integer::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( wchar_t  ,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( char16_t  ,
{return v8::Integer::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( char32_t  ,
{return v8::Integer::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( short  ,
{return v8::Integer::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( int  ,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( unsigned  int,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( long  ,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( long  long,
{return v8::Number::New(isolate, static_cast< double >(value));}   
)
v8toolkit::CAST_TO_JS ( unsigned long  long,
{return v8::Number::New(isolate, static_cast< double >(value));}   
)
v8toolkit::CAST_TO_JS ( float  ,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( double  ,
{return v8::Number::New(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( std::string  ,
{return v8::String::NewFromUtf8(isolate, value.c_str(), v8::String::kNormalString, value.length());}   
)
v8toolkit::CAST_TO_JS ( char *  ,
{return v8::String::NewFromUtf8(isolate, value);}   
)
v8toolkit::CAST_TO_JS ( char const *  ,
{return v8::String::NewFromUtf8(isolate, value);}   
)
template<template< class, class, class... > class MapTemplate, class KeyType , class ValueType , class ReferenceTypeIndicator , class... Rest>
v8::Local<v8::Value> v8toolkit::cast_to_js_map_helper ( v8::Isolate *  isolate,
MapTemplate< KeyType, ValueType, Rest... > const &  map 
)
template<template< class... > class VectorTemplate, class ValueType , class... Rest>
v8::Local<v8::Value> v8toolkit::cast_to_js_vector_helper ( v8::Isolate *  isolate,
VectorTemplate< std::remove_reference_t< ValueType >, Rest... > const &  vector 
)
template<template< class, class, class... > class MultiMapLike, class A , class B , class... Rest>
v8::Local<v8::Object> v8toolkit::casttojs_multimaplike ( v8::Isolate *  isolate,
MultiMapLike< A, B, Rest... > const &  map 
)

Definition at line 846 of file casts.hpp.

References testing::A().

Referenced by v8toolkit::CastToJS< eastl::vector_multimap< A, B, Rest... > >::operator()(), and v8toolkit::CastToJS< std::multimap< A, B, Rest... > >::operator()().

Here is the call graph for this function:

Here is the caller graph for this function:

v8toolkit::CAST_TO_NATIVE ( eastl::string  ,
{HANDLE_FUNCTION_VALUES;return eastl::string(*v8::String::Utf8Value(value));}   
)
v8toolkit::CAST_TO_JS ( eastl::string  ,
{return v8::String::NewFromUtf8(isolate, value.c_str());}   
)
template<class T , int default_arg_position = -1, class DefaultArgsTuple = std::tuple<>>
T* v8toolkit::get_default_parameter ( const v8::FunctionCallbackInfo< v8::Value > &  info,
int &  i,
std::vector< std::unique_ptr< StuffBase >> &  stuff,
DefaultArgsTuple &&  default_args_tuple 
)

Definition at line 38 of file unspecified_parameter_value.h.

template<class T >
std::string v8toolkit::type_details ( )

Definition at line 1842 of file v8_class_wrapper.h.

template<class T , std::enable_if_t< std::is_pointer< T >::value||std::is_reference< T >::value, int > = 0>
T& v8toolkit::get_object_from_embedded_cpp_object ( v8::Isolate *  isolate,
v8::Local< v8::Value >  value 
)

This can be used from CastToNative<UserType> calls to fall back to if other conversions aren't appropriate

Definition at line 1851 of file v8_class_wrapper.h.

References check_value_is_object(), and V8TOOLKIT_DEBUG.

Here is the call graph for this function:

template<class MemberT , class ClassT >
constexpr bool v8toolkit::get_member_is_readonly ( MemberTClassT::*  member)

Definition at line 32 of file v8helpers.h.

std::string v8toolkit::get_stack_trace_string ( v8::Local< v8::StackTrace >  stack_trace)

Returns a string with the given stack trace and a leading and trailing newline

Parameters
stack_tracestack trace to return a string representation of
Returns
string representation of the given stack trace

Definition at line 28 of file v8helpers.cpp.

template<class ReturnType , class... Args, class... Ts>
auto v8toolkit::run_function ( func::function< ReturnType(Args...)> &  function,
const v8::FunctionCallbackInfo< v8::Value > &  info,
Ts &&...  ts 
) -> ReturnType
template<class ReturnType , class... Args, class Callable , class... Ts>
auto v8toolkit::run_function ( Callable  callable,
const v8::FunctionCallbackInfo< v8::Value > &  info,
Ts &&...  ts 
) -> ReturnType

Definition at line 98 of file v8helpers.h.

void v8toolkit::ReportException ( v8::Isolate *  isolate,
v8::TryCatch *  try_catch 
)
std::string v8toolkit::demangle_typeid_name ( const std::string &  mangled_name)

Returns a demangled version of the typeid(T).name() passed in if it knows how, otherwise returns the mangled name exactly as passed in

Definition at line 45 of file v8helpers.cpp.

Referenced by demangle(), v8toolkit::CastToJS< T *, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), and v8toolkit::ParameterBuilder< T, std::enable_if_t< std::is_copy_constructible_v< T > &&is_wrapped_type_v< T > > >::operator()().

Here is the caller graph for this function:

template<class T >
std::string& v8toolkit::demangle ( )

Definition at line 145 of file v8helpers.h.

References demangle_typeid_name().

Referenced by v8toolkit::CastToNative< std::tuple< Ts... > >::operator()().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Destination , class Source , std::enable_if_t< std::is_polymorphic< Source >::value, int > = 0>
Destination v8toolkit::safe_dynamic_cast ( Source *  source)

Definition at line 168 of file v8helpers.h.

Referenced by v8toolkit::CastToJS< T *, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), and safe_dynamic_cast().

Here is the caller graph for this function:

template<class Destination >
Destination* v8toolkit::safe_dynamic_cast ( Destination *  source)

Definition at line 178 of file v8helpers.h.

References safe_dynamic_cast().

Here is the call graph for this function:

template<class T , std::enable_if_t< SAFE_MOVE_CONSTRUCTOR_SFINAE, int > = 0>
std::unique_ptr< T > v8toolkit::safe_move_constructor ( T &&  original)

Definition at line 194 of file v8helpers.h.

References testing::internal::move(), and testing::Ref().

Here is the call graph for this function:

template<class R , class... Ts>
auto v8toolkit::get_typelist_for_function ( func::function< R(Ts...)>  ) -> TypeList< Ts... >
template<class R , class Head , class... Tail>
auto v8toolkit::get_typelist_for_function_strip_first ( func::function< R(Head, Tail...)>  ) -> TypeList< Tail... >
template<class... Ts>
auto v8toolkit::get_typelist_for_variables ( Ts...  ts) -> TypeList< Ts... >
template<class... Ts>
auto v8toolkit::make_tuple_for_variables ( Ts &&...  ts) -> std::tuple<Ts...>

Definition at line 257 of file v8helpers.h.

void v8toolkit::print_v8_value_details ( v8::Local< v8::Value >  local_value)

prints out a ton of info about a v8::Value

Definition at line 129 of file v8helpers.cpp.

Referenced by check_value_is_object(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().

Here is the caller graph for this function:

int v8toolkit::get_array_length ( v8::Isolate *  isolate,
v8::Local< v8::Value >  array_value 
)

Returns the length of an array

Definition at line 85 of file v8helpers.cpp.

Referenced by compare_contents(), for_each_value(), make_set_from_object_keys(), pair_type_helper(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().

Here is the caller graph for this function:

std::set< std::string > v8toolkit::make_set_from_object_keys ( v8::Isolate *  isolate,
v8::Local< v8::Object > &  object,
bool  own_properties_only = true 
)

Definition at line 160 of file v8helpers.cpp.

References get_array_length().

Referenced by compare_contents(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Callable >
void v8toolkit::for_each_value ( const v8::Local< v8::Context >  context,
const v8::Local< v8::Value >  value,
Callable  callable 
)

d When passed a value representing an array, runs callable with each element of that array (but not on arrays contained within the outer array) On any other object type, runs callable with that element

Definition at line 349 of file v8helpers.h.

References call_simple_javascript_function(), expose_gc(), get_array_length(), get_type_string_for_value(), process_v8_flags(), and set_global_object_alias().

Referenced by for_each_own_property(), and multimap_type_helper().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::set_global_object_alias ( v8::Isolate *  isolate,
const v8::Local< v8::Context >  context,
std::string  alias_name 
)

Creates a variable with the given alias_name in the context's global object to point back to the global object Same as node.js "global" variable or a web browser "window" object

Definition at line 96 of file v8helpers.cpp.

Referenced by for_each_value().

Here is the caller graph for this function:

std::string v8toolkit::get_type_string_for_value ( v8::Local< v8::Value >  value)

Returns a string corresponding to the type of the value passed

Parameters
valuethe value whose type to return a string version of
Returns
a string for the type of value

Definition at line 104 of file v8helpers.cpp.

Referenced by for_each_value().

Here is the caller graph for this function:

void v8toolkit::process_v8_flags ( int &  argc,
char **  argv 
)

parses v8-related flags and removes them, adjusting argc as needed

Definition at line 46 of file v8toolkit.cpp.

Referenced by for_each_value(), and v8toolkit::Platform::init().

Here is the caller graph for this function:

void v8toolkit::expose_gc ( )

exposes the garbage collector to javascript same as passing –expose-gc as a command-line flag To encourage the javascript garbage collector to run from c++ code, use: while(!v8::Isolate::IdleNotificationDeadline([time])) {};

Definition at line 52 of file v8toolkit.cpp.

Referenced by for_each_value(), and v8toolkit::Platform::init().

Here is the caller graph for this function:

v8::Local< v8::Value > v8toolkit::call_simple_javascript_function ( v8::Isolate *  isolate,
v8::Local< v8::Function >  function 
)

Definition at line 299 of file v8helpers.cpp.

References ReportException().

Referenced by for_each_value().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void v8toolkit::for_each_own_property ( const v8::Local< v8::Context >  context,
const v8::Local< v8::Object >  object,
callable 
)

Calls callable with each javascript "own property" in the object passed.

Definition at line 399 of file v8helpers.h.

References for_each_value().

Referenced by map_type_helper(), and multimap_type_helper().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Container , class Callable >
auto v8toolkit::mapper ( const Container &  container,
Callable  callable 
) -> decltype(MapperHelper<Container, Callable>()(container, callable))

IF YOU GET AN ERROR ABOUT RESULT_OF::TYPE NOT EXISTING, MAKE SURE YOUR LAMBDA PARAMETER TYPE IS EXACTLY RIGHT, ESPECTIALLY RE; CONST

Parameters
containerinput container
callabletransformation callback
Returns
container of the transformed results

Definition at line 479 of file v8helpers.h.

template<class Callable , class Container >
auto v8toolkit::reducer ( const Container &  container,
Callable  callable 
) -> std::vector<typename std::result_of<Callable(typename Container::value_type)>::type>

Definition at line 487 of file v8helpers.h.

template<class T >
v8::Local<T> v8toolkit::get_value_as ( v8::Local< v8::Value >  value)

Definition at line 594 of file v8helpers.h.

template<class T >
v8::Local<T> v8toolkit::get_value_as ( v8::Isolate *  isolate,
v8::Global< v8::Value > &  value 
)

Definition at line 626 of file v8helpers.h.

template<class T >
v8::Local<T> v8toolkit::get_key_as ( v8::Local< v8::Context >  context,
v8::Local< v8::Object >  object,
std::string  key 
)

Definition at line 634 of file v8helpers.h.

template<class T >
v8::Local<T> v8toolkit::get_key_as ( v8::Local< v8::Context >  context,
v8::Local< v8::Value >  object,
std::string  key 
)

Definition at line 654 of file v8helpers.h.

References get_key(), global_name_conflicts(), reserved_global_names, and stringify_value().

Here is the call graph for this function:

v8::Local< v8::Value > v8toolkit::get_key ( v8::Local< v8::Context >  context,
v8::Local< v8::Object >  object,
std::string  key 
)

Definition at line 289 of file v8helpers.cpp.

Referenced by get_key_as().

Here is the caller graph for this function:

v8::Local< v8::Value > v8toolkit::get_key ( v8::Local< v8::Context >  context,
v8::Local< v8::Value >  value,
std::string  key 
)

Definition at line 293 of file v8helpers.cpp.

std::string v8toolkit::stringify_value ( v8::Isolate *  isolate,
const v8::Local< v8::Value > &  value,
bool  show_all_properties = false,
std::vector< v8::Local< v8::Value >> &&  processed_values = std::vector<v8::Local<v8::Value>>{} 
)

Takes a v8::Value and prints it out in a json-like form (but includes non-json types like function)

Good for looking at the contents of a value and also used for printobj() method added by add_print

Definition at line 187 of file v8helpers.cpp.

References get_array_length(), make_set_from_object_keys(), testing::internal::move(), print_v8_value_details(), STRINGIFY_VALUE_DEBUG, and testing::Value().

Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::_add_method(), v8toolkit::Isolate::add_assert(), add_print(), add_require(), compile_source(), JavaScriptFixture::create_context(), dump_prototypes(), get_key_as(), map_type_helper(), multimap_type_helper(), v8toolkit::CastToNative< v8::Local< v8::Function > >::operator()(), and pair_type_helper().

Here is the call graph for this function:

Here is the caller graph for this function:

bool v8toolkit::global_name_conflicts ( const std::string &  name)

Tests if the given name conflicts with a reserved javascript top-level name

Parameters
namevalue to check
Returns
true if there is a conflict

Definition at line 358 of file v8helpers.cpp.

Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::expose_static_methods(), and get_key_as().

Here is the caller graph for this function:

v8::Local<v8::Object> v8toolkit::check_value_is_object ( v8::Local< v8::Value >  value,
std::string const &  class_name 
)
inline
template<class T >
auto v8toolkit::scoped_run ( v8::Isolate *  isolate,
callable 
) -> typename std::result_of<T()>::type

Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created

Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created The isolate will be passed to the callable

Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created This version requires the isolate is currently in a context The isolate and context will be passed to the callable

Definition at line 111 of file v8toolkit.h.

Referenced by add_module_list(), v8toolkit::Isolate::operator()(), v8toolkit::Context::require_directory(), and scoped_run().

Here is the caller graph for this function:

template<class T >
auto v8toolkit::scoped_run ( v8::Isolate *  isolate,
v8::Local< v8::Context >  context,
callable 
) -> typename std::result_of<T()>::type

Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used

Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used The isolate will be passed to the callable

Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used The isolate and context will be passed to the callable

Definition at line 175 of file v8toolkit.h.

References scoped_run().

Here is the call graph for this function:

template<class T >
auto v8toolkit::scoped_run ( v8::Isolate *  isolate,
const v8::Global< v8::Context > &  context,
callable 
)

Definition at line 228 of file v8toolkit.h.

References scoped_run().

Here is the call graph for this function:

template<class R , class... Args>
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template ( v8::Isolate *  isolate,
func::function< R(Args...)>  f,
std::string const &  name 
)

Creates a function template from a func::function

Definition at line 356 of file v8toolkit.h.

References testing::Args().

Referenced by add_function(), v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::add_static_method(), and make_function_template().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class R , class CLASS , class... Args>
func::function<R(Args...)> v8toolkit::make_std_function_from_callable ( R(CLASS::*)(Args...) const  f,
CLASS  callable 
)

Takes an arbitrary class method and returns a func::function wrapping it

Definition at line 393 of file v8toolkit.h.

References testing::Args().

Referenced by make_function_template().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class R , class... Args>
func::function<R(Args...)> v8toolkit::make_std_function_from_callable ( R(*)(Args...)  callable,
std::string  name 
)

Definition at line 401 of file v8toolkit.h.

References testing::Args().

Here is the call graph for this function:

template<class T >
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template ( v8::Isolate *  isolate,
callable,
std::string  name 
)

Creates a v8::FunctionTemplate for an arbitrary callable

Definition at line 410 of file v8toolkit.h.

References testing::Args(), make_function_template(), and make_std_function_from_callable().

Here is the call graph for this function:

template<class R , class... Args>
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template ( v8::Isolate *  isolate,
R(*)(Args...)  f,
std::string const &  name 
)

Creates a function template from a c-style function pointer

Definition at line 420 of file v8toolkit.h.

References testing::Args(), and make_function_template().

Here is the call graph for this function:

template<class R , class... Args>
void v8toolkit::add_function ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
func::function< R(Args...)>  function 
)

Helper to both create a function template from a func::function and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context

Definition at line 431 of file v8toolkit.h.

References make_function_template().

Referenced by add_assert(), v8toolkit::Context::add_function(), add_function(), v8toolkit::Isolate::add_function(), add_module_list(), add_print(), and add_require().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void v8toolkit::add_function ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
callable 
)

Helper to both create a function template from an arbitrary callable and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context

Definition at line 440 of file v8toolkit.h.

References testing::Args(), and make_function_template().

Here is the call graph for this function:

template<class R , class... Args>
void v8toolkit::add_function ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
R(*)(Args...)  function 
)

Helper to both create a function template from an arbitrary function pointer and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context

Definition at line 450 of file v8toolkit.h.

References make_function_template().

Here is the call graph for this function:

template<class T >
void v8toolkit::add_function ( const v8::Local< v8::Context > &  context,
const v8::Local< v8::Object > &  object,
const char *  name,
callable 
)

Helper to both create a function template from an arbitrary callable and bind it with the specified name to the specified object template Adding functions to an object allows adding a function to any object, including a context's global object.

Definition at line 460 of file v8toolkit.h.

References add_function(), add_variable(), CONTEXT_SCOPED_RUN, and make_function_template().

Here is the call graph for this function:

void v8toolkit::add_variable ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
const v8::Local< v8::Data >  value 
)

Makes the given javascript value available to all objects created with the object_template as name. Often used to populate the object_template used to create v8::Context objects so the variable is available from all contexts created from that object_template

Definition at line 65 of file v8toolkit.cpp.

Referenced by add_function(), v8toolkit::Context::add_variable(), v8toolkit::Isolate::add_variable(), and execute_module().

Here is the caller graph for this function:

void v8toolkit::add_variable ( const v8::Local< v8::Context >  context,
const v8::Local< v8::Object > &  object,
const char *  name,
const v8::Local< v8::Value >  value 
)

Makes the given javascript value available in the given object as name. Often used to add a variable to a specific context's global object

Definition at line 71 of file v8toolkit.cpp.

void v8toolkit::add_function ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
void(*)(const v8::FunctionCallbackInfo< v8::Value > &)  function 
)

add a function that directly handles the v8 callback data explicit function typing needed to coerce non-capturing lambdas into c-style function pointers

Definition at line 78 of file v8toolkit.cpp.

References make_function_template().

Here is the call graph for this function:

template<class... OriginalTypes, class... Ts>
v8::Local<v8::Value> v8toolkit::call_javascript_function_with_vars ( const v8::Local< v8::Context >  context,
const v8::Local< v8::Function >  function,
const v8::Local< v8::Object >  receiver,
const TypeList< OriginalTypes... > &  type_list,
Ts &&...  ts 
)

Definition at line 524 of file v8toolkit.h.

References ReportException().

Referenced by v8toolkit::JSFactory< Base, JSWrapperClass, TypeList< InternalConstructorParams... >, TypeList< ExternalConstructorParams... >, FactoryBase, Deleter >::JSFactory().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TupleType = std::tuple<>>
v8::Local<v8::Value> v8toolkit::call_javascript_function ( const v8::Local< v8::Context >  context,
const v8::Local< v8::Function >  function,
const v8::Local< v8::Object >  receiver,
const TupleType &  tuple = {} 
)

Returns true on success with the result in the "result" parameter

Definition at line 550 of file v8toolkit.h.

References ReportException().

Referenced by call_javascript_function().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TupleType = std::tuple<>>
v8::Local<v8::Value> v8toolkit::call_javascript_function ( const v8::Local< v8::Context >  context,
const std::string &  function_name,
const v8::Local< v8::Object >  receiver,
const TupleType &  tuple = {} 
)

Returns true on success with the result in the "result" parameter

Definition at line 576 of file v8toolkit.h.

References call_javascript_function().

Here is the call graph for this function:

template<class T >
void v8toolkit::_variable_getter ( v8::Local< v8::String >  property,
const v8::PropertyCallbackInfo< v8::Value > &  info 
)

Definition at line 597 of file v8toolkit.h.

Referenced by expose_variable().

Here is the caller graph for this function:

template<class T , std::enable_if_t< std::is_const< T >::value, int > = 0>
void v8toolkit::_variable_setter ( v8::Local< v8::String >  property,
v8::Local< v8::Value >  value,
const v8::PropertyCallbackInfo< void > &  info 
)

Definition at line 613 of file v8toolkit.h.

Referenced by expose_variable().

Here is the caller graph for this function:

template<class T >
void v8toolkit::expose_variable ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
T &  variable 
)

Exposes the specified variable to javascript as the specified name in the given object template (usually the global template). Allows reads and writes to the variable

Definition at line 642 of file v8toolkit.h.

Referenced by v8toolkit::Context::expose_variable(), and v8toolkit::Isolate::expose_variable().

Here is the caller graph for this function:

template<class T , class... Rest>
void v8toolkit::expose_variable ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
std::unique_ptr< T, Rest... > &  variable 
)

Definition at line 651 of file v8toolkit.h.

References _variable_getter(), and _variable_setter().

Here is the call graph for this function:

template<class T >
void v8toolkit::expose_variable_readonly ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template,
const char *  name,
T &  variable 
)

Exposes the specified variable to javascript as the specified name in the given object template (usually the global template). Allows reads to the variable. Writes are ignored. TODO: consider making writes errors (throw?)

Definition at line 669 of file v8toolkit.h.

Referenced by v8toolkit::Context::expose_variable_readonly(), and v8toolkit::Isolate::expose_variable_readonly().

Here is the caller graph for this function:

template<class T >
void v8toolkit::expose_variable ( v8::Local< v8::Context >  context,
const v8::Local< v8::Object > &  object,
const char *  name,
T &  variable 
)

Exposes the C++ variable 'variable' to a specific javascript object as a read/write variable Often used to add the variable to a context's global object

Definition at line 681 of file v8toolkit.h.

template<class T >
void v8toolkit::expose_variable_readonly ( v8::Local< v8::Context >  context,
const v8::Local< v8::Object > &  object,
const char *  name,
T &  variable 
)

Exposes the C++ variable 'variable' to a specific javascript object as a read-only variable (writes are ignored but are not errors) TODO: consider making them errors (throw?) Often used to add the variable to a context's global object

Definition at line 695 of file v8toolkit.h.

References _print_helper(), _printf_helper(), add_assert(), add_print(), v8toolkit::SetWeakCallbackData::callback, compare_contents(), v8toolkit::SetWeakCallbackData::destructive, get_all_values(), and global_set_weak().

Here is the call graph for this function:

SetWeakCallbackData * v8toolkit::global_set_weak ( v8::Isolate *  isolate,
const v8::Local< v8::Object > &  javascript_object,
func::function< void(v8::WeakCallbackInfo< SetWeakCallbackData > const &)>  callback,
bool  destructive 
)

Takes a local and creates a weak global reference callback for it Useful for clearing out C++-allocated memory on javascript garbage collection of an associated javascript object Remember, this is not guaranteed to ever be called

Definition at line 863 of file v8toolkit.cpp.

References v8toolkit::SetWeakCallbackData::callback, v8toolkit::SetWeakCallbackData::global, and v8toolkit::SetWeakCallbackData::SetWeakCallbackData().

Referenced by expose_variable_readonly(), and v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::initialize_new_js_object().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string v8toolkit::_printf_helper ( const v8::FunctionCallbackInfo< v8::Value > &  args,
bool  append_newline 
)

Definition at line 116 of file v8toolkit.cpp.

References _format_helper().

Referenced by add_print(), and expose_variable_readonly().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< v8::Local< v8::Value > > v8toolkit::get_all_values ( const v8::FunctionCallbackInfo< v8::Value > &  args,
int  depth = 1 
)

Returns the values in a FunctionCallbackInfo object breaking out first-level arrays into their contained values (but not subsequent arrays for no particular reason)

Definition at line 123 of file v8toolkit.cpp.

Referenced by _format_helper(), _print_helper(), and expose_variable_readonly().

Here is the caller graph for this function:

std::string v8toolkit::_print_helper ( const v8::FunctionCallbackInfo< v8::Value > &  args,
bool  append_newline 
)

Definition at line 147 of file v8toolkit.cpp.

References get_all_values().

Referenced by add_print(), and expose_variable_readonly().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::add_print ( v8::Isolate *  isolate,
v8::Local< v8::ObjectTemplate >  object_template,
func::function< void(const std::string &)>  callback = [](const std::string & s){printf("%s", s.c_str());} 
)

Adds the print functions listed below to the given object_template (usually a v8::Context's global object) Optional callback function can be used to send the output to another source (defaults to stdout)

call this to add a set of print* functions to whatever object template you pass in (probably the global one) print takes a single variable or an array and prints each value separated by spaces

println same as print but automatically appends a newlines

printf - Treats the first parameter as a format string. any additional values will be used to fill the format string. If there are insufficient parameters to fill the format, the empty string "" will be used. Any extra parameters will be printed after the filled format string separated by spaces

printfln - same as printf but automatically appends a newline

printobj - prints a bunch of information about an object - format highly susceptible to frequent change

Definition at line 166 of file v8toolkit.cpp.

References _format_helper(), _print_helper(), _printf_helper(), add_function(), and stringify_value().

Referenced by v8toolkit::Isolate::add_print(), and expose_variable_readonly().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::add_print ( const v8::Local< v8::Context >  context,
func::function< void(const std::string &)>  callback = [](const std::string & s){printf("%s", s.c_str());} 
)

Definition at line 189 of file v8toolkit.cpp.

References _format_helper(), _print_helper(), _printf_helper(), add_function(), and stringify_value().

Here is the call graph for this function:

void v8toolkit::add_assert ( v8::Isolate *  isolate,
v8::Local< v8::ObjectTemplate >  object_template 
)

Adds an assert method that calls assert.h assert() on failure. This is different than the add_assert() in javascript.h that throws an exception on failure because if an exception is not caught before it reaches V8 execution, the program is terminated. javascript.h *Helper classes automatically catch and re-throw exceptions so it is safe to throw in that version, but not this one. The error message resulting from throwing an exception reaching code compiled without exception support is not easy to understand which is why a simple assert is preferable.

Definition at line 212 of file v8toolkit.cpp.

References add_function(), and V8_TOOLKIT_DEBUG.

Referenced by expose_variable_readonly().

Here is the call graph for this function:

Here is the caller graph for this function:

bool v8toolkit::compare_contents ( v8::Isolate *  isolate,
const v8::Local< v8::Value > &  left,
const v8::Local< v8::Value > &  right 
)

Definition at line 732 of file v8toolkit.cpp.

References get_array_length(), and make_set_from_object_keys().

Referenced by v8toolkit::Isolate::add_assert(), JavaScriptFixture::create_context(), and expose_variable_readonly().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function<R(Args...)> v8toolkit::bind ( CLASS &  object,
R(METHOD_CLASS::*)(Args...)  method 
)

unqualified Helper function to create a Bind object using type deduction and wrap it in a func::function object. This specialization is for handling non-const class methods

Const qualified

Parameters
object
method
Returns

Definition at line 855 of file v8toolkit.h.

References testing::Args().

Referenced by bind(), v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::handle_getter_result(), MyASTConsumer::MyASTConsumer(), and v8toolkit::WebsocketChannel::WebsocketChannel().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function<R(Args...)> v8toolkit::bind ( CLASS &  object,
R(METHOD_CLASS::*)(Args...) method &   
)

l-value qualified

Parameters
object
method
Returns

Definition at line 871 of file v8toolkit.h.

References testing::Args(), and bind().

Here is the call graph for this function:

template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function<R(Args...)> v8toolkit::bind ( CLASS &  object,
R(METHOD_CLASS::*)(Args...) const method &   
)

l-value and const qualified

Parameters
object
method
Returns

Definition at line 898 of file v8toolkit.h.

bool v8toolkit::get_file_contents ( std::string  filename,
std::string &  file_contents,
time_t &  file_modification_time 
)

If the filename filename exists, reeturns true and sets the last modificaiton time and contents otherwise returns false

Definition at line 249 of file v8toolkit.cpp.

References testing::internal::GetFileSize().

Referenced by v8toolkit::Context::compile_from_file(), v8toolkit::ArrayBufferAllocator::Free(), get_file_contents(), and require().

Here is the call graph for this function:

Here is the caller graph for this function:

bool v8toolkit::get_file_contents ( std::string  filename,
std::string &  file_contents 
)

same as longer version, just doesn't return modification time if it's not desired

Definition at line 239 of file v8toolkit.cpp.

References get_file_contents().

Here is the call graph for this function:

void v8toolkit::delete_require_cache_for_isolate ( v8::Isolate *  isolate)

Before deleting an isolate using require, make sure to clean up its require cache or the program will crash while exiting

Parameters
isolatewhich isolate to delete the cache for

Definition at line 340 of file v8toolkit.cpp.

Referenced by v8toolkit::ArrayBufferAllocator::Free().

Here is the caller graph for this function:

void v8toolkit::add_require ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  context,
const std::vector< std::string > &  paths 
)

adds 'require' method to javascript to emulate node require. Adds an self-referential "global" alias to the global object Must be run after the context is created so "global" can refer to the global object (if this could be changed, it should be, but I don't know how to do it beforehand)

Definition at line 650 of file v8toolkit.cpp.

References add_function(), require(), stringify_value(), and V8_TOOLKIT_DEBUG.

Referenced by v8toolkit::Isolate::add_require(), and v8toolkit::ArrayBufferAllocator::Free().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::add_module_list ( v8::Isolate *  isolate,
const v8::Local< v8::ObjectTemplate > &  object_template 
)

adds "module_list()" to javascript to require a dictionary of module path+names to exported objects currently required into the specified isolate

Definition at line 632 of file v8toolkit.cpp.

References add_function(), and scoped_run().

Referenced by v8toolkit::Isolate::add_module_list(), and v8toolkit::ArrayBufferAllocator::Free().

Here is the call graph for this function:

Here is the caller graph for this function:

bool v8toolkit::require ( v8::Local< v8::Context >  context,
std::string  filename,
v8::Local< v8::Value > &  result,
const std::vector< std::string > &  paths,
bool  track_file_modification_times = false,
bool  use_cache = true,
func::function< void(RequireResult const &)>  callback = func::function<void(RequireResult const &)>(),
func::function< std::string(std::string const &)>  resource_name_callback = func::function<std::string(std::string const &)>() 
)

Attempts to load the specified module name from the given paths (in order). Returns the exported object from the module. Same as calling require() from javascript - this is the code that is actually run for that

Attempts to load the specified external resource. Attempts to load exact match filename in each path, then <filename>.js in each path, then <filename>.json in each path

Paths are attempted in vector order[0, 1, 2...]. If the matching filename ends in .js (either because it was specified as such or because it matched after the suffix was added) it will be executed as a traditional module with the exports object being returned. If the matching filename ends in .json, the last value in the file will be returned. The results of require'd files is cached and if the same module (based on the full matching value including path and any added suffix) is required again, the cached value will be returned. The module will not be re-run.

The goal of this function is to be as close to node.js require as possible, so patches or descriptions of how it differs are appreciated. Not that much time was spent trying to determine the exact behavior, so there are likely significant differences

Definition at line 492 of file v8toolkit.cpp.

References execute_module(), and get_file_contents().

Referenced by add_require(), main(), v8toolkit::Context::require(), require_directory(), and v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::require_directory ( v8::Local< v8::Context >  context,
std::string  directory_name 
)

requires all the files in a directory

Definition at line 678 of file v8toolkit.cpp.

References require(), and V8_TOOLKIT_DEBUG.

Referenced by v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::dump_prototypes ( v8::Isolate *  isolate,
v8::Local< v8::Object >  object 
)

Definition at line 711 of file v8toolkit.cpp.

References stringify_value().

Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::_add_method(), and v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< std::string > v8toolkit::get_interesting_properties ( v8::Local< v8::Context >  context,
v8::Local< v8::Object >  object 
)

Definition at line 843 of file v8toolkit.cpp.

Referenced by v8toolkit::RequireResult::RequireResult().

Here is the caller graph for this function:

v8::Local< v8::Value > v8toolkit::run_script ( v8::Local< v8::Context >  context,
v8::Local< v8::Script >  script 
)

Definition at line 380 of file v8toolkit.cpp.

References ReportException().

Referenced by v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::foreach_file ( const std::string &  directory_name,
std::function< void(const std::string &)> const &  callback 
)

Definition at line 943 of file v8toolkit.cpp.

References v8toolkit::SetWeakCallbackData::callback, and foreach_filesystem_helper().

Referenced by v8toolkit::Context::require_directory(), and v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::foreach_directory ( const std::string &  directory_name,
std::function< void(const std::string &)> const &  callback 
)

Definition at line 947 of file v8toolkit.cpp.

References v8toolkit::SetWeakCallbackData::callback, and foreach_filesystem_helper().

Referenced by v8toolkit::RequireResult::RequireResult().

Here is the call graph for this function:

Here is the caller graph for this function:

std::atomic<int> v8toolkit::script_id_counter ( )
v8::Local<v8::Context> v8toolkit::get_debug_context ( )

Referenced by v8toolkit::Context::json(), and v8toolkit::Isolate::json().

Here is the caller graph for this function:

v8toolkit::Isolate::operator v8::Local< v8::ObjectTemplate > ( )

Definition at line 247 of file javascript.cpp.

int v8toolkit::get_array_length ( v8::Isolate *  isolate,
v8::Local< v8::Array >  array 
)

Definition at line 79 of file v8helpers.cpp.

std::string v8toolkit::_format_helper ( const v8::FunctionCallbackInfo< v8::Value > &  args,
bool  append_newline 
)

Definition at line 84 of file v8toolkit.cpp.

References get_all_values().

Referenced by _printf_helper(), and add_print().

Here is the call graph for this function:

Here is the caller graph for this function:

bool v8toolkit::_get_modification_time_of_filename ( std::string  filename,
time_t &  modification_time 
)

Definition at line 297 of file v8toolkit.cpp.

cached_isolate_modules_t& v8toolkit::get_loaded_modules ( v8::Isolate *  isolate)

Definition at line 345 of file v8toolkit.cpp.

bool v8toolkit::compile_source ( v8::Local< v8::Context > &  context,
std::string  source,
v8::Local< v8::Script > &  script,
v8::Local< v8::Value > &  error,
v8::ScriptOrigin *  script_origin = nullptr 
)

Takes in javascript source and attempts to compile it to a script. On error, it sets the output parameter error and returns false

Definition at line 356 of file v8toolkit.cpp.

References ReportException(), stringify_value(), and V8_TOOLKIT_DEBUG.

Here is the call graph for this function:

v8::Local<v8::Value> v8toolkit::execute_module ( v8::Local< v8::Context >  context,
const std::string  module_source,
const v8::ScriptOrigin &  script_origin,
v8::Local< v8::Function > &  compiled_function 
)

Compiles the given code within a containing function and returns the exports object

Parameters
context
module_source
script_origin
Returns

Definition at line 427 of file v8toolkit.cpp.

References add_variable(), and ReportException().

Referenced by require().

Here is the call graph for this function:

Here is the caller graph for this function:

void v8toolkit::foreach_filesystem_helper ( const std::string &  directory_name,
const volatile bool  files,
const volatile bool  directories,
std::function< void(const std::string &)> const &  callback 
)

Definition at line 885 of file v8toolkit.cpp.

References v8toolkit::SetWeakCallbackData::callback.

Referenced by foreach_directory(), and foreach_file().

Here is the caller graph for this function:

v8toolkit::CAST_TO_NATIVE ( WrappedString  ,
{return WrappedString(CastToNative< std::string >()(isolate, value));}   
)

Variable Documentation

template<class T >
constexpr bool v8toolkit::always_false_v = always_false<T>::value

Definition at line 28 of file casts.hpp.

template<class T >
constexpr bool v8toolkit::is_wrapped_type_v = is_wrapped_type<T>::value

Definition at line 39 of file casts.hpp.

template<class T >
constexpr bool v8toolkit::cast_to_native_supports_default_value_v = cast_to_native_supports_default_value<T>::value

Definition at line 50 of file casts.hpp.

template<class T >
constexpr bool v8toolkit::is_wrapped_typeish_v
Initial value:
=
is_wrapped_type<
std::remove_pointer_t<
std::remove_reference_t<T>
>
>::value

Definition at line 55 of file casts.hpp.

boost::uuids::random_generator v8toolkit::uuid_generator

Definition at line 10 of file javascript.cpp.

V8ClassWrapperInstanceRegistry v8toolkit::wrapper_registery
std::map< v8::Isolate *, std::vector< std::string > > v8toolkit::used_constructor_name_list_map

Constructor names already used, including things reserved by JavaScript like "Object" and "Number"

Definition at line 39 of file v8toolkit.cpp.

template<auto member>
constexpr bool v8toolkit::is_pointer_to_const_data_member_v = get_member_is_readonly(member)

Definition at line 38 of file v8helpers.h.

bool v8toolkit::AnybaseDebugPrintFlag = false

If ANYBASE_DEBUG is defined, then this flag controls whether type conversion information logs are printed to stderr

Definition at line 11 of file v8helpers.cpp.

std::vector< std::string > v8toolkit::reserved_global_names
Initial value:
= {"Boolean", "Null", "Undefined", "Number", "String",
"Object", "Symbol", "Date", "Array", "Set", "WeakSet",
"Map", "WeakMap", "JSON"}

Definition at line 368 of file v8helpers.cpp.

Referenced by get_key_as().

std::mutex v8toolkit::require_results_mutex

Definition at line 335 of file v8toolkit.cpp.

std::map<v8::Isolate *, cached_isolate_modules_t> v8toolkit::require_results
static

Definition at line 338 of file v8toolkit.cpp.