Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Include / LogicLib.nsh @ 3101

Historique | Voir | Annoter | Télécharger (30,74 ko)

1 2961 mdecorde
; NSIS LOGIC LIBRARY - LogicLib.nsh
2 2961 mdecorde
; Version 2.6 - 08/12/2007
3 2961 mdecorde
; By dselkirk@hotmail.com
4 2961 mdecorde
; and eccles@users.sf.net
5 2961 mdecorde
; with IfNot support added by Message
6 2961 mdecorde
;
7 2961 mdecorde
; Questions/Comments -
8 2961 mdecorde
; See http://forums.winamp.com/showthread.php?s=&postid=1116241
9 2961 mdecorde
;
10 2961 mdecorde
; Description:
11 2961 mdecorde
;   Provides the use of various logic statements within NSIS.
12 2961 mdecorde
;
13 2961 mdecorde
; Usage:
14 2961 mdecorde
;   The following "statements" are available:
15 2961 mdecorde
;       If|IfNot|Unless..{ElseIf|ElseIfNot|ElseUnless}..[Else]..EndIf|EndUnless
16 2961 mdecorde
;         - Conditionally executes a block of statements, depending on the value
17 2961 mdecorde
;           of an expression. IfNot and Unless are equivalent and
18 2961 mdecorde
;           interchangeable, as are ElseIfNot and ElseUnless.
19 2961 mdecorde
;       AndIf|AndIfNot|AndUnless|OrIf|OrIfNot|OrUnless
20 2961 mdecorde
;         - Adds any number of extra conditions to If, IfNot, Unless, ElseIf,
21 2961 mdecorde
;           ElseIfNot and ElseUnless statements.
22 2961 mdecorde
;       IfThen|IfNotThen..|..|
23 2961 mdecorde
;         - Conditionally executes an inline statement, depending on the value
24 2961 mdecorde
;           of an expression.
25 2961 mdecorde
;       IfCmd..||..|
26 2961 mdecorde
;         - Conditionally executes an inline statement, depending on a true
27 2961 mdecorde
;           value of the provided NSIS function.
28 2961 mdecorde
;       Select..{Case[2|3|4|5]}..[CaseElse|Default]..EndSelect
29 2961 mdecorde
;         - Executes one of several blocks of statements, depending on the value
30 2961 mdecorde
;           of an expression.
31 2961 mdecorde
;       Switch..{Case|CaseElse|Default}..EndSwitch
32 2961 mdecorde
;         - Jumps to one of several labels, depending on the value of an
33 2961 mdecorde
;           expression.
34 2961 mdecorde
;       Do[While|Until]..{ExitDo|Continue|Break}..Loop[While|Until]
35 2961 mdecorde
;         - Repeats a block of statements until stopped, or depending on the
36 2961 mdecorde
;           value of an expression.
37 2961 mdecorde
;       While..{ExitWhile|Continue|Break}..EndWhile
38 2961 mdecorde
;         - An alias for DoWhile..Loop (for backwards-compatibility)
39 2961 mdecorde
;       For[Each]..{ExitFor|Continue|Break}..Next
40 2961 mdecorde
;         - Repeats a block of statements varying the value of a variable.
41 2961 mdecorde
;
42 2961 mdecorde
;   The following "expressions" are available:
43 2961 mdecorde
;       Standard (built-in) string tests (which are case-insensitive):
44 2961 mdecorde
;         a == b; a != b
45 2961 mdecorde
;       Additional case-insensitive string tests (using System.dll):
46 2961 mdecorde
;         a S< b; a S>= b; a S> b; a S<= b
47 2961 mdecorde
;       Case-sensitive string tests:
48 2961 mdecorde
;         a S== b; a S!= b
49 2961 mdecorde
;       Standard (built-in) signed integer tests:
50 2961 mdecorde
;         a = b; a <> b; a < b; a >= b; a > b; a <= b
51 2961 mdecorde
;       Standard (built-in) unsigned integer tests:
52 2961 mdecorde
;         a U< b; a U>= b; a U> b; a U<= b
53 2961 mdecorde
;       64-bit integer tests (using System.dll):
54 2961 mdecorde
;         a L= b; a L<> b; a L< b; a L>= b; a L> b; a L<= b
55 2961 mdecorde
;       ptrdiff_t integer tests
56 2961 mdecorde
;         a P= b; a P<> b; a P< b; a P>= b; a P> b; a P<= b
57 2961 mdecorde
;       size_t integer tests
58 2961 mdecorde
;         a Z= b; a Z<> b; a Z< b; a Z>= b; a Z> b; a Z<= b
59 2961 mdecorde
;       Built-in NSIS flag tests:
60 2961 mdecorde
;         ${Abort}; ${Errors}; ${RebootFlag}; ${Silent}
61 2961 mdecorde
;       Built-in NSIS other tests:
62 2961 mdecorde
;         ${FileExists} a
63 2961 mdecorde
;       Any conditional NSIS instruction test:
64 2961 mdecorde
;         ${Cmd} a
65 2961 mdecorde
;       Section flag tests:
66 2961 mdecorde
;         ${SectionIsSelected} a; ${SectionIsSectionGroup} a;
67 2961 mdecorde
;         ${SectionIsSectionGroupEnd} a; ${SectionIsBold} a;
68 2961 mdecorde
;         ${SectionIsReadOnly} a; ${SectionIsExpanded} a;
69 2961 mdecorde
;         ${SectionIsPartiallySelected} a
70 2961 mdecorde
;
71 2961 mdecorde
; Examples:
72 2961 mdecorde
;   See LogicLib.nsi in the Examples folder for lots of example usage.
73 2961 mdecorde
74 2961 mdecorde
!verbose push
75 2961 mdecorde
!verbose 3
76 2961 mdecorde
!ifndef LOGICLIB_VERBOSITY
77 2961 mdecorde
  !define LOGICLIB_VERBOSITY 3
78 2961 mdecorde
!endif
79 2961 mdecorde
!define _LOGICLIB_VERBOSITY ${LOGICLIB_VERBOSITY}
80 2961 mdecorde
!undef LOGICLIB_VERBOSITY
81 2961 mdecorde
!verbose ${_LOGICLIB_VERBOSITY}
82 2961 mdecorde
83 2961 mdecorde
!ifndef LOGICLIB
84 2961 mdecorde
  !define LOGICLIB
85 2961 mdecorde
  !define | "'"
86 2961 mdecorde
  !define || "' '"
87 2961 mdecorde
  !define LOGICLIB_COUNTER 0
88 2961 mdecorde
89 2961 mdecorde
  !include Sections.nsh
90 2961 mdecorde
91 2961 mdecorde
  !macro _LOGICLIB_TEMP
92 2961 mdecorde
    !ifndef _LOGICLIB_TEMP
93 2961 mdecorde
      !define _LOGICLIB_TEMP
94 2961 mdecorde
      Var /GLOBAL _LOGICLIB_TEMP  ; Temporary variable to aid the more elaborate logic tests
95 2961 mdecorde
    !endif
96 2961 mdecorde
  !macroend
97 2961 mdecorde
98 2961 mdecorde
  !macro _IncreaseCounter
99 2961 mdecorde
    !define _LOGICLIB_COUNTER ${LOGICLIB_COUNTER}
100 2961 mdecorde
    !undef LOGICLIB_COUNTER
101 2961 mdecorde
    !define /math LOGICLIB_COUNTER ${_LOGICLIB_COUNTER} + 1
102 2961 mdecorde
    !undef _LOGICLIB_COUNTER
103 2961 mdecorde
  !macroend
104 2961 mdecorde
105 2961 mdecorde
  !macro _PushLogic
106 2961 mdecorde
    !insertmacro _PushScope Logic _LogicLib_Label_${LOGICLIB_COUNTER}
107 2961 mdecorde
    !insertmacro _IncreaseCounter
108 2961 mdecorde
  !macroend
109 2961 mdecorde
110 2961 mdecorde
  !macro _PopLogic
111 2961 mdecorde
    !insertmacro _PopScope Logic
112 2961 mdecorde
  !macroend
113 2961 mdecorde
114 2961 mdecorde
  !macro _PushScope Type label
115 2961 mdecorde
    !ifdef _${Type}                                       ; If we already have a statement
116 2961 mdecorde
      !define _Cur${Type} ${_${Type}}
117 2961 mdecorde
      !undef _${Type}
118 2961 mdecorde
      !define _${Type} ${label}
119 2961 mdecorde
      !define ${_${Type}}Prev${Type} ${_Cur${Type}}       ; Save the current logic
120 2961 mdecorde
      !undef _Cur${Type}
121 2961 mdecorde
    !else
122 2961 mdecorde
      !define _${Type} ${label}                           ; Initialise for first statement
123 2961 mdecorde
    !endif
124 2961 mdecorde
  !macroend
125 2961 mdecorde
126 2961 mdecorde
  !macro _PopScope Type
127 2961 mdecorde
    !ifndef _${Type}
128 2961 mdecorde
      !error "Cannot use _Pop${Type} without a preceding _Push${Type}"
129 2961 mdecorde
    !endif
130 2961 mdecorde
    !ifdef ${_${Type}}Prev${Type}                         ; If a previous statment was active then restore it
131 2961 mdecorde
      !define _Cur${Type} ${_${Type}}
132 2961 mdecorde
      !undef _${Type}
133 2961 mdecorde
      !define _${Type} ${${_Cur${Type}}Prev${Type}}
134 2961 mdecorde
      !undef ${_Cur${Type}}Prev${Type}
135 2961 mdecorde
      !undef _Cur${Type}
136 2961 mdecorde
    !else
137 2961 mdecorde
      !undef _${Type}
138 2961 mdecorde
    !endif
139 2961 mdecorde
  !macroend
140 2961 mdecorde
141 2961 mdecorde
  ; String tests
142 2961 mdecorde
  !macro _== _a _b _t _f
143 2961 mdecorde
    StrCmp `${_a}` `${_b}` `${_t}` `${_f}`
144 2961 mdecorde
  !macroend
145 2961 mdecorde
146 2961 mdecorde
  !macro _!= _a _b _t _f
147 2961 mdecorde
    !insertmacro _== `${_a}` `${_b}` `${_f}` `${_t}`
148 2961 mdecorde
  !macroend
149 2961 mdecorde
150 2961 mdecorde
  ; Case-sensitive string tests
151 2961 mdecorde
  !macro _S== _a _b _t _f
152 2961 mdecorde
    StrCmpS `${_a}` `${_b}` `${_t}` `${_f}`
153 2961 mdecorde
  !macroend
154 2961 mdecorde
155 2961 mdecorde
  !macro _S!= _a _b _t _f
156 2961 mdecorde
    !insertmacro _S== `${_a}` `${_b}` `${_f}` `${_t}`
157 2961 mdecorde
  !macroend
158 2961 mdecorde
159 2961 mdecorde
  ; Extra string tests (cannot do these case-sensitively - I tried and lstrcmp still ignored the case)
160 2961 mdecorde
  !macro _StrCmpI _a _b _e _l _m
161 2961 mdecorde
    !insertmacro _LOGICLIB_TEMP
162 2961 mdecorde
    System::Call `kernel32::lstrcmpiA(ts, ts) i.s` `${_a}` `${_b}`
163 2961 mdecorde
    Pop $_LOGICLIB_TEMP
164 2961 mdecorde
    IntCmp $_LOGICLIB_TEMP 0 `${_e}` `${_l}` `${_m}`
165 2961 mdecorde
  !macroend
166 2961 mdecorde
167 2961 mdecorde
  !macro _S< _a _b _t _f
168 2961 mdecorde
    !insertmacro _StrCmpI `${_a}` `${_b}` `${_f}` `${_t}` `${_f}`
169 2961 mdecorde
  !macroend
170 2961 mdecorde
171 2961 mdecorde
  !macro _S>= _a _b _t _f
172 2961 mdecorde
    !insertmacro _S< `${_a}` `${_b}` `${_f}` `${_t}`
173 2961 mdecorde
  !macroend
174 2961 mdecorde
175 2961 mdecorde
  !macro _S> _a _b _t _f
176 2961 mdecorde
    !insertmacro _StrCmpI `${_a}` `${_b}` `${_f}` `${_f}` `${_t}`
177 2961 mdecorde
  !macroend
178 2961 mdecorde
179 2961 mdecorde
  !macro _S<= _a _b _t _f
180 2961 mdecorde
    !insertmacro _S> `${_a}` `${_b}` `${_f}` `${_t}`
181 2961 mdecorde
  !macroend
182 2961 mdecorde
183 2961 mdecorde
  ; Integer tests
184 2961 mdecorde
  !macro _= _a _b _t _f
185 2961 mdecorde
    IntCmp `${_a}` `${_b}` `${_t}` `${_f}` `${_f}`
186 2961 mdecorde
  !macroend
187 2961 mdecorde
188 2961 mdecorde
  !macro _<> _a _b _t _f
189 2961 mdecorde
    !insertmacro _= `${_a}` `${_b}` `${_f}` `${_t}`
190 2961 mdecorde
  !macroend
191 2961 mdecorde
192 2961 mdecorde
  !macro _< _a _b _t _f
193 2961 mdecorde
    IntCmp `${_a}` `${_b}` `${_f}` `${_t}` `${_f}`
194 2961 mdecorde
  !macroend
195 2961 mdecorde
196 2961 mdecorde
  !macro _>= _a _b _t _f
197 2961 mdecorde
    !insertmacro _< `${_a}` `${_b}` `${_f}` `${_t}`
198 2961 mdecorde
  !macroend
199 2961 mdecorde
200 2961 mdecorde
  !macro _> _a _b _t _f
201 2961 mdecorde
    IntCmp `${_a}` `${_b}` `${_f}` `${_f}` `${_t}`
202 2961 mdecorde
  !macroend
203 2961 mdecorde
204 2961 mdecorde
  !macro _<= _a _b _t _f
205 2961 mdecorde
    !insertmacro _> `${_a}` `${_b}` `${_f}` `${_t}`
206 2961 mdecorde
  !macroend
207 2961 mdecorde
208 2961 mdecorde
  ; Unsigned integer tests (NB: no need for extra equality tests)
209 2961 mdecorde
  !macro _U< _a _b _t _f
210 2961 mdecorde
    IntCmpU `${_a}` `${_b}` `${_f}` `${_t}` `${_f}`
211 2961 mdecorde
  !macroend
212 2961 mdecorde
213 2961 mdecorde
  !macro _U>= _a _b _t _f
214 2961 mdecorde
    !insertmacro _U< `${_a}` `${_b}` `${_f}` `${_t}`
215 2961 mdecorde
  !macroend
216 2961 mdecorde
217 2961 mdecorde
  !macro _U> _a _b _t _f
218 2961 mdecorde
    IntCmpU `${_a}` `${_b}` `${_f}` `${_f}` `${_t}`
219 2961 mdecorde
  !macroend
220 2961 mdecorde
221 2961 mdecorde
  !macro _U<= _a _b _t _f
222 2961 mdecorde
    !insertmacro _U> `${_a}` `${_b}` `${_f}` `${_t}`
223 2961 mdecorde
  !macroend
224 2961 mdecorde
225 2961 mdecorde
  ; Int64 tests
226 2961 mdecorde
  !macro _Int64Cmp _a _o _b _t _f
227 2961 mdecorde
    !insertmacro _LOGICLIB_TEMP
228 2961 mdecorde
    System::Int64Op `${_a}` `${_o}` `${_b}`
229 2961 mdecorde
    Pop $_LOGICLIB_TEMP
230 2961 mdecorde
    !insertmacro _= $_LOGICLIB_TEMP 0 `${_f}` `${_t}`
231 2961 mdecorde
  !macroend
232 2961 mdecorde
233 2961 mdecorde
  !macro _L= _a _b _t _f
234 2961 mdecorde
    !insertmacro _Int64Cmp `${_a}` = `${_b}` `${_t}` `${_f}`
235 2961 mdecorde
  !macroend
236 2961 mdecorde
237 2961 mdecorde
  !macro _L<> _a _b _t _f
238 2961 mdecorde
    !insertmacro _L= `${_a}` `${_b}` `${_f}` `${_t}`
239 2961 mdecorde
  !macroend
240 2961 mdecorde
241 2961 mdecorde
  !macro _L< _a _b _t _f
242 2961 mdecorde
    !insertmacro _Int64Cmp `${_a}` < `${_b}` `${_t}` `${_f}`
243 2961 mdecorde
  !macroend
244 2961 mdecorde
245 2961 mdecorde
  !macro _L>= _a _b _t _f
246 2961 mdecorde
    !insertmacro _L< `${_a}` `${_b}` `${_f}` `${_t}`
247 2961 mdecorde
  !macroend
248 2961 mdecorde
249 2961 mdecorde
  !macro _L> _a _b _t _f
250 2961 mdecorde
    !insertmacro _Int64Cmp `${_a}` > `${_b}` `${_t}` `${_f}`
251 2961 mdecorde
  !macroend
252 2961 mdecorde
253 2961 mdecorde
  !macro _L<= _a _b _t _f
254 2961 mdecorde
    !insertmacro _L> `${_a}` `${_b}` `${_f}` `${_t}`
255 2961 mdecorde
  !macroend
256 2961 mdecorde
257 2961 mdecorde
  ; ptrdiff_t & size_t tests
258 2961 mdecorde
  !macro _P= _a _b _t _f
259 2961 mdecorde
    !insertmacro _= `${_a}` `${_b}` `${_t}` `${_f}`
260 2961 mdecorde
  !macroend
261 2961 mdecorde
  !macro _P<> _a _b _t _f
262 2961 mdecorde
    !insertmacro _<> `${_a}` `${_b}` `${_t}` `${_f}`
263 2961 mdecorde
  !macroend
264 2961 mdecorde
  !macro _P< _a _b _t _f
265 2961 mdecorde
    !insertmacro _< `${_a}` `${_b}` `${_t}` `${_f}`
266 2961 mdecorde
  !macroend
267 2961 mdecorde
  !macro _P>= _a _b _t _f
268 2961 mdecorde
    !insertmacro _>= `${_a}` `${_b}` `${_t}` `${_f}`
269 2961 mdecorde
  !macroend
270 2961 mdecorde
  !macro _P> _a _b _t _f
271 2961 mdecorde
    !insertmacro _> `${_a}` `${_b}` `${_t}` `${_f}`
272 2961 mdecorde
  !macroend
273 2961 mdecorde
  !macro _P<= _a _b _t _f
274 2961 mdecorde
    !insertmacro _<= `${_a}` `${_b}` `${_t}` `${_f}`
275 2961 mdecorde
  !macroend
276 2961 mdecorde
  !macro _Z= _a _b _t _f
277 2961 mdecorde
    !insertmacro _= `${_a}` `${_b}` `${_t}` `${_f}`
278 2961 mdecorde
  !macroend
279 2961 mdecorde
  !macro _Z<> _a _b _t _f
280 2961 mdecorde
    !insertmacro _<> `${_a}` `${_b}` `${_t}` `${_f}`
281 2961 mdecorde
  !macroend
282 2961 mdecorde
  !macro _Z< _a _b _t _f
283 2961 mdecorde
    !insertmacro _U< `${_a}` `${_b}` `${_t}` `${_f}`
284 2961 mdecorde
  !macroend
285 2961 mdecorde
  !macro _Z>= _a _b _t _f
286 2961 mdecorde
    !insertmacro _U>= `${_a}` `${_b}` `${_t}` `${_f}`
287 2961 mdecorde
  !macroend
288 2961 mdecorde
  !macro _Z> _a _b _t _f
289 2961 mdecorde
    !insertmacro _U> `${_a}` `${_b}` `${_t}` `${_f}`
290 2961 mdecorde
  !macroend
291 2961 mdecorde
  !macro _Z<= _a _b _t _f
292 2961 mdecorde
    !insertmacro _U<= `${_a}` `${_b}` `${_t}` `${_f}`
293 2961 mdecorde
  !macroend
294 2961 mdecorde
295 2961 mdecorde
  ; Flag tests
296 2961 mdecorde
  !macro _Abort _a _b _t _f
297 2961 mdecorde
    IfAbort `${_t}` `${_f}`
298 2961 mdecorde
  !macroend
299 2961 mdecorde
  !define Abort `"" Abort ""`
300 2961 mdecorde
301 2961 mdecorde
  !macro _Errors _a _b _t _f
302 2961 mdecorde
    IfErrors `${_t}` `${_f}`
303 2961 mdecorde
  !macroend
304 2961 mdecorde
  !define Errors `"" Errors ""`
305 2961 mdecorde
306 2961 mdecorde
  !macro _FileExists _a _b _t _f
307 2961 mdecorde
    IfFileExists `${_b}` `${_t}` `${_f}`
308 2961 mdecorde
  !macroend
309 2961 mdecorde
  !define FileExists `"" FileExists`
310 2961 mdecorde
311 2961 mdecorde
  !macro _RebootFlag _a _b _t _f
312 2961 mdecorde
    IfRebootFlag `${_t}` `${_f}`
313 2961 mdecorde
  !macroend
314 2961 mdecorde
  !define RebootFlag `"" RebootFlag ""`
315 2961 mdecorde
316 2961 mdecorde
  !macro _Silent _a _b _t _f
317 2961 mdecorde
    IfSilent `${_t}` `${_f}`
318 2961 mdecorde
  !macroend
319 2961 mdecorde
  !define Silent `"" Silent ""`
320 2961 mdecorde
321 2961 mdecorde
  ; "Any instruction" test
322 2961 mdecorde
  !macro _Cmd _a _b _t _f
323 2961 mdecorde
    !define _t=${_t}
324 2961 mdecorde
    !ifdef _t=                                            ; If no true label then make one
325 2961 mdecorde
      !define __t _LogicLib_Label_${LOGICLIB_COUNTER}
326 2961 mdecorde
      !insertmacro _IncreaseCounter
327 2961 mdecorde
    !else
328 2961 mdecorde
      !define __t ${_t}
329 2961 mdecorde
    !endif
330 2961 mdecorde
    ${_b} ${__t}
331 2961 mdecorde
    !define _f=${_f}
332 2961 mdecorde
    !ifndef _f=                                           ; If a false label then go there
333 2961 mdecorde
      Goto ${_f}
334 2961 mdecorde
    !endif
335 2961 mdecorde
    !undef _f=${_f}
336 2961 mdecorde
    !ifdef _t=                                            ; If we made our own true label then place it
337 2961 mdecorde
      ${__t}:
338 2961 mdecorde
    !endif
339 2961 mdecorde
    !undef __t
340 2961 mdecorde
    !undef _t=${_t}
341 2961 mdecorde
  !macroend
342 2961 mdecorde
  !define Cmd `"" Cmd`
343 2961 mdecorde
344 2961 mdecorde
  ; Section flag test
345 2961 mdecorde
  !macro _SectionFlagIsSet _a _b _t _f
346 2961 mdecorde
    !insertmacro _LOGICLIB_TEMP
347 2961 mdecorde
    SectionGetFlags `${_b}` $_LOGICLIB_TEMP
348 2961 mdecorde
    IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP & `${_a}`
349 2961 mdecorde
    !insertmacro _= $_LOGICLIB_TEMP `${_a}` `${_t}` `${_f}`
350 2961 mdecorde
  !macroend
351 2961 mdecorde
  !define SectionIsSelected `${SF_SELECTED} SectionFlagIsSet`
352 2961 mdecorde
  !define SectionIsSubSection `${SF_SUBSEC} SectionFlagIsSet`
353 2961 mdecorde
  !define SectionIsSubSectionEnd `${SF_SUBSECEND} SectionFlagIsSet`
354 2961 mdecorde
  !define SectionIsSectionGroup `${SF_SECGRP} SectionFlagIsSet`
355 2961 mdecorde
  !define SectionIsSectionGroupEnd `${SF_SECGRPEND} SectionFlagIsSet`
356 2961 mdecorde
  !define SectionIsBold `${SF_BOLD} SectionFlagIsSet`
357 2961 mdecorde
  !define SectionIsReadOnly `${SF_RO} SectionFlagIsSet`
358 2961 mdecorde
  !define SectionIsExpanded `${SF_EXPAND} SectionFlagIsSet`
359 2961 mdecorde
  !define SectionIsPartiallySelected `${SF_PSELECTED} SectionFlagIsSet`
360 2961 mdecorde
361 2961 mdecorde
  !define IfCmd `!insertmacro _IfThen "" Cmd ${|}`
362 2961 mdecorde
363 2961 mdecorde
  !macro _If _c _a _o _b
364 2961 mdecorde
    !verbose push
365 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
366 2961 mdecorde
    !insertmacro _PushLogic
367 2961 mdecorde
    !define ${_Logic}If
368 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the Else
369 2961 mdecorde
    !insertmacro _IncreaseCounter
370 2961 mdecorde
    !define _c=${_c}
371 2961 mdecorde
    !ifdef _c=true                                        ; If is true
372 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
373 2961 mdecorde
    !else                                                 ; If condition is false
374 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
375 2961 mdecorde
    !endif
376 2961 mdecorde
    !undef _c=${_c}
377 2961 mdecorde
    !verbose pop
378 2961 mdecorde
  !macroend
379 2961 mdecorde
  !define If     `!insertmacro _If true`
380 2961 mdecorde
  !define Unless `!insertmacro _If false`
381 2961 mdecorde
  !define IfNot  `!insertmacro _If false`
382 2961 mdecorde
383 2961 mdecorde
  !macro _And _c _a _o _b
384 2961 mdecorde
    !verbose push
385 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
386 2961 mdecorde
    !ifndef _Logic | ${_Logic}If
387 2961 mdecorde
      !error "Cannot use And without a preceding If or IfNot/Unless"
388 2961 mdecorde
    !endif
389 2961 mdecorde
    !ifndef ${_Logic}Else
390 2961 mdecorde
      !error "Cannot use And following an Else"
391 2961 mdecorde
    !endif
392 2961 mdecorde
    !define _c=${_c}
393 2961 mdecorde
    !ifdef _c=true                                        ; If is true
394 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
395 2961 mdecorde
    !else                                                 ; If condition is false
396 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
397 2961 mdecorde
    !endif
398 2961 mdecorde
    !undef _c=${_c}
399 2961 mdecorde
    !verbose pop
400 2961 mdecorde
  !macroend
401 2961 mdecorde
  !define AndIf     `!insertmacro _And true`
402 2961 mdecorde
  !define AndUnless `!insertmacro _And false`
403 2961 mdecorde
  !define AndIfNot  `!insertmacro _And false`
404 2961 mdecorde
405 2961 mdecorde
  !macro _Or _c _a _o _b
406 2961 mdecorde
    !verbose push
407 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
408 2961 mdecorde
    !ifndef _Logic | ${_Logic}If
409 2961 mdecorde
      !error "Cannot use Or without a preceding If or IfNot/Unless"
410 2961 mdecorde
    !endif
411 2961 mdecorde
    !ifndef ${_Logic}Else
412 2961 mdecorde
      !error "Cannot use Or following an Else"
413 2961 mdecorde
    !endif
414 2961 mdecorde
    !define _label _LogicLib_Label_${LOGICLIB_COUNTER}                           ; Skip this test as we already
415 2961 mdecorde
    !insertmacro _IncreaseCounter
416 2961 mdecorde
    Goto ${_label}                                        ; have a successful result
417 2961 mdecorde
    ${${_Logic}Else}:                                     ; Place the Else label
418 2961 mdecorde
    !undef ${_Logic}Else                                  ; and remove it
419 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new If
420 2961 mdecorde
    !insertmacro _IncreaseCounter
421 2961 mdecorde
    !define _c=${_c}
422 2961 mdecorde
    !ifdef _c=true                                        ; If is true
423 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
424 2961 mdecorde
    !else                                                 ; If condition is false
425 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
426 2961 mdecorde
    !endif
427 2961 mdecorde
    !undef _c=${_c}
428 2961 mdecorde
    ${_label}:
429 2961 mdecorde
    !undef _label
430 2961 mdecorde
    !verbose pop
431 2961 mdecorde
  !macroend
432 2961 mdecorde
  !define OrIf     `!insertmacro _Or true`
433 2961 mdecorde
  !define OrUnless `!insertmacro _Or false`
434 2961 mdecorde
  !define OrIfNot  `!insertmacro _Or false`
435 2961 mdecorde
436 2961 mdecorde
  !macro _Else
437 2961 mdecorde
    !verbose push
438 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
439 2961 mdecorde
    !ifndef _Logic | ${_Logic}If
440 2961 mdecorde
      !error "Cannot use Else without a preceding If or IfNot/Unless"
441 2961 mdecorde
    !endif
442 2961 mdecorde
    !ifndef ${_Logic}Else
443 2961 mdecorde
      !error "Cannot use Else following an Else"
444 2961 mdecorde
    !endif
445 2961 mdecorde
    !ifndef ${_Logic}EndIf                                ; First Else for this If?
446 2961 mdecorde
      !define ${_Logic}EndIf _LogicLib_Label_${LOGICLIB_COUNTER}                 ; Get a label for the EndIf
447 2961 mdecorde
      !insertmacro _IncreaseCounter
448 2961 mdecorde
    !endif
449 2961 mdecorde
    Goto ${${_Logic}EndIf}                                ; Go to the EndIf
450 2961 mdecorde
    ${${_Logic}Else}:                                     ; Place the Else label
451 2961 mdecorde
    !undef ${_Logic}Else                                  ; and remove it
452 2961 mdecorde
    !verbose pop
453 2961 mdecorde
  !macroend
454 2961 mdecorde
  !define Else `!insertmacro _Else`
455 2961 mdecorde
456 2961 mdecorde
  !macro _ElseIf _c _a _o _b
457 2961 mdecorde
    !verbose push
458 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
459 2961 mdecorde
    ${Else}                                               ; Perform the Else
460 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new If
461 2961 mdecorde
    !insertmacro _IncreaseCounter
462 2961 mdecorde
    !define _c=${_c}
463 2961 mdecorde
    !ifdef _c=true                                        ; If is true
464 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
465 2961 mdecorde
    !else                                                 ; If condition is false
466 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
467 2961 mdecorde
    !endif
468 2961 mdecorde
    !undef _c=${_c}
469 2961 mdecorde
    !verbose pop
470 2961 mdecorde
  !macroend
471 2961 mdecorde
  !define ElseIf     `!insertmacro _ElseIf true`
472 2961 mdecorde
  !define ElseUnless `!insertmacro _ElseIf false`
473 2961 mdecorde
  !define ElseIfNot  `!insertmacro _ElseIf false`
474 2961 mdecorde
475 2961 mdecorde
  !macro _EndIf _n
476 2961 mdecorde
    !verbose push
477 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
478 2961 mdecorde
    !ifndef _Logic | ${_Logic}If
479 2961 mdecorde
      !error "Cannot use End${_n} without a preceding If or IfNot/Unless"
480 2961 mdecorde
    !endif
481 2961 mdecorde
    !ifdef ${_Logic}Else
482 2961 mdecorde
      ${${_Logic}Else}:                                   ; Place the Else label
483 2961 mdecorde
      !undef ${_Logic}Else                                ; and remove it
484 2961 mdecorde
    !endif
485 2961 mdecorde
    !ifdef ${_Logic}EndIf
486 2961 mdecorde
      ${${_Logic}EndIf}:                                  ; Place the EndIf
487 2961 mdecorde
      !undef ${_Logic}EndIf                               ; and remove it
488 2961 mdecorde
    !endif
489 2961 mdecorde
    !undef ${_Logic}If
490 2961 mdecorde
    !insertmacro _PopLogic
491 2961 mdecorde
    !verbose pop
492 2961 mdecorde
  !macroend
493 2961 mdecorde
  !define EndIf     `!insertmacro _EndIf If`
494 2961 mdecorde
  !define EndUnless `!insertmacro _EndIf Unless`
495 2961 mdecorde
496 2961 mdecorde
  !macro _IfThen _a _o _b _t
497 2961 mdecorde
    !verbose push
498 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
499 2961 mdecorde
    ${If} `${_a}` `${_o}` `${_b}`
500 2961 mdecorde
      ${_t}
501 2961 mdecorde
    ${EndIf}
502 2961 mdecorde
    !verbose pop
503 2961 mdecorde
  !macroend
504 2961 mdecorde
  !define IfThen `!insertmacro _IfThen`
505 2961 mdecorde
506 2961 mdecorde
  !macro _IfNotThen _a _o _b _t
507 2961 mdecorde
    !verbose push
508 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
509 2961 mdecorde
    ${IfNot} `${_a}` `${_o}` `${_b}`
510 2961 mdecorde
      ${_t}
511 2961 mdecorde
    ${EndIf}
512 2961 mdecorde
    !verbose pop
513 2961 mdecorde
  !macroend
514 2961 mdecorde
  !define IfNotThen `!insertmacro _IfNotThen`
515 2961 mdecorde
516 2961 mdecorde
  !macro _ForEach _v _f _t _o _s
517 2961 mdecorde
    !verbose push
518 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
519 2961 mdecorde
    StrCpy "${_v}" "${_f}"                                ; Assign the initial value
520 2961 mdecorde
    Goto +2                                               ; Skip the loop expression for the first iteration
521 2961 mdecorde
    !define _DoLoopExpression `IntOp "${_v}" "${_v}" "${_o}" "${_s}"` ; Define the loop expression
522 2961 mdecorde
    !define _o=${_o}
523 2961 mdecorde
    !ifdef _o=+                                           ; Check the loop expression operator
524 2961 mdecorde
      !define __o >                                       ; to determine the correct loop condition
525 2961 mdecorde
    !else ifdef _o=-
526 2961 mdecorde
      !define __o <
527 2961 mdecorde
    !else
528 2961 mdecorde
      !error "Unsupported ForEach step operator (must be + or -)"
529 2961 mdecorde
    !endif
530 2961 mdecorde
    !undef _o=${_o}
531 2961 mdecorde
    !insertmacro _Do For false `${_v}` `${__o}` `${_t}`   ; Let Do do the rest
532 2961 mdecorde
    !undef __o
533 2961 mdecorde
    !verbose pop
534 2961 mdecorde
  !macroend
535 2961 mdecorde
  !define ForEach `!insertmacro _ForEach`
536 2961 mdecorde
537 2961 mdecorde
  !macro _For _v _f _t
538 2961 mdecorde
    !verbose push
539 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
540 2961 mdecorde
    ${ForEach} `${_v}` `${_f}` `${_t}` + 1                ; Pass on to ForEach
541 2961 mdecorde
    !verbose pop
542 2961 mdecorde
  !macroend
543 2961 mdecorde
  !define For `!insertmacro _For`
544 2961 mdecorde
545 2961 mdecorde
  !define ExitFor `!insertmacro _Goto ExitFor For`
546 2961 mdecorde
547 2961 mdecorde
  !define Next      `!insertmacro _Loop For Next "" "" "" ""`
548 2961 mdecorde
549 2961 mdecorde
  !define While     `!insertmacro _Do While true`
550 2961 mdecorde
551 2961 mdecorde
  !define ExitWhile `!insertmacro _Goto ExitWhile While`
552 2961 mdecorde
553 2961 mdecorde
  !define EndWhile  `!insertmacro _Loop While EndWhile "" "" "" ""`
554 2961 mdecorde
555 2961 mdecorde
  !macro _Do _n _c _a _o _b
556 2961 mdecorde
    !verbose push
557 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
558 2961 mdecorde
    !insertmacro _PushLogic
559 2961 mdecorde
    !define ${_Logic}${_n} _LogicLib_Label_${LOGICLIB_COUNTER}                   ; Get a label for the start of the loop
560 2961 mdecorde
    !insertmacro _IncreaseCounter
561 2961 mdecorde
    ${${_Logic}${_n}}:
562 2961 mdecorde
    !insertmacro _PushScope Exit${_n} _LogicLib_Label_${LOGICLIB_COUNTER}        ; Get a label for the end of the loop
563 2961 mdecorde
    !insertmacro _IncreaseCounter
564 2961 mdecorde
    !insertmacro _PushScope Break ${_Exit${_n}}           ; Break goes to the end of the loop
565 2961 mdecorde
    !ifdef _DoLoopExpression
566 2961 mdecorde
      ${_DoLoopExpression}                                ; Special extra parameter for inserting code
567 2961 mdecorde
      !undef _DoLoopExpression                            ; between the Continue label and the loop condition
568 2961 mdecorde
    !endif
569 2961 mdecorde
    !define _c=${_c}
570 2961 mdecorde
    !ifdef _c=                                            ; No starting condition
571 2961 mdecorde
      !insertmacro _PushScope Continue _LogicLib_Label_${LOGICLIB_COUNTER}       ; Get a label for Continue at the end of the loop
572 2961 mdecorde
      !insertmacro _IncreaseCounter
573 2961 mdecorde
    !else
574 2961 mdecorde
      !insertmacro _PushScope Continue ${${_Logic}${_n}}  ; Continue goes to the start of the loop
575 2961 mdecorde
      !ifdef _c=true                                      ; If is true
576 2961 mdecorde
        !insertmacro _${_o} `${_a}` `${_b}` "" ${_Exit${_n}}
577 2961 mdecorde
      !else                                               ; If condition is false
578 2961 mdecorde
        !insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} ""
579 2961 mdecorde
      !endif
580 2961 mdecorde
    !endif
581 2961 mdecorde
    !undef _c=${_c}
582 2961 mdecorde
    !define ${_Logic}Condition ${_c}                      ; Remember the condition used
583 2961 mdecorde
    !verbose pop
584 2961 mdecorde
  !macroend
585 2961 mdecorde
  !define Do      `!insertmacro _Do Do "" "" "" ""`
586 2961 mdecorde
  !define DoWhile `!insertmacro _Do Do true`
587 2961 mdecorde
  !define DoUntil `!insertmacro _Do Do false`
588 2961 mdecorde
589 2961 mdecorde
  !macro _Goto _n _s
590 2961 mdecorde
    !verbose push
591 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
592 2961 mdecorde
    !ifndef _${_n}
593 2961 mdecorde
      !error "Cannot use ${_n} without a preceding ${_s}"
594 2961 mdecorde
    !endif
595 2961 mdecorde
    Goto ${_${_n}}
596 2961 mdecorde
    !verbose pop
597 2961 mdecorde
  !macroend
598 2961 mdecorde
  !define ExitDo   `!insertmacro _Goto ExitDo Do`
599 2961 mdecorde
600 2961 mdecorde
  !macro _Loop _n _e _c _a _o _b
601 2961 mdecorde
    !verbose push
602 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
603 2961 mdecorde
    !ifndef _Logic | ${_Logic}${_n}
604 2961 mdecorde
      !error "Cannot use ${_e} without a preceding ${_n}"
605 2961 mdecorde
    !endif
606 2961 mdecorde
    !define _c=${${_Logic}Condition}
607 2961 mdecorde
    !ifdef _c=                                            ; If Do had no condition place the Continue label
608 2961 mdecorde
      ${_Continue}:
609 2961 mdecorde
    !endif
610 2961 mdecorde
    !undef _c=${${_Logic}Condition}
611 2961 mdecorde
    !define _c=${_c}
612 2961 mdecorde
    !ifdef _c=                                            ; No ending condition
613 2961 mdecorde
      Goto ${${_Logic}${_n}}
614 2961 mdecorde
    !else ifdef _c=true                                   ; If condition is true
615 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}${_n}} ${_Exit${_n}}
616 2961 mdecorde
    !else                                                 ; If condition is false
617 2961 mdecorde
      !insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} ${${_Logic}${_n}}
618 2961 mdecorde
    !endif
619 2961 mdecorde
    !undef _c=${_c}
620 2961 mdecorde
    Goto ${_Continue}                                     ; Just to ensure it is referenced at least once
621 2961 mdecorde
	Goto ${_Exit${_n}}                                    ; Just to ensure it is referenced at least once
622 2961 mdecorde
    ${_Exit${_n}}:                                        ; Place the loop exit point
623 2961 mdecorde
    !undef ${_Logic}Condition
624 2961 mdecorde
    !insertmacro _PopScope Continue
625 2961 mdecorde
    !insertmacro _PopScope Break
626 2961 mdecorde
    !insertmacro _PopScope Exit${_n}
627 2961 mdecorde
    !undef ${_Logic}${_n}
628 2961 mdecorde
    !insertmacro _PopLogic
629 2961 mdecorde
    !verbose pop
630 2961 mdecorde
  !macroend
631 2961 mdecorde
  !define Loop      `!insertmacro _Loop Do Loop "" "" "" ""`
632 2961 mdecorde
  !define LoopWhile `!insertmacro _Loop Do LoopWhile true`
633 2961 mdecorde
  !define LoopUntil `!insertmacro _Loop Do LoopUntil false`
634 2961 mdecorde
635 2961 mdecorde
  !define Continue `!insertmacro _Goto Continue "For or Do or While"`
636 2961 mdecorde
  !define Break    `!insertmacro _Goto Break "For or Do or While"`
637 2961 mdecorde
638 2961 mdecorde
  !macro _Select _a
639 2961 mdecorde
    !verbose push
640 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
641 2961 mdecorde
    !insertmacro _PushLogic
642 2961 mdecorde
    !define ${_Logic}Select `${_a}`                       ; Remember the left hand side of the comparison
643 2961 mdecorde
    !verbose pop
644 2961 mdecorde
  !macroend
645 2961 mdecorde
  !define Select `!insertmacro _Select`
646 2961 mdecorde
647 2961 mdecorde
  !macro _Select_CaseElse
648 2961 mdecorde
    !verbose push
649 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
650 2961 mdecorde
    !ifndef _Logic | ${_Logic}Select
651 2961 mdecorde
      !error "Cannot use Case without a preceding Select"
652 2961 mdecorde
    !endif
653 2961 mdecorde
    !ifdef ${_Logic}EndSelect                             ; This is set only after the first case
654 2961 mdecorde
      !ifndef ${_Logic}Else
655 2961 mdecorde
        !error "Cannot use Case following a CaseElse"
656 2961 mdecorde
      !endif
657 2961 mdecorde
      Goto ${${_Logic}EndSelect}                          ; Go to the EndSelect
658 2961 mdecorde
      ${${_Logic}Else}:                                   ; Place the Else label
659 2961 mdecorde
      !undef ${_Logic}Else                                ; and remove it
660 2961 mdecorde
    !else
661 2961 mdecorde
      !define ${_Logic}EndSelect _LogicLib_Label_${LOGICLIB_COUNTER}             ; Get a label for the EndSelect
662 2961 mdecorde
      !insertmacro _IncreaseCounter
663 2961 mdecorde
    !endif
664 2961 mdecorde
    !verbose pop
665 2961 mdecorde
  !macroend
666 2961 mdecorde
  !define CaseElse `!insertmacro _CaseElse`
667 2961 mdecorde
  !define Case_Else `!insertmacro _CaseElse`              ; Compatibility with 2.2 and earlier
668 2961 mdecorde
  !define Default `!insertmacro _CaseElse`                ; For the C-minded
669 2961 mdecorde
670 2961 mdecorde
  !macro _Select_Case _a
671 2961 mdecorde
    !verbose push
672 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
673 2961 mdecorde
    ${CaseElse}                                           ; Perform the CaseElse
674 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new Case
675 2961 mdecorde
    !insertmacro _IncreaseCounter
676 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else}
677 2961 mdecorde
    !verbose pop
678 2961 mdecorde
  !macroend
679 2961 mdecorde
  !define Case `!insertmacro _Case`
680 2961 mdecorde
681 2961 mdecorde
  !macro _Case2 _a _b
682 2961 mdecorde
    !verbose push
683 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
684 2961 mdecorde
    ${CaseElse}                                           ; Perform the CaseElse
685 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new Case
686 2961 mdecorde
    !insertmacro _IncreaseCounter
687 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_a}` +2 ""
688 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else}
689 2961 mdecorde
    !verbose pop
690 2961 mdecorde
  !macroend
691 2961 mdecorde
  !define Case2 `!insertmacro _Case2`
692 2961 mdecorde
693 2961 mdecorde
  !macro _Case3 _a _b _c
694 2961 mdecorde
    !verbose push
695 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
696 2961 mdecorde
    ${CaseElse}                                           ; Perform the CaseElse
697 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new Case
698 2961 mdecorde
    !insertmacro _IncreaseCounter
699 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_a}` +3 ""
700 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_b}` +2 ""
701 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else}
702 2961 mdecorde
    !verbose pop
703 2961 mdecorde
  !macroend
704 2961 mdecorde
  !define Case3 `!insertmacro _Case3`
705 2961 mdecorde
706 2961 mdecorde
  !macro _Case4 _a _b _c _d
707 2961 mdecorde
    !verbose push
708 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
709 2961 mdecorde
    ${CaseElse}                                           ; Perform the CaseElse
710 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new Case
711 2961 mdecorde
    !insertmacro _IncreaseCounter
712 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_a}` +4 ""
713 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_b}` +3 ""
714 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_c}` +2 ""
715 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_d}` "" ${${_Logic}Else}
716 2961 mdecorde
    !verbose pop
717 2961 mdecorde
  !macroend
718 2961 mdecorde
  !define Case4 `!insertmacro _Case4`
719 2961 mdecorde
720 2961 mdecorde
  !macro _Case5 _a _b _c _d _e
721 2961 mdecorde
    !verbose push
722 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
723 2961 mdecorde
    ${CaseElse}                                           ; Perform the CaseElse
724 2961 mdecorde
    !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER}                    ; Get a label for the next Else and perform the new Case
725 2961 mdecorde
    !insertmacro _IncreaseCounter
726 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_a}` +5 ""
727 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_b}` +4 ""
728 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_c}` +3 ""
729 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_d}` +2 ""
730 2961 mdecorde
    !insertmacro _== `${${_Logic}Select}` `${_e}` "" ${${_Logic}Else}
731 2961 mdecorde
    !verbose pop
732 2961 mdecorde
  !macroend
733 2961 mdecorde
  !define Case5 `!insertmacro _Case5`
734 2961 mdecorde
735 2961 mdecorde
  !macro _EndSelect
736 2961 mdecorde
    !verbose push
737 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
738 2961 mdecorde
    !ifndef _Logic | ${_Logic}Select
739 2961 mdecorde
      !error "Cannot use EndSelect without a preceding Select"
740 2961 mdecorde
    !endif
741 2961 mdecorde
    !ifdef ${_Logic}Else
742 2961 mdecorde
      ${${_Logic}Else}:                                   ; Place the Else label
743 2961 mdecorde
      !undef ${_Logic}Else                                ; and remove it
744 2961 mdecorde
    !endif
745 2961 mdecorde
    !ifdef ${_Logic}EndSelect                             ; This won't be set if there weren't any cases
746 2961 mdecorde
      ${${_Logic}EndSelect}:                              ; Place the EndSelect
747 2961 mdecorde
      !undef ${_Logic}EndSelect                           ; and remove it
748 2961 mdecorde
    !endif
749 2961 mdecorde
    !undef ${_Logic}Select
750 2961 mdecorde
    !insertmacro _PopLogic
751 2961 mdecorde
    !verbose pop
752 2961 mdecorde
  !macroend
753 2961 mdecorde
  !define EndSelect `!insertmacro _EndSelect`
754 2961 mdecorde
755 2961 mdecorde
  !macro _Switch _a
756 2961 mdecorde
    !verbose push
757 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
758 2961 mdecorde
    !insertmacro _PushLogic
759 2961 mdecorde
    !insertmacro _PushScope Switch ${_Logic}              ; Keep a separate stack for switch data
760 2961 mdecorde
    !insertmacro _PushScope Break _LogicLib_Label_${LOGICLIB_COUNTER}            ; Get a lable for beyond the end of the switch
761 2961 mdecorde
    !insertmacro _IncreaseCounter
762 2961 mdecorde
    !define ${_Switch}Var `${_a}`                         ; Remember the left hand side of the comparison
763 2961 mdecorde
    !tempfile ${_Switch}Tmp                               ; Create a temporary file
764 2961 mdecorde
    !define ${_Logic}Switch _LogicLib_Label_${LOGICLIB_COUNTER}                  ; Get a label for the end of the switch
765 2961 mdecorde
    !insertmacro _IncreaseCounter
766 2961 mdecorde
    Goto ${${_Logic}Switch}                               ; and go there
767 2961 mdecorde
    !verbose pop
768 2961 mdecorde
  !macroend
769 2961 mdecorde
  !define Switch `!insertmacro _Switch`
770 2961 mdecorde
771 2961 mdecorde
  !macro _Case _a
772 2961 mdecorde
    !verbose push
773 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
774 2961 mdecorde
    !ifdef _Logic & ${_Logic}Select                       ; Check for an active Select
775 2961 mdecorde
      !insertmacro _Select_Case `${_a}`
776 2961 mdecorde
    !else ifndef _Switch                                  ; If not then check for an active Switch
777 2961 mdecorde
      !error "Cannot use Case without a preceding Select or Switch"
778 2961 mdecorde
    !else
779 2961 mdecorde
      !define _label _LogicLib_Label_${LOGICLIB_COUNTER}                         ; Get a label for this case,
780 2961 mdecorde
      !insertmacro _IncreaseCounter
781 2961 mdecorde
      ${_label}:                                          ; place it and add it's check to the temp file
782 2961 mdecorde
      !appendfile "${${_Switch}Tmp}" `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n`
783 2961 mdecorde
      !undef _label
784 2961 mdecorde
    !endif
785 2961 mdecorde
    !verbose pop
786 2961 mdecorde
  !macroend
787 2961 mdecorde
788 2961 mdecorde
  !macro _CaseElse
789 2961 mdecorde
    !verbose push
790 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
791 2961 mdecorde
    !ifdef _Logic & ${_Logic}Select                       ; Check for an active Select
792 2961 mdecorde
      !insertmacro _Select_CaseElse
793 2961 mdecorde
    !else ifndef _Switch                                  ; If not then check for an active Switch
794 2961 mdecorde
      !error "Cannot use Case without a preceding Select or Switch"
795 2961 mdecorde
    !else ifdef ${_Switch}Else                            ; Already had a default case?
796 2961 mdecorde
      !error "Cannot use CaseElse following a CaseElse"
797 2961 mdecorde
    !else
798 2961 mdecorde
      !define ${_Switch}Else _LogicLib_Label_${LOGICLIB_COUNTER}                 ; Get a label for the default case,
799 2961 mdecorde
      !insertmacro _IncreaseCounter
800 2961 mdecorde
      ${${_Switch}Else}:                                  ; and place it
801 2961 mdecorde
    !endif
802 2961 mdecorde
    !verbose pop
803 2961 mdecorde
  !macroend
804 2961 mdecorde
805 2961 mdecorde
  !macro _EndSwitch
806 2961 mdecorde
    !verbose push
807 2961 mdecorde
    !verbose ${LOGICLIB_VERBOSITY}
808 2961 mdecorde
    !ifndef _Logic | ${_Logic}Switch
809 2961 mdecorde
      !error "Cannot use EndSwitch without a preceding Switch"
810 2961 mdecorde
    !endif
811 2961 mdecorde
    Goto ${_Break}                                        ; Skip the jump table
812 2961 mdecorde
    ${${_Logic}Switch}:                                   ; Place the end of the switch
813 2961 mdecorde
    !undef ${_Logic}Switch
814 2961 mdecorde
    !include "${${_Switch}Tmp}"                           ; Include the jump table
815 2961 mdecorde
    !delfile "${${_Switch}Tmp}"                           ; and clear it up
816 2961 mdecorde
    !ifdef ${_Switch}Else                                 ; Was there a default case?
817 2961 mdecorde
      Goto ${${_Switch}Else}                              ; then go there if all else fails
818 2961 mdecorde
      !undef ${_Switch}Else
819 2961 mdecorde
    !endif
820 2961 mdecorde
    !undef ${_Switch}Tmp
821 2961 mdecorde
    !undef ${_Switch}Var
822 2961 mdecorde
    ${_Break}:                                            ; Place the break label
823 2961 mdecorde
    !insertmacro _PopScope Break
824 2961 mdecorde
    !insertmacro _PopScope Switch
825 2961 mdecorde
    !insertmacro _PopLogic
826 2961 mdecorde
    !verbose pop
827 2961 mdecorde
  !macroend
828 2961 mdecorde
  !define EndSwitch `!insertmacro _EndSwitch`
829 2961 mdecorde
830 2961 mdecorde
!endif ; LOGICLIB
831 2961 mdecorde
!verbose 3
832 2961 mdecorde
!define LOGICLIB_VERBOSITY ${_LOGICLIB_VERBOSITY}
833 2961 mdecorde
!undef _LOGICLIB_VERBOSITY
834 2961 mdecorde
!verbose pop