v8toolkit
0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
|
Go to the source code of this file.
Namespaces | |
v8toolkit | |
Macros | |
#define | V8TOOLKIT_BIDIRECTIONAL_ENABLED |
#define | JS_ACCESS_CORE_DEBUG false |
#define | JS_ACCESS_CORE(ReturnType, name, ...) |
#define | JS_ACCESS(return_type, name) |
#define | JS_ACCESS_0(return_type, name) |
#define | JS_ACCESS_1(return_type, name, t1) |
#define | JS_ACCESS_2(return_type, name, t1, t2) |
#define | JS_ACCESS_3(return_type, name, t1, t2, t3) |
#define | JS_ACCESS_4(return_type, name, t1, t2, t3, t4) |
#define | JS_ACCESS_5(return_type, name, t1, t2, t3, t4, t5) |
#define | JS_ACCESS_6(return_type, name, t1, t2, t3, t4, t5, t6) |
#define | JS_ACCESS_7(return_type, name, t1, t2, t3, t4, t5, t6, t7) |
#define | JS_ACCESS_8(return_type, name, t1, t2, t3, t4, t5, t6, t7, t8) |
#define | JS_ACCESS_9(return_type, name, t1, t2, t3, t4, t5, t6, t7, t8, t9) |
#define | JS_ACCESS_CONST(return_type, name) |
#define | JS_ACCESS_0_CONST(return_type, name) |
#define | JS_ACCESS_1_CONST(return_type, name, t1) |
#define | JS_ACCESS_2_CONST(return_type, name, t1, t2) |
#define | JS_ACCESS_3_CONST(return_type, name, t1, t2, t3) |
#define | JS_ACCESS_4_CONST(return_type, name, t1, t2, t3, t4) |
#define | JS_ACCESS_5_CONST(return_type, name, t1, t2, t3, t4, t5) |
#define | JS_ACCESS_6_CONST(return_type, name, t1, t2, t3, t4, t5, t6) |
#define | JS_ACCESS_7_CONST(return_type, name, t1, t2, t3, t4, t5, t6, t7) |
#define | JS_ACCESS_8_CONST(return_type, name, t1, t2, t3, t4, t5, t6, t7, t8) |
#define | JS_ACCESS_9_CONST(return_type, name, t1, t2, t3, t4, t5, t6, t7, t8, t9) |
Functions | |
template<class T > | |
std::enable_if_t< std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > | v8toolkit::safe_get_javascript_object (T *object) |
template<class T > | |
std::enable_if_t<!std::is_base_of< JSWrapperBase, T >::value, v8::Local< v8::Object > > | v8toolkit::safe_get_javascript_object (T *object) |
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.
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::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.
#define V8TOOLKIT_BIDIRECTIONAL_ENABLED |
Definition at line 5 of file bidirectional.h.
#define JS_ACCESS_CORE_DEBUG false |
Definition at line 493 of file bidirectional.h.
#define JS_ACCESS_CORE | ( | ReturnType, | |
name, | |||
... | |||
) |
This code looks for a javascript method on the JavaScript object contained in the "this" JSWrapper object and call the "name"d method on it. It must work when this method is called directly to start the method call (using a bidirectional object from C++) as well as when the method call is started from javascript (where the javascript interpreter checks the prototype chain initially and might find this function) If not careful, this function can find itself while looking for a javascript version to call because even though its methods aren't mapped into javascript, the parent type's are and dynamic dispatch will call the derived class's version instead of the base class. That is why static dispatch is specifically used for the C++ fallback case: this->BASE_TYPE::name( __VA_ARGS__ );
Definition at line 507 of file bidirectional.h.
#define JS_ACCESS | ( | return_type, | |
name | |||
) |
Definition at line 540 of file bidirectional.h.
#define JS_ACCESS_0 | ( | return_type, | |
name | |||
) |
Definition at line 546 of file bidirectional.h.
#define JS_ACCESS_1 | ( | return_type, | |
name, | |||
t1 | |||
) |
Definition at line 552 of file bidirectional.h.
#define JS_ACCESS_2 | ( | return_type, | |
name, | |||
t1, | |||
t2 | |||
) |
Definition at line 558 of file bidirectional.h.
#define JS_ACCESS_3 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3 | |||
) |
Definition at line 564 of file bidirectional.h.
#define JS_ACCESS_4 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4 | |||
) |
Definition at line 570 of file bidirectional.h.
#define JS_ACCESS_5 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5 | |||
) |
Definition at line 576 of file bidirectional.h.
#define JS_ACCESS_6 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6 | |||
) |
Definition at line 582 of file bidirectional.h.
#define JS_ACCESS_7 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7 | |||
) |
Definition at line 588 of file bidirectional.h.
#define JS_ACCESS_8 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7, | |||
t8 | |||
) |
Definition at line 594 of file bidirectional.h.
#define JS_ACCESS_9 | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7, | |||
t8, | |||
t9 | |||
) |
Definition at line 600 of file bidirectional.h.
#define JS_ACCESS_CONST | ( | return_type, | |
name | |||
) |
Definition at line 606 of file bidirectional.h.
#define JS_ACCESS_0_CONST | ( | return_type, | |
name | |||
) |
Definition at line 612 of file bidirectional.h.
#define JS_ACCESS_1_CONST | ( | return_type, | |
name, | |||
t1 | |||
) |
Definition at line 619 of file bidirectional.h.
#define JS_ACCESS_2_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2 | |||
) |
Definition at line 625 of file bidirectional.h.
#define JS_ACCESS_3_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3 | |||
) |
Definition at line 631 of file bidirectional.h.
#define JS_ACCESS_4_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4 | |||
) |
Definition at line 637 of file bidirectional.h.
#define JS_ACCESS_5_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5 | |||
) |
Definition at line 643 of file bidirectional.h.
#define JS_ACCESS_6_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6 | |||
) |
Definition at line 649 of file bidirectional.h.
#define JS_ACCESS_7_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7 | |||
) |
Definition at line 655 of file bidirectional.h.
#define JS_ACCESS_8_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7, | |||
t8 | |||
) |
Definition at line 661 of file bidirectional.h.
#define JS_ACCESS_9_CONST | ( | return_type, | |
name, | |||
t1, | |||
t2, | |||
t3, | |||
t4, | |||
t5, | |||
t6, | |||
t7, | |||
t8, | |||
t9 | |||
) |
Definition at line 667 of file bidirectional.h.