|CDT API for macro introspections [message #1008405]
||Tue, 12 February 2013 11:01
| Michaël Melchiore
Registered: April 2012
I am implementing an automatic data types importer from C source files to a custom EMF (IDL like) metamodel. I chose CDT for my first prototype as it provides convenient introspection abilities and would allow me to remain in the Eclipse/Java ecosystem.
As references, I use "Using CDT APIs to programmatically introspect C/C++ code" from Markus Schorn, a CDT dev FAQ and the project generated javadoc.
I have written a small C project on which I can test my features as I implement them. Using C-Model and C-Index cooperatively, I can successfully query a CDT project for its defined type aliases, arrays, structs and unions. Yet, I am having trouble dealing with macros.
I found no simple way to compute which types relied on macros (ex: array sizes, ...) in their definitions: macro values are already expanded in typedef bindings and AST. The C-Index does provide methods to quickly find out all references of a given macro, but I have been unable to link a reference with its enclosing definition: the "getEnclosingDefinition" method is unimplemented for macros.
Is it difficult to implement it ? Should I try to compare file locations instead ? It seems tedious and with scaling issues.
Powered by FUDForum
. Page generated in 0.01612 seconds