Skip to content

put pause_parse/unpause_parse in RAII - #7749

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:refactor/raii_pause_parse
Open

put pause_parse/unpause_parse in RAII#7749
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:refactor/raii_pause_parse

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

Replace pause_parse()/unpause_parse() with a PauseParseGuard class that bookmarks the parse state, points the parser at the supplied text and filename, and restores the bookmarked state on destruction or an explicit early unpause(). Lookahead sites construct the guard with the current parse position and rewind on unpause.

Unlike pause_parse(), the guard also bookmarks Parse_text, so get_line_num() now walks the correct buffer during nested parses. Consequently, allocate_parse_text() now asserts that parsing is not paused, since clearing or reallocating the shared buffers mid-pause has always silently corrupted the paused parse.

Also remove the unused text parameter from reset_parse(), which recreated the Parse_text/Mp mismatch with no bookmark to restore from.

@Goober5000 Goober5000 added the refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability label Aug 27, 2026
Replace pause_parse()/unpause_parse() with a PauseParseGuard class that bookmarks the parse state, points the parser at the supplied text and filename, and restores the bookmarked state on destruction or an explicit early unpause().  Lookahead sites construct the guard with the current parse position and rewind on unpause.

Unlike pause_parse(), the guard also bookmarks Parse_text, so get_line_num() now walks the correct buffer during nested parses.  Consequently, allocate_parse_text() now asserts that parsing is not paused, since clearing or reallocating the shared buffers mid-pause has always silently corrupted the paused parse.

Also remove the unused text parameter from reset_parse(), which recreated the Parse_text/Mp mismatch with no bookmark to restore from.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Goober5000
Goober5000 force-pushed the refactor/raii_pause_parse branch from 32ade80 to 3916acb Compare August 27, 2026 22:32
@Goober5000 Goober5000 added this to the Release 27.0 milestone Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant