Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / Util.nsh @ 3136

Historique | Voir | Annoter | Télécharger (5,09 ko)

1 728 mdecorde
; ---------------------
2 728 mdecorde
;       Util.nsh
3 728 mdecorde
; ---------------------
4 728 mdecorde
;
5 728 mdecorde
; Voodoo macros to make end-user usage easier. This may be documented someday.
6 728 mdecorde
7 2956 mdecorde
!verbose push 3
8 728 mdecorde
!ifndef ___UTIL__NSH___
9 728 mdecorde
!define ___UTIL__NSH___
10 728 mdecorde
11 2956 mdecorde
# CallArtificialFunction, see WinVer.nsh and *Func.nsh for usage examples
12 2956 mdecorde
!macro CallArtificialFunctionHelper TYPE NAME
13 2956 mdecorde
  !verbose pop
14 2956 mdecorde
  Call :.${NAME}${TYPE}
15 2956 mdecorde
  !ifndef ${NAME}${TYPE}_DEFINED
16 2956 mdecorde
    !verbose push 2
17 2956 mdecorde
    Goto ${NAME}${TYPE}_DONE
18 2956 mdecorde
    !define ${NAME}${TYPE}_DEFINED
19 2956 mdecorde
    !verbose pop
20 2956 mdecorde
    .${NAME}${TYPE}:
21 728 mdecorde
      !insertmacro ${NAME}
22 2956 mdecorde
      Return
23 2956 mdecorde
    ${NAME}${TYPE}_DONE:
24 728 mdecorde
  !endif
25 2956 mdecorde
  !verbose push 2
26 728 mdecorde
!macroend
27 728 mdecorde
28 2956 mdecorde
!macro CallArtificialFunction NAME
29 2956 mdecorde
  !verbose push 2
30 2956 mdecorde
  !ifdef __UNINSTALL__
31 2956 mdecorde
    !insertmacro CallArtificialFunctionHelper uninst ${NAME}
32 728 mdecorde
  !else
33 2956 mdecorde
    !insertmacro CallArtificialFunctionHelper inst ${NAME}
34 728 mdecorde
  !endif
35 2956 mdecorde
  !verbose pop
36 728 mdecorde
!macroend
37 2956 mdecorde
!define CallArtificialFunction `!insertmacro CallArtificialFunction`
38 728 mdecorde
39 2956 mdecorde
!macro CallArtificialFunction2 NAME ; Retained for v2.4x..v3.0b0 compatibility
40 2956 mdecorde
  ${CallArtificialFunction} ${NAME}
41 2956 mdecorde
!macroend
42 2956 mdecorde
!define CallArtificialFunction2 `!insertmacro CallArtificialFunction`
43 728 mdecorde
44 2956 mdecorde
45 2956 mdecorde
!define Int32Op '!insertmacro Int32Op '
46 2956 mdecorde
!define Int64Op '!insertmacro Int64Op '
47 2956 mdecorde
!define IntPtrOp '!insertmacro IntPtrOp '
48 2956 mdecorde
!macro Int32Op r a o b
49 2956 mdecorde
IntOp `${r}` `${a}` `${o}` ${b}
50 2956 mdecorde
!macroend
51 2956 mdecorde
!macro Int64Op r a o b
52 2956 mdecorde
!echo "Int64Op ${r}=${a}${o}${b}"
53 2956 mdecorde
!verbose push 2
54 2956 mdecorde
System::Int64Op `${a}` `${o}` ${b}
55 2956 mdecorde
Pop ${r}
56 728 mdecorde
!verbose pop
57 2956 mdecorde
!macroend
58 2956 mdecorde
!macro IntPtrOp r a o b
59 2956 mdecorde
IntPtrOp `${r}` `${a}` `${o}` `${b}`
60 2956 mdecorde
!macroend
61 2956 mdecorde
62 2956 mdecorde
!define Int32Cmp '!insertmacro Int32Cmp '
63 2956 mdecorde
!define Int64Cmp '!insertmacro Int64Cmp '
64 2956 mdecorde
!define IntPtrCmp '!insertmacro IntPtrCmp '
65 2956 mdecorde
!macro Int32Cmp a b jeek jles jgtr
66 2956 mdecorde
IntCmp `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
67 2956 mdecorde
!macroend
68 2956 mdecorde
!macro Int64Cmp a b jeek jles jgtr
69 2956 mdecorde
!if ${NSIS_PTR_SIZE} <= 4
70 2956 mdecorde
!ifmacrondef _LOGICLIB_TEMP
71 2956 mdecorde
!include LogicLib.nsh
72 2956 mdecorde
!endif
73 2956 mdecorde
!echo "Int64Cmp ${a}:${b} =${jeek}, <${jles}, >${jgtr}"
74 2956 mdecorde
!verbose push 2
75 2956 mdecorde
${IfThen} ${a} L= ${b} ${|} Goto ${jeek} ${|}
76 2956 mdecorde
!insertmacro _L< ${a} ${b} `${jles}` `${jgtr}`
77 2956 mdecorde
!verbose pop
78 2956 mdecorde
!else
79 2956 mdecorde
Int64Cmp `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
80 2956 mdecorde
!endif
81 2956 mdecorde
!macroend
82 2956 mdecorde
!macro IntPtrCmp a b jeek jles jgtr
83 2956 mdecorde
IntPtrCmp `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
84 2956 mdecorde
!macroend
85 2956 mdecorde
86 2956 mdecorde
!define Int32CmpU '!insertmacro Int32CmpU '
87 2956 mdecorde
!define Int64CmpU '!insertmacro Int64CmpU '
88 2956 mdecorde
!define IntPtrCmpU '!insertmacro IntPtrCmpU '
89 2956 mdecorde
!macro Int32CmpU a b jeek jles jgtr
90 2956 mdecorde
IntCmpU `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
91 2956 mdecorde
!macroend
92 2956 mdecorde
!macro Int64CmpUHelper
93 2956 mdecorde
; This macro performs "$_LOGICLIB_TEMP = a < b ? -1 : a > b ? 1 : 0" but System::Int64Op does not support unsigned operations so we have to perform multiple steps
94 2956 mdecorde
!ifmacrondef _LOGICLIB_TEMP
95 2956 mdecorde
!include LogicLib.nsh
96 2956 mdecorde
!endif
97 2956 mdecorde
!insertmacro _LOGICLIB_TEMP
98 2956 mdecorde
Exch $2 ; b
99 2956 mdecorde
Exch
100 2956 mdecorde
Exch $1 ; a
101 2956 mdecorde
; if (a == b) return 0;
102 2956 mdecorde
; if (a < 0)
103 2956 mdecorde
; {
104 2956 mdecorde
;   if (b >= 0) return 1
105 2956 mdecorde
; }
106 2956 mdecorde
; else
107 2956 mdecorde
; {
108 2956 mdecorde
;   if (b < 0) return -1
109 2956 mdecorde
; }
110 2956 mdecorde
; return a < b ? -1 : 1
111 2956 mdecorde
System::Int64Op $1 ^ $2 ; Using xor so $_LOGICLIB_TEMP ends up as 0 when they are equal
112 2956 mdecorde
Pop $_LOGICLIB_TEMP
113 2956 mdecorde
StrCmp $_LOGICLIB_TEMP 0 ret ; NOTE: Must use StrCmp, IntCmp fails on "0x8000000000000001 Z> 1"
114 2956 mdecorde
System::Int64Op $1 < 0
115 2956 mdecorde
Pop $_LOGICLIB_TEMP
116 2956 mdecorde
StrCmp $_LOGICLIB_TEMP 0 checkNegOther
117 2956 mdecorde
System::Int64Op $2 < 0 ; System::Int64Op does not support the >= operator so we invert the operation
118 2956 mdecorde
Pop $_LOGICLIB_TEMP
119 2956 mdecorde
StrCmp $_LOGICLIB_TEMP 0 retPos finalCmp
120 2956 mdecorde
retPos:
121 2956 mdecorde
StrCpy $_LOGICLIB_TEMP "1"
122 2956 mdecorde
Goto ret
123 2956 mdecorde
checkNegOther:
124 2956 mdecorde
System::Int64Op $2 < 0
125 2956 mdecorde
Pop $_LOGICLIB_TEMP
126 2956 mdecorde
StrCmp $_LOGICLIB_TEMP 0 finalCmp retNeg
127 2956 mdecorde
retNeg:
128 2956 mdecorde
StrCpy $_LOGICLIB_TEMP "-1"
129 2956 mdecorde
Goto ret
130 2956 mdecorde
finalCmp:
131 2956 mdecorde
System::Int64Op $1 < $2
132 2956 mdecorde
Pop $_LOGICLIB_TEMP
133 2956 mdecorde
StrCmp $_LOGICLIB_TEMP 0 retPos retNeg
134 2956 mdecorde
ret:
135 2956 mdecorde
Pop $1
136 2956 mdecorde
Pop $2
137 2956 mdecorde
!macroend
138 2956 mdecorde
!macro Int64CmpU a b jeek jles jgtr
139 2956 mdecorde
!if ${NSIS_PTR_SIZE} <= 4
140 2956 mdecorde
!echo "Int64CmpU ${a}:${b} =${jeek}, <${jles}, >${jgtr}"
141 2956 mdecorde
!verbose push 2
142 2956 mdecorde
Push `${a}`
143 2956 mdecorde
Push `${b}`
144 2956 mdecorde
!insertmacro CallArtificialFunction Int64CmpUHelper
145 2956 mdecorde
IntCmp $_LOGICLIB_TEMP 0 `${jeek}` `${jles}` `${jgtr}`
146 2956 mdecorde
!verbose pop
147 2956 mdecorde
!else
148 2956 mdecorde
Int64CmpU `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
149 2956 mdecorde
!endif
150 2956 mdecorde
!macroend
151 2956 mdecorde
!macro IntPtrCmpU a b jeek jles jgtr
152 2956 mdecorde
IntPtrCmpU `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
153 2956 mdecorde
!macroend
154 2956 mdecorde
155 2956 mdecorde
156 2956 mdecorde
!define MakeARPInstallDate "!insertmacro MakeARPInstallDate "
157 2956 mdecorde
!macro MakeARPInstallDate _outvar
158 2956 mdecorde
System::Call 'KERNEL32::GetDateFormat(i0x409,i0,p0,t"yyyyMMdd",t.s,i${NSIS_MAX_STRLEN})'
159 2956 mdecorde
Pop ${_outvar}
160 2956 mdecorde
!macroend
161 2956 mdecorde
162 2956 mdecorde
163 2956 mdecorde
!define /IfNDef SPI_GETHIGHCONTRAST 0x42
164 2956 mdecorde
!define /IfNDef HCF_HIGHCONTRASTON 0x01
165 2956 mdecorde
!define /IfNDef /math SYSSIZEOF_HIGHCONTRAST 8 + ${NSIS_PTR_SIZE}
166 2956 mdecorde
!define IsHighContrastModeActive '"" IsHighContrastModeActive ""'
167 2956 mdecorde
!macro _IsHighContrastModeActive _lhs _rhs _t _f
168 2956 mdecorde
!ifmacrondef _LOGICLIB_TEMP
169 2956 mdecorde
!include LogicLib.nsh
170 2956 mdecorde
!endif
171 2956 mdecorde
!insertmacro _LOGICLIB_TEMP
172 2956 mdecorde
Push $1
173 2956 mdecorde
System::Call '*(i${SYSSIZEOF_HIGHCONTRAST},i0,p)p.r1'
174 2956 mdecorde
System::Call 'USER32::SystemParametersInfo(i${SPI_GETHIGHCONTRAST},i${SYSSIZEOF_HIGHCONTRAST},pr1,i0)'
175 2956 mdecorde
System::Call '*$1(i,i.s)'
176 2956 mdecorde
Pop $_LOGICLIB_TEMP
177 2956 mdecorde
System::Free $1
178 2956 mdecorde
Pop $1
179 2956 mdecorde
!insertmacro _& $_LOGICLIB_TEMP ${HCF_HIGHCONTRASTON} `${_t}` `${_f}`
180 2956 mdecorde
!macroend
181 2956 mdecorde
182 2956 mdecorde
183 2956 mdecorde
!endif # !___UTIL__NSH___
184 2956 mdecorde
!verbose pop