Generates the C/C++ bridge between the engine and a CoD2rev-Plus module.
python3 scripts/gen_script_bridge.py [--module script|server] [--build build/check-linux] [--names]
The engine calls the module by C names; CoD2rev-Plus's code (src/script, the
VM, or src/server) defines C++ functions (some overloaded) and calls engine
functions by C++ names. Reading the module's objects of a build configured
with it on (the VM is in every build; the server with COD2_PLUS_SERVER), this writes:
- src/compat/<module>_exports.cpp: for each name in
test/<module>_interface.txt, an extern "C" thunk whose symbol is the C name
(an __asm__ label) and which calls the C++ function.
- src/compat/<module>_imports.cpp: for each C++ engine function the module
needs and no other CoD2rev-Plus code defines, a C++ definition that calls
the engine's C symbol. Variadic ones format into a 4096-byte buffer and pass
it on as "%s".
Return types come from decltype on the real CoD2rev-Plus declarations, so the
compiler checks every thunk against them. When test/<module>_abi.txt exists
(format in scripts/engine_abi.py), each thunk also asserts that the return class and
size and the stack slot of every parameter match the engine's definition,
and widens an integer return the two sides give different sizes.
--names prints the imports and exports instead, one per line.