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)
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 Strings
can be set as a Lua array of stringsCollection
can be set as a Lua array ofCollectionItem
or 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
,TSize
values in Free Pascal one needs to pass all of the fields in Lua - to set
TTextStyle
one can pass any subset of fields, rest will beDefault
ed
Unsupported types:
- records not explicitly mentioned
- event functions
- procedural types for method parameters
- class references
object
variables- list
- 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
var
parameters 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
Unsupported class methods are specified in exclude. Reference
property and enumerators are not supported.
Examples These examples also serve as tests
Tips, tricks and tools Tools in that repo can serve as complicated examples of using VCLua.
cd vclua/source-generator
For 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.patch
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
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"/>
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.lpi
Check and update the following files: VarTypes, component exclude file inside source-generator/exclude
, classdef.lua, LuaProxy.pas
-- 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.dll
vcl
folder should end up inside one of the package.cpath
folders
lua lua_make/import.lua true true
This uses the installed library to get published properties.