Add type-safe GUI widget accessor generator#5608
Open
JohnVonDrashek wants to merge 2 commits intosupertuxkart:masterfrom
Open
Add type-safe GUI widget accessor generator#5608JohnVonDrashek wants to merge 2 commits intosupertuxkart:masterfrom
JohnVonDrashek wants to merge 2 commits intosupertuxkart:masterfrom
Conversation
Generate C++ headers from .stkgui XML files providing compile-time
type safety for widget access. Replaces stringly-typed getWidget<T>("id")
calls with typed struct members, catching typos and type mismatches
at compile time instead of runtime.
Features:
- Python generator script (tools/generate_gui_headers.py)
- CMake integration (runs at configure time)
- 82 generated headers for all .stkgui files
- C++ keyword escaping (e.g., "new" -> "new_")
Demo conversion of OptionsScreenAudio to use generated widgets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Bulk conversion of 26 screen/dialog pairs to use generated widget
accessor structs, replacing stringly-typed getWidget<T>("id") calls.
Converted:
- Options: 7 screens (device, display, general, language, ui, video, user)
- Online: 5 screens (online, lan, create_server, networking_lobby, user_search)
- Dialogs: 9 dialogs (addons_loading, confirm_resolution, custom_camera,
custom_video, enter_address, ghost_replay_info, high_score_info,
kart_color_slider, select_challenge)
- Main: 5 screens (main_menu, addons, arenas, race_setup, soccer_setup)
Generator improvements:
- Use AbstractTopLevelContainer* for bind() (works with Screen and ModalDialog)
- Handle identifiers starting with digits (prefix with underscore)
- Handle spaces in identifiers (replace with underscores)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/generate_gui_headers.py) that parses.stkguiXML files and generates type-safe C++ header files with widget accessor methodsChanges
Generator Infrastructure:
tools/generate_gui_headers.py- Parses STKGUI files, generates typed accessorsCMakeLists.txt- Build integrationsrc/generated/gui/- Generated header filesScreen Conversions:
getWidget<Type>("name")calls with generatedwidgets()->name()methodsBenefits
Test plan
Split from #5606 per reviewer feedback to keep PRs focused
🤖 Generated with Claude Code