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提供了經過測試且可靠的解決方案,可以使所有內容保持獨立和表現。

用❤️在德爾菲製造