SEH问题阻止了该库与Delphi正确合作。发展转移到https://github.com/tinybiggames/callisto,这不会遭受这些问题和其他问题的困扰。

Jetlua是一个精心设计的Delphi开发人员精心制作的高级Luajit集成库,在Delphi应用程序和Luajit脚本之间提供了无缝的接口界面。通过合并Delphi固有的鲁棒性?随着Luajit的恰到时光汇编(JIT)汇编的出色运行时效率,Jetlua针对旨在将动态⚡功能纳入其软件而不损害性能或稳定性的专业开发人员。
Jetlua集成了Luajit 2.1+版本,并在您的Delphi应用程序中静态编译,从而消除了对外部DLL依赖关系的需求?这大大增强了便携性吗?在应用程序中简化分布,并促进在Delphi环境中纳入脚本功能。
使用Jetlua,开发人员可以将Delphi类方法公开到LUA脚本,从而使他们的应用程序具有动态的可扩展性?该库利用Delphi的RTTI(运行时类型信息)?以简化的方式促进有效的方法注册和与Luajit集成。
此外,Jetlua利用强大的外国功能接口(FFI)?由Luajit提供,允许导出的Delphi/DLL例程直接注册并在LUA脚本中使用。利用FFI消除了复杂的中介结合物的必要性,促进了Delphi和Luajit之间更快,更有效的整合。
dbg()启动了交互式调试会话,对于运行时问题识别至关重要。import命令允许将脚本组合在一起,编译为单个单元,并选择嵌入为EXE资源,从而产生完全独立的应用程序。 要开始使用Jetlua,请按照以下步骤:
Testbed程序提供了一个全面的Jetlua功能示例,证明了Luajit脚本与Delphi应用程序的整合。说明的关键功能包括算术操作➕,字符串操纵✂️,记录处理,内存管理?和复杂的错误处理
print ( " Testing TTestClass methods... " )
print ( " Add: " , TTestClass . Add ( 5 , 3 ))
print ( " Multiply: " , TTestClass . Multiply ( 4.5 , 2.0 ))
print ( " Concat: " , TTestClass . Concat ( " Hello " , " World " ))
-- Record handling example
local rec = TTestClass . CreateRecord ( 1 , " Test Record " , 42.0 )
print ( " Initial Record Value: " , TTestClass . GetRecordValue ( rec ))
TTestClass . UpdateRecord ( rec , 100.0 )
print ( " Updated Record Value: " , TTestClass . GetRecordValue ( rec ))
-- Memory management example
local mem = TTestClass . AllocateMemory ( 4 )
TTestClass . WriteToMemory ( mem , 12345 )
print ( " Memory Value: " , TTestClass . ReadFromMemory ( mem ))
TTestClass . FreeMemory ( mem )
-- FFI example: Calling a native function directly
local ffi = require ( " ffi " )
ffi . cdef [[
int Add ( int a , int b );
]]
print ( " FFI Add: " , ffi . C . Add ( 10 , 20 ))
-- Loading an external DLL and accessing its functions
ffi . cdef [[
void MessageBoxA ( void * hwnd , const char * text , const char * caption , int type );
]]
local user32 = ffi . load ( " user32.dll " )
user32 . MessageBoxA ( nil , " Hello from LuaJIT! " , " FFI Example " , 0 )以下是一个示例,说明了如何在Delphi应用程序中使用Jetlua:
type
TTestRecord = record
ID: Integer;
Name : string;
Value : Double;
end ;
PTestRecord = ^TTestRecord;
{ $M+ }
TTestClass = class
published
class function Add (A, B: Integer): Integer;
class function Multiply (A, B: Double): Double;
class function Concat ( const A, B: string): string;
class function CreateList : TStringList;
class function GetListCount (List: TStringList): Integer;
class function CreateRecord (ID: Integer; const Name : string; Value : Double): TTestRecord;
class procedure UpdateRecord (P: PTestRecord; NewValue: Double);
class function GetRecordValue (P: PTestRecord): Double;
class function AllocateMemory (Size: Integer): Pointer;
class procedure FreeMemory (P: Pointer);
class procedure WriteToMemory (P: Pointer; Value : Integer);
class function ReadFromMemory (P: Pointer): Integer;
end ;
{ $M- }
var
LJetLua: TJetLua;
LRec: TTestRecord;
begin
LJetLua := TJetLua.Create();
try
try
LJetLua.RegisterRoutines(TTestClass);
LJetLua.LoadString(CScript);
WriteLn( ' Integer value: ' , LJetLua.Call( ' add ' , [ 50 , 50 ]).AsInteger);
WriteLn( ' String value: ' , LJetLua.Call( ' concat ' , [ ' Hello, ' , ' World! ' ]).AsString);
LRec.ID := 1 ;
LRec. Name := ' test ' ;
LRec. Value := 200 ;
LJetLua.Call( ' process_record ' , [@LRec, ' test ' ]);
except
on E: Exception do
begin
WriteLn(Format( ' Error: %s ' , [E.Message]));
end ;
end ;
finally
LJetLua.Free();
end ;
end ;此示例演示了多功能性和互操作性? Delphi和Luajit:
Jetlua使用luajit 2.1+,静态嵌入到Delphi应用程序中,以确保没有外部库依赖性的独立部署。
Jetlua自动注册为已发布的类方法的Delphi例程,消除了对手动绑定的需求。宣布published方法可以保证他们从Luajit脚本中的可访问性。
Luajit的外国功能接口(FFI)允许直接从LUA脚本中注册和调用本机Delphi例程。关键优势包括:
Jetlua支持参数和返回值的基本数据类型,包括:
stringfloat (单人还是双)?Boolean ✅Pointer ➡️在设计LUAJIT互操作性的方法时,请确保所有参数和返回值符合这些支持类型。
Delphi中产生的指针应由Delphi专门管理。重要考虑因素包括:
TestBed程序提供了将Luajit脚本与Delphi应用程序集成的示例,包括:
Jetlua提供了一种有效,可靠的解决方案,用于将Luajit脚本集成到Delphi应用程序中。它使开发人员能够利用Luajit的动态灵活性,而不会损害Delphi在打字和性能方面的内在优势。通过合并Jetlua,开发人员可以大大增加其Delphi应用程序的可扩展性,可维护性和定制潜力。
您的目标是促进运行时定制还是实现基于复杂的脚本配置,Jetlua为Delphi开发人员提供了强大而易于访问的方式,以实现增强的脚本集成?
强烈鼓励对Jetlua的贡献。请随时提交问题,建议新功能或创建拉动请求,以扩大脚本引擎的功能和鲁棒性。
Jetlua分布在? BSD-3-clause许可证,允许在特定条件下进行或不进行修改的源和二进制形式的再分配和使用。有关更多详细信息,请参见许可证文件。
对于任何有兴趣通过脚本功能增强应用程序灵活性的专业Delphi开发人员,Jetlua提供了经过测试且可靠的解决方案,可以使所有内容保持独立和表现。

用❤️在德尔菲制造