Building a C++ Reflection System
summary
A concrete C++ reflection system that parses the AST with LLVM/clang libTooling and generates a header with AST-driven code generation to provide runtime types, fields and functions; implements JSON stringify/dump, visitation, FNV-1a type hashes and typedef expansion; uses attributes/macros to mark what to reflect and emits a header per translation unit (header cogeneration); roughly 3k LOC of hand code plus ~5k lines of tooling, demonstrated compiling and working but intrusive and requiring a separate tool.
AI-written summary · about
chapters (44)
- 0:00Introduction
- 0:11Structure as function
- 3:22Get type
- 6:52How to start
- 11:47Getting the data
- 13:35Primitive types
- 17:48LLVM
- 18:56Lib tooling
- 19:33Code generation
- 20:26Hello ASD program
- 21:44Hello LLVM program
- 23:35Annotation
- 24:17Secret Files
- 24:53Property Macro
- 25:49Class Finder
- 27:43Run method
- 29:11Calling dumb function
- 29:34Running the tool
- 30:23Single record
- 31:45Generating code
- 32:34Cogeneration
- 33:25Generate
- 34:55emeritus
- 35:22the little
- 36:39user
- 39:12public API
- 39:32dumping
- 40:26debug information
- 40:52class implementation
- 42:41detail illumination
- 43:03type
- 44:22function parameters
- 45:27class
- 45:52supervisor
- 46:21middle class
- 46:46end class
- 47:03branch
- 47:44primitive
- 47:59string
- 48:49primitive function
- 49:13future
- 50:58working confession
- 51:38how does it expand
- 51:51creating a fully qualified name
related talks
58mWriting a reflection engine from scratch
01h 03mC++ Reflection: Back on Track
01h 05mC++ Reflection Based Libraries to Look Forward To
01h 21mGazing Beyond Reflection for C++26
40mReflection in C++ Next
39mReflection without Reflection TS
05mUsing type_traits and constexpr to make code more readable/debuggable
02h 02mPeering forward: C++'s next decade
