[cfe-dev] Writing a more robust code generation system
chris nuernberger
cnuernber at gmail.com
Mon Mar 7 15:29:24 PST 2011
Hey All,
I have written and for a small amount of time maintained a c++ code
generator at work. It uses clang to parse a bunch of c++ headers and
writes out metadata objects doing things like:
find properties (things that look like get[name] const, set[name])
find collections (getNb, get) etc.
Basically it writes out c++ meta objects that describe the
"properties" on the interfaces.
I would like to lift the entire system up into .net and use F# to do
the actual AST analyzation and transformation and data dumping.
Really I would like to use F# script to do this, running on top of a
Clang# dll that pairs with a clang dll or shared library.
Basically I have a couple questions. First off, I do my parsing in a
frontend action. This action gets a callback every so often when new
c++ class is noticed because I derive from the RecursiveASTVisitor
pattern.
What I would like is an interface that basically takes all the
compiler arguments (include paths, etc) and a set of files and returns
an AST that has been lifted into .net-land. Notice that I say "set of
files" not a single cpp or hpp file. I could hack this by just
creating a header and including all the files in the header but there
may be better options.
How insane is it to imagine lifting the AST into .net? I could use
swig to perhaps auto-create .net bindings for most of the AST classes,
etc.
How persistent are the AST classes? The frontends have a callback on
them, HandleTranslationUnit, and I was wondering what in AST land gets
deleted in between calls to HandleTranslationUnit?
Is anyone else working on something like this?
Chris
--
A foolish consistency is the hobgoblin of little minds - Emerson
More information about the cfe-dev
mailing list