v8toolkit
0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
|
#include <javascript.h>
Public Member Functions | |
Script ()=delete | |
Script (const Script &)=delete | |
Script (Script &&)=default | |
Script & | operator= (const Script &)=delete |
Script & | operator= (Script &&)=default |
virtual | ~Script () |
std::string const & | get_source_code () const |
std::string | get_source_location () const |
int64_t | get_script_id () const |
operator v8::Global< v8::Script > & () | |
template<class... Args> | |
void | operator() (Args &&...args) |
auto | get_context_helper () |
v8::Global< v8::Value > | run () |
auto | run_async (std::launch launch_policy=std::launch::async|std::launch::deferred) |
std::thread | run_thread () |
void | run_detached () |
v8::Local< v8::UnboundScript > | get_unbound_script () const |
Friends | |
class | Context |
Helper class for a v8::Script object. As long as a Script shared_ptr is around, the associated Context will be maintined (which keeps the Isolate around, too)
Definition at line 374 of file javascript.h.
|
delete |
|
delete |
|
default |
|
inlinevirtual |
Definition at line 396 of file javascript.h.
std::string const & v8toolkit::Script::get_source_code | ( | ) | const |
Definition at line 489 of file javascript.cpp.
std::string v8toolkit::Script::get_source_location | ( | ) | const |
Definition at line 493 of file javascript.cpp.
int64_t v8toolkit::Script::get_script_id | ( | ) | const |
Definition at line 499 of file javascript.cpp.
|
inline |
Allows implicit conversion to a v8::Global<v8::Script>
Definition at line 411 of file javascript.h.
References testing::Args().
|
inline |
Calls scoped_run with the associated isolate and context
Definition at line 417 of file javascript.h.
|
inline |
Returns the Context associated with this Script
Definition at line 422 of file javascript.h.
|
inline |
Definition at line 425 of file javascript.h.
|
inline |
Run this script in a std::async and return the associated future. The future value is a std::pair<javascript_result, shared_ptr<Script>>. It contains a shared_ptr to the Script so the Script (and it's associated dependencies) cannot be destroyed until after the async has finished and the caller has had a chance to use the results contained in the future The order of the pair elements matters to make sure the Global is cleaned up before the ScriptPtr
Definition at line 435 of file javascript.h.
References v8toolkit::Context::run(), v8toolkit::Context::run_detached(), and v8toolkit::Context::run_thread().
std::thread v8toolkit::Script::run_thread | ( | ) |
Run this script in a std::thread, returning the std::thread object for joining/detaching. The thread maintains a shared_ptr to this Script so it cannot be destroyed until after the thread completes. Remember, letting the std::thread go out of scope without joinin/detaching is very bad.
Definition at line 471 of file javascript.cpp.
References v8toolkit::Context::run().
void v8toolkit::Script::run_detached | ( | ) |
Same as run_thread, but the thread is automatically detached. The Script object is still protected for the lifetime of the
Definition at line 485 of file javascript.cpp.
References v8toolkit::Context::run_thread().
v8::Local< v8::UnboundScript > v8toolkit::Script::get_unbound_script | ( | ) | const |
Definition at line 234 of file javascript.cpp.
|
friend |
Definition at line 376 of file javascript.h.