Lua In Free Pascal |
|
All routines from the C API and auxiliary library mentioned in the Lua 5.1 reference manual are supported in the lua, lualib or lauxlib libraries of Free Pascal 2.4. There is no documentation, but you can use the Lua manual since the call sequences are basically identical, with a few exceptions.
In order to split strings over multiple lines in Free Pascal, create multiple string constants that are concatenated via the '+' operator. Alternatively, you can store your Lua code in files, or put it all on one line.
luaL_Reg => lua_CFunctionMost others are obvious, with P used for pointer, e.g.
luaState* => Plua_Stateor standard, e.g.
void* => Pointer int => IntegerYou can always look at the interface of lauxlib.pas etc (package fpc-source on Ubuntu) to make sure.
Some names starting with lua_L are different (probably typos):
luaL_dofile => lua_dofile luaL_dostring => lua_dostring luaL_getmetatable => lua_Lgetmetatable
uses lua, lualib, lauxlib;
var L: Plua_State;
begin
L := lua_open(); luaL_openlibs(L);
result := lua_dostring(L,
'for k in string.gmatch("a,b,c,d,e,f,g,h","([^,]+),") do print(k) end'
);
lua_close(L);
end.