##// END OF EJS Templates
watchman: refactor `ctypes.windll.kernel32` references to a local variable...
Matt Harbison -
r50750:36afe74e default
parent child Browse files
Show More
@@ -92,7 +92,9 b' if os.name == "nt":'
92 92
93 93 LPDWORD = ctypes.POINTER(wintypes.DWORD)
94 94
95 CreateFile = ctypes.windll.kernel32.CreateFileA
95 _kernel32 = ctypes.windll.kernel32 # pytype: disable=module-attr
96
97 CreateFile = _kernel32.CreateFileA
96 98 CreateFile.argtypes = [
97 99 wintypes.LPSTR,
98 100 wintypes.DWORD,
@@ -104,11 +106,11 b' if os.name == "nt":'
104 106 ]
105 107 CreateFile.restype = wintypes.HANDLE
106 108
107 CloseHandle = ctypes.windll.kernel32.CloseHandle
109 CloseHandle = _kernel32.CloseHandle
108 110 CloseHandle.argtypes = [wintypes.HANDLE]
109 111 CloseHandle.restype = wintypes.BOOL
110 112
111 ReadFile = ctypes.windll.kernel32.ReadFile
113 ReadFile = _kernel32.ReadFile
112 114 ReadFile.argtypes = [
113 115 wintypes.HANDLE,
114 116 wintypes.LPVOID,
@@ -118,7 +120,7 b' if os.name == "nt":'
118 120 ]
119 121 ReadFile.restype = wintypes.BOOL
120 122
121 WriteFile = ctypes.windll.kernel32.WriteFile
123 WriteFile = _kernel32.WriteFile
122 124 WriteFile.argtypes = [
123 125 wintypes.HANDLE,
124 126 wintypes.LPVOID,
@@ -128,15 +130,15 b' if os.name == "nt":'
128 130 ]
129 131 WriteFile.restype = wintypes.BOOL
130 132
131 GetLastError = ctypes.windll.kernel32.GetLastError
133 GetLastError = _kernel32.GetLastError
132 134 GetLastError.argtypes = []
133 135 GetLastError.restype = wintypes.DWORD
134 136
135 SetLastError = ctypes.windll.kernel32.SetLastError
137 SetLastError = _kernel32.SetLastError
136 138 SetLastError.argtypes = [wintypes.DWORD]
137 139 SetLastError.restype = None
138 140
139 FormatMessage = ctypes.windll.kernel32.FormatMessageA
141 FormatMessage = _kernel32.FormatMessageA
140 142 FormatMessage.argtypes = [
141 143 wintypes.DWORD,
142 144 wintypes.LPVOID,
@@ -148,9 +150,9 b' if os.name == "nt":'
148 150 ]
149 151 FormatMessage.restype = wintypes.DWORD
150 152
151 LocalFree = ctypes.windll.kernel32.LocalFree
153 LocalFree = _kernel32.LocalFree
152 154
153 GetOverlappedResult = ctypes.windll.kernel32.GetOverlappedResult
155 GetOverlappedResult = _kernel32.GetOverlappedResult
154 156 GetOverlappedResult.argtypes = [
155 157 wintypes.HANDLE,
156 158 ctypes.POINTER(OVERLAPPED),
@@ -159,9 +161,7 b' if os.name == "nt":'
159 161 ]
160 162 GetOverlappedResult.restype = wintypes.BOOL
161 163
162 GetOverlappedResultEx = getattr(
163 ctypes.windll.kernel32, "GetOverlappedResultEx", None
164 )
164 GetOverlappedResultEx = getattr(_kernel32, "GetOverlappedResultEx", None)
165 165 if GetOverlappedResultEx is not None:
166 166 GetOverlappedResultEx.argtypes = [
167 167 wintypes.HANDLE,
@@ -172,7 +172,7 b' if os.name == "nt":'
172 172 ]
173 173 GetOverlappedResultEx.restype = wintypes.BOOL
174 174
175 WaitForSingleObjectEx = ctypes.windll.kernel32.WaitForSingleObjectEx
175 WaitForSingleObjectEx = _kernel32.WaitForSingleObjectEx
176 176 WaitForSingleObjectEx.argtypes = [
177 177 wintypes.HANDLE,
178 178 wintypes.DWORD,
@@ -180,7 +180,7 b' if os.name == "nt":'
180 180 ]
181 181 WaitForSingleObjectEx.restype = wintypes.DWORD
182 182
183 CreateEvent = ctypes.windll.kernel32.CreateEventA
183 CreateEvent = _kernel32.CreateEventA
184 184 CreateEvent.argtypes = [
185 185 LPDWORD,
186 186 wintypes.BOOL,
@@ -190,7 +190,7 b' if os.name == "nt":'
190 190 CreateEvent.restype = wintypes.HANDLE
191 191
192 192 # Windows Vista is the minimum supported client for CancelIoEx.
193 CancelIoEx = ctypes.windll.kernel32.CancelIoEx
193 CancelIoEx = _kernel32.CancelIoEx
194 194 CancelIoEx.argtypes = [wintypes.HANDLE, ctypes.POINTER(OVERLAPPED)]
195 195 CancelIoEx.restype = wintypes.BOOL
196 196
General Comments 0
You need to be logged in to leave comments. Login now