v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
Classes | Namespaces | Macros | Typedefs | Functions
v8toolkit.h File Reference
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <tuple>
#include <string.h>
#include "v8helpers.h"
#include "casts.hpp"
#include "stdfunctionreplacement.h"
#include "call_callable.h"
#include <dirent.h>
#include "casts_impl.hpp"
Include dependency graph for v8toolkit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  v8toolkit::SetWeakCallbackData
 
struct  v8toolkit::WrappedData< T >
 
class  v8toolkit::V8Exception
 
class  v8toolkit::V8AssertionException
 
class  v8toolkit::V8ExecutionException
 
class  v8toolkit::V8CompilationException
 
struct  v8toolkit::remove_const_from_reference< T >
 
struct  v8toolkit::remove_const_from_reference< T const & >
 
struct  v8toolkit::remove_const_from_reference< T const >
 
struct  v8toolkit::FunctionTemplateData< R, Args >
 
struct  v8toolkit::TupleForEach< position, Tuple >
 
struct  v8toolkit::TupleForEach< position, Tuple >
 
struct  v8toolkit::TupleForEach< 0, Tuple >
 
struct  v8toolkit::Bind< class >
 
struct  v8toolkit::Bind< R(T::*)(Args...)>
 
struct  v8toolkit::Bind< R(T::*)(Args...)& >
 
struct  v8toolkit::Bind< R(T::*)(Args...) const >
 
struct  v8toolkit::Bind< R(T::*)(Args...) const & >
 
class  v8toolkit::ArrayBufferAllocator
 
struct  v8toolkit::RequireResult
 

Namespaces

 v8toolkit
 

Macros

#define V8_TOOLKIT_DEBUG   false
 
#define CONTEXT_SCOPED_RUN(local_context)
 
#define GLOBAL_CONTEXT_SCOPED_RUN(isolate, global_context)
 
#define ISOLATE_SCOPED_RUN(isolate)
 
#define DEBUG_SCOPED_RUN(isolate)
 

Typedefs

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

Functions

template<class T >
auto v8toolkit::scoped_run (v8::Isolate *isolate, T callable) -> typename std::result_of< T()>::type
 
template<class T >
auto v8toolkit::scoped_run (v8::Isolate *isolate, v8::Local< v8::Context > context, T callable) -> typename std::result_of< T()>::type
 
template<class T >
auto v8toolkit::scoped_run (v8::Isolate *isolate, const v8::Global< v8::Context > &context, T callable)
 
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)
 
template<class R , class CLASS , class... Args>
func::function< R(Args...)> v8toolkit::make_std_function_from_callable (R(CLASS::*f)(Args...) const, CLASS callable)
 
template<class R , class... Args>
func::function< R(Args...)> v8toolkit::make_std_function_from_callable (R(*callable)(Args...), std::string name)
 
template<class T >
v8::Local< v8::FunctionTemplate > v8toolkit::make_function_template (v8::Isolate *isolate, T callable, std::string name)
 
template<class R , class... Args>
v8::Local< v8::FunctionTemplate > v8toolkit::make_function_template (v8::Isolate *isolate, R(*f)(Args...), std::string const &name)
 
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)
 
template<class T >
void v8toolkit::add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T callable)
 
template<class R , class... Args>
void v8toolkit::add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, R(*function)(Args...))
 
template<class T >
void v8toolkit::add_function (const v8::Local< v8::Context > &context, const v8::Local< v8::Object > &object, const char *name, T callable)
 
void v8toolkit::add_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, const v8::Local< v8::Data > value)
 
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)
 
void v8toolkit::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 > 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)
 
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={})
 
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={})
 
template<class T >
void v8toolkit::_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 v8toolkit::_variable_setter (v8::Local< v8::String > property, v8::Local< v8::Value > value, const v8::PropertyCallbackInfo< void > &info)
 
template<class T >
void v8toolkit::expose_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable)
 
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)
 
template<class T >
void v8toolkit::expose_variable_readonly (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable)
 
template<class T >
void v8toolkit::expose_variable (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable)
 
template<class T >
void v8toolkit::expose_variable_readonly (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable)
 
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)
 
std::string v8toolkit::_printf_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline)
 
std::vector< v8::Local< v8::Value > > v8toolkit::get_all_values (const v8::FunctionCallbackInfo< v8::Value > &args, int depth=1)
 
std::string v8toolkit::_print_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline)
 
void v8toolkit::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 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());})
 
void v8toolkit::add_assert (v8::Isolate *isolate, v8::Local< v8::ObjectTemplate > object_template)
 
bool v8toolkit::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...)> v8toolkit::bind (CLASS &object, R(METHOD_CLASS::*method)(Args...))
 
template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function< R(Args...)> v8toolkit::bind (CLASS &object, R(METHOD_CLASS::*method)(Args...)&)
 
template<class CLASS , class R , class METHOD_CLASS , class... Args>
func::function< R(Args...)> v8toolkit::bind (CLASS &object, R(METHOD_CLASS::*method)(Args...) const &)
 
bool v8toolkit::get_file_contents (std::string filename, std::string &file_contents, time_t &file_modification_time)
 
bool v8toolkit::get_file_contents (std::string filename, std::string &file_contents)
 
void v8toolkit::delete_require_cache_for_isolate (v8::Isolate *isolate)
 
void v8toolkit::add_require (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &context, const std::vector< std::string > &paths)
 
void v8toolkit::add_module_list (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template)
 
bool v8toolkit::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 v8toolkit::require_directory (v8::Local< v8::Context > context, std::string directory_name)
 
void v8toolkit::dump_prototypes (v8::Isolate *isolate, v8::Local< v8::Object > object)
 
std::vector< std::string > v8toolkit::get_interesting_properties (v8::Local< v8::Context > context, v8::Local< v8::Object > object)
 
v8::Local< v8::Value > v8toolkit::run_script (v8::Local< v8::Context > context, v8::Local< v8::Script > script)
 
void v8toolkit::foreach_file (const std::string &directory_name, std::function< void(const std::string &)> const &callback)
 
void v8toolkit::foreach_directory (const std::string &directory_name, std::function< void(const std::string &)> const &callback)
 

Class Documentation

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 325 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::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
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.

Macro Definition Documentation

#define V8_TOOLKIT_DEBUG   false
#define CONTEXT_SCOPED_RUN (   local_context)
Value:
v8::Isolate * _v8toolkit_internal_isolate = (local_context)->GetIsolate(); \
v8::Locker _v8toolkit_internal_locker(_v8toolkit_internal_isolate); \
v8::Isolate::Scope _v8toolkit_internal_isolate_scope(_v8toolkit_internal_isolate); \
v8::HandleScope _v8toolkit_internal_handle_scope(_v8toolkit_internal_isolate); \
v8::Context::Scope _v8toolkit_internal_context_scope((local_context));

Definition at line 78 of file v8toolkit.h.

Referenced by v8toolkit::add_function().

#define GLOBAL_CONTEXT_SCOPED_RUN (   isolate,
  global_context 
)
Value:
v8::Locker _v8toolkit_internal_locker(isolate); \
v8::Isolate::Scope _v8toolkit_internal_isolate_scope(isolate); \
v8::HandleScope _v8toolkit_internal_handle_scope(isolate); \
/* creating local context must be after creating handle scope */ \
v8::Local<v8::Context> _v8toolkit_internal_local_context = global_context.Get(isolate); \
v8::Context::Scope _v8toolkit_internal_context_scope(_v8toolkit_internal_local_context);

Definition at line 85 of file v8toolkit.h.

Referenced by v8toolkit::Context::add_function(), v8toolkit::Context::add_variable(), v8toolkit::Context::compile(), v8toolkit::Context::operator()(), v8toolkit::Context::run(), and v8toolkit::WebsocketChannel::WebsocketChannel().

#define ISOLATE_SCOPED_RUN (   isolate)
Value:
v8::Locker _v8toolkit_internal_locker((isolate)); \
v8::Isolate::Scope _v8toolkit_internal_isolate_scope((isolate)); \
v8::HandleScope _v8toolkit_internal_handle_scope((isolate));

Definition at line 93 of file v8toolkit.h.

Referenced by v8toolkit::Isolate::create_context(), v8toolkit::Isolate::create_debug_context(), v8toolkit::Isolate::operator()(), v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::set_parent_type(), and WrappedClassFixture::WrappedClassFixture().

#define DEBUG_SCOPED_RUN (   isolate)
Value:
v8::Locker _v8toolkit_internal_locker((isolate)); \
v8::Isolate::Scope _v8toolkit_internal_isolate_scope((isolate)); \
v8::HandleScope _v8toolkit_internal_handle_scope((isolate)); \
v8::Context::Scope _v8toolkit_internal_context_scope(v8::Debug::GetDebugContext((isolate)));

Definition at line 98 of file v8toolkit.h.