|
Oxygen Engine
Modern C++ 3D Engine using OpenGL
|
JavaScript runtime. More...
#include <OxygenEngine/ext/javascript.h>
Public Member Functions | |
| void | addClass (CallableEntity class_info, const std::vector< CallableEntity > &methods) |
| Add a class type available in JavaScript code. | |
| void | addFunction (CallableEntity function_info) |
| add a C function available in in JavaScript code | |
| void | eval (const char *data) |
| Evaluate a script in the current runtime. | |
Static Public Member Functions | |
| static void | pushJson (duk_context *ctx, const nlohmann::json &data, bool is_object=true) |
| push a nlhomann::json object as a json to the runtime | |
| static nlohmann::json | getJson (duk_context *ctx, int index) |
| pull a nlhomann::json object from a parameter | |
Public Attributes | |
| duk_context * | ctx |
JavaScript runtime.
Can bind function calls to C functions
Usage:
Here is another example where a class is defined and used as first argument:
|
inline |
Add a class type available in JavaScript code.
|
inline |
Evaluate a script in the current runtime.
This method may be called multiple times (for example when appending multiples JS files)
|
inlinestatic |
pull a nlhomann::json object from a parameter
Used to fetch json parameters from C++ functions
|
inlinestatic |
push a nlhomann::json object as a json to the runtime
| ctx | Duktape context |
| data | JSON data |
| is_object | does the object should be sent as an object (true) or as an array (false) |