v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
Public Member Functions | Friends | List of all members
v8toolkit::Isolate Class Reference

#include <javascript.h>

Inheritance diagram for v8toolkit::Isolate:
Inheritance graph
[legend]
Collaboration diagram for v8toolkit::Isolate:
Collaboration graph
[legend]

Public Member Functions

virtual ~Isolate ()
 
 operator v8::Isolate * ()
 
 operator v8::Local< v8::ObjectTemplate > ()
 
Isolateadd_print (func::function< void(const std::string &)>)
 
Isolateadd_print ()
 
void add_assert ()
 
void add_require (std::vector< std::string > paths=std::vector< std::string >{"./"})
 
void add_module_list ()
 
std::shared_ptr< Contextcreate_context ()
 
std::shared_ptr< DebugContextcreate_debug_context (short port)
 
v8::Isolate * get_isolate ()
 
v8::Local< v8::ObjectTemplate > get_object_template ()
 
template<class Callable >
auto operator() (Callable &&callable) -> std::result_of_t< Callable()>
 
template<class Callable >
auto operator() (Callable &&callable) -> typename std::result_of< Callable(v8::Isolate *)>::type
 
template<class Callable >
auto operator() (Callable &&callable) -> typename std::result_of_t< Callable(v8::Isolate *, v8::Local< v8::Context >)>
 
template<class Callable >
void add_function (std::string name, Callable &&callable)
 
template<class Variable >
void expose_variable (std::string name, Variable &variable)
 
template<class Variable >
void expose_variable_readonly (std::string name, Variable &variable)
 
void add_variable (const std::string &name, v8::Local< v8::ObjectTemplate > template_to_attach)
 Not sure what this is used for. More...
 
template<class T >
auto & wrap_class ()
 
v8::Local< v8::Value > json (std::string json)
 
ContextPtr get_debug_context ()
 

Friends

class Platform
 

Detailed Description

Represents a v8::Isolate object. Any changes made here will be reflected in any contexts created after the change was made. An IsolateHleper will remain as long as the user has a shared_ptr to the Isolate itself or a unique_ptr to any Context created from the Isolate. Can only be created by calling Platform::create_isolate()

Definition at line 476 of file javascript.h.

Constructor & Destructor Documentation

v8toolkit::Isolate::~Isolate ( )
virtual

Definition at line 339 of file javascript.cpp.

References v8toolkit::V8ClassWrapperInstanceRegistry::cleanup_isolate(), and v8toolkit::wrapper_registery.

Here is the call graph for this function:

Member Function Documentation

v8toolkit::Isolate::operator v8::Isolate * ( )

Implicit cast to v8::Isolate* so an Isolate can be used where a v8::Isolate* would otherwise be required

Definition at line 241 of file javascript.cpp.

References v8toolkit::Context::isolate.

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

Implicit cast to Local<ObjectTemplate> for the global object template used to create new contexts

Isolate & v8toolkit::Isolate::add_print ( func::function< void(const std::string &)>  callback)

Adds print helpers to global object template as defined in v8toolkit::add_print()

Definition at line 253 of file javascript.cpp.

References v8toolkit::add_print().

Here is the call graph for this function:

Isolate & v8toolkit::Isolate::add_print ( )

Definition at line 262 of file javascript.cpp.

References v8toolkit::add_print().

Here is the call graph for this function:

void v8toolkit::Isolate::add_assert ( )

Definition at line 353 of file javascript.cpp.

References v8toolkit::Context::add_function(), v8toolkit::compare_contents(), and v8toolkit::stringify_value().

Here is the call graph for this function:

void v8toolkit::Isolate::add_require ( std::vector< std::string >  paths = std::vector<std::string>{"./"})

Adds require() function to javascript as defined in v8toolkit::add_require()

Definition at line 271 of file javascript.cpp.

References v8toolkit::add_require().

Here is the call graph for this function:

void v8toolkit::Isolate::add_module_list ( )
inline

Definition at line 529 of file javascript.h.

References v8toolkit::add_module_list(), and v8toolkit::Context::get_isolate().

Here is the call graph for this function:

std::shared_ptr< Context > v8toolkit::Isolate::create_context ( )

Creates a Context populated by all customizations already applied to this Isolate, but subsequent customizations to the Isolate will not be applied to Contexts already created.

Definition at line 285 of file javascript.cpp.

References ISOLATE_SCOPED_RUN.

Referenced by TEST_F().

Here is the caller graph for this function:

std::shared_ptr< DebugContext > v8toolkit::Isolate::create_debug_context ( short  port)

Definition at line 305 of file javascript.cpp.

References ISOLATE_SCOPED_RUN.

v8::Isolate * v8toolkit::Isolate::get_isolate ( )

Returns the isolate associated with this Isolate

Definition at line 279 of file javascript.cpp.

References v8toolkit::Context::isolate.

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

Returns the v8::ObjectTemplate used to create contexts from this Isolate

Definition at line 326 of file javascript.cpp.

template<class Callable >
auto v8toolkit::Isolate::operator() ( Callable &&  callable) -> std::result_of_t<Callable()>
inline

wraps "callable" in appropriate thread locks, isolate, and handle scopes

Definition at line 556 of file javascript.h.

References ISOLATE_SCOPED_RUN.

template<class Callable >
auto v8toolkit::Isolate::operator() ( Callable &&  callable) -> typename std::result_of<Callable(v8::Isolate*)>::type
inline

wraps "callable" in appropriate thread locks, isolate, and handle scopes Passes the v8::Isolate * to the callable function

Definition at line 567 of file javascript.h.

References ISOLATE_SCOPED_RUN.

template<class Callable >
auto v8toolkit::Isolate::operator() ( Callable &&  callable) -> typename std::result_of_t<Callable(v8::Isolate*, v8::Local<v8::Context>)>
inline

wraps "callable" in appropriate thread locks, isolate, and handle scopes Passes the v8::Isolate * and v8::Local<v8::Context> to the callable function. Throws v8toolkit::InvalidCallException if the isolate is not currently in a context

Definition at line 579 of file javascript.h.

References v8toolkit::scoped_run().

Here is the call graph for this function:

template<class Callable >
void v8toolkit::Isolate::add_function ( std::string  name,
Callable &&  callable 
)
inline

Adds the specified callable as <name> in javascript This can be a standard C++ function, a lambda, or anything else that supports being called with operator()

Definition at line 590 of file javascript.h.

References v8toolkit::add_function().

Here is the call graph for this function:

template<class Variable >
void v8toolkit::Isolate::expose_variable ( std::string  name,
Variable &  variable 
)
inline

Exposes an existing C++ variable as <name> to javascript

Definition at line 604 of file javascript.h.

References v8toolkit::expose_variable().

Here is the call graph for this function:

template<class Variable >
void v8toolkit::Isolate::expose_variable_readonly ( std::string  name,
Variable &  variable 
)
inline

Definition at line 610 of file javascript.h.

References v8toolkit::expose_variable_readonly().

Here is the call graph for this function:

void v8toolkit::Isolate::add_variable ( const std::string &  name,
v8::Local< v8::ObjectTemplate >  template_to_attach 
)
inline

Not sure what this is used for.

Definition at line 616 of file javascript.h.

References v8toolkit::add_variable().

Here is the call graph for this function:

template<class T >
auto& v8toolkit::Isolate::wrap_class ( )
inline

Returns a V8ClassWrapper object for wrapping C++ classes in this isolate. Classes must be wrapped before contexts using them are created

Definition at line 626 of file javascript.h.

v8::Local<v8::Value> v8toolkit::Isolate::json ( std::string  json)
inline

Returns a value representing the JSON string specified or throws on bad JSON

Definition at line 635 of file javascript.h.

References v8toolkit::get_debug_context().

Here is the call graph for this function:

ContextPtr v8toolkit::Isolate::get_debug_context ( )

Returns the debug context for the isolate

Returns
the debug context for the isolate

Definition at line 332 of file javascript.cpp.

Friends And Related Function Documentation

friend class Platform
friend

Definition at line 477 of file javascript.h.


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