/
uProjectFile.pas
160 lines (143 loc) · 4.99 KB
/
uProjectFile.pas
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
unit uProjectFile;
interface
uses
SysUtils, Classes, uSharedGlobals, uVisualMASMFile, System.Generics.Collections;
type
PProjectFile = ^TProjectFile;
TProjectFile = class(TVisualMASMFile)
private
FProjectFileType: TProjectFileType;
FPath: string;
FContent: string;
FSizeInBytes: int64;
FModified: boolean;
FIsOpen: boolean;
FAssembleFile: boolean;
FAssemblyErrors: TList<TAssemblyError>;
FChildFileRCId: string; // Used to refer to another file that is required and part
// of the original file. For example, a dialog (*.dlg) file
// requires a resource definition (*.rc) file. The
// resource definition file would be the dependent file.
// The resource definition file's ParentFileId would be emtpy.
FChildFileASMId: string;
FParentFileId: string; // The equivalent file from the child file id above. The
// resource definition file would have the file id of the
// dialog file.
FOutputFile: string; // The filename of the output including path. E.g. for
// an assembly file, this would be c:\path\file.obj if the
// FFileName was file.asm
procedure Initialize;
procedure SetProjectFileType(value: TProjectFileType);
procedure SetContent(value: string);
procedure SetPath(value: string);
procedure SetSizeInBytes(value: int64);
procedure SetIsOpen(value: boolean);
procedure SetAssembleFile(value: boolean);
procedure SetFileName(value: string);
public
constructor Create; overload;
constructor Create (Name: string); overload;
property ProjectFileType: TProjectFileType read FProjectFileType write SetProjectFileType;
property Content: string read FContent write SetContent;
property Path: string read FPath write SetPath;
property SizeInBytes: int64 read FSizeInBytes write SetSizeInBytes;
property IsOpen: boolean read FIsOpen write SetIsOpen;
property AssembleFile: boolean read FAssembleFile write SetAssembleFile;
property AssemblyErrors: TList<TAssemblyError> read FAssemblyErrors write FAssemblyErrors;
property ChildFileRCId: string read FChildFileRCId write FChildFileRCId;
property ChildFileASMId: string read FChildFileASMId write FChildFileASMId;
property ParentFileId: string read FParentFileId write FParentFileId;
property OutputFile: string read FOutputFile write FOutputFile;
property FileName: string read FFileName write SetFileName;
published
procedure MarkFileClosed;
end;
implementation
procedure TProjectFile.Initialize;
begin
FProjectFileType := pftASM;
FContent := '';
FIsOpen := true;
FAssembleFile := true;
FAssemblyErrors := TList<TAssemblyError>.Create;
self.Modified := false;
end;
constructor TProjectFile.Create;
begin
inherited Create;
Initialize;
end;
constructor TProjectFile.Create(name: string);
begin
inherited Create(name);
Initialize;
end;
procedure TProjectFile.SetProjectFileType(value: TProjectFileType);
begin
FProjectFileType := value;
// self.Modified := true;
end;
procedure TProjectFile.SetContent(value: string);
begin
FContent := value;
// self.Modified := true;
end;
procedure TProjectFile.SetPath(value: string);
begin
FPath := value;
// self.Modified := true;
end;
procedure TProjectFile.SetSizeInBytes(value: int64);
begin
FSizeInBytes := value;
// self.Modified := true;
end;
procedure TProjectFile.SetIsOpen(value: boolean);
begin
FIsOpen := value;
// self.Modified := true;
end;
procedure TProjectFile.SetAssembleFile(value: boolean);
begin
FAssembleFile := value;
// self.Modified := true;
end;
procedure TProjectFile.MarkFileClosed;
begin
FIsOpen := false;
// FModified := true;
end;
procedure TProjectFile.SetFileName(value: string);
var
fileExt: string;
begin
FFileName := value;
if value = '' then exit;
fileExt := UpperCase(ExtractFileExt(value));
if (fileExt = '.ASM') then
FProjectFileType := pftASM
else if fileExt = '.INC' then
FProjectFileType := pftINC
else if fileExt = '.BAT' then
FProjectFileType := pftBAT
else if fileExt = '.TXT' then
FProjectFileType := pftTXT
else if fileExt = '.RC' then
FProjectFileType := pftRC
else if fileExt = '.INI' then
FProjectFileType := pftINI
else if (fileExt = '.C') or (fileExt = '.CPP') or (fileExt = '.CC') or (fileExt = '.H') or (fileExt = '.HPP') or (fileExt = '.HH') or (fileExt = '.CXX') or (fileExt = '.HXX') or (fileExt = '.CU') then
FProjectFileType := pftCPP
else if fileExt = '.DLG' then
FProjectFileType := pftDLG
else if fileExt = '.LIB' then
FProjectFileType := pftLib
else if fileExt = '.DEF' then
FProjectFileType := pftDef
else if fileExt = '.XML' then
FProjectFileType := pftManifest
else
// FProjectFileType := pftOther;
FProjectFileType := pftBinary;
end;
end.