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
TemplatableValue<uint16_t> no longer accepts raw integer assignment.
Wrap USE_WEBSERVER_PORT, USE_SENDSPIN_PORT, and get_port() calls in
stateless lambdas.
Specialize TemplatableValue so non-string types use function-pointer-only
storage (4 bytes on 32-bit) instead of the tagged union with std::function
support (8 bytes). The std::string specialization retains full support for
VALUE, STATIC_STRING, FLASH_STRING, and stateful lambdas.
Codegen now wraps non-string constants in stateless lambdas automatically,
so the generated C++ always assigns a function pointer.