Lua Binding Generator
A Lua binding is the interface between the Lua virtual machine and a native C function or a C++ method. It is the glue code that makes it possible to call C functions from within a Lua script.
The idea is that you extend the Lua virtual machine to include your own (e.g.,device management) functions. Lua bindings can be designed manually or generated automatically. This web-application is designed for new users that want to include their proprietary functions and methods without having to learn how to manually construct the Lua bindings.
How to generate Lua bindings for C or C++
- Create a text file with the name functions.txt
- Copy all function declarations from your header file(s) and paste the declarations into functions.txt
- Navigate to the online Lua Binding Generator.
- Select a module name for your functions.
- Select C or C++ and click Continue.
- Use a browser that supports drag and drop such as Firefox or Chrome and drop the functions.txt file into the browser window.
- Download the generated C or C++ file.
- Integrate the generated C file with your build.
Note: Your function declarations pasted into functions.txt may depend on defines, types, enumerations, etc. Do not include these declarations in functions.txt. Instead, drop the header files, where these declarations are defined, into the browser. You can drag and drop multiple files at the same time. For example, select functions.txt and the header files with the declarations and drop these files into the browser. You cannot drop multiple times; all files needed must be dropped simultaneously.
Note: The generator will generate bindings for all functions found in your header files if you drag and drop header files into the browser window, but do not include functions.txt. The purpose with functions.txt is to limit the number of generated bindings to the functions you want to make available to Lua.
Note: functions.txt must include a copy of the class declarations and the class methods if you generate C++ code.
Note: You can ZIP all files together into one file and upload the file using the "traditional" upload button if you use a browser that does not support drag and drop.
Simplified Wrapper Generator (SWIG)
The Lua Binding Generator Web Application is using SWIG under the hood. See the two following links if you run into problems or if you would like to know more about how to generate code:
- SWIG and Lua
- The complete SWIG documentation
Note: The module interface file used by SWIG is automatically created by the Lua Binding Generator Web Application. The file is assembled as follows: