<div dir="ltr">Hi Jonathan,<div><br></div><div>Thanks - that looks similar to what I’ve already got:</div><div><br></div><div><a href="https://github.com/pybee/seasnake">https://github.com/pybee/seasnake</a><br></div><div><br></div><div>The problem I’m hitting isn’t with the method declarations - those are pretty easy to sort out. My problem is with the contents of the COMPOUND_STMT type, which is the body of the methods, and the CALL_EXPR node type in particular.</div><div><br></div><div>Yours,</div><div>Russ Magee %-)</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 21, 2016 at 8:28 AM, Jonathan Coe <span dir="ltr"><<a href="mailto:jbcoe@me.com" target="_blank">jbcoe@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have worked on an early-stage python c++ code model which is built on top of the libclang python API.<div><br></div><div><a href="https://github.com/jbcoe/clang_cpp_code_model" target="_blank">https://github.com/jbcoe/clang_cpp_code_model</a><br></div><div><br></div><div>The code-model is good enough to drive simple code generators and makes it simple to extract a lot of AST info. It is incomplete.</div><div><br></div><div>I don't know what you're trying to do, but maybe the code-model above could be useful.</div><div><br></div><div>regards,</div><div><br></div><div>Jon</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 20 January 2016 at 14:11, Russell Keith-Magee via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div style="font-size:13px">Hi all,</div><div style="font-size:13px"><br></div><div style="font-size:13px">I’ve got some questions about the data returned by the Python bindings to clang.</div><div style="font-size:13px"><br></div></div><div>When clang is invoked with “-Xclang -ast-dump -fsyntax-only” to dump the AST for a source file, the output of clang appears to provide much richer output than the Python bindings exposes. I’m guessing this is because the relevant details are deeply embedded in the cursor object returned by the Python API, but I’m not sure where I should be looking for this extra detail.</div><div><br></div><div><div style="font-size:13px">In particular, when clang returns a CXXConstructExpr, the Python API returns CursorKind.CALL_EXPR, which is the same node type returned by a normal function call - so it isn’t possible to differentiate a normal method call from a constructor.</div><div style="font-size:13px"><br></div><div style="font-size:13px">Similarly, when clang returns a MaterializeTemporaryExpr or ImplicitCastExpr, the Python API returns a CursorKind.UNEXPOSED_EXPR. </div><div style="font-size:13px"><br></div><div style="font-size:13px">How do you interrogate the Python API to determine the richer node types that clang is returning?</div><div style="font-size:13px"><br></div><div style="font-size:13px"><div>If it helps, I’ve posted full example code and output in a gist:</div><div><br></div><span style="font-size:small"><a href="https://gist.github.com/freakboy3742/5826ef09789dfba9042e" target="_blank">https://gist.github.com/freakboy3742/5826ef09789dfba9042e</a></span><br><div><br></div><div>This contains three files: </div><div><br></div><div> * a sample.cpp file with a simple class, and a function using that class</div><div> </div><div> * An AST dump of the file provided by clang</div><div><br></div><div> * The AST produced by the Python bindings, generated by walking the tree, printing the node kind, type, return type and spelling, and then doing the same for each child.</div></div><div style="font-size:13px"><br></div><div style="font-size:13px">Yours,</div><div style="font-size:13px">Russ Magee %-)</div></div></div>
<br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>