Repository navigation
refactor(codegen): extract lifecycle/loop.zig from main_zig.zig (#183 step 8a) - #204
Conversation
There was a problem hiding this comment.
Code Review
This pull request extracts the loop-lifecycle code builders (buildSetupCode and buildGuiDrawCode) from src/main_zig.zig into a new dedicated module src/codegen/lifecycle/loop.zig as part of the #183 refactoring plan. To maintain backward compatibility and preserve existing call sites, these functions are re-exported from src/main_zig.zig. Additionally, several internal helpers in src/main_zig.zig (such as writeImageBackendWiring, LoadStyle, and emitResourceLoad) have been made public so they can be accessed by the new module. I have no feedback to provide as there are no review comments and the refactoring is clean and well-documented.
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 7ac29fe. Bugbot is set up for automated code reviews on this repo. Configure here. |
… of #183) Per the plan in #193. Moved buildSetupCode (raylib/sdl/bgfx/wgpu loop-backend setup) + buildGuiDrawCode to src/codegen/lifecycle/loop.zig (235 lines). Re-exported from main_zig.zig so the orchestrator's references stay unchanged. HIGH-risk extraction per the plan -- preserves call order across writeXxxWiring helpers + emitResourceLoad. Verified bit-identical across all 8 working bundled examples (scripts/gen_all_examples.sh); sokol_imgui still soft-fails because the labelle-imgui sibling repo is absent, same as on origin/main. On this branch the helpers reached by buildSetupCode (writeImageBackendWiring, writeAudioBackendWiring, writeFontBackendWiring, emitResourceLoad, LoadStyle) are still inline in main_zig.zig -- pubified here so the new module can reach them. When the parallel blocks/asset_wiring + blocks/resource_loader cuts (PRs #197, #199) land, lifecycle/loop.zig's imports flip to the new modules and the pub markers in main_zig.zig retire alongside the moved bodies. main_zig.zig shrank 3817 -> 3628 lines (-189). zig build test: 506/510 passed (4 skipped) -- unchanged from baseline. Refs: #183 Builds on: #202 (umbrella) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3226c9d to
7ac29fe
Compare
Summary
Step 8a of the #183 refactor plan. Moves
buildSetupCode(raylib/sdl/bgfx/wgpu loop-backend setup) andbuildGuiDrawCodeout ofsrc/main_zig.ziginto a dedicatedsrc/codegen/lifecycle/loop.zig(235 lines). Re-exported frommain_zig.zigso the orchestrator'sbuildSetupCode(...)/buildGuiDrawCode(...)call sites stay unchanged.HIGH-risk extraction per the plan -- preserves call order across
writeImageBackendWiring,writeAudioBackendWiring,writeFontBackendWiring, andemitResourceLoad. Verified bit-identical across all 8 working bundled examples (raylib, sokol, null, plugin-controllers, flows-smoke, asset-streaming-smoke, bgfx, wgpu).sokol_imguistill soft-fails because thelabelle-imguisibling repo is absent locally, same as onorigin/main.main_zig.zig: 3817 -> 3628 lines (-189)src/codegen/lifecycle/loop.zig: 235 linesHelpers reached back via
main_zig.zigOn this branch the helpers consumed by
buildSetupCode(writeImageBackendWiring,writeAudioBackendWiring,writeFontBackendWiring,emitResourceLoad,LoadStyle) are still inline inmain_zig.zig-- they're pubified here so the new module can reach them. When the parallelblocks/asset_wiring.zig(#197) +blocks/resource_loader.zig(#199) cuts land,lifecycle/loop.zig's imports flip to those new modules and thepubmarkers inmain_zig.zigretire alongside the moved bodies.Test plan
zig build-- cleanzig build test-- 506/510 passed (4 skipped), unchanged from baselinescripts/gen_all_examples.shbefore/after -- every generatedmain.zigbyte-identical (onlyflow_catalog.json'sgenerated_attimestamp differs, as documented in the plan)--forcepush, no logic edits, pure cut + importBuilds on: #202 (umbrella branch
feat/183-split-main-zig).Refs: #183.
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com