diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-11-29 06:22:28 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-16 11:28:44 -0700 |
| commit | 4f6ecc5d11a9a3f3e628080db6f03e8dd4ef3e9d (patch) | |
| tree | 7c2d3f87aa5c98ea1cb9882f56e463cacb5652cc /util.h | |
| parent | 3aa3501aa6d93e96653eb8e8c3662f724d3090ce (diff) | |
| download | vis-4f6ecc5d11a9a3f3e628080db6f03e8dd4ef3e9d.tar.gz vis-4f6ecc5d11a9a3f3e628080db6f03e8dd4ef3e9d.tar.xz | |
main: replace key action enum, prototype, and table with single X-macro list
The lists were very long and if you need to change anything in
them you need to do so in at least 3 different places to ensure
they remain in sync. The idiomatic way of solving this problem in
C (without using features outside the language) is to use a
sequence of X-macros.
This was motivated by the fact that many of the functions in this
file have names that collide with other names in the program. When
the program is compiled into separate object files this is not a
problem but I want to compile vis in a single translation unit. It
also adds more mental overhead when debugging if you have to keep
track of which file you are in as well as which function you are
in.
The macro definition for the function args is less common but is a
good way of ensuring that if you need to modify the type of the
function pointer (i.e. change its arguments) you will not have to
locate hundreds of locations throughout the code.
This also makes it much easier to potentially refactor the
KeyAction array of structs into separate arrays.
Diffstat (limited to 'util.h')
0 files changed, 0 insertions, 0 deletions
