Statistiques
| Révision :

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

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