[cfe-commits] [PATCH] Add Python bindings to comment AST introspection APIs

Dmitri Gribenko gribozavr at gmail.com
Thu Dec 20 15:52:04 PST 2012


On Fri, Dec 21, 2012 at 1:33 AM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
> On 12/20/12 2:06 PM, Ben Gertzfield wrote:
> I didn't pay much attention to the development of the libclang commenting
> APIs, but I'm guessing the reason we went with a single struct (CXComment)
> is because that's just how C works. The underlying C++ implementation,
> however, does use separate classes for each comment type.
>
> Separate Python classes seem to make sense to me. I'm not too worried about
> fragility because the C bindings will tend to reflect what's happening in
> C++ land. Besides, the C API is supposed to be relatively stable. If you
> model the Python class hierarchy after C++, I think things will be fine.
> Besides, having to call is_foo_type() instead of using isinstance()
> everywhere isn't very "Pythonic."

Honestly, I don't like the comment AST traversal APIs.  I think adding
them was a mistake and I'd support their removal while they still have
zero users.  The comment AST will change, sooner or later, in order to
accommodate new features, and then we will have to invent some
compatibility layer in libclang or remove the APIs, but breaking some
users' code.

@Doug:
Could you please comment on this?  Since we have export to XML, which
is supposed to be stable, I don't see much value in these AST
traversal APIs.  I feel that they will get broken, for example, when
we will start to parse declaration references in inline commands'
arguments (like \c foo()).

If there's anything important missing in the XML, we should add it there.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list