[PR #1583] gen_d3d12_stubs: preserve multiline comment breaks, reject empty paths, and write atomically (GEN-D3D12-STUBS-COMMENTS-AND-IO) #1601

Open
opened 2026-11-26 20:21:49 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1583
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/gen-d3d12-stubs-comments-and-io


📝 Commits (1)

  • 664a36d gen_d3d12_stubs: preserve multiline comment line breaks, reject empty paths, and write atomically

📊 Changes

2 files changed (+178 additions, -14 deletions)

View changed files

📝 tests/test_gen_d3d12_stubs.py (+118 -0)
📝 tools/gen_d3d12_stubs.py (+60 -14)

📄 Description

Item: GEN-D3D12-STUBS-COMMENTS-AND-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/gen_d3d12_stubs.py).

Summary

  • Preserve line breaks when stripping multiline /* ... */ block comments in parse_interfaces(), preventing adjacent declarations or preprocessor directives after */ from merging into a single malformed method signature.
  • Reject empty or whitespace-only --out, --report, and --header arguments instead of silently ignoring "", falling back to INCLUDE on --header "", or creating whitespace-named files in cwd.
  • Make write_if_changed() read with newline="" (so stale CRLF files are rewritten to LF) and stage writes atomically via file_mode.published_mode + replace_retry.replace (preserving existing files on failure and keeping direct writes for non-regular targets), with strict JSON (allow_nan=False).
  • Catch OSError when reading --header or --source files in main(argv=None) and return a clean one-line ERROR: with exit code 2 instead of a raw traceback.

Verification

  • python3 -W error -I tests/test_gen_d3d12_stubs.py -v: 49 passed, 1 skipped (Windows-only case-fold test).
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py: passed.
  • python3 -m compileall -q tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py: passed.
  • Mutation check (running the new test suite against unpatched main:tools/gen_d3d12_stubs.py): failures=9, errors=1 across all 5 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python build tool; synthetic headers only, no game data)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1583 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/gen-d3d12-stubs-comments-and-io` --- ### 📝 Commits (1) - [`664a36d`](https://github.com/ubiquitarianism/leonida/commit/664a36ddb9fab18325a8f47f5c38d1dcd2781289) gen_d3d12_stubs: preserve multiline comment line breaks, reject empty paths, and write atomically ### 📊 Changes **2 files changed** (+178 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_gen_d3d12_stubs.py` (+118 -0) 📝 `tools/gen_d3d12_stubs.py` (+60 -14) </details> ### 📄 Description Item: `GEN-D3D12-STUBS-COMMENTS-AND-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/gen_d3d12_stubs.py`). ### Summary - Preserve line breaks when stripping multiline `/* ... */` block comments in `parse_interfaces()`, preventing adjacent declarations or preprocessor directives after `*/` from merging into a single malformed method signature. - Reject empty or whitespace-only `--out`, `--report`, and `--header` arguments instead of silently ignoring `""`, falling back to `INCLUDE` on `--header ""`, or creating whitespace-named files in `cwd`. - Make `write_if_changed()` read with `newline=""` (so stale CRLF files are rewritten to LF) and stage writes atomically via `file_mode.published_mode` + `replace_retry.replace` (preserving existing files on failure and keeping direct writes for non-regular targets), with strict JSON (`allow_nan=False`). - Catch `OSError` when reading `--header` or `--source` files in `main(argv=None)` and return a clean one-line `ERROR:` with exit code 2 instead of a raw traceback. ### Verification - `python3 -W error -I tests/test_gen_d3d12_stubs.py -v`: 49 passed, 1 skipped (Windows-only case-fold test). - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py`: passed. - `python3 -m compileall -q tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py`: passed. - Mutation check (running the new test suite against unpatched `main:tools/gen_d3d12_stubs.py`): `failures=9, errors=1` across all 5 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python build tool; synthetic headers only, no game data) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1601
No description provided.