[core] Dispatch controller updates through generated direct calls

APIServer and WebServer inherited both Component and Controller, so each
on_*_update override reached through the registry needed a non-virtual
thunk to adjust this to the secondary base, and every publish iterated a
StaticVector of Controller pointers with an indirect call.

Drop the Controller base class and the runtime list. ControllerRegistry
only declares notify_*; code generation defines each one in main.cpp as
direct calls on the registered controllers through the entity_types.h
X-macro. A ControllerContract concept with a generated static_assert per
controller reports a missing callback clearly.

On an ESP32 IDF config with api, web_server and four entity types this
saves 256 B of flash and 24 B of RAM.
This commit is contained in:
J. Nick Koston
2026-09-24 16:55:18 +01:00
parent f8e8295088
commit d731ddefc9
19 changed files with 114 additions and 163 deletions
-2
View File
@@ -1,5 +1,4 @@
import esphome.codegen as cg
from esphome.core import CORE
from tests.testing_helpers import ComponentManifestOverride
@@ -12,6 +11,5 @@ def override_manifest(manifest: ComponentManifestOverride) -> None:
cg.add_define("API_MAX_SEND_QUEUE", 8)
cg.add_define("MAX_API_CONNECTIONS", 1)
cg.add_define("USE_SOCKET_IMPL_BSD_SOCKETS")
CORE.register_controller() # api_server registers with the controller registry
manifest.to_code = to_code_testing