Skip to content

a lua google flatbuffers encode/decode module base on google flatbuffers reflection

Notifications You must be signed in to change notification settings

changnet/lua_flatbuffers

Repository files navigation

lua_flatbuffers

Build Status

a lua google flatbuffers encode/decode module base on google flatbuffers reflection
See more about google flatbuffers at http://google.github.io/flatbuffers/

Dependency

make sure flatbuffers shared library is built if you need to build the lua_flatbuffers.so.

Installation

Make sure lua and FlatBuffers develop environment already installed

  • git clone https://github.com/changnet/lua_flatbuffers.git
  • cd lua_flatbuffers
  • make buildfbb(this will install FlatBuffers with shared library)
  • make
  • make test
  • copy lua_flatbuffers.so to your lua project's c module directory or link against liblua_flatbuffers.a

Api

-- encode lua table into flatbuffer and return the buffer
encode( bfbs,object,tbl )

-- decode flatbuffer into a lua table,return the lua table
decode( bfbs,object,buffer )

-- load all the flatbuffers binary schema file in path with suffix
load_bfbs_path( path,suffix )

-- load one binary schema file
load_bfbs_file( path )

Example & Benchmark

See 'test.lua'

Travis-ci test 100000 times,encode elapsed time: 1.14 second,decode elapsed time: 2.36 second

Note

  1. namespace not supported! you have to put objects with same name in different schema file,though they are in different namespace.
  2. deprecated field still be encode or decode.
  3. [byte] or [ubyte] will be encode as lua string

How flatbuffers reflection work

See document

About

a lua google flatbuffers encode/decode module base on google flatbuffers reflection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published