0.0.14 • Published 8 months ago

flatt v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

flatt

Flatbuffers ~code~ reflection based generation tool with scripting support.

Why?

Flatbuffers is awesome, but you'll eventually need to (or wish you could) write additional code generation steps for your schema files. For example, generating a network protocol handler/dispatcher for you client and server and keep them in sync.

How does it work?

flatt exposes a lua runtime with some additional helper functions to help you deal with Flatbuffers schema files, reflection and template rendering. You can for example write a flatt script that will reflect your schema, manipulate that data, and render (using a template engine or not) a file with the content you just processed.

All builtin lua libraries are exported and you can use luarocks packages with it if you want to.

An example of what a flatt script looks like:

-- luarocks install lunajson
local lunajson = require("lunajson")

flatt.log.info("Generating headers...")
flatt.flatc({ "--cpp", "./schema.fbs" })

local json = flatt.reflect("./schema.fbs")
flatt.log.trace(json)

--[[
  {
    "tables": [
      {
        "id": 182975129,
        "name": "MyTable",
        "namespace": "my.namespace",
        "fields": [
          {
            "name": "some_field",
            ...
          }
        ]
      }
      ...
    ],
    "structs": [
      ...
    ],
    ...
  }
]]

local info = lunajson.decode(json)

-- generate a file using `info` data

Usage

Installation

  • npm install -g flatt

Requirements

  • Windows (PRs welcome to add Linux+WSL and Mac support)

Overview

flatt some/project.lua

Building

Requirements

  • scoop install cmake
  • scoop install charm-gum
  • scoop install just

Compiling

npm install && npm run build


API Docs

WIP

0.0.14

8 months ago

0.0.10

8 months ago

0.0.11

8 months ago

0.0.12

8 months ago

0.0.13

8 months ago

0.0.9

9 months ago

0.0.8

10 months ago

0.0.6

10 months ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago