All Projects → Leandros → Metareflect

Leandros / Metareflect

Licence: mit
Metareflect is a lightweight reflection system for C++, based on LLVM and Clangs libtooling.

Programming Languages

reflection
70 projects

Labels

Projects that are alternatives of or similar to Metareflect

Cppinsights
C++ Insights - See your source code with the eyes of a compiler
Stars: ✭ 1,382 (+1005.6%)
Mutual labels:  llvm, clang
Seeless
C IDE for iOS
Stars: ✭ 71 (-43.2%)
Mutual labels:  llvm, clang
Zapcc
zapcc is a caching C++ compiler based on clang, designed to perform faster compilations
Stars: ✭ 1,109 (+787.2%)
Mutual labels:  llvm, clang
C2goasm
C to Go Assembly
Stars: ✭ 1,072 (+757.6%)
Mutual labels:  llvm, clang
Bsodsurvivor
This project aims to facilitate debugging a kernel driver in windows by adding support for a code change on the fly without reboot/unload, and more!
Stars: ✭ 122 (-2.4%)
Mutual labels:  llvm, clang
Llvm 9.0 Learner Tutorial
A blog for LLVM(v9.0.0 or v11.0.0) beginner, step by step, with detailed documents and comments. Record the way I learn LLVM and accomplish a complete project for FPGA High-Level Synthesis with it.
Stars: ✭ 58 (-53.6%)
Mutual labels:  llvm, clang
Avalonstudio
Cross platform IDE and Shell
Stars: ✭ 1,132 (+805.6%)
Mutual labels:  llvm, clang
Clangkit
ClangKit provides an Objective-C frontend to LibClang. Source tokenization, diagnostics and fix-its are actually implemented.
Stars: ✭ 330 (+164%)
Mutual labels:  llvm, clang
Llvm Vs2017 Integration
MSBuild 15.0 Toolset integration for multiple LLVM (From v5 to v8)
Stars: ✭ 84 (-32.8%)
Mutual labels:  llvm, clang
Codechecker
CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
Stars: ✭ 1,209 (+867.2%)
Mutual labels:  llvm, clang
Woboq codebrowser
Woboq CodeBrowser
Stars: ✭ 837 (+569.6%)
Mutual labels:  llvm, clang
Tre
LLVM backed progamming language (Go subset)
Stars: ✭ 100 (-20%)
Mutual labels:  llvm, clang
Fcd
An optimizing decompiler
Stars: ✭ 622 (+397.6%)
Mutual labels:  llvm, clang
Cxxctp
DEPRECATED. USE INSTEAD github.com/blockspacer/flextool
Stars: ✭ 58 (-53.6%)
Mutual labels:  llvm, clang
Enzyme
High-performance automatic differentiation of LLVM.
Stars: ✭ 418 (+234.4%)
Mutual labels:  llvm, clang
Optviewer Demo
Demonstration of LLVM's opt-viewer tool
Stars: ✭ 63 (-49.6%)
Mutual labels:  llvm, clang
Clang Power Tools
Bringing clang-tidy magic to Visual Studio C++ developers.
Stars: ✭ 285 (+128%)
Mutual labels:  llvm, clang
Swiftweekly.github.io
A community-driven weekly newsletter about Swift.org
Stars: ✭ 305 (+144%)
Mutual labels:  llvm, clang
Meta Clang
Clang C/C++ cross compiler and runtime for OpenEmbedded/Yocto Project
Stars: ✭ 76 (-39.2%)
Mutual labels:  llvm, clang
Termux Ndk
android-ndk for termux
Stars: ✭ 91 (-27.2%)
Mutual labels:  llvm, clang

MetaReflect

Metareflect is a lightweight reflection system for C++, based on LLVM and Clangs libtooling.

  • Lookup members of reflected classes: Once reflection data has been generated, you can query the members of the class, inspect their types, size and where they're located in the class, as well as qualifiers and storage class.
  • Control over which classes are reflected: By annotating your class with CLASS, and each member which you want to be reflected with PROPERTY, you have fine-grained control over what you want to reflect, and what you want to keep completely private.
  • Extensible: It's easy to add new flags, which can be queried at runtime. This allows for easily adding any feature you like. Currently used to provide serialization from and to a byte stream for annotated classes.

Getting Started

To get started download the latest release here.

Setting Up The Runtime

Metareflect requires the runtime, it's consisting of the interface and a couple helper macros for annotating your classes. To include it into your project, simply copy over the /metareflect folder into your project. Unfortunately, the runtime is not fully header-only and requires you to compile the files ending in .cxx.

Annotating Your Classes

Every class which you want to be reflected needs to be annotated.

point.hxx:

#include <metareflect/metareflect.hxx>

CLASS() Point
{
public:
    PROPERTY()
    int x;

    PROPERTY()
    int y;

    PROPERTY()
    int z;

    FUNCTION()
    size_t Hash() const
    {
        return x ^ y ^ z;
    }
};

point.cxx:

#include "point.hxx"
#include "point.generated.hxx"

/* rest of the code */

For a full example take a look at our /example.

Run The Metareflect Tool

To provide the reflection data, the metareflect tool generates a header-file which contains the reflection data in a format consumable by the runtime. The generated file needs to be in your include path and included into the implementation file of the reflected class.

Since metareflect is based on libtooling, all the flags common to libtooling tools apply to it to. That means if you have a build system which can generate a compile_commands.json (for example: ninja or CMake) you can simply provide it the path to your compilation database and metareflect will pick the correct flags automatically. For further information, consult the LLVM documentation for libtooling.

To generate a compilation database using CMake, pass it -DCMAKE_EXPORT_COMPILE_COMMANDS=ON while generating your build files.

Contributing

Any contribution is welcome. Take a look at the open tickets to get started with the development of metareflect.

Requirements

  • A clone of the LLVM 6.0.0 source code, including clang and clang-extra-tools. See LLVM_SETUP how to setup LLVM for development.
  • A clone of the metareflect repository
  • A beefy computer, otherwise compiling LLVM will take some time

Structure

Metareflect consists of two parts, the runtime and the libtooling tool.

The runtime lives in the metareflect/ folder, while the tooling/ folder contains the source code for the tool.

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/metareflect/metareflect. The directory contains the source code for metareflect and anything you need to get started developing metareflect.

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.

Inspiration

Parts of the design and how the tool works has been based upon prior research done in Unreal Engine 4s UHT (Unreal Header Tool) and Qts moc. If you've used either of the two, you might spot the similarities.

License

MIT License

Copyright (c) 2018 Arvid Gerstmann.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].