27 lines
1.7 KiB
Python
27 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Conservative static inventory: implemented names do not establish behavioral parity."""
|
|
import json,re
|
|
from pathlib import Path
|
|
root=Path(__file__).resolve().parents[1]
|
|
rows=[]
|
|
candidates=[]
|
|
paths=sorted((root/'src/scripting').glob('python_*.cpp'))
|
|
if not paths:
|
|
raise SystemExit('No scripting sources found; refusing an empty parity inventory')
|
|
for path in paths:
|
|
source=path.read_text()
|
|
constant_handlers={m[1]:m.start() for m in re.finditer(
|
|
r'PyObject\s*\*\s*(\w+)\s*\([^;{}]*\)\s*\{\s*return\s+(?:Py_BuildNone\(\)|Py_BuildValue\("[ib]",\s*[01]\)|PyInt_FromLong\([01]\))\s*;\s*\}',source)}
|
|
for name,handler in re.findall(r'\{\s*"([^"]+)"\s*,\s*(\w+)\s*,\s*METH_',source):
|
|
if 'dummy' in handler:
|
|
rows.append({'file':str(path.relative_to(root)),'api':name,'handler':handler,'status':'placeholder'})
|
|
if handler in constant_handlers:
|
|
candidates.append({'file':str(path.relative_to(root)),'line':source.count('\n',0,constant_handlers[handler])+1,
|
|
'api':name,'handler':handler,'status':'constant-return candidate; compare original behavior before treating as a defect'})
|
|
report={'scope':'Static Python method-table inventory in src/scripting. Constant returns are review candidates, not proven defects. Packet/renderer behavior still requires source comparison. Full parity is NOT established.',
|
|
'source_count':len(paths),'placeholder_count':len(rows),'placeholders':rows,
|
|
'constant_return_candidate_count':len(candidates),'constant_return_candidates':candidates}
|
|
output=root/'docs/WINDOWS-PARITY-INVENTORY.json'
|
|
output.write_text(json.dumps(report,indent=2)+'\n')
|
|
print(f'{len(rows)} placeholder bindings; report: {output}')
|