You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static PyMethodDef node_methods[] = {
{
.ml_name = "walk",
.ml_meth = (PyCFunction)node_walk,
.ml_flags = METH_NOARGS,
.ml_doc = "walk()\n--\n\n\
Get a tree cursor for walking the tree starting at this node.",
},
It seems like the intent is to be able to invoke walk from any node. The value of .ml_doc seems to suggest this, as it says:
Get a tree cursor for walking the tree starting at this node.
Yeah, this is actually the expected behavior. The cursor only "walks" within the node that it started from, and it can't go outside of it. This is possible to change, but it would add some complexity. Maybe it's worth it though, because this has confused people before.
In order to access a field name for a node, it appears necessary to create the cursor not on the node itself but on an ancestor (so, parent will work). I ran a test now and found that I could get back a non-None appropriate value via current_field_name().
In the comment referenced above you mentioned the possibility of changing how things work. I don't suppose that's still a possibility?
The text was updated successfully, but these errors were encountered:
lunixbochs
changed the title
cursors are different when walking from the root node vs another node
cursors are different when walking from a child node
Feb 8, 2022
Originally posted by @sogaiu in #19 (comment)
The text was updated successfully, but these errors were encountered: