Follow-up Comment #9, bug #16457 (project freeciv):
Some possible approaches to fixing settings.c:
Change all the pointed-to settings (in map.server, game.server etc) to be
'int's. Simplest solution, but ugly in the source code -- it makes the link
between the storage and its type much less obvious.
Use trivial accessor functions to encapsulate the setting storage. These
could take a standard pattern which is autogenerated by a macro
("GEN_ENUM_ACCESSORS(game.info.borders, borders_accessor)" generating a pair
of read/write accessor functions, and we could even hope that on most
platforms the toolchain would spot that all the autogenerated functions boil
down to the same code and merge the object code; but this would make the
source harder to read: the GEN_ENUM_ACCESSORS() invocations would have to be
distant from the GEN_ENUM() definitions, and the latter would look different
from GEN_INT() et al due to not referencing the setting storage directly. So
it would be much harder to work out where a setting actually lived starting
from the GEN_ENUM() definition.
It would be possible to unify it all again by moving to defining settings
<http://en.wikibooks.org/wiki/C_Programming/Preprocessor#X-Macros> or similar,
but at the cost of making it even harder to understand what's going on under
the hood of GEN_ENUM() etc.
Doesn't feel worth the hassle, given the imperfections in the result.
Reply to this item at:
Message sent via/by Gna!
Freeciv-dev mailing list