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. C# 操作配置文件

    1.配置文件app.config的书写: string mdbPath = ConfigurationManager.AppSettings["mdbPath"].ToString ...

  2. vs 点击就设置项目为默认启动项

    装好系统没注意 做项目的时候解决方案比较多 发现点击哪个项目哪个项目就成了默认启动项目 这个开始没觉出来 最后发现挺烦人的 想想难道是我装vs装的么 我于是卸载了全新安装了 还是一个吊样 无意间试了下 ...

  3. 窗口对象的方法 prompt() 用来输入数据

    prompt()    窗口对象的方法,用来输入信息的 一.window.prompt('提示信息',默认值); 1.例: window.prompt('请输入文字','这是默认值'); var us ...

  4. LINQ 从 CSV 文件生成 XML

    本文参考:http://msdn.microsoft.com/zh-cn/library/bb387090.aspx 下面的代码对字符串数组执行 LINQ 查询. 在 C# 版本中,该查询使用 let ...

  5. C# WinForm获取程序所在路径方法

    多个获取WinForm程序所在文件夹路径的方法,收藏备忘. 1)获取当前进程的完整路径,包含文件名(进程名). 代码:string str =this.GetType().Assembly.Locat ...

  6. 自定义控件(视图)2期笔记10:自定义视图之View事件分发机制("瀑布流"的案例)

    1. Touch事件的传递:   图解Touch事件的传递,如下: 当我们点击子View 02内部的Button控件时候,我们就触发了Touch事件. • 这个Touch事件首先传递给了顶级父View ...

  7. CGLIB学习笔记

    0 概述 CGLIB基于ASM实现.提供比反射更为强大的动态特性.使用CGLIB可以非常方便的实现的动态代理. 0.1 CGLIB包结构 net.sf.cglib.core    底层字节码处理类. ...

  8. angular应用前景

    完成了angularJs的学习,突然想到,angularJS是否会影响到seo.于是查阅了很多资料,技术博客,这种想法得到了证实. 爬虫不能识别js渲染的内容.所以引起了我对angular应用前景的思 ...

  9. HashMap深度解析(一)

    本文来自:高爽|Coder,原文地址:http://blog.csdn.net/ghsau/article/details/16843543 HashMap可以说是Java中最常用的集合类框架之一,是 ...

  10. (转载)loadrunner简单使用——HTTP,WebService,Socket压力测试脚本编写

    原文出处:http://ajita.iteye.com/blog/1728243/ 先说明一下,本人是开发,对测试不是特别熟悉,但因工作的需要,也做过一些性能测试方面的东西.比较久之前很简单的用过,最 ...