# luatablegen
`luatablegen` takes a list of C structures and generates lua tables in C.
The input is in the form of a JSON file that describes the C structure and the Lua types you want.
Each structure will have it's own pair of C source and header. There is an option for an aggregate header which will include all the headers and in has a function that registers all the tables with Lua.
`luatablegen` will generate a lua file that includes default constructors for all tables which you can use in Lua with `require`. luatablegen will also generate a markdown file listing the methods for the tables.
For an example you can look under the test directory.
## Lua Version
The generated code is supposed to be used with lua 5.3.
## table gen file
Each entry in the JSON file should have the following fields:
* field_name: a list of the names of the C structure field names.
* field_type: a list of the names of the C types for the C structure fields.
* lua_type: a list of the names of the lua types that the Lua table fields corresponding to the C structure fields will have.
* methods: a list of the methods that will be generated for the Lua table corresponding to the C structure.
## Options
```bash
-h, --help show this help message and exit
--out OUT output directory
--tbg TBG the table gen file
--pre PRE path to source code file to add after header
guard/extern c
--post POST path to source code file to add before header
guard/extern c end
--luaheader LUAHEADER
path to lua header files
--dbg debug
--singlefile should all the generated code be added to a single
file
--makemacro generate a makefile containing all objects in a macro
to be included by another makefile
--outfile OUTFILE name of the output file if signlefile is set, ignored
otherwise
--headeraggr HEADERAGGR
header aggregate file name
--lualibpath LUALIBPATH
where the lua module file will be placed
--docpath DOCPATH where the doc file will be placed
```
## Projects
The list of the projects that use luatablegen:
* [bruiser](https://github.com/bloodstalker/mutator/tree/master/bruiser)
## TODO
* fields should be able to reference each other.
* add more options for the table fileds.