2 * ion/ioncore/region-iter.h
4 * Copyright (c) Tuomo Valkonen 1999-2008.
6 * See the included file LICENSE for details.
9 #ifndef ION_IONCORE_REGION_ITER_H
10 #define ION_IONCORE_REGION_ITER_H
12 #define REGION_FIRST_CHILD(PAR) (((WRegion*)(PAR))->children)
13 #define REGION_LAST_CHILD(PAR) \
14 (REGION_FIRST_CHILD(PAR)==NULL ? NULL \
15 : REGION_PREV_CHILD_WRAP(REGION_FIRST_CHILD(PAR), REGION_FIRST_CHILD(PAR)))
16 #define REGION_NEXT_CHILD(PAR, REG) (((WRegion*)(REG))->p_next)
17 #define REGION_PREV_CHILD(PAR, REG) ((((WRegion*)(REG))->p_prev->p_next) ? \
18 (((WRegion*)(REG))->p_prev) : NULL)
19 #define REGION_NEXT_CHILD_WRAP(PAR, REG) \
20 (((REG) && ((WRegion*)(REG))->p_next) \
21 ? ((WRegion*)(REG))->p_next : REGION_FIRST_CHILD(PAR))
22 #define REGION_PREV_CHILD_WRAP(PAR, REG) \
23 ((REG) ? ((WRegion*)(REG))->p_prev \
24 : REGION_FIRST_CHILD(PAR))
26 #define FOR_ALL_CHILDREN(PAR, REG) \
27 for((REG)=((WRegion*)(PAR))->children; (REG)!=NULL; (REG)=(REG)->p_next)
29 #define FOR_ALL_CHILDREN_W_NEXT(PAR, REG, NEXT) \
30 for((REG)=((WRegion*)(PAR))->children, (NEXT)=((REG)==NULL ? NULL : (REG)->p_next);\
32 (REG)=(NEXT), (NEXT)=((REG)==NULL ? NULL : (REG)->p_next))
34 #endif /* ION_IONCORE_REGION_ITER_H */