Skip to content

Clang based C++ preprocessor for annotation based reflection generation

License

Notifications You must be signed in to change notification settings

BentouDev/AnnotationGenerator

Repository files navigation

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

About

Clang based C++ preprocessor for annotation based reflection generation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published