37#define ITERATOR(p) ((struct iterator *)(p))
105#define generic_iterate(TYPE_it, TYPE_a, NAME_a, FUNC_size, FUNC_init, ...) \
107 gi_mem MY_mem_##NAME_a(FUNC_size()); \
108 struct iterator *MY_it_##NAME_a; \
111 FUNC_init((TYPE_it *) MY_mem_##NAME_a.array , ## __VA_ARGS__); \
112 for (; iterator_valid(MY_it_##NAME_a); iterator_next(MY_it_##NAME_a)) { \
113 NAME_a = (TYPE_a) iterator_get(MY_it_##NAME_a);
117#define generic_iterate(TYPE_it, TYPE_a, NAME_a, FUNC_size, FUNC_init, ...) \
119 char MY_mem_##NAME_a[FUNC_size()]; \
120 struct iterator *MY_it_##NAME_a; \
123 FUNC_init((TYPE_it *) (void *) MY_mem_##NAME_a , ## __VA_ARGS__); \
124 for (; iterator_valid(MY_it_##NAME_a); iterator_next(MY_it_##NAME_a)) { \
125 NAME_a = (TYPE_a) iterator_get(MY_it_##NAME_a);
129#define generic_iterate_end \
static void * iterator_get(const struct iterator *it)
static bool iterator_valid(const struct iterator *it)
static void iterator_next(struct iterator *it)
struct iterator * invalid_iter_init(struct iterator *it)
bool(* valid)(const struct iterator *it)
void *(* get)(const struct iterator *it)
void(* next)(struct iterator *it)