|
| 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