#!/usr/bin/env python3 """Method-name comparison against active AVA2 Windows extension tables. Presence is not behavioral parity. Macros use ONLY AVA2 Windows headers. """ from pathlib import Path import re,json,subprocess,sys root=Path(__file__).resolve().parents[1] compiler=sys.argv[1] if len(sys.argv)>1 else 'clang++' headers=''.join(f'#include "{root/p}"\n' for p in ('upstream/ava2-client/UserInterface/Locale_inc.h','upstream/ava2-client/EterBase/ServiceDefs.h')) def modules(paths,preprocess=False): result={} for path in paths: source=path.read_text(errors='replace') if preprocess: source=re.sub(r'^\s*#\s*include[^\n]*','',source,flags=re.M) source=source.replace('#pragma once','') source=subprocess.check_output([compiler,'-E','-P','-x','c++','-'],input=headers+source,text=True,stderr=subprocess.DEVNULL) tables=list(re.finditer(r'PyMethodDef\s+(\w+)\s*\[\s*\]\s*=\s*\{(.*?)\};',source,re.S)) for call in re.finditer(r'Py_InitModule\s*\(\s*"([^"\n]+)"\s*,\s*(\w+)',source): candidates=[t for t in tables if t[1]==call[2] and t.start()