mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
37258de6b1
Scan all enum definitions in api.proto at codegen time and automatically populate max_value for enum-typed fields. This eliminates the need for manual (max_value) annotations on every enum field. When max_value < 128, the generated calculate_size uses constant-size arithmetic instead of a function call: - `calc_uint32(1, static_cast<uint32_t>(field))` → `field ? 2 : 0` For repeated enum fields with constant element size, the per-element loop is replaced with a multiply: `size += count * bytes_per_element`.