vclua
Gui library for lua
- Active · last change 6-11-2026
- ★ 11 on GitHub
README
vclua
Gui library for lua
Version 1.0.0
Made with Lazarus version 3.2
Binary releases at sourceforge (win32, win64, linux)
Lua 5.1-5.4 and Luajit
vclua binaries or from vt-form distributives (only Luajit/5.4)
Free Pascal -> Lua generator
Supported features
Types
Automatic inference from source files:
- basic types
- enums, sets, chars are represented as Lua strings, also TShortCut if possible
- dynamic arrays are represented as Lua arrays
- event procedures (to set/get properties)
- type aliases
Configurable list of LCL and other classes
- supported classes with constructors with 0 or 1 parameters
- if the class isn't in that list, only its published properties are supported
- additional functions can be added
- global variables can be exported for use in Lua
- the object pointer is stored in the field
Handle - rule of thumb: LCL class
T<name>would be available as<name>in Lua Stringscan be set as a Lua array of stringsCollectioncan be set as a Lua array ofCollectionItemor a Lua array of tables of properties of those items
Records: TPoint, TRect, TSize, TTextStyle
- record fields can be of any casing when passing from Lua to Free Pascal
- to set
TPoint,TRect,TSizevalues in Free Pascal one needs to pass all of the fields in Lua - to set
TTextStyleone can pass any subset of fields, rest will beDefaulted
Unsupported types:
- records not explicitly mentioned
- event functions
- procedural types for method parameters
- class references
objectvariables- list
Language features
- published properties (any casing is supported)
- public properties
- public and protected event procedures
- public variables
- array properties
- functions and procedures, also class functions and procedures
- overloaded methods are implemented with numeric suffix
- each method with
varparameters is provided twice to be called either without those parameters (since they are used asout), or with them (forTCustomDrawGrid.DefaultDrawCell,TCustomListBox.MeasureItem, ...) - optional parameters
- inheritance (everything generated for the class is available for instances of class descendants)
- manual typechecking (
is) - exceptions are transformed into Lua errors
- within class declaration: non-nested
{$ifdefand{$ifndefwith possible{$else
Unsupported class methods are specified in exclude. Reference property and enumerators are not supported.
Documentation
Examples These examples also serve as tests
Tips, tricks and tools Tools in that repo can serve as complicated examples of using VCLua.
Compiling vclua library
Prepare source code
cd vclua/source-generatorFor Windows version you'll need to apply the patch to avoid errors like this
Just replace original file with the provided file or do in Git Bash:
patch --binary /f/Work/Dev/lazarus2/lcl/interfaces/win32/win32object.inc patch/win32object.inc.patchAdd your components
If you want to add new component source to the generated source codes (see src/components) you must use the source code parser/generator tool. First configure the fpc and lazarus source directories, with editing the file lua_make/config.lua
-- linux
local LAZPATH = "/usr/share/lazarus/3.2/"
local FPCSOURCE = "/usr/share/fpcsrc/3.2.2/"-- windows
local LAZPATH = "f:/Work/Dev/lazarus3/"
local FPCSOURCE = LAZPATH.."fpc/3.2.2/source/"run the fpc source parser/generator tool
lua lua_make/import.lua true false EnabledDefinesWin64Set Lua version
check and set the desired lua version at the vcl.lpi file
<CustomOptions Value="-dLUA54"/>or if you want use with LuaJit then set the compiler directive to
<CustomOptions Value="-dLUA51
-dLUAJIT"/>Compile source code
open the project in Lazarus and do Run - Clean up and build, or go to the vclua directory and run lazbuild
cd vclua-- linux
lazbuild -B vcl-linux.lpi-- windows
lazbuild -B vcl.lpiIf added components won't compile
Check and update the following files: VarTypes, component exclude file inside source-generator/exclude, classdef.lua, LuaProxy.pas
Install library
-- linux
sudo mkdir /usr/local/lib/lua/5.x/vcl
sudo cp libcore.so /usr/local/lib/lua/5.x/vcl/core.so-- windows
copy core.dll my_lua_libs/vcl/core.dllvcl folder should end up inside one of the package.cpath folders
Maybe create docs
lua lua_make/import.lua true true EnabledDefinesWin64This uses the installed library to get published properties.

