1 ; BEGIN ISPPBUILTINS.ISS
3 // Inno Setup Preprocessor
5
5 // Copyright (C
) 2001-2004 Alex Yackimoff
. All Rights Reserved
.
6 // Portions by Martijn Laan
.
7 // http
://ispp
.sourceforge
.net
9 // Inno
Setup (C
) 1997-2009 Jordan Russell
. All Rights Reserved
.
10 // Portions by Martijn Laan
.
12 // $Id
: ISPPBuiltins
.iss
,v
1.3 2010/12/29 15:20:26 mlaan Exp $
14 #
if defined(ISPP_INVOKED
) && !defined(_BUILTINS_ISS_
)
16 #
if PREPROCVER
< 0x01000000
17 # error Inno Setup Preprocessor version
is outdated
20 #define _BUILTINS_ISS_
22 // ===========================================================================
24 // Default states
for options
.
26 //#pragma parseroption
-b
+ ; short circuit
boolean evaluation
: on
27 //#pragma parseroption
-m
- ; short circuit multiplication
evaluation (0 * A will
not eval A
): off
28 //#pragma parseroption
-p
+ ; string literals without escape sequences
: on
29 //#pragma parseroption
-u
- ; allow undeclared identifiers
: off
30 //#pragma option
-c
+ ; pass script
to the compiler
: on
31 //#pragma option
-e
- ; emit empty lines
to translation
: off
32 //#pragma option
-v
- ; verbose mode
: off
34 // ---------------------------------------------------------------------------
37 // 0 - #include
and #
file acknowledgements
38 // 1 - information about any temp
files created by #
file
39 // 2 - #insert
and #append acknowledgements
41 // 4 - #dim
, #define
and #undef acknowledgements
43 // 6 - conditional inclusion acknowledgements
45 // 8 - show strings emitted
with #emit directive
46 // 9 - macro
and functions successfull call acknowledgements
47 //10 - Local macro
array allocation acknowledgements
49 //#pragma verboselevel
0
52 # define
private CStrings
53 # pragma parseroption
-p
+
56 #pragma spansymbol
"\"
63 #define MaxInt 0x7FFFFFFFL
64 #define MinInt 0x80000000L
73 #define TYPE_INTEGER 2
79 // Helper macro to find out the type of an array element or expression. TypeOf
80 // standard function only allows identifier as its parameter. Use this macro
81 // to convert an expression to identifier.
83 #define TypeOf2(any Expr) TypeOf(Expr)
87 #define HKEY_CLASSES_ROOT 0x80000000UL
88 #define HKEY_CURRENT_USER 0x80000001UL
89 #define HKEY_LOCAL_MACHINE 0x80000002UL
90 #define HKEY_USERS 0x80000003UL
92 #define HKCR HKEY_CLASSES_ROOT
93 #define HKCU HKEY_CURRENT_USER
94 #define HKLM HKEY_LOCAL_MACHINE
95 #define HKU HKEY_USERS
100 #define SW_SHOWNORMAL 1
102 #define SW_SHOWMINIMIZED 2
103 #define SW_SHOWMAXIMIZED 3
104 #define SW_MAXIMIZE 3
105 #define SW_SHOWNOACTIVATE 4
107 #define SW_MINIMIZE 6
108 #define SW_SHOWMINNOACTIVE 7
111 #define SW_SHOWDEFAULT 10
116 #define FIND_MATCH 0x00
117 #define FIND_BEGINS 0x01
118 #define FIND_ENDS 0x02
119 #define FIND_CONTAINS 0x03
120 #define FIND_CASESENSITIVE 0x04
121 #define FIND_SENSITIVE FIND_CASESENSITIVE
122 #define FIND_AND 0x00
124 #define FIND_NOT 0x10
125 #define FIND_TRIM 0x20
127 // FindFirst constants
129 #define faReadOnly 0x00000001
130 #define faHidden 0x00000002
131 #define faSysFile 0x00000004
132 #define faVolumeID 0x00000008
133 #define faDirectory 0x00000010
134 #define faArchive 0x00000020
135 #define faSymLink 0x00000040
136 #define faAnyFile 0x0000003F
138 // GetStringFileInfo standard names
140 #define COMPANY_NAME "CompanyName
"
141 #define FILE_DESCRIPTION "FileDescription
"
142 #define FILE_VERSION "FileVersion
"
143 #define INTERNAL_NAME "InternalName
"
144 #define LEGAL_COPYRIGHT "LegalCopyright
"
145 #define ORIGINAL_FILENAME "OriginalFilename
"
146 #define PRODUCT_NAME "ProductName
"
147 #define PRODUCT_VERSION "ProductVersion
"
149 // GetStringFileInfo helpers
151 #define GetFileCompany(str FileName) GetStringFileInfo(FileName, COMPANY_NAME)
152 #define GetFileCopyright(str FileName) GetStringFileInfo(FileName, LEGAL_COPYRIGHT)
153 #define GetFileDescription(str FileName) GetStringFileInfo(FileName, FILE_DESCRIPTION)
154 #define GetFileProductVersion(str FileName) GetStringFileInfo(FileName, PRODUCT_VERSION)
155 #define GetFileVersionString(str FileName) GetStringFileInfo(FileName, FILE_VERSION)
159 // Macro internally calls GetFileVersion function and parses string returned
160 // by that function (in form "0.0.0.0"). All four version elements are stored
161 // in by-reference parameters Major, Minor, Rev, and Build. Macro returns
162 // string returned by GetFileVersion.
164 #define DeleteToFirstPeriod(str *S) \
165 Local[1] = Copy(S, 1, (Local[0] = Pos(".", S)) - 1), \
166 S = Copy(S, Local[0] + 1), \
169 #define ParseVersion(str FileName, *Major, *Minor, *Rev, *Build) \
170 Local[1] = Local[0] = GetFileVersion(FileName), \
171 Local[1] == "" ? "" : ( \
172 Major = Int(DeleteToFirstPeriod(Local[1])), \
173 Minor = Int(DeleteToFirstPeriod(Local[1])), \
174 Rev = Int(DeleteToFirstPeriod(Local[1])), \
175 Build = Int(Local[1]), \
180 // Encodes given four version elements to a 32 bit integer number (8 bits for
181 // each element, i.e. elements must be within 0...255 range).
183 #define EncodeVer(int Major, int Minor, int Revision = 0, int Build = -1) \
184 Major << 24 | (Minor & 0xFF) << 16 | (Revision & 0xFF) << 8 | (Build >= 0 ? Build & 0xFF : 0)
188 // Decodes given 32 bit integer encoded version to its string representation,
189 // Digits parameter indicates how many elements to show (if the fourth element
190 // is 0, it won't be shown anyway).
192 #define DecodeVer(int Ver, int Digits = 3) \
193 Str(Ver >> 0x18 & 0xFF) + (Digits > 1 ? "." : "") + \
195 Str(Ver >> 0x10 & 0xFF) + (Digits > 2 ? "." : "") : "") + \
197 Str(Ver >> 0x08 & 0xFF) + (Digits > 3 && (Local = Ver & 0xFF) ? "." : "") : "") + \
198 (Digits > 3 && Local ? \
199 Str(Ver & 0xFF) : "")
203 // Returns index of the line following the header of the section. This macro
204 // is intended to be used with #insert directive.
206 #define FindSection(str Section = "Files") \
207 Find(0, "[" + Section + "]", FIND_MATCH | FIND_TRIM) + 1
211 // Returns index of the line following last entry of the section. This macro
212 // is intended to be used with #insert directive.
214 #if VER >= 0x03000000
215 # define FindNextSection(int Line) \
216 Find(Line, "[", FIND_BEGINS | FIND_TRIM, "]", FIND_ENDS | FIND_AND)
217 # define FindSectionEnd(str Section = "Files") \
218 FindNextSection(FindSection(Section))
220 # define FindSectionEnd(str Section = "Files") \
221 FindSection(Section) + EntryCount(Section)
226 // Returns index of the line (of translation) following either [Code] section
227 // header, or "program" keyword, if any.
230 Local[1] = FindSection("Code
"), \
231 Local[0] = Find(Local[1] - 1, "program", FIND_BEGINS, ";", FIND_ENDS | FIND_AND), \
232 (Local[0] < 0 ? Local[1] : Local[0] + 1)
236 // Returns directory portion of the given filename without backslash (unless
237 // it is a root directory). If PathName doesn't contain directory portion,
238 // the result is an empty string.
240 #define ExtractFilePath(str PathName) \
242 !(Local[1] = RPos("\", PathName
)) ? \
244 Copy(PathName
, 1, Local
[1] - 1)), \
246 ((Local
[2] = Len(Local
[0])) == 2 && Copy(Local
[0], Local
[2]) == ":" ? \
249 #define ExtractFileDir(str PathName) \
250 RemoveBackslash(ExtractFilePath(PathName))
252 #define ExtractFileExt(str PathName) \
253 Local[0] = RPos(".", PathName), \
254 Copy(PathName, Local[0] + 1)
258 // Returns name portion of the given filename. If PathName ends with
259 // a backslash, the result is an empty string.
261 #define ExtractFileName(str PathName) \
262 !(Local[0] = RPos("\", PathName
)) ? \
264 Copy(PathName
, Local
[0] + 1)
268 // Changes extension
in FileName
with NewExt
. NewExt must
not contain
271 #define
ChangeFileExt(str FileName
, str NewExt
) \
272 !(Local
[0] = RPos(".", FileName
)) ? \
273 FileName
+ "." + NewExt
: \
274 Copy(FileName
, 1, Local
[0]) + NewExt
278 // Adds a backslash
to the
string, if it
's not already there.
280 #define AddBackslash(str S) \
281 Copy(S, Len(S)) == "\" ? S : S + "\"
285 // Removes trailing backslash from the string unless the string points to
288 #define RemoveBackslash(str S) \
291 Copy(S, Local[0]) == "\" ? \
292 (Local[0] == 3 && Copy(S, 2, 1) == ":" ? \
294 Copy(S, 1, Local[0] - 1)) : \
300 // Deletes specified number of characters beginning with Index from S. S is
301 // passed by reference (therefore is modified). Acts like Delete function in
302 // Delphi (from System unit).
304 #define Delete(str *S, int Index, int Count = MaxInt) \
305 S = Copy(S, 1, Index - 1) + Copy(S, Index + Count)
309 // Inserts specified Substr at Index'th character into S
. S
is passed by
310 // reference (therefore
is modified
).
312 #define
Insert(str
*S
, int Index
, str Substr
) \
313 Index
> Len(S
) + 1 ? \
315 S
= Copy(S
, 1, Index
- 1) + SubStr
+ Copy(S
, Index
)
319 // Returns nonzero value
if given
string is "yes", "true" or "1". Intended
to
320 // be used
with SetupSetting
function. This macro replaces YesNo
function
321 // available
in previous releases
.
323 #define
YesNo(str S
) \
324 (S
= LowerCase(S
)) == "yes" || S
== "true" || S
== "1"
326 #define
IsDirSet(str SetupDirective
) \
327 YesNo(SetupSetting(SetupDirective
))
330 #define
Power(int X
, int P
= 2) \
331 !P ?
1 : X
* Power(X
, P
- 1)
333 #define
Min(int A
, int B
, int C
= MaxInt
) \
334 A
< B ? A
< C ?
Int(A
) : Int(C
) : Int(B
)
336 #define
Max(int A
, int B
, int C
= MinInt
) \
337 A
> B ? A
> C ?
Int(A
) : Int(C
) : Int(B
)
341 # pragma parseroption
-p
-
344 ; END ISPPBUILTINS.ISS