Skip to content

refactor(slf): extract FormulaHelper to its own TU (isolate exprtk)#57

Closed
alandtse wants to merge 1 commit into
test/cpp-tier2-extracted-logicfrom
test/cpp-tier2-formulahelper
Closed

refactor(slf): extract FormulaHelper to its own TU (isolate exprtk)#57
alandtse wants to merge 1 commit into
test/cpp-tier2-extracted-logicfrom
test/cpp-tier2-formulahelper

Conversation

@alandtse
Copy link
Copy Markdown
Owner

Summary

Completes the Tier-2 plan: extracts FormulaHelper (the exprtk-backed score / redraw-interval / redraw-budget formula evaluator) out of ShadowCasterManager into its own TU, with an opt-in slow-tests target for it (your chosen approach — keeps the fast suite/CI gate fast).

Stacked on #56. Review/merge the Tier-2 stack (#55#56 → this) in order; auto-retargets to dev.

Extraction (pure code move, plugin-validated)

  • New Features/LightLimitFix/FormulaHelper.{h,cpp}: the FormulaParams enum, the kFormulaVars table, and FormulaHelper (Parse/Calculate/Reparse/Validate/SetParam). The header uses a void* pimpl so it stays exprtk-free; FormulaHelper.cpp is the one TU that compiles the huge exprtk header.
  • ShadowCasterManager.cpp is now exprtk-free — the scoring loop still calls FormulaHelper::SetParam(...) unchanged, and the formula-editor UI keeps using kFormulaVars from the header.
  • No behavior change. Plugin (CommunityShaders) builds clean with the extraction.

Opt-in slow-tests target

cpp_tests_slow (-DBUILD_CPP_SLOW_TESTS=ON, OFF by default) compiles FormulaHelper.cpp + exprtk + test_formulahelper.cpp (Parse/Calculate/Validate/Reparse, param binding, malformed/unknown-variable handling). The default cpp_tests and the PR gate are untouched, so the fast loop stays fast.

⚠️ Known issue (flagged)

cpp_tests_slow builds and links but currently registers 0 Catch2 test cases under the local MSVC 14.50 / VS2026 toolchain — a trivial probe TEST_CASE in the main TU also fails to register, so this is a target-level Catch2 registration problem (likely a CRT-runtime/registry-singleton interaction in the minimal standalone target), not an issue with the extraction or the test code. The fast cpp_tests registers fine, so the test logic is sound. The tests don't execute until this harness issue is resolved.

Suggested split: the extraction is clean, validated, and independently valuable — it can merge on its own. The slow-test target is scaffolding pending the registration fix.

Move the FormulaParams enum, kFormulaVars table, and the exprtk-backed
FormulaHelper out of ShadowCasterManager into FormulaHelper.{h,cpp}. The
header uses a void* pimpl so it stays exprtk-free; FormulaHelper.cpp is the
single TU that compiles the (huge) exprtk header. ShadowCasterManager.cpp is
now exprtk-free (the score/redraw formulas still call FormulaHelper::SetParam
etc. unchanged); the formula-editor UI keeps using kFormulaVars from the
header. Pure code move -- no behavior change. Plugin builds clean.

Also adds an opt-in cpp_tests_slow target (-DBUILD_CPP_SLOW_TESTS=ON, OFF by
default so the fast suite / PR gate is unaffected) with test_formulahelper.cpp
covering Parse/Calculate/Validate/Reparse, param binding, and error handling.

KNOWN ISSUE: cpp_tests_slow builds but currently registers 0 Catch2 test
cases under the local MSVC 14.50 toolchain (a trivial probe TEST_CASE in the
main TU also fails to register), so the tests don't yet execute -- a
target-level Catch2 registration problem to resolve, independent of the
extraction (which is plugin-validated) and the test code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f266850e-65e5-4c95-835a-3d9704fc25fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/cpp-tier2-formulahelper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

No actionable suggestions for changed features.

@alandtse
Copy link
Copy Markdown
Owner Author

Abandoning this approach. The opt-in slow-test target registers 0 Catch2 cases under local MSVC 14.50 (a target-level registration issue), so per direction the dead test is removed. Restoring ShadowCasterManager (un-extracting FormulaHelper) per request.

Note on /bigobj: verified empirically that it is NOT avoidable by restoring SCM — exprtk alone exceeds the COFF section limit under MSVC 14.50 (C1128 at exprtk.hpp:12094 even in a standalone FormulaHelper.cpp). So SCM+exprtk and FormulaHelper.cpp+exprtk both require /bigobj locally; CI's VS2022 doesn't need it. /bigobj stays in #56 as a harmless enabler for local VS2026 builds.

@alandtse alandtse closed this May 29, 2026
@alandtse alandtse deleted the test/cpp-tier2-formulahelper branch May 29, 2026 01:50
@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant