Metapp
A cpp side compiler used for static reflection.
Install / Use
/learn @cppreflect/MetappREADME
Metapp
Metapp is a lightweight side compiler, a tool for static reflection and code generation. It is intended for C++ and is based on LLVM and Clangs libtooling.
It's inpired on regen, cxxctp and metareflect, out of which only cxxctp seems in active development. It is intended to support the custom templating engine of regen, the user pluggable features of cxxctp and combine them with the approach of metareflect and utilize the most of Clangs libtooling.
It was forked from the great work of Metareflect, the project seems now inactive.
Getting Started
Annotating Your Classes
Every class which you want to be reflected needs to be annotated.
complex.hpp:
#define STRUCT struct __attribute__((annotate("reflect-class")))
namespace cxCom {
STRUCT Complex {
double real;
double imaginary;
};
}
After that, you define the template how you would want the genrated code to look like:
printable.inja
#include <iostream>
{% if exists("qualifiedNamespace") %}namespace {{qualifiedNamespace}} { {% endif %}
std::ostream& operator<<(std::ostream& out, const {{type}}& x) {
out
## for field in fields
<< x.{{field}} << ' '
## endfor
<< std::endl;
return out;
}
{% if exists("qualifiedNamespace") %}} // namespace {{qualifiedNamespace}}{% endif %}
The generated code for the above would look like this:
complex_generated.hpp:
#include <iostream>
namespace cxCom {
std::ostream& operator<<(std::ostream& out, const Complex& x) {
out
<< x.real << ' '
<< x.imaginary << ' '
<< std::endl;
return out;
}
} // namespace cxCom
For the full example take a look at the examples directory.
Contributing
Any contribution is welcome. Take a look at the open tickets to get started with the development of metapp.
Requirements
- A clone of the LLVM source code, including clang and clang-extra-tools. See LLVM_SETUP how to setup LLVM for development.
- A clone of the metapp repository
- A beefy computer, otherwise compiling LLVM will take some time
Getting Started
Once you've cloned the LLVM repo (by following the guide at LLVM_SETUP),
navigate to path/to/llvm/tools/clang/tools/extra/metapp/metapp.
The directory contains the source code for metapp and anything you need
to get started developing metapp.
The following resources give an insight into how to develop an libtooling application:
To contribute your changes back, please open a pull request! We welcome any contribution.
License
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
