C++ API Introduction
The Varjus C++ API allows integration of Varjus scripting into your applications. It provides tools to execute scripts, manage execution states, and handle errors efficiently.
Key Features
- Cross-Platform Compatibility: The API works on Windows, Linux, and macOS.
- Simple Script Execution: Load and execute Varjus scripts with minimal setup.
- Error Handling: Capture and process syntax and runtime errors gracefully.
- Multithreading Support: Run multiple independent states in parallel.
- Custom C++ Callbacks: Define and expose C++ functions to be callable from Varjus scripts.
- Custom Object Bindings: Declare custom objects with properties and methods accessible from scripts.
Understanding Execution States
A Varjus::State
represents an isolated execution environment for scripts. Each state maintains its own memory, variables, and execution context. Key properties of states include:
- Automatic Memory Management: The state automatically handles memory allocation and garbage collection.
- Non-Copyable: A
Varjus::State
cannot be copied, as it is explicitly declared non-copyable to prevent unintended behavior. - Thread-Safe: Multiple
Varjus::State
instances can be created and run in parallel across different threads, but each state must be managed independently.
To manage multiple states, create separate instances rather than attempting to share or copy them.