diff options
| author | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-08-20 11:46:11 +0000 |
|---|---|---|
| committer | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-08-20 11:46:11 +0000 |
| commit | 5d659b719d4065eefc2e37a2e7c6dcccb63f27f4 (patch) | |
| tree | 68c44c0c5bb52797db69d42083110037d7723664 /packages/fcl-process/src | |
| parent | 7c838c6c55acb75c384d4709a0c0846e3f9c1b92 (diff) | |
| download | fpc-5d659b719d4065eefc2e37a2e7c6dcccb63f27f4.tar.gz | |
* centralize some type definitions so that they are compatible between process and processunicode
* add an extra parameter to the callback in preparation of readoutput callbacks.
This is needed to let the callback differentiate between stderr or stdout callbacks
* rename processunicode class to TProcess on recommendation of MvC.
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@39651 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-process/src')
| -rw-r--r-- | packages/fcl-process/src/process.pp | 7 | ||||
| -rw-r--r-- | packages/fcl-process/src/processbody.inc | 18 | ||||
| -rw-r--r-- | packages/fcl-process/src/processunicode.pp | 9 |
3 files changed, 20 insertions, 14 deletions
diff --git a/packages/fcl-process/src/process.pp b/packages/fcl-process/src/process.pp index e3f413cc36..179482efa7 100644 --- a/packages/fcl-process/src/process.pp +++ b/packages/fcl-process/src/process.pp @@ -40,6 +40,13 @@ Type TProcessOptions = set of TProcessOption; TStartupOptions = set of TStartupOption; + TRunCommandEventCode = (RunCommandIdle,RunCommandReadOutput,RunCommandFinished,RunCommandException); + TOnRunCommandEvent = procedure(Sender,Context : TObject;Status:TRunCommandEventCode;const Message:string) of object; + EProcess = Class(Exception); + + {$ifdef UNIX} + TProcessForkEvent = procedure(Sender : TObject) of object; + {$endif UNIX} {$macro on} {define processunicodestring} diff --git a/packages/fcl-process/src/processbody.inc b/packages/fcl-process/src/processbody.inc index 71211b48b1..89ca3fbfd9 100644 --- a/packages/fcl-process/src/processbody.inc +++ b/packages/fcl-process/src/processbody.inc @@ -40,13 +40,6 @@ Type TProcessStringList = TStringList; {$endif} - {$ifdef UNIX} - TProcessForkEvent = procedure(Sender : TObject) of object; - {$endif UNIX} - - TRunCommandEventCode = (RunCommandIdle,RunCommandFinished,RunCommandException); - TOnRunCommandEvent = procedure(Sender : TObject;Status:TRunCommandEventCode;const Message:string) of object; - { TProcess } TProcessnamemacro = Class (TComponent) @@ -103,7 +96,7 @@ Type procedure SetEnvironment(const Value: TProcessStrings); Procedure ConvertCommandLine; function PeekExitStatus: Boolean; - Procedure IntOnIdleSleep(Sender : TObject;Status:TRunCommandEventCode;const Message:String); + Procedure IntOnIdleSleep(Sender,Context : TObject;Status:TRunCommandEventCode;const Message:String); Protected FRunning : Boolean; FExitCode : Cardinal; @@ -174,7 +167,6 @@ Type end; TProcessClass = Class of TProcessnamemacro; - EProcess = Class(Exception); Procedure CommandToList(S : TProcessString; List : TProcessStrings); @@ -532,7 +524,7 @@ begin end; end; -procedure TProcessnamemacro.IntOnIdleSleep(Sender : TObject;status:TRunCommandEventCode;const message:string); +procedure TProcessnamemacro.IntOnIdleSleep(Sender,Context : TObject;status:TRunCommandEventCode;const message:string); begin if status=RunCommandIdle then sleep(FRunCommandSleepTime); @@ -571,7 +563,7 @@ begin gotoutputstderr:=ReadInputStream(StdErr,StdErrBytesRead,StdErrLength,StdErrString,1); if not gotoutput and not gotoutputstderr and Assigned(FOnRunCommandEvent) Then - FOnRunCommandEvent(self,RunCommandIdle,''); + FOnRunCommandEvent(self,Nil,RunCommandIdle,''); end; // Get left output after end of execution ReadInputStream(output,BytesRead,OutputLength,OutputString,250); @@ -582,7 +574,7 @@ begin anexitstatus:=exitstatus; result:=0; // we came to here, document that. if Assigned(FOnRunCommandEvent) then // allow external apps to react to that and finish GUI - FOnRunCommandEvent(self,RunCommandFinished,''); + FOnRunCommandEvent(self,Nil,RunCommandFinished,''); except on e : Exception do @@ -591,7 +583,7 @@ begin setlength(outputstring,BytesRead); setlength(stderrstring,StderrBytesRead); if Assigned(FOnRunCommandEvent) then - FOnRunCommandEvent(self,RunCommandException,e.Message); + FOnRunCommandEvent(self,Nil,RunCommandException,e.Message); end; end; end; diff --git a/packages/fcl-process/src/processunicode.pp b/packages/fcl-process/src/processunicode.pp index 6b27be5464..6bfbc0d9fa 100644 --- a/packages/fcl-process/src/processunicode.pp +++ b/packages/fcl-process/src/processunicode.pp @@ -29,10 +29,17 @@ Type TProcessPriority = process.TProcessPriority; TProcessOptions = process.TProcessOptions; TStartupOptions = process.TStartupOptions; + {$ifdef UNIX} + TProcessForkEvent = Process.TProcessForkEvent; + {$endif UNIX} + + TRunCommandEventCode = Process.TRunCommandEventCode; + TOnRunCommandEvent = Process.TOnRunCommandEvent; + EProcess = Process.EProcess; {$macro on} {$define processunicodestring} -{$define TProcessnamemacro:=TProcessUnicode} +{$define TProcessnamemacro:=TProcess} {$i processbody.inc} end. |
