Skip to content

fix(lint): add FL_NO_EXCEPT to TypeToJson<u32> / <u16> converters - #3532

Merged
zackees merged 2 commits into
masterfrom
fix/noexcept-type-to-json
Jul 1, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/noexcept-type-to-json

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Closes 2 pre-existing NoexceptAstChecker violations in src/fl/remote/rpc/type_to_json.h:37,46. Discovered during #3531 lint pass. Test plan: bash test --cpp = 345/345, bash lint --cpp = clean.

Summary by CodeRabbit

  • New Features

    • Added support for ESP32 I2S buffer-refill callbacks, enabling streaming audio/data workflows to request the next buffer during DMA playback.
    • Expanded mock support to simulate refill events and inspect callback results for more realistic behavior.
  • Tests

    • Added coverage for callback registration, callback failure handling, callback disabling, and coexistence with existing transmit-done behavior.

zackees and others added 2 commits July 1, 2026 10:36
…e 2b prep)

Extends the II2sPeripheralEsp32Dev peripheral interface with the
streaming buffer-refill callback surface that #3526 Phase 2b
needs when it wires the real DMA-EOF ISR into
I2sPeripheralEsp32DevEsp. Ships the API surface + mock impl + host
tests now so:

1. Phase 2b (bench work) can be written against a stable, host-tested
   interface — no design churn when someone with bench access starts.
2. The engine can be structurally exercised end-to-end on host
   (transmit → refill → refill → ... → done) via the mock's
   simulateBufferRefill(), matching how simulateTransmitDone() lets
   the engine test the done-signal path.

## API additions

### `ii2s_peripheral_esp32dev.h`
- New callback signature `I2sEsp32DevBufferRefillCallback`:
  `void(*)(int buffer_index, bool *done, void *user_ctx)`. Fired
  per DMA-EOF interrupt. Caller sets `*done = true` to stop the
  refill cadence.
- New virtual `registerBufferRefillCallback(cb, user_ctx)`. Default
  implementation returns false — impls that don't support streaming
  refill (Stage-4 stub, pure done-only impls) can leave it alone.

### `i2s_peripheral_esp32dev_mock.{h,cpp.hpp}`
- Real implementation of `registerBufferRefillCallback` — stores
  callback + user_ctx.
- New mock-only test hook `simulateBufferRefill(buffer_index)` fires
  the stored callback synchronously and records the `done` return.
- New introspection accessors: `bufferRefillInvocationCount()`,
  `lastRefillBufferIndex()`, `lastRefillDone()`.
- `reset()` clears all new state.

### `channel_engine_i2s_esp32dev.cpp` (host tests)
Six new FL_TEST_CASE covering the refill surface:
- Register + single fire, verify buffer_index + done reporting.
- Cadence across a full buffer ring, verify caller-driven stop.
- nullptr callback + fire is no-op.
- Register nullptr clears the callback.
- setRegisterCallbackFailure knob respected.
- Coexistence with the transmit-done callback (both fire independently).

## What this does NOT do

- Does NOT implement the real DMA-EOF ISR wiring in
  `I2sPeripheralEsp32DevEsp` — that's Phase 2b proper (needs WROOM
  bench). The real impl inherits the default `return false` from the
  interface until it's implemented.
- Does NOT touch the Yves classic driver — that's untouched pending
  Phase 2e deletion.

## Verification

- `bash test --cpp`: 345/345 pass (6 new test cases inside the
  existing `channel_engine_i2s_esp32dev.cpp` test file).
- `bash lint --cpp`: clean modulo 2 pre-existing NoexceptAstChecker
  violations in `src/fl/remote/rpc/type_to_json.h` (unrelated to this
  PR).

Part of #3516 meta / #3526 Phase 2b prep.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closes the two `NoexceptAstChecker` violations in
`src/fl/remote/rpc/type_to_json.h:37,46` — the `convert(...)` overrides
on `TypeToJson<fl::u32>` and `TypeToJson<fl::u16>` were missing
`FL_NO_EXCEPT`. Every other `convert(...)` specialization in the file
that goes through primitive-type paths is trivially noexcept, so
these two just needed the annotation.

Also adds the `fl/stl/noexcept.h` include since the macro wasn't
transitively available through the existing includes.

Discovered while landing #3531 (I2S refill callback interface) —
the pre-existing violations surfaced in the lint pass and were noted
as unrelated. This fixes them so the classic-ESP32 I2S umbrella
(#3516) rollup CI is fully clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 508a5db into master Jul 1, 2026
11 checks passed
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 74ad9e03-ea06-4671-ae9a-e638b99ec806

📥 Commits

Reviewing files that changed from the base of the PR and between 48fab84 and bcbf50e.

📒 Files selected for processing (5)
  • src/fl/remote/rpc/type_to_json.h
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.h
  • src/platforms/esp/32/drivers/i2s/ii2s_peripheral_esp32dev.h
  • tests/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp

📝 Walkthrough

Walkthrough

This PR adds a streaming buffer-refill ISR callback interface (I2sEsp32DevBufferRefillCallback) to the ESP32 I2S peripheral, implements a mock version with simulation and inspection APIs, adds corresponding unit tests, and separately marks two JSON converter functions with FL_NO_EXCEPT.

Changes

ESP32 I2S Buffer Refill Callback

Layer / File(s) Summary
Callback interface contract
src/platforms/esp/32/drivers/i2s/ii2s_peripheral_esp32dev.h
Defines I2sEsp32DevBufferRefillCallback type and adds registerBufferRefillCallback virtual method with a stub default implementation returning false.
Mock header declarations
src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.h
Declares the override for registerBufferRefillCallback plus mock-only simulateBufferRefill and inspection accessors.
Mock implementation
src/platforms/esp/32/drivers/i2s/i2s_peripheral_esp32dev_mock.cpp.hpp
Implements callback registration with failure injection, simulateBufferRefill invocation logic, getters, reset handling, and new state members.
Unit tests
tests/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp
Adds RefillState/refillCb helpers and tests for registration, no-op, disablement, registration failure, and coexistence with transmit-done callbacks.

JSON Conversion Noexcept Annotation

Layer / File(s) Summary
FL_NO_EXCEPT annotations
src/fl/remote/rpc/type_to_json.h
Adds fl/stl/noexcept.h include and marks TypeToJson<fl::u32>::convert and TypeToJson<fl::u16>::convert with FL_NO_EXCEPT.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Code
    participant Mock as I2sPeripheralEsp32DevMock
    participant Callback as refillCb

    Test->>Mock: registerBufferRefillCallback(refillCb, ctx)
    Mock-->>Test: true/false (per mFailRegisterCallback)
    Test->>Mock: simulateBufferRefill(buffer_index)
    Mock->>Callback: invoke(buffer_index, &done, ctx)
    Callback-->>Mock: sets done flag
    Mock-->>Mock: increment invocation count, store last index/done
    Test->>Mock: bufferRefillInvocationCount()
    Mock-->>Test: count
    Test->>Mock: lastRefillBufferIndex() / lastRefillDone()
    Mock-->>Test: last recorded values
Loading

Possibly related PRs

  • FastLED/FastLED#3473: Extends the same Stage-1 ESP32 I2S peripheral mock/interface and channel_engine_i2s_esp32dev.cpp tests with the preceding transmit-done callback behavior that this PR builds upon.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/noexcept-type-to-json

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.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant