Repository navigation
feat(channels): introduce IChannel ABC base for ChannelEvents (Phase 3a of #2428) - #2433
Merged
zackees merged 1 commit intoMay 10, 2026
Merged
Conversation
…3a of #2428) Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b. Phase 3a is purely an API surface refactor -- no behavior changes: - New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`, noexcept special members, non-copyable/movable. Holds the public surface that any callback might reasonably want. - Channel now derives from CPixelLEDController<RGB> AND IChannel; existing `id()` / `name()` accessors marked `override`. - ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>` to `function_list<void(const IChannel&, ...)>`. Callsites that fire events pass `*this` which upcasts implicitly via the new inheritance. - Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp, fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed. Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211) flagged by lint -- the test-lock fix from #2432 introduced try-except blocks catching Exception without KeyboardInterrupt re-raise. Added the standard `except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki); raise` clause before each `except Exception`. Verification: - bash lint clean. - bash test --cpp passes (286/286). - ChannelEvents tests verified: pointer-identity comparisons `tracker.mLastChannel == channel.get()` still work because Channel inherits from IChannel (implicit upcast). Stacked on top of Phase 2 (#2431). When Phase 3b lands, Channel<B, Chipset> will simply derive from IChannel the same way -- no further event-system changes needed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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
Phase 3a of #2428. Adds a non-template polymorphic anchor
fl::IChannelsoChannelEventscallbacks keep working afterChannel<Bus, Chipset>becomes a template in Phase 3b. Pure API surface refactor — no behavior changes.Stacked on #2431 (Phase 2). Re-target to
masterafter Phase 2 merges.What's in this PR
New file:
src/fl/channels/ichannel.hMinimal ABC with virtual
id()andname(), FL_NOEXCEPT special members, non-copyable/movable. Holds the public surface that any callback might reasonably want to identify a channel.Channelnow derives fromIChannelMultiple inheritance:
class Channel: public CPixelLEDController<RGB>, public IChannel. Existingid()/name()accessors markedoverride. No behavior change — the methods already returned the same types.ChannelEventscallbacks takeIChannelfunction_list<void(const Channel&, ...)>->function_list<void(const IChannel&, ...)>for all 7 event types.channel.cpp.hppthat fire events (events.onChannelCreated(*channel)etc.) work unchanged thanks to the implicitChannel*->IChannel*upcast.Tests + docs migrated
tests/fastled_core.cppEventTracker::mLastChanneltyped asconst IChannel*; methods takeconst IChannel&. Pointer-identity comparisontracker.mLastChannel == channel.get()works becauseChannelinherits fromIChannel.fastled_core.cpp+ 2 infl/channels/driver.cpp+ 2 infl/chipsets/ucs7604.cppupdated toconst IChannel&.README.mdandFastLED.hdocstring examples refreshed.Bonus: fixes pre-existing KBI lint failures in
test.pyThe test-lock fix from #2432 introduced three
try: ... except Exception: passblocks attest.py:186, 193, 211withoutKeyboardInterrupthandlers, which theKeyboardInterrupt handler checkslinter rejects. Added the standardexcept KeyboardInterrupt as ki: handle_keyboard_interrupt(ki); raiseclause before eachexcept Exception. Surfaced because my changes invalidated the lint cache; per project policy fix-when-encountered.Why
Foundation step for Phase 3b (templatize
ChannelConfig<Chipset>andChannel<Bus, Chipset>). Once Channel becomes templated, the event system needs a non-template type to take. Adding theIChannelABC now lets Phase 3b focus purely on the templatization without simultaneously re-plumbing events.Verification
bash lintclean.bash test --cpppasses (286/286).autodeduction tricks,FL_NOEXCEPTeverywhere per project convention).Test plan
Channel<B, Chipset>deriving from IChannel the same way.Related
🤖 Generated with Claude Code