v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
Classes | Namespaces | Macros | Typedefs | Functions | Variables
v8helpers.h File Reference
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <set>
#include <typeinfo>
#include <fmt/ostream.h>
#include <libplatform/libplatform.h>
#include <v8.h>
#include "stdfunctionreplacement.h"
Include dependency graph for v8helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  v8toolkit::MethodAdderData
 
class  v8toolkit::CastException
 
struct  v8toolkit::ProxyType< T, typename >
 
struct  v8toolkit::ProxyType< T, void_t< typename T::V8TOOLKIT_PROXY_TYPE > >
 
struct  v8toolkit::is_specialization< Test, Ref >
 
struct  v8toolkit::is_specialization< Ref< Args... >, Ref >
 
struct  v8toolkit::LTG< T >
 
struct  v8toolkit::LTG< T && >
 
struct  v8toolkit::TypeList<... >
 
struct  v8toolkit::static_any< b >
 
struct  v8toolkit::static_any< true, tail... >
 
struct  v8toolkit::static_any< false, tail... >
 
struct  v8toolkit::static_any<>
 
struct  v8toolkit::static_all_of< b >
 
struct  v8toolkit::static_all_of< true, tail... >
 
struct  v8toolkit::static_all_of< false, tail... >
 
struct  v8toolkit::static_all_of<>
 
class  v8toolkit::InvalidCallException
 
class  v8toolkit::DuplicateNameException
 
class  v8toolkit::UndefinedPropertyException
 
struct  v8toolkit::MapperHelper< Container, Callable >
 
struct  v8toolkit::MapperHelper< Container< Data, AddParams... >, Callable >
 
struct  v8toolkit::MapperHelper< std::map< Key, Value, AddParams... >, Callable >
 
struct  v8toolkit::AnyBase
 
struct  v8toolkit::AnyPtr< T, class >
 
struct  v8toolkit::AnyPtr< T, std::enable_if_t<!std::is_pointer< T >::value &&!std::is_reference< T >::value > >
 
struct  v8toolkit::StuffBase
 
struct  v8toolkit::Stuff< T >
 
struct  v8toolkit::Any< T >
 

Namespaces

 v8toolkit
 
 v8toolkit::literals
 

Macros

#define V8TOOLKIT_COMMA   ,
 
#define V8TOOLKIT_MACRO_TYPE(...)   __VA_ARGS__
 
#define SAFE_MOVE_CONSTRUCTOR_SFINAE   !std::is_const<T>::value && std::is_move_constructible<T>::value
 
#define ANYBASE_DEBUG
 
#define ANYBASE_PRINT(format_string, ...)
 

Typedefs

using v8toolkit::StdFunctionCallbackType = func::function< void(const v8::FunctionCallbackInfo< v8::Value > &info)>
 
template<class T >
using v8toolkit::void_t = void
 
template<class T >
using v8toolkit::int_t = int
 

Functions

template<class MemberT , class ClassT >
constexpr bool v8toolkit::get_member_is_readonly (MemberT(ClassT::*member))
 
std::string v8toolkit::get_stack_trace_string (v8::Local< v8::StackTrace > stack_trace)
 
v8::Local< v8::String > v8toolkit::literals::operator""_v8 (char const *string, unsigned long)
 
v8::Local< v8::Number > v8toolkit::literals::operator""_v8 (long double number)
 
v8::Local< v8::Integer > v8toolkit::literals::operator""_v8 (unsigned long long int number)
 
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
 
void v8toolkit::ReportException (v8::Isolate *isolate, v8::TryCatch *try_catch)
 
std::string v8toolkit::demangle_typeid_name (const std::string &mangled_name)
 
template<class T >
std::string & v8toolkit::demangle ()
 
template<class Destination , class Source , std::enable_if_t< std::is_polymorphic< Source >::value, int > = 0>
Destination v8toolkit::safe_dynamic_cast (Source *source)
 
template<class Destination >
Destination * v8toolkit::safe_dynamic_cast (Destination *source)
 
template<class T , std::enable_if_t< SAFE_MOVE_CONSTRUCTOR_SFINAE, int > = 0>
std::unique_ptr< T > v8toolkit::safe_move_constructor (T &&original)
 
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... >
 
void v8toolkit::print_v8_value_details (v8::Local< v8::Value > local_value)
 
int v8toolkit::get_array_length (v8::Isolate *isolate, v8::Local< v8::Value > array_value)
 
std::set< std::string > v8toolkit::make_set_from_object_keys (v8::Isolate *isolate, v8::Local< v8::Object > &object, bool own_properties_only=true)
 
template<class Callable >
void v8toolkit::for_each_value (const v8::Local< v8::Context > context, const v8::Local< v8::Value > value, Callable callable)
 
void v8toolkit::set_global_object_alias (v8::Isolate *isolate, const v8::Local< v8::Context > context, std::string alias_name)
 
std::string v8toolkit::get_type_string_for_value (v8::Local< v8::Value > value)
 
void v8toolkit::process_v8_flags (int &argc, char **argv)
 
void v8toolkit::expose_gc ()
 
v8::Local< v8::Value > v8toolkit::call_simple_javascript_function (v8::Isolate *isolate, v8::Local< v8::Function > function)
 
template<class T >
void v8toolkit::for_each_own_property (const v8::Local< v8::Context > context, const v8::Local< v8::Object > object, T callable)
 
template<class Container , class Callable >
auto v8toolkit::mapper (const Container &container, Callable callable) -> decltype(MapperHelper< Container, Callable >()(container, callable))
 
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 >
 
template<class T >
v8::Local< T > v8toolkit::get_value_as (v8::Local< v8::Value > value)
 
template<class T >
v8::Local< T > v8toolkit::get_value_as (v8::Isolate *isolate, v8::Global< v8::Value > &value)
 
template<class T >
v8::Local< T > v8toolkit::get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key)
 
template<class T >
v8::Local< T > v8toolkit::get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Value > object, std::string key)
 
v8::Local< v8::Value > v8toolkit::get_key (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key)
 
v8::Local< v8::Value > v8toolkit::get_key (v8::Local< v8::Context > context, v8::Local< v8::Value > value, std::string key)
 
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 >>{})
 
bool v8toolkit::global_name_conflicts (const std::string &name)
 
v8::Local< v8::Object > v8toolkit::check_value_is_object (v8::Local< v8::Value > value, std::string const &class_name)
 

Variables

template<auto member>
constexpr bool v8toolkit::is_pointer_to_const_data_member_v = get_member_is_readonly(member)
 
bool v8toolkit::AnybaseDebugPrintFlag = false
 
std::vector< std::string > v8toolkit::reserved_global_names
 

Class Documentation

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::TypeList

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

Definition at line 73 of file sample2.h.

struct v8toolkit::static_any

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

Definition at line 262 of file v8helpers.h.

struct v8toolkit::static_all_of

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

Definition at line 275 of file v8helpers.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::AnyPtr

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

Definition at line 546 of file v8helpers.h.

Macro Definition Documentation

#define V8TOOLKIT_COMMA   ,

Definition at line 131 of file v8helpers.h.

#define V8TOOLKIT_MACRO_TYPE (   ...)    __VA_ARGS__

Definition at line 134 of file v8helpers.h.

#define SAFE_MOVE_CONSTRUCTOR_SFINAE   !std::is_const<T>::value && std::is_move_constructible<T>::value

Definition at line 192 of file v8helpers.h.

#define ANYBASE_DEBUG

When passing an Any-type through a void *, always static_cast it to an AnyBase * pointer and pass that as the void *. This allows you to safely cast it back to a AnyBase* on the other side and then dynamic_cast to any child types to determine the type of the object actually stored.

Definition at line 509 of file v8helpers.h.

#define ANYBASE_PRINT (   format_string,
  ... 
)