Add explicit Storage union with trivial ctor/dtor so that
TemplatableValue works with non-trivially-constructible types like
std::vector<uint8_t>. The union's value_ lifetime is managed
externally via placement new and destroy_().
Reverts esp32_ble_server back to TEMPLATABLE_VALUE macro.
TemplatableStorage now selects TemplatableFn (4 bytes) for trivially
copyable types and TemplatableValue (8 bytes) for non-trivial types.
This automatically handles std::string (PROGMEM support) and
std::vector<uint8_t> (raw value assignment from C++) without
special-casing.
Reverts esp32_ble_server back to TEMPLATABLE_VALUE macro since
std::vector<uint8_t> now correctly gets TemplatableValue.
- sprinkler: fix codegen to use cg.size_t for valve_number (was cg.uint8)
- remote_base/toto: move send_times/send_wait defaults to codegen
- remote_base/abbwelcome: wrap auto_message_id bool via cg.templatable
- http_request: wrap capture_response bool via cg.templatable
- core/automation.h: add casting trampoline to TemplatableValue (same as
TemplatableFn) for codegen with mismatched return types
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()