瀏覽代碼

Another cleanup.

Martijn Laan 9 月之前
父節點
當前提交
ca8bbd69bc
共有 1 個文件被更改,包括 13 次插入8 次删除
  1. 13 8
      Projects/Src/Setup.ScriptFunc.pas

+ 13 - 8
Projects/Src/Setup.ScriptFunc.pas

@@ -42,6 +42,7 @@ type
     ScriptFunc: TScriptFunc;
     ScriptFunc: TScriptFunc;
     Typ: TScriptFuncTyp;
     Typ: TScriptFuncTyp;
     constructor Create(const AOrgName: AnsiString; const AScriptFunc: TScriptFunc; const ATyp: TScriptFuncTyp);
     constructor Create(const AOrgName: AnsiString; const AScriptFunc: TScriptFunc; const ATyp: TScriptFuncTyp);
+    procedure Run(const Caller: TPSExec; const Stack: TPSStack);
   end;
   end;
 
 
   TScriptFuncs = TDictionary<AnsiString, TScriptFuncEx>;
   TScriptFuncs = TDictionary<AnsiString, TScriptFuncEx>;
@@ -56,19 +57,23 @@ begin
   Typ := ATyp;
   Typ := ATyp;
 end;
 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 }
 { Called by ROPS }
 function ScriptFuncPSProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
 function ScriptFuncPSProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
 begin
 begin
   var ScriptFuncEx: TScriptFuncEx;
   var ScriptFuncEx: TScriptFuncEx;
   Result := ScriptFuncs.TryGetValue(Proc.Name, ScriptFuncEx);
   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;
 end;
 
 
 procedure ScriptFuncLibraryRegister_R(ScriptInterpreter: TPSExec);
 procedure ScriptFuncLibraryRegister_R(ScriptInterpreter: TPSExec);