GithubHelp home page GithubHelp logo

blockspacer / librfl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from feed57005/librfl

0.0 2.0 0.0 1.64 MB

Library for generating code from C++ annotations

License: BSD 3-Clause "New" or "Revised" License

Vim Script 0.17% Python 11.41% CMake 16.10% C++ 71.43% C 0.77% HTML 0.12%

librfl's Introduction

librfl

(WIP)

Library for generating code from C++ annotations using Clang Tooling.

#include "rfl/annotations.h"

class rfl_class(name="Hello World") HelloWorld {
public:
  rfl_method(name = "Do Something")
  void DoSomething(rfl_arg(name = "A", kind = "in") int a,
                   rfl_arg(name = "B", kind = "in") int b);

private:
  rfl_property(id = "int_value",
               kind = "number",
               name = "Integer Value",
               default = 10,
               min = 0,
               max = 100,
               step = 1,
               page_step = 1,
               page_size = 1,
               precision = 0)
  int int_value_;
};

How it works

Currently annotations are supported on typedefs, enums, structures & classes, member fields and methods. Source files are fed to rfl-scan that parses the annotations into internal hierachical representation (see rfl/reflected.h):

Package
  PackageFile
    Namespace
      Class
        Method
        Property
        Class
      Enum

Resulting Package is then feed to the Generator plugin which takes care of output (more on that bellow).

Scanner needs an access to compilation flags. These can be provided either via JSON compilation database (generated by CMake) :

rfl-scan -p <cmake_build_directory> <annotated files...>

Or directly using -- :

rfl-scan <annotated files...> -- <c++ flags>
rfl-scan [options] <source0> [... <sourceN>]
  -G=<generator-name>        - Specify output generator
  -basedir=<string>          - Package basedir
  -i=<string>                - Import rfl library
  -l=<string>                - Link library
  -output=<string>           - Output file name prefix
  -p=<string>                - Build path
  -pkg-name=<string>         - Package name
  -pkg-version=<string>      - Package version

See example directory for a more real-like usage.

Installation

  • Requires Clang 3.6 libraries and CMake to be installed
  • Set environment variable LLVM_PATH to point to the Clang installation (eg. export LLVM_PATH=/opt/clang)
  • Use CMake to generate the build

TODO

  • Only single inheritance is supported
  • Support templates

Known limitations

  • Member field offsets may differ when using other compiler than Clang, if so you need to use compiler specific way to compute member offset
  • Tested on Linux and Mac OS X

librfl's People

Contributors

feed57005 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.