##// 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 LPDWORD = ctypes.POINTER(wintypes.DWORD)
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 CreateFile.argtypes = [
98 CreateFile.argtypes = [
97 wintypes.LPSTR,
99 wintypes.LPSTR,
98 wintypes.DWORD,
100 wintypes.DWORD,
@@ -104,11 +106,11 b' if os.name == "nt":'
104 ]
106 ]
105 CreateFile.restype = wintypes.HANDLE
107 CreateFile.restype = wintypes.HANDLE
106
108
107 CloseHandle = ctypes.windll.kernel32.CloseHandle
109 CloseHandle = _kernel32.CloseHandle
108 CloseHandle.argtypes = [wintypes.HANDLE]
110 CloseHandle.argtypes = [wintypes.HANDLE]
109 CloseHandle.restype = wintypes.BOOL
111 CloseHandle.restype = wintypes.BOOL
110
112
111 ReadFile = ctypes.windll.kernel32.ReadFile
113 ReadFile = _kernel32.ReadFile
112 ReadFile.argtypes = [
114 ReadFile.argtypes = [
113 wintypes.HANDLE,
115 wintypes.HANDLE,
114 wintypes.LPVOID,
116 wintypes.LPVOID,
@@ -118,7 +120,7 b' if os.name == "nt":'
118 ]
120 ]
119 ReadFile.restype = wintypes.BOOL
121 ReadFile.restype = wintypes.BOOL
120
122
121 WriteFile = ctypes.windll.kernel32.WriteFile
123 WriteFile = _kernel32.WriteFile
122 WriteFile.argtypes = [
124 WriteFile.argtypes = [
123 wintypes.HANDLE,
125 wintypes.HANDLE,
124 wintypes.LPVOID,
126 wintypes.LPVOID,
@@ -128,15 +130,15 b' if os.name == "nt":'
128 ]
130 ]
129 WriteFile.restype = wintypes.BOOL
131 WriteFile.restype = wintypes.BOOL
130
132
131 GetLastError = ctypes.windll.kernel32.GetLastError
133 GetLastError = _kernel32.GetLastError
132 GetLastError.argtypes = []
134 GetLastError.argtypes = []
133 GetLastError.restype = wintypes.DWORD
135 GetLastError.restype = wintypes.DWORD
134
136
135 SetLastError = ctypes.windll.kernel32.SetLastError
137 SetLastError = _kernel32.SetLastError
136 SetLastError.argtypes = [wintypes.DWORD]
138 SetLastError.argtypes = [wintypes.DWORD]
137 SetLastError.restype = None
139 SetLastError.restype = None
138
140
139 FormatMessage = ctypes.windll.kernel32.FormatMessageA
141 FormatMessage = _kernel32.FormatMessageA
140 FormatMessage.argtypes = [
142 FormatMessage.argtypes = [
141 wintypes.DWORD,
143 wintypes.DWORD,
142 wintypes.LPVOID,
144 wintypes.LPVOID,
@@ -148,9 +150,9 b' if os.name == "nt":'
148 ]
150 ]
149 FormatMessage.restype = wintypes.DWORD
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 GetOverlappedResult.argtypes = [
156 GetOverlappedResult.argtypes = [
155 wintypes.HANDLE,
157 wintypes.HANDLE,
156 ctypes.POINTER(OVERLAPPED),
158 ctypes.POINTER(OVERLAPPED),
@@ -159,9 +161,7 b' if os.name == "nt":'
159 ]
161 ]
160 GetOverlappedResult.restype = wintypes.BOOL
162 GetOverlappedResult.restype = wintypes.BOOL
161
163
162 GetOverlappedResultEx = getattr(
164 GetOverlappedResultEx = getattr(_kernel32, "GetOverlappedResultEx", None)
163 ctypes.windll.kernel32, "GetOverlappedResultEx", None
164 )
165 if GetOverlappedResultEx is not None:
165 if GetOverlappedResultEx is not None:
166 GetOverlappedResultEx.argtypes = [
166 GetOverlappedResultEx.argtypes = [
167 wintypes.HANDLE,
167 wintypes.HANDLE,
@@ -172,7 +172,7 b' if os.name == "nt":'
172 ]
172 ]
173 GetOverlappedResultEx.restype = wintypes.BOOL
173 GetOverlappedResultEx.restype = wintypes.BOOL
174
174
175 WaitForSingleObjectEx = ctypes.windll.kernel32.WaitForSingleObjectEx
175 WaitForSingleObjectEx = _kernel32.WaitForSingleObjectEx
176 WaitForSingleObjectEx.argtypes = [
176 WaitForSingleObjectEx.argtypes = [
177 wintypes.HANDLE,
177 wintypes.HANDLE,
178 wintypes.DWORD,
178 wintypes.DWORD,
@@ -180,7 +180,7 b' if os.name == "nt":'
180 ]
180 ]
181 WaitForSingleObjectEx.restype = wintypes.DWORD
181 WaitForSingleObjectEx.restype = wintypes.DWORD
182
182
183 CreateEvent = ctypes.windll.kernel32.CreateEventA
183 CreateEvent = _kernel32.CreateEventA
184 CreateEvent.argtypes = [
184 CreateEvent.argtypes = [
185 LPDWORD,
185 LPDWORD,
186 wintypes.BOOL,
186 wintypes.BOOL,
@@ -190,7 +190,7 b' if os.name == "nt":'
190 CreateEvent.restype = wintypes.HANDLE
190 CreateEvent.restype = wintypes.HANDLE
191
191
192 # Windows Vista is the minimum supported client for CancelIoEx.
192 # Windows Vista is the minimum supported client for CancelIoEx.
193 CancelIoEx = ctypes.windll.kernel32.CancelIoEx
193 CancelIoEx = _kernel32.CancelIoEx
194 CancelIoEx.argtypes = [wintypes.HANDLE, ctypes.POINTER(OVERLAPPED)]
194 CancelIoEx.argtypes = [wintypes.HANDLE, ctypes.POINTER(OVERLAPPED)]
195 CancelIoEx.restype = wintypes.BOOL
195 CancelIoEx.restype = wintypes.BOOL
196
196
General Comments 0
You need to be logged in to leave comments. Login now