diff -r 7d4e31d295af -r c4dae6fe6d5b src/cx/tree.h --- a/src/cx/tree.h Sat Feb 17 20:51:27 2024 +0100 +++ b/src/cx/tree.h Sun Feb 18 12:24:04 2024 +0100 @@ -46,14 +46,23 @@ /** * When entering a node. + * + * When this is the first sibling, source is the parent, otherwise it is the previous child. */ #define CX_TREE_ITERATOR_ENTER 0x1 /** * When advancing to the next child. + * + * The visited node is the next child and the source is the previous child. + * This pass is triggered after exiting the previous child and before entering the next child. */ #define CX_TREE_ITERATOR_NEXT_CHILD 0x2 /** * When exiting the node. + * + * The visited node is the node being exited and source is the previously entered node + * (usually the last child of the exited node, unless it has no children, in which case it is the node itself). + * When advancing to the next child in a list of siblings, the previous child is exited, first. */ #define CX_TREE_ITERATOR_EXIT 0x4 @@ -278,8 +287,8 @@ * @see cxTreeIteratorDispose() */ __attribute__((__nonnull__)) -CxTreeIterator cx_tree_iterate( - void const *root, +CxTreeIterator cx_tree_iterator( + void *root, int passes, ptrdiff_t loc_children, ptrdiff_t loc_next