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

#include <javascript.h>

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

Public Member Functions

 Script ()=delete
 
 Script (const Script &)=delete
 
 Script (Script &&)=default
 
Scriptoperator= (const Script &)=delete
 
Scriptoperator= (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
 

Detailed Description

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.

Constructor & Destructor Documentation

v8toolkit::Script::Script ( )
delete

Referenced by v8toolkit::Platform::create_isolate().

Here is the caller graph for this function:

v8toolkit::Script::Script ( const Script )
delete
v8toolkit::Script::Script ( Script &&  )
default
virtual v8toolkit::Script::~Script ( )
inlinevirtual

Definition at line 396 of file javascript.h.

Member Function Documentation

Script& v8toolkit::Script::operator= ( const Script )
delete
Script& v8toolkit::Script::operator= ( Script &&  )
default
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.

v8toolkit::Script::operator v8::Global< v8::Script > & ( )
inline

Allows implicit conversion to a v8::Global<v8::Script>

Definition at line 411 of file javascript.h.

References testing::Args().

Here is the call graph for this function:

template<class... Args>
void v8toolkit::Script::operator() ( Args &&...  args)
inline

Calls scoped_run with the associated isolate and context

Definition at line 417 of file javascript.h.

auto v8toolkit::Script::get_context_helper ( )
inline

Returns the Context associated with this Script

Definition at line 422 of file javascript.h.

v8::Global<v8::Value> v8toolkit::Script::run ( )
inline

Definition at line 425 of file javascript.h.

auto v8toolkit::Script::run_async ( std::launch  launch_policy = std::launch::async | std::launch::deferred)
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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

v8::Local< v8::UnboundScript > v8toolkit::Script::get_unbound_script ( ) const

Definition at line 234 of file javascript.cpp.

Friends And Related Function Documentation

friend class Context
friend

Definition at line 376 of file javascript.h.


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