OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
gen_script_bridge Namespace Reference

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dict OVERLOADS
dict EXTRA_ARGS
dict EXPORT_TRAILING
dict RENAMED
dict PROVIDED
dict EXPORT_CUSTOM

Detailed Description

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.

Variable Documentation

◆ EXPORT_CUSTOM

dict gen_script_bridge.EXPORT_CUSTOM
Initial value:
1= {
2 'Scr_FreeScripts': ,
3 # CoD2rev-Plus returns scr_anim_s by value, which GCC on Linux i386 returns
4 # through a hidden pointer; the engine declares unsigned int and reads eax.
5 'Scr_GetAnim': ,
6 'Scr_ShutdownSystem': ,
7}

◆ EXPORT_TRAILING

dict gen_script_bridge.EXPORT_TRAILING
Initial value:
1= {
2 'MT_Alloc': ['int'], # type
3 'SL_GetString_': ['int'], # type
4 'SL_GetStringOfLen': ['int'], # type
5}

◆ EXTRA_ARGS

dict gen_script_bridge.EXTRA_ARGS
Initial value:
1= {
2 'FS_ListFiles': (['int'], ['10']),
3 'FS_FreeFileList': (['int'], ['10']),
4}

◆ OVERLOADS

dict gen_script_bridge.OVERLOADS
Initial value:
1= {
2 'AddRefToValue': ['int', 'VariableUnion'],
3 'RemoveRefToValue': ['int', 'VariableUnion'],
4}

◆ PROVIDED

dict gen_script_bridge.PROVIDED
Initial value:
1= {'Dvar_FindVar', 'Hunk_AllocXAnimTreePrecache', 'Q_rint', 'Q_vsnprintf', 'Sys_UnimplementedFunctionInternal',
2 'VectorCompare'}

◆ RENAMED

dict gen_script_bridge.RENAMED
Initial value:
1= {
2 'Hunk_ClearTempMemoryHighInternal': 'Hunk_ClearTempMemoryHigh',
3}

◆ ROOT

gen_script_bridge.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))