Skip to content

refactor: 宣言/実装の物理分離 (src/ → impl/) - #11

Merged
ainyan03 merged 11 commits into
mainfrom
claude/impl-separation
Feb 9, 2026
Merged

refactor: 宣言/実装の物理分離 (src/ → impl/)#11
ainyan03 merged 11 commits into
mainfrom
claude/impl-separation

Conversation

@ainyan03

@ainyan03 ainyan03 commented Feb 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • src/fleximg/ を宣言のみ(公開ヘッダ)、impl/fleximg/ に実装(.inl)を配置
  • #ifdef FLEXIMG_IMPLEMENTATION パターンを廃止し、fleximg.cpp が宣言ヘッダと .inl 実装の両方をインクルードする構成に変更
  • Arduino ライブラリとして安全にインクルード可能に(ユーザーが誤って実装部を含むヘッダを直接コンパイルするリスクを排除)

Changes

Phase 0: CI

  • impl/ ディレクトリの clang-format チェックを追加

Phase 1-3: 実装分離(26ファイル → .inl)

  • Core: platform.h, pool_allocator.h, node.h
  • Image: pixel_format.h 系(10ファイル), viewport.h
  • Operations: filters.h
  • Nodes: 全11ノード

Phase 4: クリーンアップ

  • #define FLEXIMG_IMPLEMENTATION を全箇所から除去
  • dda.h, format_converter.h を削除(実装は .inl に移行済み)
  • ARCHITECTURE.md, CLAUDE.md, CHANGELOG.md を更新

追加修正

  • examples の FLEXIMG_IMPLEMENTATION 依存を解消(platformio.inifleximg.cpp をビルド対象に追加)
  • common.h: __has_include による FreeRTOS 自動検出(ESP-IDF 直接利用対応)、Arduino フォールバック
  • ninepatch_source_node.inl: setPivot(0, 0) の曖昧性を解消
  • filter_node_base.inl, source_node.inl: implicit int conversion 警告を修正

Test plan

  • pio test -e test_native — 202 test cases, 67,870 assertions passed
  • pio run -e bench_native — SUCCESS
  • WASM build (build.sh) — SUCCESS
  • M5Stack ビルド(ローカル環境の Python バージョン問題で未検証、CI で確認)

ヘッダ/実装分離に備え、impl/ ディレクトリに対するフォーマットチェックを CI に追加。
platform.h, pool_allocator.h, node.h から #ifdef FLEXIMG_IMPLEMENTATION
ブロックを抽出し、impl/fleximg/core/ に .inl ファイルとして配置。
fleximg.cpp から .inl ファイルをインクルードする構造に変更。
viewport.h, filters.h から実装ブロックを抽出し、
impl/fleximg/ に .inl ファイルとして配置。
pixel_format.h, 7つのサブフォーマット .h, dda.h, format_converter.h
から実装ブロックを抽出。pixel_format.inl を集約ファイルとして作成し、
依存順序を維持した include 構成で .inl ファイルを配置。
11ノードファイル (affine, composite, distributor, filter_node_base,
horizontal_blur, matte, ninepatch_source, renderer, sink, source,
vertical_blur) から実装ブロックを抽出し impl/fleximg/nodes/ に配置。
- fleximg.cpp から #define FLEXIMG_IMPLEMENTATION を削除
- dda.h, format_converter.h を削除(実装は .inl に移行済み)
- pixel_format.h の stale コメントを修正
- ARCHITECTURE.md を新しい impl/ 分離構造に合わせて更新
- CLAUDE.md のディレクトリ構成に impl/ を追加
- 各 example から #define FLEXIMG_IMPLEMENTATION を削除
- platformio.ini の全 example 環境に +<fleximg/fleximg.cpp> を追加
- example は宣言ヘッダのみインクルードし、実装は fleximg.cpp 経由で取り込む
- common.h: FreeRTOS/Arduino/PC の3段階分岐でデバッグディレイを定義
  - __has_include で FreeRTOS を検出(ESP-IDF 直接利用にも対応)
  - FreeRTOS なし Arduino 環境では delay() にフォールバック
  - PC/WASM では no-op
- ninepatch_source_node.inl: setPivot(0, 0) の曖昧性を int_fixed キャストで解消
- filter_node_base.inl: computeInputMargin() の戻り値を int_fast16_t にキャスト
- source_node.inl: validWidth の型を int → int_fast16_t に変更
pool_allocator.h に perf_metrics.h のインクルードを追加。
FLEXIMG_DEBUG_PERF_METRICS マクロが stats_ メンバ宣言より前に
定義される必要があるが、fleximg.cpp のインクルード順では
pool_allocator.h が perf_metrics.h より先に処理されるため、
stats_ が未宣言のまま .inl 内で参照されていた。
@ainyan03
ainyan03 merged commit 20b6219 into main Feb 9, 2026
6 checks passed
@ainyan03
ainyan03 deleted the claude/impl-separation branch February 9, 2026 03:36
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