diff options
author | Łukasz Czerwiński <milimetr88@gmail.com> | 2012-04-30 13:11:48 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2012-04-30 13:15:19 +0200 |
commit | 1152d91a1c8ac90528660df7dfa6be2181f89c05 (patch) | |
tree | 3f124b6912dab5ec8b5e13ff9b4db375c53d8007 /flower | |
parent | a8841c7b9212700f2ebac56e0713afa78a8f0ca0 (diff) |
Issue 2491: Macro for(UP_and_DOWN) and 3 similar.
Replaces do{ ... } while(flip (&d) != DOWN/UP/... with a macro for(DOWN_and_UP/UP_and_DOWN/....) { }
Signed-off-by: David Kastrup <dak@gnu.org>
Diffstat (limited to 'flower')
-rw-r--r-- | flower/include/direction.hh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/flower/include/direction.hh b/flower/include/direction.hh index 50c41a4ab4..97c0f6d79b 100644 --- a/flower/include/direction.hh +++ b/flower/include/direction.hh @@ -60,7 +60,7 @@ operator - (Direction const d) return other_dir (d); } -// huh? +// to be deleted soon (after coping with issues 2491 and 2493 inline Direction flip (Direction *i) { @@ -71,6 +71,16 @@ flip (Direction *i) return *i; } +#define UP_and_DOWN(d) \ + Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) + +#define DOWN_and_UP(d) \ + Direction d = DOWN; d != CENTER; d = (d == DOWN ? UP : CENTER) + +#define LEFT_and_RIGHT(d) \ + Direction d = LEFT; d != CENTER; d = (d == LEFT ? RIGHT : CENTER) + + /** if d > 0: the max operator if d < 0: the min operator |