Skip to content

Commit 42710e5

Browse files
committed
feat: Adding TEntriesEnumerator
1 parent 3435441 commit 42710e5

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

utilities/script_builder/Common/scriptbuilder.common.pas

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,19 @@ implementation
6161
cTestBash = 'test_all.sh';
6262
cRunBash = 'run_all.sh';
6363

64-
cLazbuild = '%s -B "%s"';
64+
cLazbuildDefault = '%s -B "%s"';
6565
cLazbuildRelease = '%s -B --bm="Release" "%s"';
6666

6767
cReplaceName = '[[name]]';
6868
cReplaceJSONResults = '[[results-json]]';
6969
cReplaceEntryBinary = '[[entry-binary]]';
7070
cReplaceEntryInput = '[[input]]';
7171
cReplaceEntryThreads = '[[threads]]';
72+
7273
cCompilerFPC = 'fpc';
74+
// cCompilerDelphi = 'delphi';
7375
cSSD = 'SSD';
7476
cHDD = 'HDD';
75-
// cCompilerDelphi = 'delphi';
7677

7778
resourcestring
7879
rsEPatternsLengthDOntMatch = 'Patterns length does not match';
@@ -135,13 +136,15 @@ function TBuilder.StringsReplace(
135136
procedure TBuilder.BuildCompileScriptBash;
136137
var
137138
index: Integer;
139+
//entry: TEntry;
138140
line: String;
139141
begin
140142
FScriptFile:= IncludeTrailingPathDelimiter(FConfig.RootFolder) + cCompileBash;
141143
FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
142144
try
143145
line:= '#!/bin/bash' + LineEnding + LineEnding;
144146
for index:= 0 to Pred(FConfig.Entries.Count) do
147+
//for entry in FConfig.Entries do
145148
begin
146149
Write(GenerateProgressBar(index+1, FConfig.Entries.Count, 50), lineBreak);
147150
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
@@ -164,7 +167,7 @@ procedure TBuilder.BuildCompileScriptBash;
164167
else
165168
begin
166169
line:= line +
167-
Format(cLazbuild, [
170+
Format(cLazbuildDefault, [
168171
FConfig.Lazbuild,
169172
ExpandFileName(
170173
ConcatPaths([

utilities/script_builder/Common/scriptbuilder.data.entries.pas

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface
3131
// ENodeStatusParamsWrongType = Exception;
3232

3333
{ TEntry }
34-
TEntry = class
34+
TEntry = class(TObject)
3535
private
3636
FName: String;
3737
FNotes: String;
@@ -85,7 +85,8 @@ TEntry = class
8585
end;
8686

8787
{ TEntries }
88-
TEntries = class
88+
TEntriesEnumerator = class; //Forward
89+
TEntries = class(TObject)
8990
private
9091
FEntries: TFPObjectList;
9192

@@ -103,15 +104,32 @@ TEntries = class
103104

104105
destructor Destroy; override;
105106

107+
function GetEnumerator: TEntriesEnumerator;
108+
106109
property Count: Integer
107110
read GetCount;
108111
property Items[Index: Integer]: TEntry
109112
read GetEntry
110113
write SetEntry; default;
111114
published
112115
end;
116+
//TEntriesClass = class of TEntries;
117+
118+
{ TEntriesEnumerator }
119+
TEntriesEnumerator = class(TObject)
120+
private
121+
FEntries: TEntries;
122+
FPosition: Integer;
123+
protected
124+
public
125+
constructor Create(const AEntries: TEntries);
126+
function GetCurrent: TEntry;
127+
function MoveNext: Boolean;
113128

114-
{ TEntriesIterator }
129+
property Current: TEntry
130+
read GetCurrent;
131+
published
132+
end;
115133

116134
implementation
117135

@@ -234,4 +252,28 @@ destructor TEntries.Destroy;
234252
inherited Destroy;
235253
end;
236254

255+
function TEntries.GetEnumerator: TEntriesEnumerator;
256+
begin
257+
Result:= TEntriesEnumerator.Create(Self);
258+
end;
259+
260+
{ TEntriesEnumerator }
261+
262+
constructor TEntriesEnumerator.Create(const AEntries: TEntries);
263+
begin
264+
FEntries := AEntries;
265+
FPosition := -1;
266+
end;
267+
268+
function TEntriesEnumerator.GetCurrent: TEntry;
269+
begin
270+
Result:= FEntries.Items[FPosition] as TEntry;
271+
end;
272+
273+
function TEntriesEnumerator.MoveNext: Boolean;
274+
begin
275+
Inc(FPosition);
276+
Result := FPosition < FEntries.Count;
277+
end;
278+
237279
end.

0 commit comments

Comments
 (0)