Parsing headers with libclang and retrieve information

Hi,

I’m trying to replace my old code generator based on gccxml by clang and according to the doc, libclang seemed better fitted than writting a fully fledge standalone or a plugin.
I’ve started with the Python bindings, but I couldn’t figure out several things:

  • when I get a type like std::vector, with display name I can get vector, but I never can retrieve the std::. Is there a way of doing so?
  • when I parse headers, I can get the arguments types of a function/method prototype, but not their name. Is there a way of doing so?

I’ve seen many bindings for libclang in Python. Will the current bindings be upgraded at some point? (for instance, I’ve a binding with a better AccessSpecifier handling mecanism)

Perhaps I’m not using the correct approach for this job, so feel free to point me directions!

Regards,

Matthieu Brucher

I've started with the Python bindings, but I couldn't figure out several things:

Are you using ipython? I find ipython's tab-completion is an
excellent way of discovering the libclang API. See for example
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023449.html

- when I get a type like std::vector<something>, with display name I can get vector<something>, but I never can retrieve the std::. Is there a way of doing so?

Here's how clang-ctags does it:

Will the current bindings be upgraded at some point? (for instance, I've a binding with a better AccessSpecifier handling mecanism)

I'm sure the maintainers are open to patches. :slight_smile:

--Dave.

Hi David,

I finally manage to get to the name. I didn't see that I could get the
function's arguments directly without using the function type itself.

If you send patches to the Python bindings to this list they will be
reviewed and hopefully added to the official repository. You can ping me
for a review if nobody is attentive to it.