v8toolkit
0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
|
#include <javascript.h>
Public Member Functions | |
virtual | ~Isolate () |
operator v8::Isolate * () | |
operator v8::Local< v8::ObjectTemplate > () | |
Isolate & | add_print (func::function< void(const std::string &)>) |
Isolate & | add_print () |
void | add_assert () |
void | add_require (std::vector< std::string > paths=std::vector< std::string >{"./"}) |
void | add_module_list () |
std::shared_ptr< Context > | create_context () |
std::shared_ptr< DebugContext > | create_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 |
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.
|
virtual |
Definition at line 339 of file javascript.cpp.
References v8toolkit::V8ClassWrapperInstanceRegistry::cleanup_isolate(), and v8toolkit::wrapper_registery.
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().
Isolate & v8toolkit::Isolate::add_print | ( | ) |
Definition at line 262 of file javascript.cpp.
References v8toolkit::add_print().
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().
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().
|
inline |
Definition at line 529 of file javascript.h.
References v8toolkit::add_module_list(), and v8toolkit::Context::get_isolate().
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().
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.
|
inline |
wraps "callable" in appropriate thread locks, isolate, and handle scopes
Definition at line 556 of file javascript.h.
References ISOLATE_SCOPED_RUN.
|
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.
|
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().
|
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().
|
inline |
Exposes an existing C++ variable as <name> to javascript
Definition at line 604 of file javascript.h.
References v8toolkit::expose_variable().
|
inline |
Definition at line 610 of file javascript.h.
References v8toolkit::expose_variable_readonly().
|
inline |
Not sure what this is used for.
Definition at line 616 of file javascript.h.
References v8toolkit::add_variable().
|
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.
|
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().
ContextPtr v8toolkit::Isolate::get_debug_context | ( | ) |
Returns the debug context for the isolate
Definition at line 332 of file javascript.cpp.
|
friend |
Definition at line 477 of file javascript.h.