From 5bb6b5ce3fa82b7088b0a75ad65e55cd3ad162e8 Mon Sep 17 00:00:00 2001 From: pzx521521 Date: Tue, 17 Nov 2020 11:28:42 +0800 Subject: [PATCH 1/4] Update ConfigApp.dpr --- demos/ConfigApp/ConfigApp.dpr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demos/ConfigApp/ConfigApp.dpr b/demos/ConfigApp/ConfigApp.dpr index 3bad90a..8d2b23d 100644 --- a/demos/ConfigApp/ConfigApp.dpr +++ b/demos/ConfigApp/ConfigApp.dpr @@ -2,8 +2,7 @@ program ConfigApp; uses Forms, - MainForm in 'MainForm.pas' {frmMain}, - luaConfig; + MainForm in 'MainForm.pas' {frmMain}; {$R *.res} From 1ce4eb092cbf8406de0274d7cc1380fcf7ca18f5 Mon Sep 17 00:00:00 2001 From: pzx521521 Date: Tue, 17 Nov 2020 11:29:08 +0800 Subject: [PATCH 2/4] Update ConfigApp.dpr --- demos/ConfigApp/ConfigApp.dpr | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/ConfigApp/ConfigApp.dpr b/demos/ConfigApp/ConfigApp.dpr index 8d2b23d..44a6eb5 100644 --- a/demos/ConfigApp/ConfigApp.dpr +++ b/demos/ConfigApp/ConfigApp.dpr @@ -7,6 +7,7 @@ uses {$R *.res} begin + ReportMemoryLeaksOnShutdown := True; Application.Initialize; Application.CreateForm(TfrmMain, frmMain); Application.Run; From 53b69dd71b76771a6fd7c62cc83bf2675a957c37 Mon Sep 17 00:00:00 2001 From: pzx521521 Date: Tue, 17 Nov 2020 11:29:45 +0800 Subject: [PATCH 3/4] Update MainForm.pas --- demos/ConfigApp/MainForm.pas | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/demos/ConfigApp/MainForm.pas b/demos/ConfigApp/MainForm.pas index 6c5ce5f..1772634 100644 --- a/demos/ConfigApp/MainForm.pas +++ b/demos/ConfigApp/MainForm.pas @@ -24,7 +24,7 @@ TfrmMain = class(TForm) implementation uses - luaConfig, pluaRecord; + pluaRecord; {$R *.dfm} @@ -57,9 +57,6 @@ procedure TfrmMain.FormCreate(Sender: TObject); Lua.LoadFile('config.lua'); Lua.RegisterLuaMethod('HexToInt', @lua_HexToInt); Lua.RegisterLuaMethod('SetConfig', @lua_SetConfig); - // Create a "new" version of our virtual record type and register it to the lua - // global name of "Config" - plua_registerExistingRecord(Lua.LuaState, 'Config', nil, RecordTypesList['TConfig']); end; procedure TfrmMain.FormShow(Sender: TObject); From 34e578f2b57a2bba2640da88704ea42163203670 Mon Sep 17 00:00:00 2001 From: pzx521521 Date: Tue, 17 Nov 2020 11:30:04 +0800 Subject: [PATCH 4/4] Delete luaConfig.pas --- demos/ConfigApp/luaConfig.pas | 59 ----------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 demos/ConfigApp/luaConfig.pas diff --git a/demos/ConfigApp/luaConfig.pas b/demos/ConfigApp/luaConfig.pas deleted file mode 100644 index da35400..0000000 --- a/demos/ConfigApp/luaConfig.pas +++ /dev/null @@ -1,59 +0,0 @@ -unit luaConfig; - -interface - -uses - Classes, SysUtils, lua, pLua, pLuaRecord; - -implementation - -uses - MainForm; - -function GetCaption(RecordPointer : pointer; l : Plua_State; paramidxstart, paramcount : integer) : Integer; -begin - // Get the value of the caption and put it on the stack - lua_pushstring(l, frmMain.Caption); - result := 1; -end; - -function SetCaption(RecordPointer : pointer; l : Plua_State; paramidxstart, paramcount : integer) : Integer; -begin - // Get the new caption from the stack and set frmMain.Caption to it - frmMain.Caption := lua_tostring(L, paramidxstart); - result := 0; -end; - -function GetColor(RecordPointer : pointer; l : Plua_State; paramidxstart, paramcount : integer) : Integer; -begin - // Get the value of the Color and put it on the stack - lua_pushinteger(l, frmMain.Color); - result := 1; -end; - -function SetColor(RecordPointer : pointer; l : Plua_State; paramidxstart, paramcount : integer) : Integer; -begin - // Get the new Color from the stack and set frmMain.Color to it - frmMain.Color := lua_tointeger(L, paramidxstart); - result := 0; -end; - -procedure Init; -var - ri : PLuaRecordInfo; -begin - // Create a virtual "Config" global variable (record) that will allow - // the lua script to access application properties. - ri := RecordTypesList.Add('TConfig'); - plua_AddRecordProperty(ri^, 'Caption', @GetCaption, @SetCaption); - plua_AddRecordProperty(ri^, 'Color', @GetColor, @SetColor); -end; - -initialization - -Init; - -finalization - -end. -