diff --git a/demos/ConfigApp/ConfigApp.dpr b/demos/ConfigApp/ConfigApp.dpr index 3bad90a..44a6eb5 100644 --- a/demos/ConfigApp/ConfigApp.dpr +++ b/demos/ConfigApp/ConfigApp.dpr @@ -2,12 +2,12 @@ program ConfigApp; uses Forms, - MainForm in 'MainForm.pas' {frmMain}, - luaConfig; + MainForm in 'MainForm.pas' {frmMain}; {$R *.res} begin + ReportMemoryLeaksOnShutdown := True; Application.Initialize; Application.CreateForm(TfrmMain, frmMain); Application.Run; 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); 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. -