+/* Convenience macros for iteration.
+
+ These macros automatically use ABT_DATA to obtain the data elements that
+ encapsulate abt nodes, which often saves typing and can make code easier to
+ read. Refer to the large comment near the top of this file for an example.
+
+ These macros evaluate their arguments many times. */
+#define ABT_FIRST(STRUCT, MEMBER, ABT) \
+ ABT_NULLABLE_DATA (abt_first (ABT), STRUCT, MEMBER)
+#define ABT_NEXT(DATA, STRUCT, MEMBER, ABT) \
+ ABT_NULLABLE_DATA (abt_next (ABT, &(DATA)->MEMBER), STRUCT, MEMBER)
+#define ABT_FOR_EACH(DATA, STRUCT, MEMBER, ABT) \
+ for ((DATA) = ABT_FIRST (STRUCT, MEMBER, ABT); \
+ (DATA) != NULL; \
+ (DATA) = ABT_NEXT (DATA, STRUCT, MEMBER, ABT))
+#define ABT_FOR_EACH_SAFE(DATA, NEXT, STRUCT, MEMBER, ABT) \
+ for ((DATA) = ABT_FIRST (STRUCT, MEMBER, ABT); \
+ ((DATA) != NULL \
+ ? ((NEXT) = ABT_NEXT (DATA, STRUCT, MEMBER, ABT), 1) \
+ : 0); \
+ (DATA) = (NEXT))
+