fbagen
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

fbagen

fbagen generates object-based accessor code from FlatBuffers schema. Currently fbagen only generate C# code, support of Java / JavaScript is comming soon.

Motivation

While FlatBuffers provides a performance boost on accessing serialized data, it is a little bit of pain to handwrite serialization code for every message. Especially in the prototype stage, schema changes a lot and serialization code have to be adopted.

fbagen parses FlatBuffers schema with Jison and generates traditional object-based, read-only accessors and serializers for FlatBuffer struct or table.

Usage

Install from NPM

$ npm install fbagen
$ node_modules/.bin/fbagen -n -o /path/to/accessors /path/to/flatbuffer/schema

Clone from Github

$ git clone https://github.com/wuyuntao/fbagen.git
cd fbagen
$ node index.js -n -o /path/to/accessors /path/to/flatbuffer/schema

Command-line options

$ node index.js --help
 
  Generate object-based C# accessor code from FlatBuffer schema
 
  Usage
    $ fbagen <files>
 
  Options
    -o, --output-path       Output generated files to path
    -n, --csharp            Generate C# code
 
  Examples
    $ fbagen -o GeneratedCode -n Schema.fbs

Extra schema attributes

fbagen provides several attributes to customize code generation.

  • use_list: When this attribute is added to a Vector type, fbagen will use List<T> as field type instead of Array.

Generated code style

You can find a sample schema and accessors here.

Todo-list

  • Support union syntax
  • Support include syntax
  • Add accessor generation for Java / JavaScript

Readme

Keywords

Package Sidebar

Install

npm i fbagen

Weekly Downloads

2

Version

0.0.3

License

MIT

Last publish

Collaborators

  • wyt.brandon