C++ Reflection using clang
Please see the project homepage for more details: http://donw.org/b/?d=clReflect
The executables in the "bin" directory can be run directly but require the MSVC 2005 SP1 redistributables:
Use "bin\clscan" to parse your C++ files and output a readable database of type information:
clscan.exe file_a.cpp -output file_a.csv -ast_log file_a_astlog.txt -spec_log file_a_speclog.txt -i "include_path"
Use "bin\clmerge" to merge the output of many C++ files into one readable database of type information:
clmerge.exe module.csv file_a.csv file_b.csv file_c.csv ...
Use "bin\clexport" to convert the readable database to a memory-mapped, C++ loadable/queryable database:
clexport.exe module.csv -cpp module.cppbin -cpp_log module_cpplog.txt -map module.map
* Without a reference to the mapfile generated by your executable/DLL (-map), function addresses won't be exported with your database.
* Only primitives specified by clcpp_reflect will be included in the output databases.
* Pay attention to all reported warnings and be sure to inspect all output logs if you suspect there is a problem.
39/11/2011 - 0.3:
* Updated to use the new clang/LLVM 3.0 release branch, including the source as part of the tree.
* Added container support with iterator interfaces and a means of registering/parsing the containers in C++.
* Added support for constant-size arrays as field types (classes, functions, methods).
* Added constant-time, string-less GetType and GetTypeNameHash functions so that a runtime should never need to depend on string processing and the functions can be used in templated functions.
* Added support for anonymous structs and unions.
* Added new utility library that contains optional C++ runtime components that can be used with clReflect.
* Added versioned, binary serialisation for reflected types.
* Added a JSON serialiser for reflected types with no external library dependencies.
* Added a basic object model implementation with base objects and object database with iterators.
* Added a generic field visitor with delegate for callback.
* Added support for template types as base classes. Template types can now also have base classes/template types.
* Added support for '__int64', 'unsigned __int64', 'long long', 'unsigned long long' and 'wchar_t'.
* Added support for typedefs - treated as typical C++ type aliases.
* Added function address rebasing for the case of rebased DLLs.
* Added a Module (DLL-only) abstraction to utilities with interface/implementation support.
* Added a DerivesFrom method to Classes.
* Added the 'noreflect' attribute for skipping reflection of problematic primitives.
* Added flag attribute bit fields for common flag attributes.
* Added support for the colon character in attribute parsing, for scoped symbols.
* Added primitive searching for overloaded primitives (e.g. functions).
* Added command-line option for system include files - these don't display compile warnings.
* Added CallConstructor/CallDestructor and made it so that clcpp_impl_class now only requires one parameter.
* Big refactor of is_const/modifier parameters. Introduced the Qualifier type to abstract this concept and make it usable elsewhere.
* Field names are no longer fully-scoped, leading to smaller storage, less chance of CRC conflicts and simpler runtime querying/serialisation.
* Shifted unresolved primitive references to clexport where the problem can be more accurately diagnosed. clscan was the wrong place to do this for the majority of cases as types can be forward referenced without a reflection spec.
* Pushed Name construction as far back in the AST consumer as possible. This is potentially slower but it prevents an awful lot of unused name data being constructed, hence reducing the size of the cppbin file (by 20% in my game).
* Using the minimum-size config for linking with clang/LLVM to reduce clscan.exe size by 1MB.
* Fixed bug with the clcpp::FindPrimitive binary search and larger than int range hashes.
* Fixed nasty crash bug with clReflectExport's use of CArray.
* Fixed typo in the database binary serialiser that crashed when a file didn't exist.
* Fixed an assert in the pointer relocator that would assert when allocated data was sizeof(0) and at the end of the allocated stack data.
* Fixed return code of clscan.exe when there are compile errors.
* Fixed bug with reflection spec warnings being generated incorrectly for partially reflected primitives.
* Many more bug fixes and lots of refactoring; see the commit list for more info (https://bitbucket.org/dwilliamson/clreflect/changesets).