This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.
“Lua is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe’s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games (e.g., World of Warcraft). Lua is currently the leading scripting language in games and it has a deserved reputation for performance. To claim to be “as fast as Lua” is an aspiration of other scripting languages.”

This Lua Wrapper is based on Lua-Pascal v0.2 by Marco Antonio Abreu
- converted PChar to PAnsiChar
- converted Char to AnsiChar
- added function LuaLibLoaded: Boolean;
- added a new base class (TLua) with OOP call back functions

Download
LuaDelphi2010-v1.3

History
1.3 Improved Callback, now uses pointer instead of object index. Modified RegisterFunctions to allow methods from other class to be registered, moved object table into TLua class
1.2  Added example on how to extend lua with a delphi dll
1.1  Improved global object table, optimized delphi function calls
1.0  Initial Release

Example
TLua automatically creates OOP callback functions for Delphi <-> Lua:

uses
Lua, LuaLib;
 
type
TMyLua = class(TLua)
published
function HelloWorld(LuaState: TLuaState): Integer;
end;
 
function TMyLua.HelloWorld: Integer;
var
ArgCount: Integer;
I: integer;
begin
writeln('Delphi: Hello World');
 
ArgCount := Lua_GetTop(LuaState);
writeln('Arguments: ', ArgCount);
for I := 1 to ArgCount do
writeln('Arg1', I, ': ', Lua_ToInteger(LuaState, I));
 
// Clear stack
Lua_Pop(LuaState, Lua_GetTop(LuaState));
 
// Push return values
Lua_PushInteger(LuaState, 101);
Lua_PushInteger(LuaState, 102);
Result := 2;
end;
 
var
MyLua: TLua;
 
begin
MyLua := TMyLua.Create;
MyLua.DoFile('Helloworld.lua');
MyLua.Free;
end;

helloworld.lua

print("LuaDelphi Test");
p1,p2 = HelloWorld(1,2,3)
print "Results:";
print (p1);
print (p2);

Tags: Delphi ProgrammingLua

Lua 5.1 for Delphi 2010的更多相关文章

  1. delphi 2010与delphi XE破解版的冲突

    在系统中同时安装了Dephi 2010LITE版与Delphi XE lite后,总是会有一个有问题 是因为两者都是读取C:\ProgramData\Embarcadero目录下的license文件, ...

  2. RAD Studio/Delphi 2010 3615下载+破解

    RAD Studio/Delphi 2010 3615下载+破解 官方下载地址: http://altd.embarcadero.com/download/RADStudio2010/delphicb ...

  3. Delphi 2010错误 "displayNotification: 内存不够"

    打开 Delphi 2010 的时候, 它报一个错误 "displayNotification: 内存不够",从而无法使用 Delphi , 解决办法 摘自http://www.cnblogs.com ...

  4. Delphi 2010初体验,是时候抛弃Delphi 7了

    Delphi 2010已于近日由Embarcadero公司发布.作者Kim Madsen作为一名资深的Delphi开发者,在他的博客中谈到了Delphi 2010的新性能.它的使用感受以及对Delph ...

  5. delphi 2010是动画GIF的支持方法

    下面delphi 2010是动画GIF的支持方法:  1.在窗体上放一个Image1控件.注意:这时设置其Picture属性,加载一幅动画GIF是不会动画显示的.  2.在窗体的FormCreate事 ...

  6. delphi 2010 导出sql server 数据到DBF乱码问题

    近日,由于业务需要导出sql server 数据到DBF文件,要查询多表记录,并适当处理后生成导出DBF文件,系统使用delphi2010平台开发. 首先按要求在VFP里创建DBF表,字段数有240个 ...

  7. Delphi 2010 安装及调试

    呵呵,毫不客气地说,Delphi 2010 这个版本可以算是 Delphi 的一个“里程碑”,为什么这么说?因为这个版本实现了几个 Delphi 应该有却一直没有的功能 Delphi 2010 的新功 ...

  8. Delphi 2010

    Delphi 2010已早由Embarcadero公司发布.作者Kim Madsen作为一名资深的Delphi开发者,在他的博客中谈到了Delphi 2010的新性能.它的使用感受以及对Delphi语 ...

  9. delphi 2010 动态链接库DLL断点调试

    DELPHI 2010 动态链接库DLL断点调试 马根峰 (广东联合电子服务股份有限公司,广州 510300) 摘要:本文详细介绍了Delphi 2010中的动态链接库DLL断点调试技术 关键词:DE ...

随机推荐

  1. poj 1011 搜索减枝

    题目链接:http://poj.org/problem?id=1011 #include<cstdio> #include<cstring> #include<algor ...

  2. 常用的MySQL图形化管理软件

    本博文的主要内容有 .SQLyog软件的安装.下载和使用 .Navicat for MySQL软件的安装.下载和使用 1.SQLyog软件的安装.下载和使用 2.Navicat for MySQL软件 ...

  3. IE的Cookie目录和临时缓存目录的关系

    1.IE的Cookie位置注册表设置: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folde ...

  4. C基础

    一.关于整型数据 1.整型常量:十进制数前面可以加+.-号,但是不能有前缀0 八进制数:必须以前缀0开头,不是O.不能加负号(-),否则不能识别. 十六进制数:前缀必须为0x或者0X.不能加负号(-) ...

  5. CSS3动画变形Animations

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. [Redux] Navigating with React Router <Link>

    We will learn how to change the address bar using a component from React Router. In Root.js: We need ...

  7. etrace 跟踪 nginx之HTTP请求流程

    curl 127.0.0.1 | | | \--ngx_epoll_process_events | | | | \--ngx_time_update | | | | | \--ngx_gmtime ...

  8. windows 下解决 Time_Wait 和 CLOSE_WAIT 方法

    修改Time_Wait参数的方法 (在服务端修改)Windows下在HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Paramet ...

  9. block没那么难(二):block和变量的内存管理

    本系列博文总结自<Pro Multithreading and Memory Management for iOS and OS X with ARC> 了解了 block的实现,我们接着 ...

  10. 关于Sublime Text3 pyV8无法加载的问题

    昨天切换到sublime text 3  安装 emmet插件 不起作用  提示  pyv8 无法加载 手动下载安装解决 问题描述 PyV8 Binaries Archive of pre-compi ...