A tiny C++ Reflection implementation project
use Cmake to run a .exe file before every time build system(or IDE like VS) try to compiling main.cpp.
This Project is for learning purpose
//Todo:use Clang
============Chinese Start===============
实现一个C++反射系统,采用LLVM Clang制作反射工具,构建系统选择Cmake,
实现了在编译main.cpp前执行precompile.exe(metareflect.exe)来生成反射信息。
============Chinese End===============
llvm version: 16.0.0git
put the metareflect folder to you-path-to\llvm-project\clang-tools-extra\
add following texts in CMakeLists.txt in you-path-to\llvm-project\clang-tools-extra\
add_subdirectory(metareflect/tooling)
move to you-path-to\llvm-project\build
type in (use VS for example, not gurantee other compiler or platform can build successfully)
cmake -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -G "Visual Studio 17 2022" -A x64 -Thost=x64 ..\llvm
compile_commands.json
must in (use ninja to generate that file)
you-path-to\llvm-project\clang-tools-extra\metareflect\metareflect
than use VS to biuld metareflect
command line:
./metareflect.exe <path_to_file>
<path_to_file> can be you-path-to\llvm-project\clang-tools-extra\metareflect\metareflect\test.hxx
after parse, build CMakeList.txt in you-path-to\llvm-project\clang-tools-extra\metareflect\metareflect\
run test program.
Integrated metareflect in my tinyReflection Cmake project , change the Class declaration in the test.hxx and run, information of the class
will automatically print to cmdline.
- //TODO: add some GUI stuff to display reflection information;
- //TODO: call object's function by name;
- //TODO: fix compile_commans.json bug, compile_commans.json is generated by ninja build,and may not work well on other computer!
