check_ln_api_parity.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. import re
  3. from pathlib import Path
  4. root = Path('/Users/yanxuyao/Vap/QGVAPlayer/QGVAPlayer')
  5. parity = root / 'LNSwift/Bridges/LN_API_PARITY_TABLE.md'
  6. facade = root / 'LNSwift/Core/LNVAPFacade.swift'
  7. parity_text = parity.read_text(encoding='utf-8')
  8. facade_text = facade.read_text(encoding='utf-8')
  9. expected = set()
  10. for token in re.findall(r'`LNVAPFacade\.([^`]+)`', parity_text):
  11. # token may include " / `lnXxx:`" in same line; split conservatively.
  12. for part in token.split(' / '):
  13. part = part.strip()
  14. if not part:
  15. continue
  16. # keep selector-like text only
  17. if re.match(r'^[A-Za-z_][A-Za-z0-9_:]*$', part):
  18. expected.add(part)
  19. exposed = set(re.findall(r'@objc\(([^\)]+)\)', facade_text))
  20. missing = sorted(s for s in expected if s not in exposed)
  21. print(f'expected_from_table={len(expected)}')
  22. print(f'exposed_in_facade={len(exposed)}')
  23. if missing:
  24. print('MISSING_SELECTORS:')
  25. for s in missing:
  26. print(s)
  27. raise SystemExit(1)
  28. print('OK: parity table selectors all exposed in LNVAPFacade')