Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / LogicLib.nsh @ 3119

Historique | Voir | Annoter | Télécharger (32,55 ko)

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