<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hello,<br>
<br>
I am using the clang python bindings and I can easily access the children of a node/cursor with the function<br>
node.get_children(). See below the code of this function.<br>
<br>
Do you have any idea how to get the parent node from a given node? I don't want the semantic_parent or lexical_parent.
<br>
Any hack to the code of get_children would make it? I see the word "parent" written there.<br>
<br>
Cheers,<br>
<br>
Juan<br>
<br>
<br>
<br>
<br>
<br>
<br>
==================<br>
[from cindex.py]<br>
<br>
def get_children(self):<br>
"""Return an iterator for accessing the children of this cursor."""<br>
<br>
# FIXME: Expose iteration from CIndex, PR6125.<br>
def visitor(child, parent, children):<br>
# FIXME: Document this assertion in API.<br>
# FIXME: There should just be an isNull method.<br>
assert child != conf.lib.clang_getNullCursor()<br>
<br>
# Create reference to TU so it isn't GC'd before Cursor.<br>
child._tu = self._tu<br>
children.append(child)<br>
return 1 # continue<br>
children = []<br>
conf.lib.clang_visitChildren(self, callbacks['cursor_visit'](visitor),<br>
children)<br>
return iter(children)<br>
</div>
</body>
</html>