C++ Modules interface for QuickJS(ng) API.
The purpose of this project is to import C-style API without polluting the global namespace.
If you want to use QuickJS in C++, please consider quickjspp first.
-
Use C++ Modules & Namespace to keep the global namespace clean and avoid macro pollution.
-
Compile-time constants are wrapped as
inline constexpr auto variable. -
Non-compile-time constants (such as
JS_NULL) are wrapped asinline auto const variable. -
Functions and function-like macros are wrapped by a layer of
inline functionwith the same signature as the original function. -
Functions with variadic arguments are wrapped as
pointerto the original function. -
Some conditional macros are wrapped as
inline constexpr auto variableofbooltype, which are true when defined and false otherwise. -
Some macros cannot be perfectly implemented as functions or variables. If necessary, please define them yourself. Unimplemented macros are:
JS_CFUNC_SPECIAL_DEF.
-
Enable
C++20in your project. -
Import
qjsm.cppmin your project. -
Add
import qjsm;in hpp/cpp files. -
Finally, use the
qjsmnamespace to access the quickjs interface.
Note: All interfaces are prefixed with
$to avoid naming conflicts with macros, such asJS_NULL->qjsm::$JS_NULL.