2003-12-14 00:22:02 +00:00
|
|
|
; NSIS LOGIC LIBRARY - logiclib.nsh
|
2003-12-14 00:29:15 +00:00
|
|
|
; Version 2.3 - 12/06/2003
|
|
|
|
; By dselkirk@hotmail.com
|
|
|
|
; and eccles@users.sf.net
|
|
|
|
;
|
|
|
|
; Questions/Comments -
|
|
|
|
; See http://forums.winamp.com/showthread.php?s=&postid=1116241
|
2003-12-14 00:18:16 +00:00
|
|
|
;
|
|
|
|
; Description:
|
2003-12-14 00:23:56 +00:00
|
|
|
; Provides the use of various logic statements within NSIS.
|
2003-12-14 00:22:02 +00:00
|
|
|
;
|
|
|
|
; Notes:
|
2003-12-14 00:23:56 +00:00
|
|
|
; Version 2 is a complete rewrite of the original. Here are some of the major differences:
|
|
|
|
; - Structure redesign based upon version by eccles.
|
|
|
|
; - No statement limitations.
|
|
|
|
; - Following statements are now available.
|
2003-12-14 00:29:15 +00:00
|
|
|
; if/unless..elseif/unless..else..endif/unless
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Conditionally executes a group of statements, depending on the value of an expression.
|
|
|
|
; ifthen..|..|
|
|
|
|
; - Conditionally executes an inline statement, depending on the value of an expression.
|
|
|
|
; ifcmd..||..|
|
|
|
|
; - Conditionally executes an inline statement, depending on a True value of the provided NSIS function.
|
2003-12-14 00:29:15 +00:00
|
|
|
; select..case..case2..case3..case4..case5..caseelse..endselect
|
2003-12-14 00:26:54 +00:00
|
|
|
; - Executes one of several groups of statements, depending on the value of an expression.
|
2003-12-14 00:29:15 +00:00
|
|
|
; for..exitfor..continue..break..next
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Repeats a group of statements a specified number of times.
|
2003-12-14 00:25:22 +00:00
|
|
|
; foreach..exitfor..continue..break..next
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Repeats a group of statements a specified number of times stepping in order specified.
|
2003-12-14 00:25:22 +00:00
|
|
|
; do..exitdo..continue..break..loop
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Repeats a block of statements until stopped.
|
2003-12-14 00:29:15 +00:00
|
|
|
; dowhile..exitdo..continue..break..loop
|
|
|
|
; - Repeats a block of statements while a condition is True.
|
2003-12-14 00:25:22 +00:00
|
|
|
; dountil..exitdo..continue..break..loop
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Repeats a block of statements until a condition is True.
|
2003-12-14 00:29:15 +00:00
|
|
|
; do..exitdo..continue..break..loopwhile
|
|
|
|
; - Repeats a block of statements while a condition is True.
|
2003-12-14 00:25:22 +00:00
|
|
|
; do..exitdo..continue..break..loopuntil
|
2003-12-14 00:23:56 +00:00
|
|
|
; - Repeats a block of statements until a condition is True.
|
2003-12-14 00:25:22 +00:00
|
|
|
; while..exitwhile..continue..break..endwhile
|
2003-12-14 00:29:15 +00:00
|
|
|
; - Same as dowhile..loop.
|
2003-12-14 00:18:16 +00:00
|
|
|
;
|
|
|
|
; Usage:
|
2003-12-14 00:23:56 +00:00
|
|
|
; See example.nsi
|
2003-12-14 00:18:16 +00:00
|
|
|
;
|
|
|
|
; History:
|
2003-12-14 00:29:15 +00:00
|
|
|
; 1.0 - 09/19/2003 - Initial release.
|
|
|
|
; 1.1 - 09/20/2003 - Added simplified macros and removed NAME requirement.
|
|
|
|
; 1.2 - 09/21/2003 - Changed library name to LogicLib.
|
|
|
|
; - Allow for 5 statements deep without use of name variable.
|
|
|
|
; - Added If..ElseIf..Else..Endif statements.
|
|
|
|
; 1.3 - 09/22/2003 - Fixed maximum allow statements.
|
|
|
|
; - Now allows 10 statement depth.
|
|
|
|
; - Condensed code.
|
|
|
|
; 2.0 - 10/03/2003 - Inital release 2, see notes.
|
|
|
|
; 2.1 - 10/05/2003 - Added continue and break labels to repeat type statements.
|
|
|
|
; 2.2 - 10/07/2003 - Updates by eccles
|
|
|
|
; - Simplified IfThen by utilising If and EndIf.
|
|
|
|
; - Simplified For by utilising ForEach.
|
|
|
|
; - Fixed ForEach missing the final iteration.
|
|
|
|
; - Fixed a couple of Break/Continue bugs.
|
|
|
|
; 2.3 - 12/10/2003 - Much reworking and refactoring of things to help reduce
|
|
|
|
; duplication, etc. E.g. all loop varieties now go through
|
|
|
|
; a common set of macros.
|
|
|
|
; - Added built-in support for the rest of NSIS's built-in
|
|
|
|
; conditional tests (Abort, Errors, FileExists, RebootFlag,
|
|
|
|
; Silent).
|
|
|
|
; - Added ability to use any NSIS conditional command in a
|
|
|
|
; normal If type statement (no longer restricted to the
|
|
|
|
; specialised IfCmd statement).
|
|
|
|
; - Optimised the code produced by If (fewer Goto's).
|
|
|
|
; - Added statement similar to If that works in reverse:
|
|
|
|
; "Unless" executes the code in the contained block if the
|
|
|
|
; condition is false. If, Unless, ElseIf, ElseUnless, EndIf
|
|
|
|
; and ElseUnless can be used freely in any combination.
|
|
|
|
; - Fixed bug where using Continue in a Do..LoopUntil loop
|
|
|
|
; went to the top of the loop and not the loop condition.
|
|
|
|
; - Added DoWhile..Loop and Do..LoopWhile loop varieties (the
|
|
|
|
; existing While..EndWhile loop is still available and is
|
|
|
|
; identical to DoWhile..Loop).
|
|
|
|
; - Optimised the code prodiced by Select (fewer Goto's).
|
|
|
|
; - Renamed Case_Else to CaseElse (nothing else has an
|
|
|
|
; underscore so why should that one). The old name is still
|
|
|
|
; available too though (if you must).
|
|
|
|
; - CaseElse can also be called Default (for the C-minded).
|
|
|
|
|
|
|
|
!verbose push
|
2003-12-14 00:23:56 +00:00
|
|
|
!verbose 3
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifndef LOGICLIB_VERBOSITY
|
|
|
|
!define LOGICLIB_VERBOSITY 3
|
|
|
|
!endif
|
|
|
|
!define _LOGICLIB_VERBOSITY ${LOGICLIB_VERBOSITY}
|
|
|
|
!undef LOGICLIB_VERBOSITY
|
|
|
|
!verbose ${_LOGICLIB_VERBOSITY}
|
2003-12-14 00:22:02 +00:00
|
|
|
|
|
|
|
!ifndef LOGICLIB
|
|
|
|
!define LOGICLIB
|
2003-12-14 00:23:56 +00:00
|
|
|
!define | "'"
|
|
|
|
!define || "' '"
|
2003-12-14 00:22:02 +00:00
|
|
|
|
2003-12-14 00:23:56 +00:00
|
|
|
!macro _PushLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _PushScope Logic _${__LINE__}
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _PopLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _PopScope Logic
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _PushScope Type label
|
|
|
|
!ifdef _${Type} ; If we already have a statement
|
2003-12-14 00:23:56 +00:00
|
|
|
!define _Cur${Type} ${_${Type}}
|
|
|
|
!undef _${Type}
|
2003-12-14 00:25:22 +00:00
|
|
|
!define _${Type} ${label}
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ${_${Type}}Prev${Type} ${_Cur${Type}} ; Save the current logic
|
2003-12-14 00:23:56 +00:00
|
|
|
!undef _Cur${Type}
|
2003-12-14 00:22:02 +00:00
|
|
|
!else
|
2003-12-14 00:29:15 +00:00
|
|
|
!define _${Type} ${label} ; Initialise for first statement
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
|
|
|
!macroend
|
2003-12-14 00:22:02 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _PopScope Type
|
2003-12-14 00:23:56 +00:00
|
|
|
!ifndef _${Type}
|
|
|
|
!error "Cannot use _Pop${Type} without a preceding _Push${Type}"
|
2003-12-14 00:22:02 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifdef ${_${Type}}Prev${Type} ; If a previous statment was active then restore it
|
2003-12-14 00:23:56 +00:00
|
|
|
!define _Cur${Type} ${_${Type}}
|
|
|
|
!undef _${Type}
|
|
|
|
!define _${Type} ${${_Cur${Type}}Prev${Type}}
|
|
|
|
!undef ${_Cur${Type}}Prev${Type}
|
|
|
|
!undef _Cur${Type}
|
2003-12-14 00:22:02 +00:00
|
|
|
!else
|
2003-12-14 00:23:56 +00:00
|
|
|
!undef _${Type}
|
|
|
|
!endif
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
; String tests
|
|
|
|
!macro _== _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
StrCmp `${_a}` `${_b}` `${_t}` `${_f}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _!= _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _== `${_a}` `${_b}` `${_f}` `${_t}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
; Integer tests
|
|
|
|
!macro _= _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
IntCmp `${_a}` `${_b}` `${_t}` `${_f}` `${_f}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _<> _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _= `${_a}` `${_b}` `${_f}` `${_t}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _< _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
IntCmp `${_a}` `${_b}` `${_f}` `${_t}` `${_f}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _>= _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _< `${_a}` `${_b}` `${_f}` `${_t}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _> _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
IntCmp `${_a}` `${_b}` `${_f}` `${_f}` `${_t}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro _<= _a _b _t _f
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _> `${_a}` `${_b}` `${_f}` `${_t}`
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
; Flag tests
|
|
|
|
!macro _Abort _a _b _t _f
|
|
|
|
IfAbort `${_t}` `${_f}`
|
|
|
|
!macroend
|
|
|
|
!define Abort `"" Abort ""`
|
|
|
|
|
|
|
|
!macro _Errors _a _b _t _f
|
|
|
|
IfErrors `${_t}` `${_f}`
|
|
|
|
!macroend
|
|
|
|
!define Errors `"" Errors ""`
|
|
|
|
|
|
|
|
!macro _FileExists _a _b _t _f
|
|
|
|
IfFileExists `${_b}` `${_t}` `${_f}`
|
|
|
|
!macroend
|
|
|
|
!define FileExists `"" FileExists`
|
|
|
|
|
|
|
|
!macro _RebootFlag _a _b _t _f
|
|
|
|
IfRebootFlag `${_t}` `${_f}`
|
|
|
|
!macroend
|
|
|
|
!define RebootFlag `"" RebootFlag ""`
|
|
|
|
|
|
|
|
!macro _Silent _a _b _t _f
|
|
|
|
IfSilent `${_t}` `${_f}`
|
|
|
|
!macroend
|
|
|
|
!define Silent `"" Silent ""`
|
|
|
|
|
|
|
|
; "Any instruction" test
|
|
|
|
!macro _Cmd _a _b _t _f
|
|
|
|
!define _t=${_t}
|
|
|
|
!ifdef _t=
|
|
|
|
!define __t +2 ; If no jump then make sure we skip the Goto below
|
|
|
|
!else
|
|
|
|
!define __t ${_t}
|
|
|
|
!endif
|
|
|
|
!undef _t=${_t}
|
|
|
|
${_b} ${__t}
|
|
|
|
!undef __t
|
|
|
|
Goto ${_f}
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define Cmd `"" Cmd`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!define IfCmd `!insertmacro _IfThen "" Cmd ${|}`
|
|
|
|
|
|
|
|
!macro _If _c _a _o _b
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PushLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ${_Logic}If
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the Else
|
|
|
|
!define _c=${_c}
|
|
|
|
!ifdef _c=true ; If is true
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
|
|
|
|
!else ; If condition is false
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
|
|
|
|
!endif
|
|
|
|
!undef _c=${_c}
|
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define If `!insertmacro _If true`
|
|
|
|
!define Unless `!insertmacro _If false`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _Else
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _Logic | ${_Logic}If
|
|
|
|
!error "Cannot use Else without a preceding If or Unless"
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifndef ${_Logic}Else
|
|
|
|
!error "Cannot use Else following an Else"
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifndef ${_Logic}EndIf ; First Else for this If?
|
|
|
|
!define ${_Logic}EndIf _${__LINE__} ; Get a label for the EndIf
|
|
|
|
!endif
|
|
|
|
Goto ${${_Logic}EndIf} ; Go to the EndIf
|
|
|
|
${${_Logic}Else}: ; Place the Else label
|
|
|
|
!undef ${_Logic}Else ; and remove it
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Else `!insertmacro _Else`
|
|
|
|
|
|
|
|
!macro _ElseIf _c _a _o _b
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${Else} ; Perform the Else
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new If
|
|
|
|
!define _c=${_c}
|
|
|
|
!ifdef _c=true ; If is true
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
|
|
|
|
!else ; If condition is false
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} ""
|
|
|
|
!endif
|
|
|
|
!undef _c=${_c}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define ElseIf `!insertmacro _ElseIf true`
|
|
|
|
!define ElseUnless `!insertmacro _ElseIf false`
|
|
|
|
|
|
|
|
!macro _EndIf _n
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _Logic | ${_Logic}If
|
|
|
|
!error "Cannot use End${_n} without a preceding If or Unless"
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
|
|
|
!ifdef ${_Logic}Else
|
2003-12-14 00:29:15 +00:00
|
|
|
${${_Logic}Else}: ; Place the Else label
|
|
|
|
!undef ${_Logic}Else ; and remove it
|
|
|
|
!endif
|
|
|
|
!ifdef ${_Logic}EndIf
|
|
|
|
${${_Logic}EndIf}: ; Place the EndIf
|
|
|
|
!undef ${_Logic}EndIf ; and remove it
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!undef ${_Logic}If
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PopLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define EndIf `!insertmacro _EndIf If`
|
|
|
|
!define EndUnless `!insertmacro _EndIf Unless`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _IfThen _a _o _b _t
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${If} `${_a}` `${_o}` `${_b}`
|
2003-12-14 00:26:54 +00:00
|
|
|
${_t}
|
|
|
|
${EndIf}
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define IfThen `!insertmacro _IfThen`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _ForEach _v _f _t _o _s
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
StrCpy "${_v}" "${_f}" ; Assign the initial value
|
|
|
|
Goto +2 ; Skip the loop expression for the first iteration
|
|
|
|
!define _DoLoopExpression `IntOp "${_v}" "${_v}" "${_o}" "${_s}"` ; Define the loop expression
|
2003-12-14 00:26:54 +00:00
|
|
|
!define _o=${_o}
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifdef _o=+ ; Check the loop expression operator
|
|
|
|
!define __o > ; to determine the correct loop condition
|
2003-12-14 00:26:54 +00:00
|
|
|
!else ifdef _o=-
|
2003-12-14 00:29:15 +00:00
|
|
|
!define __o <
|
2003-12-14 00:26:54 +00:00
|
|
|
!else
|
2003-12-14 00:29:15 +00:00
|
|
|
!error "Unsupported ForEach step operator (must be + or -)"
|
2003-12-14 00:26:54 +00:00
|
|
|
!endif
|
|
|
|
!undef _o=${_o}
|
2003-12-14 00:29:15 +00:00
|
|
|
!insertmacro _Do For false `${_v}` `${__o}` `${_t}` ; Let Do do the rest
|
|
|
|
!undef __o
|
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ForEach `!insertmacro _ForEach`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _For _v _f _t
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${ForEach} `${_v}` `${_f}` `${_t}` + 1 ; Pass on to ForEach
|
|
|
|
!verbose pop
|
2003-12-14 00:26:54 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define For `!insertmacro _For`
|
2003-12-14 00:26:54 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ExitFor `!insertmacro _Goto ExitFor For`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!define Next `!insertmacro _Loop For Next "" "" "" ""`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!define While `!insertmacro _Do While true`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ExitWhile `!insertmacro _Goto ExitWhile While`
|
|
|
|
|
|
|
|
!define EndWhile `!insertmacro _Loop While EndWhile "" "" "" ""`
|
|
|
|
|
|
|
|
!macro _Do _n _c _a _o _b
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PushLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ${_Logic}${_n} _${__LINE__} ; Get a label for the start of the loop
|
|
|
|
${${_Logic}${_n}}:
|
|
|
|
!insertmacro _PushScope Exit${_n} _${__LINE__} ; Get a label for the end of the loop
|
|
|
|
!insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop
|
|
|
|
!ifdef _DoLoopExpression
|
|
|
|
${_DoLoopExpression} ; Special extra parameter for inserting code
|
|
|
|
!undef _DoLoopExpression ; between the Continue label and the loop condition
|
2003-12-14 00:22:02 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!define _c=${_c}
|
|
|
|
!ifdef _c= ; No starting condition
|
|
|
|
!insertmacro _PushScope Continue _${__LINE__} ; Get a label for Continue at the end of the loop
|
|
|
|
!else
|
|
|
|
!insertmacro _PushScope Continue ${${_Logic}${_n}} ; Continue goes to the start of the loop
|
|
|
|
!ifdef _c=true ; If is true
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` "" ${_Exit${_n}}
|
|
|
|
!else ; If condition is false
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} ""
|
|
|
|
!endif
|
|
|
|
!endif
|
|
|
|
!undef _c=${_c}
|
|
|
|
!define ${_Logic}Condition ${_c} ; Remember the condition used
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Do `!insertmacro _Do Do "" "" "" ""`
|
|
|
|
!define DoWhile `!insertmacro _Do Do true`
|
|
|
|
!define DoUntil `!insertmacro _Do Do false`
|
|
|
|
|
|
|
|
!macro _Goto _n _s
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _${_n}
|
|
|
|
!error "Cannot use ${_n} without a preceding ${_s}"
|
|
|
|
!endif
|
|
|
|
Goto ${_${_n}}
|
|
|
|
!verbose pop
|
2003-12-14 00:22:02 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ExitDo `!insertmacro _Goto ExitDo Do`
|
2003-12-14 00:22:02 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _Loop _n _e _c _a _o _b
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _Logic | ${_Logic}${_n}
|
|
|
|
!error "Cannot use ${_e} without a preceding ${_n}"
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!define _c=${${_Logic}Condition}
|
|
|
|
!ifdef _c= ; If Do had no condition place the Continue label
|
|
|
|
${_Continue}:
|
|
|
|
!endif
|
|
|
|
!undef _c=${${_Logic}Condition}
|
|
|
|
!define _c=${_c}
|
|
|
|
!ifdef _c= ; No ending condition
|
|
|
|
Goto ${${_Logic}${_n}}
|
|
|
|
!else ifdef _c=true ; If condition is true
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}${_n}} ${_Exit${_n}}
|
|
|
|
!else ; If condition is false
|
|
|
|
!insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} ${${_Logic}${_n}}
|
|
|
|
!endif
|
|
|
|
!undef _c=${_c}
|
|
|
|
Goto ${_Continue} ; Just to ensure it is referenced at least once
|
|
|
|
${_Exit${_n}}: ; Place the loop exit point
|
|
|
|
!undef ${_Logic}Condition
|
|
|
|
!insertmacro _PopScope Continue
|
|
|
|
!insertmacro _PopScope Break
|
|
|
|
!insertmacro _PopScope Exit${_n}
|
|
|
|
!undef ${_Logic}${_n}
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PopLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define Loop `!insertmacro _Loop Do Loop "" "" "" ""`
|
|
|
|
!define LoopWhile `!insertmacro _Loop Do LoopWhile true`
|
|
|
|
!define LoopUntil `!insertmacro _Loop Do LoopUntil false`
|
|
|
|
|
|
|
|
!define Continue `!insertmacro _Goto Continue "For or Do or While"`
|
|
|
|
!define Break `!insertmacro _Goto Break "For or Do or While"`
|
2003-12-14 00:23:56 +00:00
|
|
|
|
2003-12-14 00:29:15 +00:00
|
|
|
!macro _Select _a
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PushLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!define ${_Logic}Select `${_a}` ; Remember the left hand side of the comparison
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Select `!insertmacro _Select`
|
|
|
|
|
|
|
|
!macro _CaseElse
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _Logic | ${_Logic}Select
|
|
|
|
!error "Cannot use Case without a preceding Select"
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifdef ${_Logic}EndSelect ; This is set only after the first case
|
|
|
|
!ifndef ${_Logic}Else
|
|
|
|
!error "Cannot use Case following a CaseElse"
|
|
|
|
!endif
|
|
|
|
Goto ${${_Logic}EndSelect} ; Go to the EndSelect
|
|
|
|
${${_Logic}Else}: ; Place the Else label
|
|
|
|
!undef ${_Logic}Else ; and remove it
|
|
|
|
!else
|
|
|
|
!define ${_Logic}EndSelect _${__LINE__} ; Get a label for the EndSelect
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define CaseElse `!insertmacro _CaseElse`
|
|
|
|
!define Case_Else `!insertmacro _CaseElse` ; Compatibility with 2.2 and earlier
|
|
|
|
!define Default `!insertmacro _CaseElse` ; For the C-minded
|
|
|
|
|
|
|
|
!macro _Case _a
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${CaseElse} ; Perform the CaseElse
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new Case
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Case `!insertmacro _Case`
|
|
|
|
|
|
|
|
!macro _Case2 _a _b
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${CaseElse} ; Perform the CaseElse
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new Case
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_a}` +2 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Case2 `!insertmacro _Case2`
|
|
|
|
|
|
|
|
!macro _Case3 _a _b _c
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${CaseElse} ; Perform the CaseElse
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new Case
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_a}` +3 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_b}` +2 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Case3 `!insertmacro _Case3`
|
|
|
|
|
|
|
|
!macro _Case4 _a _b _c _d
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${CaseElse} ; Perform the CaseElse
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new Case
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_a}` +4 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_b}` +3 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_c}` +2 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_d}` "" ${${_Logic}Else}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Case4 `!insertmacro _Case4`
|
|
|
|
|
|
|
|
!macro _Case5 _a _b _c _d _e
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
${CaseElse} ; Perform the CaseElse
|
|
|
|
!define ${_Logic}Else _${__LINE__} ; Get a label for the next Else and perform the new Case
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_a}` +5 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_b}` +4 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_c}` +3 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_d}` +2 ""
|
|
|
|
!insertmacro _== `${${_Logic}Select}` `${_e}` "" ${${_Logic}Else}
|
|
|
|
!verbose pop
|
|
|
|
!macroend
|
|
|
|
!define Case5 `!insertmacro _Case5`
|
|
|
|
|
|
|
|
!macro _EndSelect
|
|
|
|
!verbose push
|
|
|
|
!verbose ${LOGICLIB_VERBOSITY}
|
|
|
|
!ifndef _Logic | ${_Logic}Select
|
2003-12-14 00:23:56 +00:00
|
|
|
!error "Cannot use EndSelect without a preceding Select"
|
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!ifdef ${_Logic}Else
|
|
|
|
${${_Logic}Else}: ; Place the Else label
|
|
|
|
!undef ${_Logic}Else ; and remove it
|
|
|
|
!endif
|
|
|
|
!ifdef ${_Logic}EndSelect ; This won't be set if there weren't any cases
|
|
|
|
${${_Logic}EndSelect}: ; Place the EndSelect
|
|
|
|
!undef ${_Logic}EndSelect ; and remove it
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif
|
2003-12-14 00:29:15 +00:00
|
|
|
!undef ${_Logic}Select
|
2003-12-14 00:23:56 +00:00
|
|
|
!insertmacro _PopLogic
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose pop
|
2003-12-14 00:23:56 +00:00
|
|
|
!macroend
|
2003-12-14 00:29:15 +00:00
|
|
|
!define EndSelect `!insertmacro _EndSelect`
|
2003-12-14 00:22:02 +00:00
|
|
|
|
2003-12-14 00:23:56 +00:00
|
|
|
!endif ; LOGICLIB
|
2003-12-14 00:29:15 +00:00
|
|
|
!verbose 3
|
|
|
|
!define LOGICLIB_VERBOSITY ${_LOGICLIB_VERBOSITY}
|
|
|
|
!undef _LOGICLIB_VERBOSITY
|
|
|
|
!verbose pop
|