@@ -17,6 +17,8 @@ TProject = class(TVisualMASMFile)
17
17
FOutputFile: string;
18
18
FSizeInBytes: int64;
19
19
FBuild: boolean;
20
+ FFunctions: TList<TFunctionData>;
21
+ FSavedFunctions: TList<TFunctionData>;
20
22
21
23
FPreAssembleEventCommandLine: string;
22
24
FAssembleEventCommandLine: string;
@@ -34,6 +36,7 @@ TProject = class(TVisualMASMFile)
34
36
procedure SetProjectFile (Index: string; const Value : TProjectFile);
35
37
procedure SetActiveFile (projectFile: TProjectFile);
36
38
procedure SetSizeInBytes (value : int64);
39
+ function GetSavedFunction (f: string; fileId: string): string;
37
40
public
38
41
constructor Create; overload;
39
42
constructor Create (Name : string); overload;
@@ -54,6 +57,13 @@ TProject = class(TVisualMASMFile)
54
57
property OutputFile: string read FOutputFile write FOutputFile;
55
58
property SizeInBytes: int64 read FSizeInBytes write SetSizeInBytes;
56
59
property Build: boolean read FBuild write FBuild;
60
+ property Functions: TList<TFunctionData> read FFunctions write FFunctions;
61
+ property SavedFunctions: TList<TFunctionData> read FSavedFunctions write FSavedFunctions;
62
+ procedure ScanFunctions ;
63
+ procedure ExportFunction (name : string; exportAs: string; fileId: string);
64
+ procedure MarkAllFunctionsNotToExport ;
65
+ function WasFunctionExported (f: string; fileId: string): boolean;
66
+ procedure MarkAllFunctionsToExport ;
57
67
published
58
68
procedure DeleteProjectFile (id: string);
59
69
procedure AddProjectFile (projectFile: TProjectFile);
@@ -67,6 +77,8 @@ procedure TProject.Initialize;
67
77
begin
68
78
FProjectType := ptWin32;
69
79
FProjectFiles := TDictionary<string, TProjectFile>.Create;
80
+ FFunctions := TList<TFunctionData>.Create;
81
+ FSavedFunctions := TList<TFunctionData>.Create;
70
82
self.Modified := true;
71
83
FBuild := true;
72
84
end ;
@@ -179,6 +191,23 @@ function TProject.CreateProjectFile(name: string; options: TVisualMASMOptions; f
179
191
if fileType = pftTXT then
180
192
projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+LIB_STUB_FILENAME);
181
193
end ;
194
+ ptWin32DLL:
195
+ begin
196
+ if fileType = pftASM then
197
+ projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+WIN_32_BIT_DLL_MASM32_FILENAME);
198
+ if fileType = pftDef then
199
+ projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+WIN_DLL_DEF_FILENAME);
200
+ end ;
201
+ ptWin64DLL:
202
+ begin
203
+ if fileType = pftASM then
204
+ projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+WIN_64_BIT_DLL_MASM32_FILENAME);
205
+ end ;
206
+ ptWin16DLL:
207
+ begin
208
+ if fileType = pftASM then
209
+ projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+WIN_16_BIT_DLL_MASM32_FILENAME);
210
+ end ;
182
211
end ;
183
212
184
213
AddProjectFile(projectFile);
@@ -216,5 +245,122 @@ procedure TProject.SetSizeInBytes(value: int64);
216
245
FSizeInBytes := value ;
217
246
end ;
218
247
248
+ procedure TProject.ScanFunctions ;
249
+ var
250
+ x,i,p: integer;
251
+ s: string;
252
+ functionData: TFunctionData;
253
+ comment: boolean;
254
+ pf: TProjectFile;
255
+ source: TStringList;
256
+ begin
257
+ FFunctions.Clear;
258
+ source := TStringList.Create;
259
+ for pf in FProjectFiles.Values do
260
+ begin
261
+ source.Text := pf.Content;
262
+ for x := 0 to source.Count-1 do begin
263
+ p := pos(' PROC' ,Uppercase(source.Strings[x]));
264
+ if p > 0 then begin
265
+ s := trim(copy(source.Strings[x],0 ,p-1 ));
266
+ if (length(s)>0 ) then begin
267
+ comment := false;
268
+ for i := p downto 1 do begin
269
+ if s[i]=' ;' then begin
270
+ comment := true;
271
+ break;
272
+ end ;
273
+ end ;
274
+ if (s[1 ] <> ' ;' ) and (not comment) then begin
275
+ functionData.FileId := pf.Id;
276
+ functionData.Name := s;
277
+ functionData.ExportAs := GetSavedFunction(s, pf.Id);
278
+ functionData.Line := x+1 ;
279
+ functionData.FileName := ExtractFileName(pf.FileName);
280
+ functionData.Export := WasFunctionExported(s, pf.Id);
281
+ FFunctions.Add(functionData);
282
+ end ;
283
+ end ;
284
+ end ;
285
+ end ;
286
+ end ;
287
+ end ;
288
+
289
+ function TProject.GetSavedFunction (f: string; fileId: string): string;
290
+ var
291
+ i: Integer;
292
+ begin
293
+ result := f;
294
+ for i := 0 to FSavedFunctions.Count-1 do
295
+ begin
296
+ if (FSavedFunctions[i].FileId = fileId) and (FSavedFunctions[i].Name = f) then
297
+ begin
298
+ result := FSavedFunctions[i].ExportAs;
299
+ exit;
300
+ end ;
301
+ end ;
302
+ end ;
303
+
304
+ function TProject.WasFunctionExported (f: string; fileId: string): boolean;
305
+ var
306
+ i: Integer;
307
+ begin
308
+ result := false;
309
+ for i := 0 to FSavedFunctions.Count-1 do
310
+ begin
311
+ if (FSavedFunctions[i].FileId = fileId) and (FSavedFunctions[i].Name = f) then
312
+ begin
313
+ result := true;
314
+ exit;
315
+ end ;
316
+ end ;
317
+ end ;
318
+
319
+ procedure TProject.ExportFunction (name : string; exportAs: string; fileId: string);
320
+ var
321
+ i: Integer;
322
+ fd: TFunctionData;
323
+ begin
324
+ for i := 0 to FFunctions.Count-1 do
325
+ begin
326
+ if (FFunctions[i].FileId = fileId) and (FFunctions[i].Name = name ) then
327
+ begin
328
+ fd := FFunctions[i];
329
+ fd.Export := true;
330
+ fd.ExportAs := exportAs;
331
+ FFunctions[i] := fd;
332
+ exit;
333
+ end ;
334
+ end ;
335
+ end ;
336
+
337
+ procedure TProject.MarkAllFunctionsNotToExport ;
338
+ var
339
+ i: Integer;
340
+ fd: TFunctionData;
341
+ begin
342
+ for i := 0 to FFunctions.Count-1 do
343
+ begin
344
+ fd := FFunctions[i];
345
+ fd.Export := false;
346
+ FFunctions[i] := fd;
347
+ end ;
348
+ end ;
349
+
350
+ procedure TProject.MarkAllFunctionsToExport ;
351
+ var
352
+ i: Integer;
353
+ fd: TFunctionData;
354
+ begin
355
+ FSavedFunctions.Clear;
356
+ for i := 0 to FFunctions.Count-1 do
357
+ begin
358
+ fd := FFunctions[i];
359
+ fd.Export := true;
360
+ FFunctions[i] := fd;
361
+ FSavedFunctions.Add(fd);
362
+ end ;
363
+ end ;
364
+
219
365
220
366
end .
0 commit comments