templates are supported - though only those which are naturally instantiated (used) by the program itself- Reflected
class/structtypes have:templateparameter names, types, and valuestypedefandusingvalues (i.e.struct Foo { using F = int; /* ... */})- base classes
- class memory layout including
virtualbases, vtable pointers, etc. - fields and get/set values on live objects
- static fields and their values
- functions, member and static, which can be invoked on live objects
- constructors (and destructors) which can be invoked on raw memory to (de)initialize objects
- various type traits (
is_abstract/is_polymorphic/is_pod/...) - inspect
privatemembers
- Reflected
enumtypes have:std::stringto value conversion- value to
std::stringconversion - underlying type information
- Reflected functions:
- can be
invoke(...)'d with arbitrary arguments - list parameters; with types, names, and qualifiers
- can be
The shortest demo which covers the most features (see test/example.test.{cpp, hpp})
archimedes works via a clang plugin which runs on already compiled/template-instantiated ASTs.
It traverses ASTs and gathers type information, serializing it and emitting it in an object file emitted alongside the actual compiler output.
These object files can then be linked into any normal executable (or library) and their data loaded via archimedes::load() on program startup.
In order to not bloat compile times, the majority of information (that which doesn't rely on function pointers, constexpr values, etc.) is
serialized and embedded into the program via simple byte arrays which are deserialized at runtime.
Include include/archimedes.hpp for full access, and include/archimedes/*.hpp for submodules (any, type_id, etc.)
See Makefile for complex usage.
$ clang++
-o main.o
-fplugin=<path_to_argimedes>
-fplugin-arg-archimedes-header-include/archimedes.hpp # path to archimedes header
-fplugin-arg-archimedes-exclude-ns-std # use "exclude-ns-<regex>" to exclude namespaces from reflection
-fplugin-arg-archimedes-file-main.cpp # list files in which types should be reflected
-fplugin-arg-archimedes-file-main.hpp
-fplugin-arg-archimedes-out-main.types.o # reflection output object file
-c
main.cpp
$ clang++ -o main main.o main.types.o # link *.o and *.types.o to include reflection information
$ make plugin static shared