1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
unit fpdocproj;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
Type
{ TFPDocPackage }
TFPDocPackage = Class(TCollectionItem)
private
FContent: String;
FDescriptions: TStrings;
FImports: TStrings;
FInputs: TStrings;
FName: String;
FOutput: String;
Public
constructor Create(ACollection: TCollection); override;
destructor destroy; override;
procedure Assign(Source : TPersistent); override;
Property Name : String Read FName Write FName;
Property Inputs : TStrings Read FinPuts;
Property Descriptions : TStrings Read FDescriptions;
Property Imports : TStrings read FIMports;
Property ContentFile : String Read FContent Write FContent;
Property Output : String Read FOutput Write FOutput;
end;
{ TFPDocPackages }
TFPDocPackages = Class(TCollection)
private
function GetP(AIndex : Integer): TFPDocPackage;
procedure SetP(AIndex : Integer; const AValue: TFPDocPackage);
Public
Function IndexOfPackage(Const AName : String) : Integer;
Function FindPackage(Const AName : String) : TFPDOcPackage;
Property Packages[AIndex : Integer] : TFPDocPackage Read GetP Write SetP; Default;
end;
{ TEngineOptions }
TEngineOptions = Class(TPersistent)
private
FBackEndoptions: TStrings;
FCPUTarget: String;
FDefaultPackageName: String;
FEmitNotes: Boolean;
FEndianNess: String;
FFormat: String;
FHidePrivate: Boolean;
FHideProtected: Boolean;
FIO: Boolean;
FLanguage: String;
FMoDir: String;
FOSTarget: String;
FSOPE: Boolean;
FWarnNoNode: Boolean;
FDontTrim : Boolean;
procedure SetBackendOptions(const AValue: TStrings);
Public
Constructor Create;
Destructor Destroy; override;
procedure Assign(Source : TPersistent); override;
Published
Property OSTarget : String Read FOSTarget Write FOStarget;
Property CPUTarget : String Read FCPUTarget Write FCPUTarget;
Property EndianNess : String Read FEndianNess Write FEndianNess;
Property Language : String Read FLanguage Write fLanguage;
Property Backend : String Read FFormat Write FFormat;
Property BackendOptions : TStrings Read FBackEndoptions Write SetBackendOptions;
Property StopOnParseError : Boolean Read FSOPE Write FSOPE;
Property HideProtected : Boolean Read FHideProtected Write FHideProtected;
Property WarnNoNode : Boolean Read FWarnNoNode Write FWarnNoNode;
Property ShowPrivate : Boolean Read FHidePrivate Write FHidePrivate;
Property InterfaceOnly : Boolean Read FIO Write FIO;
Property MoDir : String Read FMoDir Write FMODir;
Property DefaultPackageName : String Read FDefaultPackageName Write FDefaultPackageName;
Property DontTrim : Boolean Read FDontTrim Write FDontTrim;
Property EmitNotes : Boolean Read FEmitNotes Write FEmitNotes;
end;
{ TFPDocProject }
TFPDocProject = Class(TComponent)
private
FOptions: TEngineOptions;
FPackages: TFPDocPackages;
procedure setOptions(const AValue: TEngineOptions);
Public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
Published
Property Packages : TFPDocPackages Read FPackages Write FPackages;
Property Options : TEngineOptions Read FOptions Write setOptions;
end;
Procedure SplitInputFileOption(Const AInputFile : String; Out AFile,AOption : String);
implementation
Procedure SplitInputFileOption(Const AInputFile : String; Out AFile,AOption : String);
Function GetNextWord(Var s : string) : String;
Const
WhiteSpace = [' ',#9,#10,#13];
var
i,j: integer;
begin
I:=1;
While (I<=Length(S)) and (S[i] in WhiteSpace) do
Inc(I);
J:=I;
While (J<=Length(S)) and (not (S[J] in WhiteSpace)) do
Inc(J);
if (I<=Length(S)) then
Result:=Copy(S,I,J-I);
Delete(S,1,J);
end;
Var
S,W,F,O : String;
begin
S:=AInputFile;
O:='';
F:='';
While (S<>'') do
begin
W:=GetNextWord(S);
If (W<>'') then
begin
if W[1]='-' then
begin
if (O<>'') then
O:=O+' ';
o:=O+W;
end
else
F:=W;
end;
end;
aFile:=F;
AOption:=O;
end;
{ TEngineOptions }
procedure TEngineOptions.SetBackendOptions(const AValue: TStrings);
begin
if FBackEndoptions=AValue then exit;
FBackEndoptions.Assign(AValue);
end;
constructor TEngineOptions.Create;
begin
FBackendOptions:=TStringList.Create;
end;
destructor TEngineOptions.Destroy;
begin
FreeAndNil(FBackendOptions);
inherited Destroy;
end;
procedure TEngineOptions.Assign(Source: TPersistent);
var
O : TEngineOptions;
begin
if (Source is TEngineOptions) then
begin
O:=Source as TEngineOptions;
FBackEndoptions.Assign(O.BackendOptions);
FCPUTarget:=O.CPUTarget;
FFormat:=O.Backend;
FLanguage:=O.Language;
FOSTarget:=O.OSTarget;
FSOPE:=O.StopOnParseError;
HideProtected:=O.HideProtected;
WarnNoNode:=O.WarnNoNode;
ShowPrivate:=O.ShowPrivate;
InterfaceOnly:=O.InterfaceOnly;
MoDir:=O.MoDir;
end
else
inherited Assign(Source);
end;
{ TFPDocProject }
procedure TFPDocProject.setOptions(const AValue: TEngineOptions);
begin
if FOptions=AValue then exit;
FOptions.Assign(AValue);
end;
constructor TFPDocProject.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPackages:=TFPDocPackages.Create(TFPDocPackage);
FOptions:=TEngineOptions.Create;
end;
destructor TFPDocProject.Destroy;
begin
FreeAndNil(Foptions);
FreeAndNil(FPackages);
inherited Destroy;
end;
{ TFPDocPackages }
function TFPDocPackages.GetP(AIndex : Integer): TFPDocPackage;
begin
Result:=TFPDocPackage(Items[AIndex]);
end;
procedure TFPDocPackages.SetP(AIndex : Integer; const AValue: TFPDocPackage);
begin
Items[AIndex]:=AValue;
end;
function TFPDocPackages.IndexOfPackage(const AName: String): Integer;
begin
Result:=Count-1;
While (Result>=0) and (CompareText(GetP(Result).Name,AName)<>0) do
Dec(Result)
end;
function TFPDocPackages.FindPackage(const AName: String): TFPDOcPackage;
Var
I : Integer;
begin
I:=IndexOfPackage(AName);
If (I=-1) then
Result:=Nil
else
Result:=GetP(I);
end;
{ TFPDocPackage }
constructor TFPDocPackage.Create(ACollection: TCollection);
begin
inherited Create(ACollection);
FImports:=TStringList.Create;
FDescriptions:=TStringList.Create;
FInputs:=TStringList.Create;
end;
destructor TFPDocPackage.destroy;
begin
FreeAndNil(FDescriptions);
FreeAndNil(FIMports);
FreeAndNil(FinPuts);
inherited destroy;
end;
procedure TFPDocPackage.Assign(Source: TPersistent);
Var
P : TFPDocPackage;
begin
If Source is TFPDocPackage then
begin
P:=Source as TFPDocPackage;
Fname:=P.Name;
FContent:=P.ContentFile;
FImports.Assign(P.Imports);
FInputs.Assign(P.Inputs);
FDescriptions.Assign(P.Descriptions);
end
else
inherited Assign(Source);
end;
end.
|