/AnnotationGenerator

Clang based C++ preprocessor for annotation based reflection generation

Primary LanguageC++MIT LicenseMIT

AnnotationGenerator

Clang based C++ preprocessor for annotation based code generation

Build status

Windows
CI (on push)

Usage

$ AnnotationGenerator [TEMPLATE] [FILES]...
$ AnnotationGenerator [TEMPLATE] -i [INPUT_LIST_FILE]

Where :

  • FILES - list of files to parse,
  • TEMPLATE - json configuration file,

agnes.json

{
  "patterns" : [
    {
      "template" :[
        "template.cpp.mustache"
      ],
      "file" : "(\\W|\\w)*\\.h\\b",
      "annotation" : "Meta"
    }
  ]
}

MyClass.h

#define Meta(...) __attribute__((annotate(#__VA_ARGS__)))
class Meta(Serialize) MyClass
{
public:
    Meta(DoNotSerialize)
    int someField;
};

template.cpp.mustache

// 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