[core] Combine entity register + configure_entity_ into one call

Add 4-arg overloads to App.register_<entity>() that call configure_entity_()
and push_back in a single function. Codegen defers App.register_<entity>(var)
emission until finalize_entity_strings(), which then emits a single combined
App.register_<entity>(var, name, hash, packed) call instead of the previous
two-statement pair (App.register_X(var); var->configure_entity_(...)).

Apollo R-PRO-1 (ESP32-S3 IDF, 122 components, 164 entities), same toolchain:
  text:     -1248 bytes
  main.cpp: -164 lines

No behavior change. configure_entity_ remains protected on EntityBase; the
Application class is now a friend so the new overloads can call it.
This commit is contained in:
J. Nick Koston
2026-04-26 14:37:37 -05:00
parent e87e78c544
commit 01e0cda3c0
30 changed files with 145 additions and 48 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ def test_button_sets_mandatory_fields(generate_main):
main_cpp = generate_main("tests/component_tests/button/test_button.yaml")
# Then
assert 'wol_1->configure_entity_("wol_test_1",' in main_cpp
assert 'App.register_button(wol_1, "wol_test_1",' in main_cpp
assert "wol_2->set_macaddr(18, 52, 86, 120, 144, 171);" in main_cpp