Menu

[r111]: / trunk / Src / UBDSCompiler.pas  Maximize  Restore  History

Download this file

203 lines (178 with data), 6.2 kB

  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
{
* UBDSCompiler.pas
*
* Class that controls and provides information about Borland Development System
* Win32 compilers.
*
* v0.1 of 08 Jan 2006 - Original version.
* v0.2 of 09 Jan 2006 - Changed Clone method to call new CreateCopy
* constructor rather than doing copy itself.
* v1.0 of 24 May 2006 - Improved and corrected comments.
* - Removed unused unit reference.
* v1.1 of 08 May 2007 - Added support for Delphi 2007 to TBDSCompiler.
* v1.2 of 11 Aug 2008 - Changed to use single resource name "BDS" for all
* compiler glyphs.
* v1.3 of 11 Oct 2008 - Added support for Delphi 2009 to TBDSCompiler.
* - Made protected and private section of class strict.
* - Assert and EBug messages now use ClassName to get name
* of class.
*
*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is UBDSCompiler.pas
*
* The Initial Developer of the Original Code is Peter Johnson
* (http://www.delphidabbler.com/).
*
* Portions created by the Initial Developer are Copyright (C) 2006-2008 Peter
* Johnson. All Rights Reserved.
*
* ***** END LICENSE BLOCK *****
}
unit UBDSCompiler;
interface
uses
// Project
IntfCommon, IntfCompilers, UBorlandCompiler;
type
{
TBDSCompiler:
Class that controls and provides information about Borland Development
System Delphi Win32 compilers.
}
TBDSCompiler = class(TBorlandCompiler,
IClonable, // can clone this object
ICompiler, // this is a compiler
ICompilerAutoDetect // can auto detect compiler exec file path
)
strict private
function ProductVersion: Integer;
{Delphi version number.
@return Required major version number.
}
strict protected
function GlyphResourceName: string; override;
{Name of any resource containing a "glyph" bitmap for a compiler.
@return Resource name or '' if the compiler has no glyph.
}
function InstallationRegKey: string; override;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
protected
{ IClonable }
function Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return New object's IInterface interface.
}
{ ICompiler method overrides }
function GetName: string; override;
{Provides the human readable name of the compiler.
@return Name of the compiler.
}
function GetIDString: string; override;
{Provides a non-localisable string that identifies the compiler.
@return Compiler id string.
}
public
constructor Create(const Id: TCompilerID);
{Class constructor: creates object for a BDS compiler.
@param Id [in] Identifies compiler version.
}
end;
implementation
uses
// Delphi
SysUtils,
// Project
UExceptions;
{ TBDSCompiler }
function TBDSCompiler.Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return New object's IInterface interface.
}
begin
Result := TBDSCompiler.CreateCopy(Self);
end;
constructor TBDSCompiler.Create(const Id: TCompilerID);
{Class constructor: creates object for a BDS compiler.
@param Id [in] Identifies compiler version.
}
begin
Assert(Id in [ciD2005w32, ciD2006w32, ciD2007, ciD2009w32],
ClassName + '.Create: Invalid Id'); // ** do not localise
inherited Create(Id);
end;
function TBDSCompiler.GetIDString: string;
{Provides a non-localisable string that identifies the compiler.
@return Compiler id string.
}
begin
// ** do not localise string literals in this method
Result := Format('D%d', [ProductVersion]);
if GetID in [ciD2005w32, ciD2006w32, ciD2009w32] then
Result := Result + 'w32';
end;
function TBDSCompiler.GetName: string;
{Provides the human readable name of the compiler.
@return Name of the compiler.
}
resourcestring
sCompilerName = 'Delphi %d'; // template for name of compiler
begin
Result := Format(sCompilerName, [ProductVersion])
end;
function TBDSCompiler.GlyphResourceName: string;
{Name of any resource containing a "glyph" bitmap for a compiler.
@return Resource name or '' if the compiler has no glyph.
}
begin
Result := 'BDS'; // ** do not localise
end;
function TBDSCompiler.InstallationRegKey: string;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
begin
// ** do not localise any literal strings in this method
case GetID of
ciD2005w32: Result := '\SOFTWARE\Borland\BDS\3.0';
ciD2006w32: Result := '\SOFTWARE\Borland\BDS\4.0';
ciD2007 : Result := '\SOFTWARE\Borland\BDS\5.0';
ciD2009w32: Result := '\SOFTWARE\CodeGear\BDS\6.0';
else
raise EBug.Create(
ClassName + '.InstallationRegKey: Invalid ID'
);
end;
end;
function TBDSCompiler.ProductVersion: Integer;
{Delphi version number.
@return Required major version number.
}
begin
case GetID of
ciD2005w32: Result := 2005;
ciD2006w32: Result := 2006;
ciD2007: Result := 2007;
ciD2009w32: Result := 2009;
else
raise EBug.Create(
ClassName + '.ProductVersion: Invalid ID' // ** do not localise
);
end;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.