Skip to content

Commit 99e3119

Browse files
committed
support for 16-bit, 32-bit, and 64-bit DLL Projects
1 parent c2578ef commit 99e3119

40 files changed

+2487
-715
lines changed

Domain/uGroup.pas

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ procedure TGroup.CreateNewProject(projectType: TProjectType; options: TVisualMAS
154154
project := CreateProject('MyLibrary.lib',projectType);
155155
project.CreateProjectFile('readme.txt', options, pftTXT);
156156
end;
157+
ptWin32DLL:
158+
begin
159+
project := CreateProject('Win32.dll',projectType);
160+
project.CreateProjectFile(WIN_DLL_MODULE_FILENAME, options, pftDef);
161+
project.CreateProjectFile(DEFAULT_FILE_NAME, options);
162+
end;
163+
ptWin64DLL:
164+
begin
165+
project := CreateProject('Win64.dll',projectType);
166+
project.CreateProjectFile(DEFAULT_FILE_NAME, options);
167+
end;
168+
ptWin16DLL:
169+
begin
170+
project := CreateProject('Win16.dll',projectType);
171+
project.CreateProjectFile(DEFAULT_FILE_NAME, options);
172+
end;
157173
end;
158174

159175
AddProject(project);

Domain/uProject.pas

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ TProject = class(TVisualMASMFile)
1717
FOutputFile: string;
1818
FSizeInBytes: int64;
1919
FBuild: boolean;
20+
FFunctions: TList<TFunctionData>;
21+
FSavedFunctions: TList<TFunctionData>;
2022

2123
FPreAssembleEventCommandLine: string;
2224
FAssembleEventCommandLine: string;
@@ -34,6 +36,7 @@ TProject = class(TVisualMASMFile)
3436
procedure SetProjectFile(Index: string; const Value: TProjectFile);
3537
procedure SetActiveFile(projectFile: TProjectFile);
3638
procedure SetSizeInBytes(value: int64);
39+
function GetSavedFunction(f: string; fileId: string): string;
3740
public
3841
constructor Create; overload;
3942
constructor Create (Name: string); overload;
@@ -54,6 +57,13 @@ TProject = class(TVisualMASMFile)
5457
property OutputFile: string read FOutputFile write FOutputFile;
5558
property SizeInBytes: int64 read FSizeInBytes write SetSizeInBytes;
5659
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;
5767
published
5868
procedure DeleteProjectFile(id: string);
5969
procedure AddProjectFile(projectFile: TProjectFile);
@@ -67,6 +77,8 @@ procedure TProject.Initialize;
6777
begin
6878
FProjectType := ptWin32;
6979
FProjectFiles := TDictionary<string, TProjectFile>.Create;
80+
FFunctions := TList<TFunctionData>.Create;
81+
FSavedFunctions := TList<TFunctionData>.Create;
7082
self.Modified := true;
7183
FBuild := true;
7284
end;
@@ -179,6 +191,23 @@ function TProject.CreateProjectFile(name: string; options: TVisualMASMOptions; f
179191
if fileType = pftTXT then
180192
projectFile.Content := TFile.ReadAllText(options.TemplatesFolder+LIB_STUB_FILENAME);
181193
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;
182211
end;
183212

184213
AddProjectFile(projectFile);
@@ -216,5 +245,122 @@ procedure TProject.SetSizeInBytes(value: int64);
216245
FSizeInBytes := value;
217246
end;
218247

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+
219365

220366
end.

Domain/uProjectFile.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ procedure TProjectFile.SetFileName(value: string);
148148
FProjectFileType := pftDLG
149149
else if fileExt = '.LIB' then
150150
FProjectFileType := pftLib
151+
else if fileExt = '.DEF' then
152+
FProjectFileType := pftDef
151153
else
152154
// FProjectFileType := pftOther;
153155
FProjectFileType := pftBinary;

Domain/uSharedGlobals.pas

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ interface
6464
COMPONENT_PALETTE_STANDARD: string = 'Standard';
6565
COMPONENT_PALETTE_WIN32: string = 'Win32';
6666
DEBUGGER_OUTPUT_FILE: string = '$OutputFile';
67+
PROJECT_NAME: string = '$ProjectName';
68+
EXPORTED_FUNCTIONS: string = '$ExportedFunctions';
6769
DOS_16_BIT_COM_STUB_FILENAME: string = 'MSDOS16COMHelloWorld.asm';
6870
DOS_16_BIT_EXE_STUB_FILENAME: string = 'MSDOS16EXEHelloWorld.asm';
6971
WIN_32_BIT_EXE_MASM32_FILENAME: string = 'Masm32HelloWorld.asm';
7072
WIN_32_BIT_DLG_MASM32_FILENAME: string = 'Win32HelloWorldDialog.asm';
7173
WIN_32_BIT_CON_MASM32_FILENAME: string = 'Win32HelloWorldConsole.asm';
7274
WIN_64_BIT_EXE_WINSDK64_FILENAME: string = 'WinSDK64HelloWorld.asm';
75+
WIN_32_BIT_DLL_MASM32_FILENAME: string = 'Win32Dll.asm';
76+
WIN_64_BIT_DLL_MASM32_FILENAME: string = 'Win64Dll.asm';
77+
WIN_16_BIT_DLL_MASM32_FILENAME: string = 'Win16Dll.asm';
78+
WIN_DLL_DEF_FILENAME: string = 'Dll.def';
79+
WIN_DLL_MODULE_FILENAME: string = 'Module.def';
7380
LIB_STUB_FILENAME: string = 'LibraryReadMe.txt';
7481
TAB: string = #9;
7582
DEFAULT_PROJECTGROUP_NAME: string = 'ProjectGroup1';
@@ -171,9 +178,18 @@ TProjectData = record
171178

172179
PFunctionData = ^TFunctionData;
173180
TFunctionData = record
181+
private
182+
FExport: boolean;
183+
FExportAs: string;
184+
procedure SetExport(Value: boolean);
185+
procedure SetExportAs(Value: string);
186+
public
174187
FileId: string;
175188
Name: string;
176189
Line: integer;
190+
FileName: string;
191+
property Export: boolean read FExport write SetExport;
192+
property ExportAs: string read FExportAs write SetExportAs;
177193
end;
178194

179195
PLabelData = ^TLabelData;
@@ -196,7 +212,7 @@ TGenericTreeData = record
196212
ptDos16EXE, ptWin16, ptWin16DLL, ptWin32Con, ptWin32Dlg, ptLib);
197213

198214
TProjectFileType = (pftASM, pftRC, pftTXT, pftDLG, pftBAT, pftOther, pftINI,
199-
pftCPP, pftINC, pftBinary, pftLib);
215+
pftCPP, pftINC, pftBinary, pftLib, pftDef);
200216

