博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lua 5.1 for Delphi 2010
阅读量:5174 次
发布时间:2019-06-13

本文共 2014 字,大约阅读时间需要 6 分钟。

This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.

 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 

- converted PChar to PAnsiChar
- converted Char to AnsiChar
- added function LuaLibLoaded: Boolean;
- added a new base class (TLua) with OOP call back functions

Download

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: , 

转载于:https://www.cnblogs.com/zerovirs/p/3297914.html

你可能感兴趣的文章
调用链监控 CAT 之 入门
查看>>
flexbox属性速览及常见布局实现
查看>>
zlib在Linux和windows中的使用
查看>>
rabbitMq实战使用
查看>>
JQuery Easyui/TopJUI表格基本的删除功能(删除当前行和多选删除)
查看>>
javascript 倒计时
查看>>
web前端工程师入门须知
查看>>
linux--->linux 各个文件夹及含义
查看>>
欢迎使用CSD横竖屏切换问题占位
查看>>
2016集训测试赛(二十)Problem B: 字典树
查看>>
中文保存在properties乱码的解决
查看>>
poj题目分类
查看>>
idea 配置mybatis Generator 不显示的解决方案 和 配置MBG
查看>>
英语生疏了,每日至少一句吧
查看>>
创建打不开文件夹
查看>>
12 for循环
查看>>
redis(hash篇)
查看>>
Scala实战高手****第12课:Scala函数式编程进阶(匿名函数、高阶函数、函数类型推断、Currying)与Spark源码鉴赏...
查看>>
Hibernate一对多关联
查看>>
python 把函数作为参数 ---高阶函数
查看>>