mirror of
https://github.com/esphome/esphome.git
synced 2026-03-01 02:14:19 -07:00
Restore template wrapper as protected register_component_
Rename the non-template to register_component_impl_ and add a protected template register_component_ that wraps it. This preserves the compiler optimization behavior (isra clones) while keeping the method inaccessible to external components. Co-Authored-By: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -79,7 +79,7 @@ static void insertion_sort_by_priority(Iterator first, Iterator last) {
|
||||
}
|
||||
}
|
||||
|
||||
void Application::register_component_(Component *comp) { this->components_.push_back(comp); }
|
||||
void Application::register_component_impl_(Component *comp) { this->components_.push_back(comp); }
|
||||
void Application::setup() {
|
||||
ESP_LOGI(TAG, "Running through setup()");
|
||||
ESP_LOGV(TAG, "Sorting components by setup priority");
|
||||
|
||||
@@ -521,7 +521,14 @@ class Application {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__attribute__((noinline)) void register_component_(Component *comp);
|
||||
/// Register a component - only callable from codegen-generated setup() via friend access.
|
||||
template<class C> C *register_component_(C *c) {
|
||||
static_assert(std::is_base_of<Component, C>::value, "Only Component subclasses can be registered");
|
||||
this->register_component_impl_((Component *) c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void register_component_impl_(Component *comp);
|
||||
|
||||
void calculate_looping_components_();
|
||||
void add_looping_components_by_state_(bool match_loop_done);
|
||||
|
||||
Reference in New Issue
Block a user