From ca8bbd69bc94c2518793f8b522690deb27295ba4 Mon Sep 17 00:00:00 2001 From: Martijn Laan <1092369+martijnlaan@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:43:56 +0100 Subject: [PATCH] Another cleanup. --- Projects/Src/Setup.ScriptFunc.pas | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Projects/Src/Setup.ScriptFunc.pas b/Projects/Src/Setup.ScriptFunc.pas index d4a1d1c10..1b121d956 100644 --- a/Projects/Src/Setup.ScriptFunc.pas +++ b/Projects/Src/Setup.ScriptFunc.pas @@ -42,6 +42,7 @@ TScriptFuncEx = record ScriptFunc: TScriptFunc; Typ: TScriptFuncTyp; constructor Create(const AOrgName: AnsiString; const AScriptFunc: TScriptFunc; const ATyp: TScriptFuncTyp); + procedure Run(const Caller: TPSExec; const Stack: TPSStack); end; TScriptFuncs = TDictionary; @@ -56,19 +57,23 @@ constructor TScriptFuncEx.Create(const AOrgName: AnsiString; const AScriptFunc: Typ := ATyp; end; +procedure TScriptFuncEx.Run(const Caller: TPSExec; const Stack: TPSStack); +begin + if (Typ = sfNoUninstall) and IsUninstaller then + NoUninstallFuncError(OrgName) + else if (Typ = sfOnlyUninstall) and not IsUninstaller then + OnlyUninstallFuncError(OrgName) + else + ScriptFunc(Caller, OrgName, Stack, Stack.Count-1); +end; + { Called by ROPS } function ScriptFuncPSProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean; begin var ScriptFuncEx: TScriptFuncEx; Result := ScriptFuncs.TryGetValue(Proc.Name, ScriptFuncEx); - if Result then begin - if (ScriptFuncEx.Typ = sfNoUninstall) and IsUninstaller then - NoUninstallFuncError(ScriptFuncEx.OrgName) - else if (ScriptFuncEx.Typ = sfOnlyUninstall) and not IsUninstaller then - OnlyUninstallFuncError(ScriptFuncEx.OrgName) - else - ScriptFuncEx.ScriptFunc(Caller, ScriptFuncEx.OrgName, Stack, Stack.Count-1); - end; + if Result then + ScriptFuncEx.Run(Caller, Stack); end; procedure ScriptFuncLibraryRegister_R(ScriptInterpreter: TPSExec);