v8toolkit
0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
|
Namespaces | |
literals | |
v8toolkit | |
Typedefs | |
using | ScriptPtr = std::shared_ptr< Script > |
using | ContextPtr = std::shared_ptr< Context > |
using | IsolatePtr = std::shared_ptr< Isolate > |
using | StdFunctionCallbackType = func::function< void(const v8::FunctionCallbackInfo< v8::Value > &info)> |
template<class T > | |
using | void_t = void |
template<class T > | |
using | int_t = int |
template<class T > | |
using | remove_const_from_reference_t = typename remove_const_from_reference< T >::type |
using | json = nlohmann::json |
typedef std::map< std::string, RequireResult > | cached_isolate_modules_t |
Enumerations | |
enum | { kDebugIdIndex = v8::Context::kDebugIdIndex, kModuleEmbedderDataIndex, kInspectorClientIndex } |
Functions | |
template<class T > | |
std::enable_if_t< std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > | safe_get_javascript_object (T *object) |
template<class T > | |
std::enable_if_t<!std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > | safe_get_javascript_object (T *object) |
CAST_TO_NATIVE (bool,{HANDLE_FUNCTION_VALUES;return static_cast< bool >(value->ToBoolean() ->Value());}) | |
CAST_TO_NATIVE (long long,{HANDLE_FUNCTION_VALUES;return static_cast< long long >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (unsigned long long,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long long >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (long,{HANDLE_FUNCTION_VALUES;return static_cast< long >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (unsigned long,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (int,{HANDLE_FUNCTION_VALUES;return static_cast< int >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (unsigned int,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned int >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (short,{HANDLE_FUNCTION_VALUES;return static_cast< short >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (unsigned short,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned short >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (char,{HANDLE_FUNCTION_VALUES;return static_cast< char >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (unsigned char,{HANDLE_FUNCTION_VALUES;return static_cast< unsigned char >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (wchar_t,{HANDLE_FUNCTION_VALUES;return static_cast< wchar_t >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (char16_t,{HANDLE_FUNCTION_VALUES;return static_cast< char16_t >(value->ToInteger() ->Value());}) | |
CAST_TO_NATIVE (char32_t,{HANDLE_FUNCTION_VALUES;return static_cast< char32_t >(value->ToInteger() ->Value());}) | |
template<class... Ts, std::size_t... Is> | |
std::tuple< Ts... > | cast_to_native_tuple_helper (v8::Isolate *isolate, v8::Local< v8::Array > array, std::tuple< Ts... >, std::index_sequence< Is... >) |
template<template< class, class > class ContainerTemplate, class FirstT , class SecondT > | |
ContainerTemplate< FirstT, SecondT > | pair_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) |
CAST_TO_NATIVE (float,{HANDLE_FUNCTION_VALUES;return static_cast< float >(value->ToNumber() ->Value());}) | |
CAST_TO_NATIVE (double,{HANDLE_FUNCTION_VALUES;return static_cast< double >(value->ToNumber() ->Value());}) | |
CAST_TO_NATIVE (long double,{HANDLE_FUNCTION_VALUES;return static_cast< long double >(value->ToNumber() ->Value());}) | |
CAST_TO_NATIVE (std::string,{HANDLE_FUNCTION_VALUES;return std::string(*v8::String::Utf8Value(value));}) | |
template<template< class, class... > class VectorTemplate, class T , class... Rest> | |
auto | vector_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) -> VectorTemplate< std::remove_reference_t< std::result_of_t< CastToNative< T >(v8::Isolate *, v8::Local< v8::Value >)>>, Rest... > |
template<template< class, class... > class SetTemplate, class T , class... Rest> | |
auto | set_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) -> SetTemplate< std::remove_reference_t< std::result_of_t< CastToNative< T >(v8::Isolate *, v8::Local< v8::Value >)>>, Rest... > |
template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest> | |
ContainerTemplate< Key, Value, Rest... > | map_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) |
template<template< class, class, class... > class ContainerTemplate, class Key , class Value , class... Rest> | |
ContainerTemplate< Key, Value, Rest... > | multimap_type_helper (v8::Isolate *isolate, v8::Local< v8::Value > value) |
CAST_TO_JS (bool,{return v8::Boolean::New(isolate, value);}) | |
CAST_TO_JS (char,{return v8::Integer::New(isolate, value);}) | |
CAST_TO_JS (unsigned char,{return v8::Integer::New(isolate, value);}) | |
CAST_TO_JS (wchar_t,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (char16_t,{return v8::Integer::New(isolate, value);}) | |
CAST_TO_JS (char32_t,{return v8::Integer::New(isolate, value);}) | |
CAST_TO_JS (short,{return v8::Integer::New(isolate, value);}) | |
CAST_TO_JS (int,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (unsigned int,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (long,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (long long,{return v8::Number::New(isolate, static_cast< double >(value));}) | |
CAST_TO_JS (unsigned long long,{return v8::Number::New(isolate, static_cast< double >(value));}) | |
CAST_TO_JS (float,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (double,{return v8::Number::New(isolate, value);}) | |
CAST_TO_JS (std::string,{return v8::String::NewFromUtf8(isolate, value.c_str(), v8::String::kNormalString, value.length());}) | |
CAST_TO_JS (char *,{return v8::String::NewFromUtf8(isolate, value);}) | |
CAST_TO_JS (char const *,{return v8::String::NewFromUtf8(isolate, value);}) | |
template<template< class, class, class... > class MapTemplate, class KeyType , class ValueType , class ReferenceTypeIndicator , class... Rest> | |
v8::Local< v8::Value > | cast_to_js_map_helper (v8::Isolate *isolate, MapTemplate< KeyType, ValueType, Rest... > const &map) |
template<template< class... > class VectorTemplate, class ValueType , class... Rest> | |
v8::Local< v8::Value > | cast_to_js_vector_helper (v8::Isolate *isolate, VectorTemplate< std::remove_reference_t< ValueType >, Rest... > const &vector) |
template<template< class, class, class... > class MultiMapLike, class A , class B , class... Rest> | |
v8::Local< v8::Object > | casttojs_multimaplike (v8::Isolate *isolate, MultiMapLike< A, B, Rest... > const &map) |
CAST_TO_NATIVE (eastl::string,{HANDLE_FUNCTION_VALUES;return eastl::string(*v8::String::Utf8Value(value));}) | |
CAST_TO_JS (eastl::string,{return v8::String::NewFromUtf8(isolate, value.c_str());}) | |
template<class T , int default_arg_position = -1, class DefaultArgsTuple = std::tuple<>> | |
T * | get_default_parameter (const v8::FunctionCallbackInfo< v8::Value > &info, int &i, std::vector< std::unique_ptr< StuffBase >> &stuff, DefaultArgsTuple &&default_args_tuple) |
template<class T > | |
std::string | type_details () |
template<class T , std::enable_if_t< std::is_pointer< T >::value||std::is_reference< T >::value, int > = 0> | |
T & | get_object_from_embedded_cpp_object (v8::Isolate *isolate, v8::Local< v8::Value > value) |
template<class MemberT , class ClassT > | |
constexpr bool | get_member_is_readonly (MemberT(ClassT::*member)) |
std::string | get_stack_trace_string (v8::Local< v8::StackTrace > stack_trace) |
template<class ReturnType , class... Args, class... Ts> | |
auto | run_function (func::function< ReturnType(Args...)> &function, const v8::FunctionCallbackInfo< v8::Value > &info, Ts &&...ts) -> ReturnType |
template<class ReturnType , class... Args, class Callable , class... Ts> | |
auto | run_function (Callable callable, const v8::FunctionCallbackInfo< v8::Value > &info, Ts &&...ts) -> ReturnType |
void | ReportException (v8::Isolate *isolate, v8::TryCatch *try_catch) |
std::string | demangle_typeid_name (const std::string &mangled_name) |
template<class T > | |
std::string & | demangle () |
template<class Destination , class Source , std::enable_if_t< std::is_polymorphic< Source >::value, int > = 0> | |
Destination | safe_dynamic_cast (Source *source) |
template<class Destination > | |
Destination * | safe_dynamic_cast (Destination *source) |
template<class T , std::enable_if_t< SAFE_MOVE_CONSTRUCTOR_SFINAE, int > = 0> | |
std::unique_ptr< T > | safe_move_constructor (T &&original) |
template<class R , class... Ts> | |
auto | get_typelist_for_function (func::function< R(Ts...)>) -> TypeList< Ts... > |
template<class R , class Head , class... Tail> | |
auto | get_typelist_for_function_strip_first (func::function< R(Head, Tail...)>) -> TypeList< Tail... > |
template<class... Ts> | |
auto | get_typelist_for_variables (Ts...ts) -> TypeList< Ts... > |
template<class... Ts> | |
auto | make_tuple_for_variables (Ts &&...ts) -> std::tuple< Ts... > |
void | print_v8_value_details (v8::Local< v8::Value > local_value) |
int | get_array_length (v8::Isolate *isolate, v8::Local< v8::Value > array_value) |
std::set< std::string > | make_set_from_object_keys (v8::Isolate *isolate, v8::Local< v8::Object > &object, bool own_properties_only=true) |
template<class Callable > | |
void | for_each_value (const v8::Local< v8::Context > context, const v8::Local< v8::Value > value, Callable callable) |
void | set_global_object_alias (v8::Isolate *isolate, const v8::Local< v8::Context > context, std::string alias_name) |
std::string | get_type_string_for_value (v8::Local< v8::Value > value) |
void | process_v8_flags (int &argc, char **argv) |
void | expose_gc () |
v8::Local< v8::Value > | call_simple_javascript_function (v8::Isolate *isolate, v8::Local< v8::Function > function) |
template<class T > | |
void | for_each_own_property (const v8::Local< v8::Context > context, const v8::Local< v8::Object > object, T callable) |
template<class Container , class Callable > | |
auto | mapper (const Container &container, Callable callable) -> decltype(MapperHelper< Container, Callable >()(container, callable)) |
template<class Callable , class Container > | |
auto | reducer (const Container &container, Callable callable) -> std::vector< typename std::result_of< Callable(typename Container::value_type)>::type > |
template<class T > | |
v8::Local< T > | get_value_as (v8::Local< v8::Value > value) |
template<class T > | |
v8::Local< T > | get_value_as (v8::Isolate *isolate, v8::Global< v8::Value > &value) |
template<class T > | |
v8::Local< T > | get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key) |
template<class T > | |
v8::Local< T > | get_key_as (v8::Local< v8::Context > context, v8::Local< v8::Value > object, std::string key) |
v8::Local< v8::Value > | get_key (v8::Local< v8::Context > context, v8::Local< v8::Object > object, std::string key) |
v8::Local< v8::Value > | get_key (v8::Local< v8::Context > context, v8::Local< v8::Value > value, std::string key) |
std::string | stringify_value (v8::Isolate *isolate, const v8::Local< v8::Value > &value, bool show_all_properties=false, std::vector< v8::Local< v8::Value >> &&processed_values=std::vector< v8::Local< v8::Value >>{}) |
bool | global_name_conflicts (const std::string &name) |
v8::Local< v8::Object > | check_value_is_object (v8::Local< v8::Value > value, std::string const &class_name) |
template<class T > | |
auto | scoped_run (v8::Isolate *isolate, T callable) -> typename std::result_of< T()>::type |
template<class T > | |
auto | scoped_run (v8::Isolate *isolate, v8::Local< v8::Context > context, T callable) -> typename std::result_of< T()>::type |
template<class T > | |
auto | scoped_run (v8::Isolate *isolate, const v8::Global< v8::Context > &context, T callable) |
template<class R , class... Args> | |
v8::Local< v8::FunctionTemplate > | 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...)> | make_std_function_from_callable (R(CLASS::*f)(Args...) const, CLASS callable) |
template<class R , class... Args> | |
func::function< R(Args...)> | make_std_function_from_callable (R(*callable)(Args...), std::string name) |
template<class T > | |
v8::Local< v8::FunctionTemplate > | make_function_template (v8::Isolate *isolate, T callable, std::string name) |
template<class R , class... Args> | |
v8::Local< v8::FunctionTemplate > | make_function_template (v8::Isolate *isolate, R(*f)(Args...), std::string const &name) |
template<class R , class... Args> | |
void | add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, func::function< R(Args...)> function) |
template<class T > | |
void | add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T callable) |
template<class R , class... Args> | |
void | add_function (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, R(*function)(Args...)) |
template<class T > | |
void | add_function (const v8::Local< v8::Context > &context, const v8::Local< v8::Object > &object, const char *name, T callable) |
void | add_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, const v8::Local< v8::Data > value) |
void | add_variable (const v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, const v8::Local< v8::Value > value) |
void | 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 > | 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 > | 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 > | 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 | _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 | _variable_setter (v8::Local< v8::String > property, v8::Local< v8::Value > value, const v8::PropertyCallbackInfo< void > &info) |
template<class T > | |
void | expose_variable (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable) |
template<class T , class... Rest> | |
void | 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 | expose_variable_readonly (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template, const char *name, T &variable) |
template<class T > | |
void | expose_variable (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable) |
template<class T > | |
void | expose_variable_readonly (v8::Local< v8::Context > context, const v8::Local< v8::Object > &object, const char *name, T &variable) |
SetWeakCallbackData * | 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 | _printf_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline) |
std::vector< v8::Local< v8::Value > > | get_all_values (const v8::FunctionCallbackInfo< v8::Value > &args, int depth=1) |
std::string | _print_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline) |
void | 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 | 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 | add_assert (v8::Isolate *isolate, v8::Local< v8::ObjectTemplate > object_template) |
bool | 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...)> | bind (CLASS &object, R(METHOD_CLASS::*method)(Args...)) |
template<class CLASS , class R , class METHOD_CLASS , class... Args> | |
func::function< R(Args...)> | bind (CLASS &object, R(METHOD_CLASS::*method)(Args...)&) |
template<class CLASS , class R , class METHOD_CLASS , class... Args> | |
func::function< R(Args...)> | bind (CLASS &object, R(METHOD_CLASS::*method)(Args...) const &) |
bool | get_file_contents (std::string filename, std::string &file_contents, time_t &file_modification_time) |
bool | get_file_contents (std::string filename, std::string &file_contents) |
void | delete_require_cache_for_isolate (v8::Isolate *isolate) |
void | add_require (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &context, const std::vector< std::string > &paths) |
void | add_module_list (v8::Isolate *isolate, const v8::Local< v8::ObjectTemplate > &object_template) |
bool | 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 | require_directory (v8::Local< v8::Context > context, std::string directory_name) |
void | dump_prototypes (v8::Isolate *isolate, v8::Local< v8::Object > object) |
std::vector< std::string > | get_interesting_properties (v8::Local< v8::Context > context, v8::Local< v8::Object > object) |
v8::Local< v8::Value > | run_script (v8::Local< v8::Context > context, v8::Local< v8::Script > script) |
void | foreach_file (const std::string &directory_name, std::function< void(const std::string &)> const &callback) |
void | foreach_directory (const std::string &directory_name, std::function< void(const std::string &)> const &callback) |
std::atomic< int > | script_id_counter (0) |
v8::Local< v8::Context > | get_debug_context () |
Isolate::operator v8::Local< v8::ObjectTemplate > () | |
int | get_array_length (v8::Isolate *isolate, v8::Local< v8::Array > array) |
std::string | _format_helper (const v8::FunctionCallbackInfo< v8::Value > &args, bool append_newline) |
bool | _get_modification_time_of_filename (std::string filename, time_t &modification_time) |
cached_isolate_modules_t & | get_loaded_modules (v8::Isolate *isolate) |
bool | compile_source (v8::Local< v8::Context > &context, std::string source, v8::Local< v8::Script > &script, v8::Local< v8::Value > &error, v8::ScriptOrigin *script_origin=nullptr) |
v8::Local< v8::Value > | execute_module (v8::Local< v8::Context > context, const std::string module_source, const v8::ScriptOrigin &script_origin, v8::Local< v8::Function > &compiled_function) |
void | foreach_filesystem_helper (const std::string &directory_name, const volatile bool files, const volatile bool directories, std::function< void(const std::string &)> const &callback) |
CAST_TO_NATIVE (WrappedString,{return WrappedString(CastToNative< std::string >()(isolate, value));}) | |
Variables | |
template<class T > | |
constexpr bool | always_false_v = always_false<T>::value |
template<class T > | |
constexpr bool | is_wrapped_type_v = is_wrapped_type<T>::value |
template<class T > | |
constexpr bool | cast_to_native_supports_default_value_v = cast_to_native_supports_default_value<T>::value |
template<class T > | |
constexpr bool | is_wrapped_typeish_v |
boost::uuids::random_generator | uuid_generator |
V8ClassWrapperInstanceRegistry | wrapper_registery |
std::map< v8::Isolate *, std::vector< std::string > > | used_constructor_name_list_map |
template<auto member> | |
constexpr bool | is_pointer_to_const_data_member_v = get_member_is_readonly(member) |
bool | AnybaseDebugPrintFlag = false |
std::vector< std::string > | reserved_global_names |
std::mutex | require_results_mutex |
static std::map< v8::Isolate *, cached_isolate_modules_t > | require_results |
This file contains things needed to create "types" and objects in both C++ and javascript and use them in either environment regardless of where they were created. Since C++ types must exist at compile time, types created with these tools cannot create actual C++ types, but instead allow behavior to be overridden on virtual functions
See samples/bidirectional_sample.cpp for examples on how to use this library.
TODO LIST
All includes should be included as #include "v8toolkit/FILENAME.h" instead of just #include "FILENAME.h" Rename javascript.h file to something much better Including "v8toolkit/v8toolkit.h" should include everything, but specific includes should also work for v8helpers.h, <new name for v8toolkit.h>, <new name for javascript.h>
struct v8toolkit::AnyPtr |
Definition at line 546 of file v8helpers.h.
struct v8toolkit::Bind |
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.
struct v8toolkit::CallCallable |
Definition at line 21 of file call_callable.h.
struct v8toolkit::CastToJS |
struct v8toolkit::CastTupleToJS |
class v8toolkit::CppFactory |
Returns a pure-C++ object of type Child which inherits from type Base. It's Base type and ConstructorArgs... must match with the Factory it is associated with. You can have it inherit from a type that inherits from v8toolkit::Factory but v8toolkit::Factory must be in the inheritance chain somewhere
Definition at line 110 of file sample.cpp.
class v8toolkit::EmptyFactoryBase |
class v8toolkit::Factory |
Common Factory Inheritance goes: v8toolkit::CppFactory => custom user-defined Factory type for additional data/functions => v8toolkit::Factory => v8toolkit::Factory<BaseType> => Common base type for all factories Internal constructor parameters are parameters only on the Base type constructor that are not specified to each instance of the derived type. The value is fixed across all isntances of the specific derived type.
External constructor parameters are parameers are all the parameters to the derived type (except an optional first parameter of the factory object which will be automatically populated) Base class for a Factory that creates a bidirectional "type" by name. The object returned can be used as a class T regardless of whether it is a pure C++ type or if it has been extended in javascript
Definition at line 159 of file bidirectional.h.
struct v8toolkit::FunctionTemplateData |
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.
Class Members | ||
---|---|---|
callable | ||
string | name |
class v8toolkit::JSFactory |
Returns a JavaScript-extended object inheriting from Base. It's Base type and *ConstructorParams must match up with the Factory class it is associated
InternalConstructorParams are ones that will be specified in the javascript code declaring the new type
ExternalConstructorParams will be potentially change for each instance of that type
Example of internal vs external parameters: if the base type is "animal" and it takes two parameters "is_mammal" and "name". Whether or not the derived type is a mammal is known when making the derived type so it would be an internal parameter, while the name isn't known until the object is constructed so it would be an external parameter.
Perhaps the order should be swapped to take external first, since that is maybe more common?
Definition at line 290 of file bidirectional.h.
struct v8toolkit::MapperHelper |
Takes a container, runs each element through Callable and returns a new container of the same container type but with a data type matching the returned type of the Callable
Definition at line 418 of file v8helpers.h.
struct v8toolkit::ParameterBuilder |
Used by CallCallable to build an actual list of values to send to a function. Each call to ParameterBuilder is responsible for one parameter.
If the parameter isn't self contained (like a char *), then the memory allocated for it will be stored in stuff
which is automatically cleaned up when the function returns.
If no explicit parameter is provided from JavaScript, a default value may be available in default_args_tuple
Definition at line 35 of file parameter_builder.h.
struct v8toolkit::ProxyType |
Definition at line 119 of file v8helpers.h.
Class Members | ||
---|---|---|
typedef T | PROXY_TYPE |
struct v8toolkit::ProxyType< T, void_t< typename T::V8TOOLKIT_PROXY_TYPE > > |
Definition at line 124 of file v8helpers.h.
Class Members | ||
---|---|---|
typedef typename V8TOOLKIT_PROXY_TYPE |
PROXY_TYPE |
struct v8toolkit::remove_const_from_reference |
Definition at line 319 of file v8toolkit.h.
Class Members | ||
---|---|---|
typedef T | type |
struct v8toolkit::remove_const_from_reference< T const > |
Definition at line 330 of file v8toolkit.h.
Class Members | ||
---|---|---|
typedef T | type |
struct v8toolkit::remove_const_from_reference< T const & > |
Definition at line 325 of file v8toolkit.h.
Class Members | ||
---|---|---|
typedef T && | type |
struct v8toolkit::static_all_of |
Definition at line 275 of file v8helpers.h.
struct v8toolkit::static_any |
Definition at line 262 of file v8helpers.h.
struct v8toolkit::TypeChecker |
Definition at line 190 of file v8_class_wrapper.h.
struct v8toolkit::TypeList |
class v8toolkit::V8ClassWrapper |
Provides a mechanism for creating javascript-ready objects from an arbitrary C++ class Can provide a JS constructor method or wrap objects created in another c++ function
Const types should not be wrapped directly. Instead, a const version of a non-const type will automatically be created and populated with read-only members and any const-qualified method added to the non-const version.
All members/methods must be added, then finalize() called, then any desired constructors may be created.
struct v8toolkit::WrapAsMostDerived |
Definition at line 160 of file v8_class_wrapper.h.
using v8toolkit::ScriptPtr = typedef std::shared_ptr<Script> |
Definition at line 26 of file javascript.h.
using v8toolkit::ContextPtr = typedef std::shared_ptr<Context> |
Definition at line 367 of file javascript.h.
using v8toolkit::IsolatePtr = typedef std::shared_ptr<Isolate> |
Definition at line 651 of file javascript.h.
using v8toolkit::StdFunctionCallbackType = typedef func::function<void(const v8::FunctionCallbackInfo<v8::Value>& info)> |
Definition at line 42 of file v8helpers.h.
using v8toolkit::void_t = typedef void |
Definition at line 62 of file v8helpers.h.
using v8toolkit::int_t = typedef int |
Definition at line 65 of file v8helpers.h.
using v8toolkit::remove_const_from_reference_t = typedef typename remove_const_from_reference<T>::type |
Definition at line 336 of file v8toolkit.h.
using v8toolkit::json = typedef nlohmann::json |
Definition at line 16 of file debugger.cpp.
typedef std::map<std::string, RequireResult> v8toolkit::cached_isolate_modules_t |
Definition at line 337 of file v8toolkit.cpp.
anonymous enum |
Enumerator | |
---|---|
kDebugIdIndex | |
kModuleEmbedderDataIndex | |
kInspectorClientIndex |
Definition at line 263 of file debugger.h.
std::enable_if_t<std::is_base_of<JSWrapperBase, T>::value, v8::Local<v8::Object> > v8toolkit::safe_get_javascript_object | ( | T * | object | ) |
Definition at line 89 of file bidirectional.h.
Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::wrap_existing_cpp_object().
std::enable_if_t<!std::is_base_of<JSWrapperBase, T>::value, v8::Local<v8::Object> > v8toolkit::safe_get_javascript_object | ( | T * | object | ) |
Definition at line 94 of file bidirectional.h.
v8toolkit::CAST_TO_NATIVE | ( | bool | , |
{HANDLE_FUNCTION_VALUES;return static_cast< bool >(value->ToBoolean() ->Value());} | |||
) |
Referenced by v8toolkit::CastToNative< void >::callable(), v8toolkit::CastToNative< const char * >::callable(), v8toolkit::CastToNative< eastl::vector_multimap< Key, Value, Args... > >::operator()(), v8toolkit::v8toolkit::CastToNative< std::pair< FirstT, SecondT > >::operator()(), and WrappedString::WrappedString().
v8toolkit::CAST_TO_NATIVE | ( | long | long, |
{HANDLE_FUNCTION_VALUES;return static_cast< long long >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | unsigned long | long, |
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long long >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | long | , |
{HANDLE_FUNCTION_VALUES;return static_cast< long >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | unsigned | long, |
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned long >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | int | , |
{HANDLE_FUNCTION_VALUES;return static_cast< int >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | unsigned | int, |
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned int >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | short | , |
{HANDLE_FUNCTION_VALUES;return static_cast< short >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | unsigned | short, |
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned short >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | char | , |
{HANDLE_FUNCTION_VALUES;return static_cast< char >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | unsigned | char, |
{HANDLE_FUNCTION_VALUES;return static_cast< unsigned char >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | wchar_t | , |
{HANDLE_FUNCTION_VALUES;return static_cast< wchar_t >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | char16_t | , |
{HANDLE_FUNCTION_VALUES;return static_cast< char16_t >(value->ToInteger() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | char32_t | , |
{HANDLE_FUNCTION_VALUES;return static_cast< char32_t >(value->ToInteger() ->Value());} | |||
) |
std::tuple<Ts...> v8toolkit::cast_to_native_tuple_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Array > | array, | ||
std::tuple< Ts... > | , | ||
std::index_sequence< Is... > | |||
) |
Definition at line 170 of file casts.hpp.
Referenced by v8toolkit::CastToNative< std::tuple< Ts... > >::operator()().
ContainerTemplate<FirstT, SecondT> v8toolkit::pair_type_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) |
Definition at line 223 of file casts.hpp.
References get_array_length(), HANDLE_FUNCTION_VALUES, and stringify_value().
v8toolkit::CAST_TO_NATIVE | ( | float | , |
{HANDLE_FUNCTION_VALUES;return static_cast< float >(value->ToNumber() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | double | , |
{HANDLE_FUNCTION_VALUES;return static_cast< double >(value->ToNumber() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | long | double, |
{HANDLE_FUNCTION_VALUES;return static_cast< long double >(value->ToNumber() ->Value());} | |||
) |
v8toolkit::CAST_TO_NATIVE | ( | std::string | , |
{HANDLE_FUNCTION_VALUES;return std::string(*v8::String::Utf8Value(value));} | |||
) |
auto v8toolkit::vector_type_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) | -> VectorTemplate<std::remove_reference_t<std::result_of_t<CastToNative<T>(v8::Isolate *, v8::Local<v8::Value>)>>, Rest...> |
Definition at line 306 of file casts.hpp.
Referenced by v8toolkit::CastToNative< eastl::vector< T, Args... > >::operator()(), and v8toolkit::CastToNative< std::vector< T, Rest... >, std::enable_if_t< std::is_copy_constructible< T >::value > >::operator()().
auto v8toolkit::set_type_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) | -> SetTemplate<std::remove_reference_t<std::result_of_t<CastToNative<T>(v8::Isolate *, v8::Local<v8::Value>)>>, Rest...> |
ContainerTemplate<Key, Value, Rest...> v8toolkit::map_type_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) |
Definition at line 433 of file casts.hpp.
References testing::Args(), for_each_own_property(), testing::Key(), stringify_value(), and testing::Value().
Referenced by v8toolkit::CastToNative< eastl::vector_map< Key, Value, Args... > >::operator()(), and v8toolkit::CastToNative< std::map< Key, Value, Args... > >::operator()().
ContainerTemplate<Key, Value, Rest...> v8toolkit::multimap_type_helper | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) |
Definition at line 463 of file casts.hpp.
References testing::Args(), for_each_own_property(), for_each_value(), testing::Key(), stringify_value(), and testing::Value().
Referenced by v8toolkit::CastToNative< eastl::vector_multimap< Key, Value, Args... > >::operator()(), and v8toolkit::CastToNative< std::multimap< Key, Value, Args... > >::operator()().
v8toolkit::CAST_TO_JS | ( | bool | , |
{return v8::Boolean::New(isolate, value);} | |||
) |
Referenced by v8toolkit::CastToNative< eastl::vector_multimap< Key, Value, Args... > >::operator()(), and v8toolkit::CastToJS< T const, std::enable_if_t<!is_wrapped_type_v< T > > >::operator()().
v8toolkit::CAST_TO_JS | ( | char | , |
{return v8::Integer::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | unsigned | char, |
{return v8::Integer::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | wchar_t | , |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | char16_t | , |
{return v8::Integer::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | char32_t | , |
{return v8::Integer::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | short | , |
{return v8::Integer::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | int | , |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | unsigned | int, |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | long | , |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | long | long, |
{return v8::Number::New(isolate, static_cast< double >(value));} | |||
) |
v8toolkit::CAST_TO_JS | ( | unsigned long | long, |
{return v8::Number::New(isolate, static_cast< double >(value));} | |||
) |
v8toolkit::CAST_TO_JS | ( | float | , |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | double | , |
{return v8::Number::New(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | std::string | , |
{return v8::String::NewFromUtf8(isolate, value.c_str(), v8::String::kNormalString, value.length());} | |||
) |
v8toolkit::CAST_TO_JS | ( | char * | , |
{return v8::String::NewFromUtf8(isolate, value);} | |||
) |
v8toolkit::CAST_TO_JS | ( | char const * | , |
{return v8::String::NewFromUtf8(isolate, value);} | |||
) |
v8::Local<v8::Value> v8toolkit::cast_to_js_map_helper | ( | v8::Isolate * | isolate, |
MapTemplate< KeyType, ValueType, Rest... > const & | map | ||
) |
Definition at line 645 of file casts.hpp.
Referenced by v8toolkit::CastToJS< eastl::vector_map< A, B, Rest... > >::operator()(), and v8toolkit::CastToJS< std::map< KeyType, ValueType, Rest... > >::operator()().
v8::Local<v8::Value> v8toolkit::cast_to_js_vector_helper | ( | v8::Isolate * | isolate, |
VectorTemplate< std::remove_reference_t< ValueType >, Rest... > const & | vector | ||
) |
Definition at line 665 of file casts.hpp.
Referenced by v8toolkit::CastToJS< eastl::vector< T, Rest... > >::operator()(), v8toolkit::CastToJS< eastl::vector_set< T, Rest... > >::operator()(), v8toolkit::CastToJS< std::vector< T, Rest... > >::operator()(), and v8toolkit::CastToJS< std::set< T, Rest... > >::operator()().
v8::Local<v8::Object> v8toolkit::casttojs_multimaplike | ( | v8::Isolate * | isolate, |
MultiMapLike< A, B, Rest... > const & | map | ||
) |
Definition at line 846 of file casts.hpp.
References testing::A().
Referenced by v8toolkit::CastToJS< eastl::vector_multimap< A, B, Rest... > >::operator()(), and v8toolkit::CastToJS< std::multimap< A, B, Rest... > >::operator()().
v8toolkit::CAST_TO_NATIVE | ( | eastl::string | , |
{HANDLE_FUNCTION_VALUES;return eastl::string(*v8::String::Utf8Value(value));} | |||
) |
v8toolkit::CAST_TO_JS | ( | eastl::string | , |
{return v8::String::NewFromUtf8(isolate, value.c_str());} | |||
) |
T* v8toolkit::get_default_parameter | ( | const v8::FunctionCallbackInfo< v8::Value > & | info, |
int & | i, | ||
std::vector< std::unique_ptr< StuffBase >> & | stuff, | ||
DefaultArgsTuple && | default_args_tuple | ||
) |
Definition at line 38 of file unspecified_parameter_value.h.
std::string v8toolkit::type_details | ( | ) |
Definition at line 1842 of file v8_class_wrapper.h.
T& v8toolkit::get_object_from_embedded_cpp_object | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | value | ||
) |
This can be used from CastToNative<UserType> calls to fall back to if other conversions aren't appropriate
Definition at line 1851 of file v8_class_wrapper.h.
References check_value_is_object(), and V8TOOLKIT_DEBUG.
constexpr bool v8toolkit::get_member_is_readonly | ( | MemberTClassT::* | member | ) |
Definition at line 32 of file v8helpers.h.
std::string v8toolkit::get_stack_trace_string | ( | v8::Local< v8::StackTrace > | stack_trace | ) |
Returns a string with the given stack trace and a leading and trailing newline
stack_trace | stack trace to return a string representation of |
Definition at line 28 of file v8helpers.cpp.
auto v8toolkit::run_function | ( | func::function< ReturnType(Args...)> & | function, |
const v8::FunctionCallbackInfo< v8::Value > & | info, | ||
Ts &&... | ts | ||
) | -> ReturnType |
Definition at line 90 of file v8helpers.h.
References testing::Args().
Referenced by v8toolkit::JSFactory< Base, JSWrapperClass, TypeList< InternalConstructorParams... >, TypeList< ExternalConstructorParams... >, FactoryBase, Deleter >::_create_factory_from_javascript(), v8toolkit::CallCallable< func::function< ReturnType(InitialArg, Args...)>, InitialArg >::operator()(), v8toolkit::CallCallable< func::function< void(InitialArg, Args...)>, InitialArg >::operator()(), v8toolkit::CallCallable< func::function< ReturnType(Args...)> >::operator()(), and v8toolkit::CallCallable< func::function< void(Args...)> >::operator()().
auto v8toolkit::run_function | ( | Callable | callable, |
const v8::FunctionCallbackInfo< v8::Value > & | info, | ||
Ts &&... | ts | ||
) | -> ReturnType |
Definition at line 98 of file v8helpers.h.
void v8toolkit::ReportException | ( | v8::Isolate * | isolate, |
v8::TryCatch * | try_catch | ||
) |
Definition at line 316 of file v8helpers.cpp.
Referenced by call_javascript_function(), call_javascript_function_with_vars(), call_simple_javascript_function(), compile_source(), execute_module(), v8toolkit::Context::run(), and run_script().
std::string v8toolkit::demangle_typeid_name | ( | const std::string & | mangled_name | ) |
Returns a demangled version of the typeid(T).name() passed in if it knows how, otherwise returns the mangled name exactly as passed in
Definition at line 45 of file v8helpers.cpp.
Referenced by demangle(), v8toolkit::CastToJS< T *, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), and v8toolkit::ParameterBuilder< T, std::enable_if_t< std::is_copy_constructible_v< T > &&is_wrapped_type_v< T > > >::operator()().
std::string& v8toolkit::demangle | ( | ) |
Definition at line 145 of file v8helpers.h.
References demangle_typeid_name().
Referenced by v8toolkit::CastToNative< std::tuple< Ts... > >::operator()().
Destination v8toolkit::safe_dynamic_cast | ( | Source * | source | ) |
Definition at line 168 of file v8helpers.h.
Referenced by v8toolkit::CastToJS< T *, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), and safe_dynamic_cast().
Destination* v8toolkit::safe_dynamic_cast | ( | Destination * | source | ) |
Definition at line 178 of file v8helpers.h.
References safe_dynamic_cast().
std::unique_ptr< T > v8toolkit::safe_move_constructor | ( | T && | original | ) |
Definition at line 194 of file v8helpers.h.
References testing::internal::move(), and testing::Ref().
auto v8toolkit::get_typelist_for_function | ( | func::function< R(Ts...)> | ) | -> TypeList< Ts... > |
auto v8toolkit::get_typelist_for_function_strip_first | ( | func::function< R(Head, Tail...)> | ) | -> TypeList< Tail... > |
auto v8toolkit::get_typelist_for_variables | ( | Ts... | ts | ) | -> TypeList< Ts... > |
auto v8toolkit::make_tuple_for_variables | ( | Ts &&... | ts | ) | -> std::tuple<Ts...> |
Definition at line 257 of file v8helpers.h.
void v8toolkit::print_v8_value_details | ( | v8::Local< v8::Value > | local_value | ) |
prints out a ton of info about a v8::Value
Definition at line 129 of file v8helpers.cpp.
Referenced by check_value_is_object(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().
int v8toolkit::get_array_length | ( | v8::Isolate * | isolate, |
v8::Local< v8::Value > | array_value | ||
) |
Returns the length of an array
Definition at line 85 of file v8helpers.cpp.
Referenced by compare_contents(), for_each_value(), make_set_from_object_keys(), pair_type_helper(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().
std::set< std::string > v8toolkit::make_set_from_object_keys | ( | v8::Isolate * | isolate, |
v8::Local< v8::Object > & | object, | ||
bool | own_properties_only = true |
||
) |
Definition at line 160 of file v8helpers.cpp.
References get_array_length().
Referenced by compare_contents(), stringify_value(), and v8toolkit::UndefinedPropertyException::what().
void v8toolkit::for_each_value | ( | const v8::Local< v8::Context > | context, |
const v8::Local< v8::Value > | value, | ||
Callable | callable | ||
) |
d When passed a value representing an array, runs callable with each element of that array (but not on arrays contained within the outer array) On any other object type, runs callable with that element
Definition at line 349 of file v8helpers.h.
References call_simple_javascript_function(), expose_gc(), get_array_length(), get_type_string_for_value(), process_v8_flags(), and set_global_object_alias().
Referenced by for_each_own_property(), and multimap_type_helper().
void v8toolkit::set_global_object_alias | ( | v8::Isolate * | isolate, |
const v8::Local< v8::Context > | context, | ||
std::string | alias_name | ||
) |
Creates a variable with the given alias_name in the context's global object to point back to the global object Same as node.js "global" variable or a web browser "window" object
Definition at line 96 of file v8helpers.cpp.
Referenced by for_each_value().
std::string v8toolkit::get_type_string_for_value | ( | v8::Local< v8::Value > | value | ) |
Returns a string corresponding to the type of the value passed
value | the value whose type to return a string version of |
Definition at line 104 of file v8helpers.cpp.
Referenced by for_each_value().
void v8toolkit::process_v8_flags | ( | int & | argc, |
char ** | argv | ||
) |
parses v8-related flags and removes them, adjusting argc as needed
Definition at line 46 of file v8toolkit.cpp.
Referenced by for_each_value(), and v8toolkit::Platform::init().
void v8toolkit::expose_gc | ( | ) |
exposes the garbage collector to javascript same as passing –expose-gc as a command-line flag To encourage the javascript garbage collector to run from c++ code, use: while(!v8::Isolate::IdleNotificationDeadline([time])) {};
Definition at line 52 of file v8toolkit.cpp.
Referenced by for_each_value(), and v8toolkit::Platform::init().
v8::Local< v8::Value > v8toolkit::call_simple_javascript_function | ( | v8::Isolate * | isolate, |
v8::Local< v8::Function > | function | ||
) |
Definition at line 299 of file v8helpers.cpp.
References ReportException().
Referenced by for_each_value().
void v8toolkit::for_each_own_property | ( | const v8::Local< v8::Context > | context, |
const v8::Local< v8::Object > | object, | ||
T | callable | ||
) |
Calls callable with each javascript "own property" in the object passed.
Definition at line 399 of file v8helpers.h.
References for_each_value().
Referenced by map_type_helper(), and multimap_type_helper().
auto v8toolkit::mapper | ( | const Container & | container, |
Callable | callable | ||
) | -> decltype(MapperHelper<Container, Callable>()(container, callable)) |
IF YOU GET AN ERROR ABOUT RESULT_OF::TYPE NOT EXISTING, MAKE SURE YOUR LAMBDA PARAMETER TYPE IS EXACTLY RIGHT, ESPECTIALLY RE; CONST
container | input container |
callable | transformation callback |
Definition at line 479 of file v8helpers.h.
auto v8toolkit::reducer | ( | const Container & | container, |
Callable | callable | ||
) | -> std::vector<typename std::result_of<Callable(typename Container::value_type)>::type> |
Definition at line 487 of file v8helpers.h.
Definition at line 594 of file v8helpers.h.
v8::Local<T> v8toolkit::get_value_as | ( | v8::Isolate * | isolate, |
v8::Global< v8::Value > & | value | ||
) |
Definition at line 626 of file v8helpers.h.
v8::Local<T> v8toolkit::get_key_as | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Object > | object, | ||
std::string | key | ||
) |
Definition at line 634 of file v8helpers.h.
v8::Local<T> v8toolkit::get_key_as | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Value > | object, | ||
std::string | key | ||
) |
Definition at line 654 of file v8helpers.h.
References get_key(), global_name_conflicts(), reserved_global_names, and stringify_value().
v8::Local< v8::Value > v8toolkit::get_key | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Object > | object, | ||
std::string | key | ||
) |
Definition at line 289 of file v8helpers.cpp.
Referenced by get_key_as().
v8::Local< v8::Value > v8toolkit::get_key | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Value > | value, | ||
std::string | key | ||
) |
Definition at line 293 of file v8helpers.cpp.
std::string v8toolkit::stringify_value | ( | v8::Isolate * | isolate, |
const v8::Local< v8::Value > & | value, | ||
bool | show_all_properties = false , |
||
std::vector< v8::Local< v8::Value >> && | processed_values = std::vector<v8::Local<v8::Value>>{} |
||
) |
Takes a v8::Value and prints it out in a json-like form (but includes non-json types like function)
Good for looking at the contents of a value and also used for printobj() method added by add_print
Definition at line 187 of file v8helpers.cpp.
References get_array_length(), make_set_from_object_keys(), testing::internal::move(), print_v8_value_details(), STRINGIFY_VALUE_DEBUG, and testing::Value().
Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::_add_method(), v8toolkit::Isolate::add_assert(), add_print(), add_require(), compile_source(), JavaScriptFixture::create_context(), dump_prototypes(), get_key_as(), map_type_helper(), multimap_type_helper(), v8toolkit::CastToNative< v8::Local< v8::Function > >::operator()(), and pair_type_helper().
bool v8toolkit::global_name_conflicts | ( | const std::string & | name | ) |
Tests if the given name conflicts with a reserved javascript top-level name
name | value to check |
Definition at line 358 of file v8helpers.cpp.
Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::expose_static_methods(), and get_key_as().
|
inline |
Definition at line 683 of file v8helpers.h.
References print_v8_value_details().
Referenced by get_object_from_embedded_cpp_object(), v8toolkit::CastToNative< T &&, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), v8toolkit::CastToNative< T *, std::enable_if_t< is_wrapped_type_v< T > > >::operator()(), and v8toolkit::CastToNative< std::unique_ptr< T, Rest... >, std::enable_if_t< is_wrapped_type_v< T > > >::operator()().
auto v8toolkit::scoped_run | ( | v8::Isolate * | isolate, |
T | callable | ||
) | -> typename std::result_of<T()>::type |
Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created
Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created The isolate will be passed to the callable
Helper function to run the callable inside contexts. If the isolate is currently inside a context, it will use that context automatically otherwise no context::scope will be created This version requires the isolate is currently in a context The isolate and context will be passed to the callable
Definition at line 111 of file v8toolkit.h.
Referenced by add_module_list(), v8toolkit::Isolate::operator()(), v8toolkit::Context::require_directory(), and scoped_run().
auto v8toolkit::scoped_run | ( | v8::Isolate * | isolate, |
v8::Local< v8::Context > | context, | ||
T | callable | ||
) | -> typename std::result_of<T()>::type |
Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used
Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used The isolate will be passed to the callable
Helper function to run the callable inside contexts. This version is good when the isolate isn't currently within a context but a context has been created to be used The isolate and context will be passed to the callable
Definition at line 175 of file v8toolkit.h.
References scoped_run().
auto v8toolkit::scoped_run | ( | v8::Isolate * | isolate, |
const v8::Global< v8::Context > & | context, | ||
T | callable | ||
) |
Definition at line 228 of file v8toolkit.h.
References scoped_run().
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template | ( | v8::Isolate * | isolate, |
func::function< R(Args...)> | f, | ||
std::string const & | name | ||
) |
Creates a function template from a func::function
Definition at line 356 of file v8toolkit.h.
References testing::Args().
Referenced by add_function(), v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::add_static_method(), and make_function_template().
func::function<R(Args...)> v8toolkit::make_std_function_from_callable | ( | R(CLASS::*)(Args...) const | f, |
CLASS | callable | ||
) |
Takes an arbitrary class method and returns a func::function wrapping it
Definition at line 393 of file v8toolkit.h.
References testing::Args().
Referenced by make_function_template().
func::function<R(Args...)> v8toolkit::make_std_function_from_callable | ( | R(*)(Args...) | callable, |
std::string | name | ||
) |
Definition at line 401 of file v8toolkit.h.
References testing::Args().
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template | ( | v8::Isolate * | isolate, |
T | callable, | ||
std::string | name | ||
) |
Creates a v8::FunctionTemplate for an arbitrary callable
Definition at line 410 of file v8toolkit.h.
References testing::Args(), make_function_template(), and make_std_function_from_callable().
v8::Local<v8::FunctionTemplate> v8toolkit::make_function_template | ( | v8::Isolate * | isolate, |
R(*)(Args...) | f, | ||
std::string const & | name | ||
) |
Creates a function template from a c-style function pointer
Definition at line 420 of file v8toolkit.h.
References testing::Args(), and make_function_template().
void v8toolkit::add_function | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
func::function< R(Args...)> | function | ||
) |
Helper to both create a function template from a func::function and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context
Definition at line 431 of file v8toolkit.h.
References make_function_template().
Referenced by add_assert(), v8toolkit::Context::add_function(), add_function(), v8toolkit::Isolate::add_function(), add_module_list(), add_print(), and add_require().
void v8toolkit::add_function | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
T | callable | ||
) |
Helper to both create a function template from an arbitrary callable and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context
Definition at line 440 of file v8toolkit.h.
References testing::Args(), and make_function_template().
void v8toolkit::add_function | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
R(*)(Args...) | function | ||
) |
Helper to both create a function template from an arbitrary function pointer and bind it with the specified name to the specified object template Adding functions to an object_template allows creation of multiple contexts with the function already added to each context
Definition at line 450 of file v8toolkit.h.
References make_function_template().
void v8toolkit::add_function | ( | const v8::Local< v8::Context > & | context, |
const v8::Local< v8::Object > & | object, | ||
const char * | name, | ||
T | callable | ||
) |
Helper to both create a function template from an arbitrary callable and bind it with the specified name to the specified object template Adding functions to an object allows adding a function to any object, including a context's global object.
Definition at line 460 of file v8toolkit.h.
References add_function(), add_variable(), CONTEXT_SCOPED_RUN, and make_function_template().
void v8toolkit::add_variable | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
const v8::Local< v8::Data > | value | ||
) |
Makes the given javascript value available to all objects created with the object_template as name. Often used to populate the object_template used to create v8::Context objects so the variable is available from all contexts created from that object_template
Definition at line 65 of file v8toolkit.cpp.
Referenced by add_function(), v8toolkit::Context::add_variable(), v8toolkit::Isolate::add_variable(), and execute_module().
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 | ||
) |
Makes the given javascript value available in the given object as name. Often used to add a variable to a specific context's global object
Definition at line 71 of file v8toolkit.cpp.
void v8toolkit::add_function | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
void(*)(const v8::FunctionCallbackInfo< v8::Value > &) | function | ||
) |
add a function that directly handles the v8 callback data explicit function typing needed to coerce non-capturing lambdas into c-style function pointers
Definition at line 78 of file v8toolkit.cpp.
References make_function_template().
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 | ||
) |
Definition at line 524 of file v8toolkit.h.
References ReportException().
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 = {} |
||
) |
Returns true on success with the result in the "result" parameter
Definition at line 550 of file v8toolkit.h.
References ReportException().
Referenced by call_javascript_function().
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 = {} |
||
) |
Returns true on success with the result in the "result" parameter
Definition at line 576 of file v8toolkit.h.
References call_javascript_function().
void v8toolkit::_variable_getter | ( | v8::Local< v8::String > | property, |
const v8::PropertyCallbackInfo< v8::Value > & | info | ||
) |
Definition at line 597 of file v8toolkit.h.
Referenced by expose_variable().
void v8toolkit::_variable_setter | ( | v8::Local< v8::String > | property, |
v8::Local< v8::Value > | value, | ||
const v8::PropertyCallbackInfo< void > & | info | ||
) |
Definition at line 613 of file v8toolkit.h.
Referenced by expose_variable().
void v8toolkit::expose_variable | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
T & | variable | ||
) |
Exposes the specified variable to javascript as the specified name in the given object template (usually the global template). Allows reads and writes to the variable
Definition at line 642 of file v8toolkit.h.
Referenced by v8toolkit::Context::expose_variable(), and v8toolkit::Isolate::expose_variable().
void v8toolkit::expose_variable | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
std::unique_ptr< T, Rest... > & | variable | ||
) |
Definition at line 651 of file v8toolkit.h.
References _variable_getter(), and _variable_setter().
void v8toolkit::expose_variable_readonly | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template, | ||
const char * | name, | ||
T & | variable | ||
) |
Exposes the specified variable to javascript as the specified name in the given object template (usually the global template). Allows reads to the variable. Writes are ignored. TODO: consider making writes errors (throw?)
Definition at line 669 of file v8toolkit.h.
Referenced by v8toolkit::Context::expose_variable_readonly(), and v8toolkit::Isolate::expose_variable_readonly().
void v8toolkit::expose_variable | ( | v8::Local< v8::Context > | context, |
const v8::Local< v8::Object > & | object, | ||
const char * | name, | ||
T & | variable | ||
) |
Exposes the C++ variable 'variable' to a specific javascript object as a read/write variable Often used to add the variable to a context's global object
Definition at line 681 of file v8toolkit.h.
void v8toolkit::expose_variable_readonly | ( | v8::Local< v8::Context > | context, |
const v8::Local< v8::Object > & | object, | ||
const char * | name, | ||
T & | variable | ||
) |
Exposes the C++ variable 'variable' to a specific javascript object as a read-only variable (writes are ignored but are not errors) TODO: consider making them errors (throw?) Often used to add the variable to a context's global object
Definition at line 695 of file v8toolkit.h.
References _print_helper(), _printf_helper(), add_assert(), add_print(), v8toolkit::SetWeakCallbackData::callback, compare_contents(), v8toolkit::SetWeakCallbackData::destructive, get_all_values(), and global_set_weak().
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 | ||
) |
Takes a local and creates a weak global reference callback for it Useful for clearing out C++-allocated memory on javascript garbage collection of an associated javascript object Remember, this is not guaranteed to ever be called
Definition at line 863 of file v8toolkit.cpp.
References v8toolkit::SetWeakCallbackData::callback, v8toolkit::SetWeakCallbackData::global, and v8toolkit::SetWeakCallbackData::SetWeakCallbackData().
Referenced by expose_variable_readonly(), and v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::initialize_new_js_object().
std::string v8toolkit::_printf_helper | ( | const v8::FunctionCallbackInfo< v8::Value > & | args, |
bool | append_newline | ||
) |
Definition at line 116 of file v8toolkit.cpp.
References _format_helper().
Referenced by add_print(), and expose_variable_readonly().
std::vector< v8::Local< v8::Value > > v8toolkit::get_all_values | ( | const v8::FunctionCallbackInfo< v8::Value > & | args, |
int | depth = 1 |
||
) |
Returns the values in a FunctionCallbackInfo object breaking out first-level arrays into their contained values (but not subsequent arrays for no particular reason)
Definition at line 123 of file v8toolkit.cpp.
Referenced by _format_helper(), _print_helper(), and expose_variable_readonly().
std::string v8toolkit::_print_helper | ( | const v8::FunctionCallbackInfo< v8::Value > & | args, |
bool | append_newline | ||
) |
Definition at line 147 of file v8toolkit.cpp.
References get_all_values().
Referenced by add_print(), and expose_variable_readonly().
void v8toolkit::add_print | ( | v8::Isolate * | isolate, |
v8::Local< v8::ObjectTemplate > | object_template, | ||
func::function< void(const std::string &)> | callback = [](const std::string & s){printf("%s", s.c_str());} |
||
) |
Adds the print functions listed below to the given object_template (usually a v8::Context's global object) Optional callback function can be used to send the output to another source (defaults to stdout)
call this to add a set of print* functions to whatever object template you pass in (probably the global one) print takes a single variable or an array and prints each value separated by spaces
println same as print but automatically appends a newlines
printf - Treats the first parameter as a format string. any additional values will be used to fill the format string. If there are insufficient parameters to fill the format, the empty string "" will be used. Any extra parameters will be printed after the filled format string separated by spaces
printfln - same as printf but automatically appends a newline
printobj - prints a bunch of information about an object - format highly susceptible to frequent change
Definition at line 166 of file v8toolkit.cpp.
References _format_helper(), _print_helper(), _printf_helper(), add_function(), and stringify_value().
Referenced by v8toolkit::Isolate::add_print(), and expose_variable_readonly().
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());} |
||
) |
Definition at line 189 of file v8toolkit.cpp.
References _format_helper(), _print_helper(), _printf_helper(), add_function(), and stringify_value().
void v8toolkit::add_assert | ( | v8::Isolate * | isolate, |
v8::Local< v8::ObjectTemplate > | object_template | ||
) |
Adds an assert method that calls assert.h assert() on failure. This is different than the add_assert() in javascript.h that throws an exception on failure because if an exception is not caught before it reaches V8 execution, the program is terminated. javascript.h *Helper classes automatically catch and re-throw exceptions so it is safe to throw in that version, but not this one. The error message resulting from throwing an exception reaching code compiled without exception support is not easy to understand which is why a simple assert is preferable.
Definition at line 212 of file v8toolkit.cpp.
References add_function(), and V8_TOOLKIT_DEBUG.
Referenced by expose_variable_readonly().
bool v8toolkit::compare_contents | ( | v8::Isolate * | isolate, |
const v8::Local< v8::Value > & | left, | ||
const v8::Local< v8::Value > & | right | ||
) |
Definition at line 732 of file v8toolkit.cpp.
References get_array_length(), and make_set_from_object_keys().
Referenced by v8toolkit::Isolate::add_assert(), JavaScriptFixture::create_context(), and expose_variable_readonly().
func::function<R(Args...)> v8toolkit::bind | ( | CLASS & | object, |
R(METHOD_CLASS::*)(Args...) | method | ||
) |
unqualified Helper function to create a Bind object using type deduction and wrap it in a func::function object. This specialization is for handling non-const class methods
Const qualified
object | |
method |
Definition at line 855 of file v8toolkit.h.
References testing::Args().
Referenced by bind(), v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::handle_getter_result(), MyASTConsumer::MyASTConsumer(), and v8toolkit::WebsocketChannel::WebsocketChannel().
func::function<R(Args...)> v8toolkit::bind | ( | CLASS & | object, |
R(METHOD_CLASS::*)(Args...) method & | |||
) |
l-value qualified
object | |
method |
Definition at line 871 of file v8toolkit.h.
References testing::Args(), and bind().
func::function<R(Args...)> v8toolkit::bind | ( | CLASS & | object, |
R(METHOD_CLASS::*)(Args...) const method & | |||
) |
l-value and const qualified
object | |
method |
Definition at line 898 of file v8toolkit.h.
bool v8toolkit::get_file_contents | ( | std::string | filename, |
std::string & | file_contents, | ||
time_t & | file_modification_time | ||
) |
If the filename filename
exists, reeturns true and sets the last modificaiton time and contents otherwise returns false
Definition at line 249 of file v8toolkit.cpp.
References testing::internal::GetFileSize().
Referenced by v8toolkit::Context::compile_from_file(), v8toolkit::ArrayBufferAllocator::Free(), get_file_contents(), and require().
bool v8toolkit::get_file_contents | ( | std::string | filename, |
std::string & | file_contents | ||
) |
same as longer version, just doesn't return modification time if it's not desired
Definition at line 239 of file v8toolkit.cpp.
References get_file_contents().
void v8toolkit::delete_require_cache_for_isolate | ( | v8::Isolate * | isolate | ) |
Before deleting an isolate using require, make sure to clean up its require cache or the program will crash while exiting
isolate | which isolate to delete the cache for |
Definition at line 340 of file v8toolkit.cpp.
Referenced by v8toolkit::ArrayBufferAllocator::Free().
void v8toolkit::add_require | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | context, | ||
const std::vector< std::string > & | paths | ||
) |
adds 'require' method to javascript to emulate node require. Adds an self-referential "global" alias to the global object Must be run after the context is created so "global" can refer to the global object (if this could be changed, it should be, but I don't know how to do it beforehand)
Definition at line 650 of file v8toolkit.cpp.
References add_function(), require(), stringify_value(), and V8_TOOLKIT_DEBUG.
Referenced by v8toolkit::Isolate::add_require(), and v8toolkit::ArrayBufferAllocator::Free().
void v8toolkit::add_module_list | ( | v8::Isolate * | isolate, |
const v8::Local< v8::ObjectTemplate > & | object_template | ||
) |
adds "module_list()" to javascript to require a dictionary of module path+names to exported objects currently required into the specified isolate
Definition at line 632 of file v8toolkit.cpp.
References add_function(), and scoped_run().
Referenced by v8toolkit::Isolate::add_module_list(), and v8toolkit::ArrayBufferAllocator::Free().
bool v8toolkit::require | ( | v8::Local< v8::Context > | context, |
std::string | filename, | ||
v8::Local< v8::Value > & | result, | ||
const std::vector< std::string > & | paths, | ||
bool | track_file_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 &)>() |
||
) |
Attempts to load the specified module name from the given paths (in order). Returns the exported object from the module. Same as calling require() from javascript - this is the code that is actually run for that
Attempts to load the specified external resource. Attempts to load exact match filename in each path, then <filename>.js in each path, then <filename>.json in each path
Paths are attempted in vector order[0, 1, 2...]. If the matching filename ends in .js (either because it was specified as such or because it matched after the suffix was added) it will be executed as a traditional module with the exports object being returned. If the matching filename ends in .json, the last value in the file will be returned. The results of require'd files is cached and if the same module (based on the full matching value including path and any added suffix) is required again, the cached value will be returned. The module will not be re-run.
The goal of this function is to be as close to node.js require as possible, so patches or descriptions of how it differs are appreciated. Not that much time was spent trying to determine the exact behavior, so there are likely significant differences
Definition at line 492 of file v8toolkit.cpp.
References execute_module(), and get_file_contents().
Referenced by add_require(), main(), v8toolkit::Context::require(), require_directory(), and v8toolkit::RequireResult::RequireResult().
void v8toolkit::require_directory | ( | v8::Local< v8::Context > | context, |
std::string | directory_name | ||
) |
requires all the files in a directory
Definition at line 678 of file v8toolkit.cpp.
References require(), and V8_TOOLKIT_DEBUG.
Referenced by v8toolkit::RequireResult::RequireResult().
void v8toolkit::dump_prototypes | ( | v8::Isolate * | isolate, |
v8::Local< v8::Object > | object | ||
) |
Definition at line 711 of file v8toolkit.cpp.
References stringify_value().
Referenced by v8toolkit::V8ClassWrapper< T, V8TOOLKIT_V8CLASSWRAPPER_USE_REAL_TEMPLATE_SFINAE >::_add_method(), and v8toolkit::RequireResult::RequireResult().
std::vector< std::string > v8toolkit::get_interesting_properties | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Object > | object | ||
) |
Definition at line 843 of file v8toolkit.cpp.
Referenced by v8toolkit::RequireResult::RequireResult().
v8::Local< v8::Value > v8toolkit::run_script | ( | v8::Local< v8::Context > | context, |
v8::Local< v8::Script > | script | ||
) |
Definition at line 380 of file v8toolkit.cpp.
References ReportException().
Referenced by v8toolkit::RequireResult::RequireResult().
void v8toolkit::foreach_file | ( | const std::string & | directory_name, |
std::function< void(const std::string &)> const & | callback | ||
) |
Definition at line 943 of file v8toolkit.cpp.
References v8toolkit::SetWeakCallbackData::callback, and foreach_filesystem_helper().
Referenced by v8toolkit::Context::require_directory(), and v8toolkit::RequireResult::RequireResult().
void v8toolkit::foreach_directory | ( | const std::string & | directory_name, |
std::function< void(const std::string &)> const & | callback | ||
) |
Definition at line 947 of file v8toolkit.cpp.
References v8toolkit::SetWeakCallbackData::callback, and foreach_filesystem_helper().
Referenced by v8toolkit::RequireResult::RequireResult().
std::atomic<int> v8toolkit::script_id_counter | ( | 0 | ) |
v8::Local<v8::Context> v8toolkit::get_debug_context | ( | ) |
Referenced by v8toolkit::Context::json(), and v8toolkit::Isolate::json().
v8toolkit::Isolate::operator v8::Local< v8::ObjectTemplate > | ( | ) |
Definition at line 247 of file javascript.cpp.
int v8toolkit::get_array_length | ( | v8::Isolate * | isolate, |
v8::Local< v8::Array > | array | ||
) |
Definition at line 79 of file v8helpers.cpp.
std::string v8toolkit::_format_helper | ( | const v8::FunctionCallbackInfo< v8::Value > & | args, |
bool | append_newline | ||
) |
Definition at line 84 of file v8toolkit.cpp.
References get_all_values().
Referenced by _printf_helper(), and add_print().
bool v8toolkit::_get_modification_time_of_filename | ( | std::string | filename, |
time_t & | modification_time | ||
) |
Definition at line 297 of file v8toolkit.cpp.
cached_isolate_modules_t& v8toolkit::get_loaded_modules | ( | v8::Isolate * | isolate | ) |
Definition at line 345 of file v8toolkit.cpp.
bool v8toolkit::compile_source | ( | v8::Local< v8::Context > & | context, |
std::string | source, | ||
v8::Local< v8::Script > & | script, | ||
v8::Local< v8::Value > & | error, | ||
v8::ScriptOrigin * | script_origin = nullptr |
||
) |
Takes in javascript source and attempts to compile it to a script. On error, it sets the output parameter error
and returns false
Definition at line 356 of file v8toolkit.cpp.
References ReportException(), stringify_value(), and V8_TOOLKIT_DEBUG.
v8::Local<v8::Value> v8toolkit::execute_module | ( | v8::Local< v8::Context > | context, |
const std::string | module_source, | ||
const v8::ScriptOrigin & | script_origin, | ||
v8::Local< v8::Function > & | compiled_function | ||
) |
Compiles the given code within a containing function and returns the exports object
context | |
module_source | |
script_origin |
Definition at line 427 of file v8toolkit.cpp.
References add_variable(), and ReportException().
Referenced by require().
void v8toolkit::foreach_filesystem_helper | ( | const std::string & | directory_name, |
const volatile bool | files, | ||
const volatile bool | directories, | ||
std::function< void(const std::string &)> const & | callback | ||
) |
Definition at line 885 of file v8toolkit.cpp.
References v8toolkit::SetWeakCallbackData::callback.
Referenced by foreach_directory(), and foreach_file().
v8toolkit::CAST_TO_NATIVE | ( | WrappedString | , |
{return WrappedString(CastToNative< std::string >()(isolate, value));} | |||
) |
constexpr bool v8toolkit::always_false_v = always_false<T>::value |
constexpr bool v8toolkit::is_wrapped_type_v = is_wrapped_type<T>::value |
constexpr bool v8toolkit::cast_to_native_supports_default_value_v = cast_to_native_supports_default_value<T>::value |
constexpr bool v8toolkit::is_wrapped_typeish_v |
boost::uuids::random_generator v8toolkit::uuid_generator |
Definition at line 10 of file javascript.cpp.
V8ClassWrapperInstanceRegistry v8toolkit::wrapper_registery |
Definition at line 42 of file v8toolkit.cpp.
Referenced by v8toolkit::V8ClassWrapperInstanceRegistry::cleanup_isolate(), and v8toolkit::Isolate::~Isolate().
std::map< v8::Isolate *, std::vector< std::string > > v8toolkit::used_constructor_name_list_map |
Constructor names already used, including things reserved by JavaScript like "Object" and "Number"
Definition at line 39 of file v8toolkit.cpp.
constexpr bool v8toolkit::is_pointer_to_const_data_member_v = get_member_is_readonly(member) |
Definition at line 38 of file v8helpers.h.
bool v8toolkit::AnybaseDebugPrintFlag = false |
If ANYBASE_DEBUG is defined, then this flag controls whether type conversion information logs are printed to stderr
Definition at line 11 of file v8helpers.cpp.
std::vector< std::string > v8toolkit::reserved_global_names |
Definition at line 368 of file v8helpers.cpp.
Referenced by get_key_as().
std::mutex v8toolkit::require_results_mutex |
Definition at line 335 of file v8toolkit.cpp.
|
static |
Definition at line 338 of file v8toolkit.cpp.