Closed kevans91 closed 6 years ago
I think I'd prefer that this return a tri-state enumeration:
I've about got that hammered out- would it make sense that a child node that's been visited may halt recursion through the rest of its siblings without halting the visit entirely? i.e. we'd bubble up the DONT_RECURSE and break out of the loop in visit(), but allow iteration over the grandfather node's siblings.
Yup. Look at libclang's visitor implementation for a good example of a well-designed tree visitor interface.
I've pushed a second cut of it- I wasn't too positive of the placement of the enum, but it seemed like within the node
class was a good candidate. I'd considered just dropping it into dtc::fdt
directly, but then flipped a coin and put it into node
.
I also wasn't sure on enum naming or name of the children, but I did like libclang's terminology for the three behaviors.
Merged, but at some point please will you add Doxygen comments for the enum values?
The callable's return value may indicate whether the recursion should happen or not.
parent
as passed tovisit
will be passed on to the callable, and the recursive call will pass the current node as the parent to its children.I've submitted this separately from /delete-if-unreferenced/ since it's worth of review on its own.