mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[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:
@@ -28,9 +28,9 @@ def test_text_sensor_sets_mandatory_fields(generate_main):
|
||||
main_cpp = generate_main("tests/component_tests/text_sensor/test_text_sensor.yaml")
|
||||
|
||||
# Then
|
||||
assert 'ts_1->configure_entity_("Template Text Sensor 1",' in main_cpp
|
||||
assert 'ts_2->configure_entity_("Template Text Sensor 2",' in main_cpp
|
||||
assert 'ts_3->configure_entity_("Template Text Sensor 3",' in main_cpp
|
||||
assert 'App.register_text_sensor(ts_1, "Template Text Sensor 1",' in main_cpp
|
||||
assert 'App.register_text_sensor(ts_2, "Template Text Sensor 2",' in main_cpp
|
||||
assert 'App.register_text_sensor(ts_3, "Template Text Sensor 3",' in main_cpp
|
||||
|
||||
|
||||
def test_text_sensor_config_value_internal_set(generate_main):
|
||||
|
||||
Reference in New Issue
Block a user