Skip to content

Type-erase command argument alignment - #483

Draft
TurkeyMan wants to merge 1 commit into
masterfrom
ow/function-adapter-footprint
Draft

Type-erase command argument alignment#483
TurkeyMan wants to merge 1 commit into
masterfrom
ow/function-adapter-footprint

Conversation

@TurkeyMan

Copy link
Copy Markdown
Member

What changed

  • Align named command arguments once in a non-template runtime helper using their declared tuple slot.
  • Pass the aligned slice to a typed converter that performs only the 1:1 Variant[N] to Arg[N] conversion.
  • Share typed converters between commands with identical argument tuples.
  • Preserve positional args and raw named_args sinks, with compile-time type checks.
  • Add focused tests for slot alignment, required and optional arguments, unknown arguments, named-argument sinks, and typed conversion.

Why

The previous make_arg_tuple!fun instantiated parameter-name matching, missing and unknown argument checks, error formatting, and type conversion for every command function. Most of that work does not depend on the command's argument types.

In the SmartEVSE release build, the old 42 tuple builders plus adapters occupied 19,760 bytes. The replacement uses 9,961 bytes:

  • 42 per-command adapters: 5,191 bytes
  • 28 shared typed converters: 4,282 bytes
  • shared alignment and error helpers: 488 bytes

The OTA image decreased from 1,743,504 to 1,732,384 bytes, saving 11,120 bytes and increasing app-slot headroom from 25,968 to 37,088 bytes.

Validation

  • Rebased onto current master.
  • OpenWatt unittest build: 128/128 modules passed.
  • SmartEVSE ESP32 release build linked successfully and produced the size measurements above.

@TurkeyMan
TurkeyMan force-pushed the ow/function-adapter-footprint branch from bda77d8 to 776f809 Compare August 16, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant