Skip to content

Commit 5ccfc18

Browse files
committed
see_missing tool
1 parent 0f4a00c commit 5ccfc18

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ cmake-build-debug
66
.idea
77
docs
88
/.vs
9+
10+
# tools
11+
tools/raylib_api.json

‎tools/see_missing.py‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/python3
2+
3+
"""
4+
lists missing calls to raylib functions
5+
6+
usage: python3 see_missing.py
7+
"""
8+
9+
import json
10+
import sys
11+
from pathlib import Path
12+
13+
14+
def print_err(*args, **kwargs) -> None:
15+
print(*args, file=sys.stderr, **kwargs)
16+
17+
18+
def main() -> int:
19+
raylib_api_path = Path("raylib_api.json")
20+
if not raylib_api_path.exists():
21+
print_err("raylib_api.json not found"
22+
"\n\nget it at raylib/tools/rlparser/output")
23+
return 1
24+
25+
raylib_api: dict[str, list] = json.loads(raylib_api_path.read_text())
26+
raylib_funcs: dict[str, dict] = {func["name"]: func for func in raylib_api["functions"]}
27+
28+
raylib_cpp_files: list[Path] = list(Path("../include").glob("**/*.hpp"))
29+
raylib_cpp_combined: str = "\n".join(x.read_text() for x in raylib_cpp_files)
30+
31+
found_func_calls: int = 0
32+
print("\n\nmissing calls for:\n")
33+
for func_name, func in raylib_funcs.items():
34+
if f"::{func_name}(" in raylib_cpp_combined:
35+
found_func_calls += 1
36+
continue
37+
params = ", ".join(f"{param["type"]} {param["name"]}" for param in func.get("params", {}))
38+
print_err(f"::{func_name}({params})")
39+
40+
percentage: float = round((found_func_calls / len(raylib_funcs)) * 100, 2)
41+
print(f"\n{found_func_calls}/{len(raylib_funcs)} implemented ({percentage}%)")
42+
43+
return 0
44+
45+
46+
if __name__ == "__main__":
47+
sys.exit(main())

0 commit comments

Comments
 (0)