Architecture - Superbelko/ohmygentool GitHub Wiki
The project consists of app entry point (main()) and single entry point for generator (gentool_run()).
main() is responsible for reading project files and passing processed options to generator.
Generator then starts with gathering all macros and then begin translation phase.
Files
Main features are grouped by files, important files list by role:
-
compiler.h:
Implements clang compiler interface, usually user of libclang are writing tools by extendind special class, but gentool needs all the information it can get, which is why Tool class is not enough -
dlang_gen.h:
Processes and translates declarations to D usable form. It gathers information about types, functions, templates, etc. and converts them to D. -
postedits.h:
Implements various post-actions to be run after translation phase, for example "write forward declarations for unknown types". -
ppcallbacks.h:
Processes macros, since macro is a token stream it combines it back to string, and does limited translation as well. -
printprettyd.h:
Implements AST printer, translates C++ AST statements to D.
The most important ones is dlang_gen.h
and printprettyd.h
, one is for declarations and other is for code.