Skip to content

Commit

Permalink
Another cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Nov 18, 2024
1 parent 9d8d786 commit ca8bbd6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Projects/Src/Setup.ScriptFunc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnsiString, TScriptFuncEx>;
Expand All @@ -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);
Expand Down

0 comments on commit ca8bbd6

Please sign in to comment.