201217
TChange = (fcNone, fcCreate, fcUpdate, fcDelete);
202218

@@ -231,6 +247,16 @@ implementation
231247
uses
232248
IdHashMessageDigest;
233249

250+
procedure TFunctionData.SetExportAs(Value: string);
251+
begin
252+
FExportAs := Value;
253+
end;
254+
255+
procedure TFunctionData.SetExport(Value: boolean);
256+
begin
257+
FExport := Value;
258+
end;
259+
234260
function CreateResourceCodeBehind(name: string): string;
235261
begin
236262
result := '.386' + CRLF;
@@ -887,7 +913,7 @@ procedure RegisterFileType(fileType: TProjectFileType; OnlyForCurrentUser: boole
887913
case fileType of
888914
pftASM: FileExt := 'asm';
889915
pftRC: FileExt := 'rc';
890-
pftTXT: ;
916+
pftTXT,pftDef: ;
891917
pftDLG: ;
892918
pftBAT: ;
893919
pftOther: ;

Domain/uVisualMASMOptions.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ procedure TVisualMASMOptions.Initialize;
111111
FContextHelpFontName := 'Tahoma';
112112
FContextHelpFontSize := 10;
113113
FOutputFontName := 'Courier New';
114-
FOutputFontSize := 8;
114+
FOutputFontSize := 10;
115115
FFunctionListFuncCol := 100;
116116
FFunctionListLabelCol := 40;
117117
FLabelsListFuncCol := 100;
118118
FLabelsListLabelCol := 40;
119119
FProjectExplorerNameCol := 100;
120-
FProjectExplorerBuildCol := 50;
121-
FProjectExplorerSizeCol := 50;
120+
FProjectExplorerBuildCol := 80;
121+
FProjectExplorerSizeCol := 100;
122122
FTheme := 'Auric';
123123
FDebugger := dtNone;
124124
FDebuggerFileName := '';
@@ -348,7 +348,7 @@ procedure TVisualMASMOptions.LoadFile;
348348
if FOutputFontName='' then
349349
FOutputFontName := 'Courier New';
350350
if FOutputFontSize<6 then
351-
FOutputFontSize := 8;
351+
FOutputFontSize := 10;
352352
frmMain.memOutput.Font.Name := FOutputFontName;
353353
frmMain.memOutput.Font.Size := FOutputFontSize;
354354

0 commit comments

Comments
 (0)