Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
The deferred IncludeFile objects introduced in #12213 could not be
serialized by the YAML dumper, causing test_build_components to fail
when merging configs that contain !include package references.
Uses add_multi_representer to also match the dynamically-created
ESPHomeDataBase subclass produced by add_class_to_obj.
valve_to_start is set from both codegen (lambdas) and C++ code
(raw size_t in sprinkler.cpp:387). Use TemplatableValue directly
instead of the TEMPLATABLE_VALUE macro since TemplatableFn doesn't
accept raw runtime values.
globals.set action passed raw values with output_type=None, bypassing
the lambda wrapping in cg.templatable(). Now explicitly wraps constants
in a stateless lambda with no return type annotation (compiler deduces
the correct type from the value).
- TemplatableFn = delete now catches both stateful lambdas AND stateless
lambdas with inconvertible return types (e.g., string -> int)
- Add test for to_exp with non-string output_type (lambda-wraps result)
TemplatableFn now accepts stateless lambdas whose return type is
convertible to T (e.g., int -> uint8_t). Uses a casting trampoline
that reconstructs the stateless lambda via F{} (default-constructible
in C++20).
Also:
- Remove std::move on trivially copyable TemplatableFn (clang-tidy)
- Wrap http_request method via cg.templatable()
TEMPLATABLE_VALUE macro now uses TemplatableStorage<T, Ts...> which
selects TemplatableFn for non-string types (4 bytes) and
TemplatableValue for std::string (full PROGMEM/FlashStringHelper support).
Fixes ESP8266 compile failure where __FlashStringHelper* couldn't
assign to TemplatableFn<std::string>.
- TemplatableFn<T, X...>: 4-byte function-pointer-only storage, used by
TEMPLATABLE_VALUE macro for codegen-managed fields
- TemplatableValue<T, X...>: 8-byte value-or-function-pointer storage,
backward compatible with raw constant init and assignment
- Revert api/user_services.h to original (uses TemplatableValue)
- Optimize sensor/number min_/max_ to TemplatableFn
- Optimize mdns port to TemplatableFn with lambda wrappers