https://github.com/bentoudev/annotationgenerator
Clang based C++ preprocessor for annotation based reflection generation
https://github.com/bentoudev/annotationgenerator
annotation clang code-generation cpp reflection
Last synced: 7 months ago
JSON representation
Clang based C++ preprocessor for annotation based reflection generation
- Host: GitHub
- URL: https://github.com/bentoudev/annotationgenerator
- Owner: BentouDev
- License: mit
- Created: 2017-09-10T19:58:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-22T14:15:46.000Z (over 1 year ago)
- Last Synced: 2024-12-22T14:28:34.922Z (over 1 year ago)
- Topics: annotation, clang, code-generation, cpp, reflection
- Language: C++
- Homepage:
- Size: 189 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AnnotationGenerator
Clang based C++ preprocessor for annotation based code generation
### Build status
|Windows|
|:-------:|
|[](https://github.com/BentouDev/AnnotationGenerator/actions/workflows/ci.yml)|
### Usage
```bash
$ AnnotationGenerator [TEMPLATE] [FILES]...
$ AnnotationGenerator [TEMPLATE] -i [INPUT_LIST_FILE]
```
Where :
- FILES - list of files to parse,
- TEMPLATE - json configuration file,
``agnes.json``
```json
{
"patterns" : [
{
"template" :[
"template.cpp.mustache"
],
"file" : "(\\W|\\w)*\\.h\\b",
"annotation" : "Meta"
}
]
}
```
``MyClass.h``
```cpp
#define Meta(...) __attribute__((annotate(#__VA_ARGS__)))
class Meta(Serialize) MyClass
{
public:
Meta(DoNotSerialize)
int someField;
};
```
``template.cpp.mustache``
```django
// Generated file, do not modify!
#include "{{header}}.h"
template <> void registerReflection<{{class_name}}>()
{
{{#fields}}
registerField( {{name}}, &{{{canonical_name}}}::{{name}}, {{access}}, Meta::GetType<{{{type}}}> );
{{/fields}}
};
```
### Dependencies
- libclang-5.0
- [nlohmann/json](https://github.com/nlohmann/json) (as conan package)
- [kainjow/Mustache](https://github.com/kainjow/Mustache) (as conan package)