[cfe-dev] using python clang.cindex library to generate bindings ?

Sebastien Binet binet at cern.ch
Mon May 3 10:51:09 PDT 2010


hi Daniel,

Excerpts from Daniel Dunbar's message of 2010-05-03 18:26:27 +0200:
> On Sat, May 1, 2010 at 1:05 AM, Sebastien Binet <binet at cern.ch> wrote:
> > hi there,
> >
> > I just noticed that llvm/clang-2.7 provides a ctypes-based library
> > wrapping libCIndex.so for python.
> > Is it possible, planned or adviseable to use such a thing to
> > programatically generate a representation (say in json/xml) of some
> > C/C++ api so it could be then used to automatically generate bindings
> > in other high-level languages ?
> 
> It seems possible, but now one is working on it as far as I know. As
> far as advisable, its certainly a better approach than doing ad hoc
> parsing of C/C++ code.

ok, so if I were to volunteer myself (always a bit dangerous,) where
should I start ?
I suppose some struct to store the various DeclXyz informations would
have to be devised, or some way to expose the various bits and pieces
of what makes wrapping an API "interesting" (function arguments, their
type, name and default values, classes/structs - their fields, names,
types, access-specifiers,...)

(I actually started a JsonPrinter visitor modeled after the
PrintFunctionNames plugin example, as hacking on a little plugin .so
is easier on the turn-around and easier for out-of-tree development)

cheers,
sebastien.
-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################



More information about the cfe-dev mailing list