Skip to content

Use overlapped signatures of _winapi functions #2723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions stdlib/3/_winapi.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Union, Tuple, Optional, Dict, NoReturn, Sequence
from typing import Any, Union, Tuple, Optional, overload, Dict, NoReturn, Sequence

CREATE_NEW_CONSOLE: int
CREATE_NEW_PROCESS_GROUP: int
Expand Down Expand Up @@ -45,7 +45,13 @@ WAIT_OBJECT_0: int
WAIT_TIMEOUT: int

def CloseHandle(handle: int) -> None: ...
def ConnectNamedPipe(handle: int, overlapped: Union[int, bool] = ...) -> None: ...

# TODO: once literal types are supported, overload with Literal[True/False]
@overload
def ConnectNamedPipe(handle: int, overlapped: Union[int, bool]) -> Any: ...
@overload
def ConnectNamedPipe(handle: int) -> None: ...

def CreateFile(file_name: str, desired_access: int, share_mode: int, security_attributes: int, creation_disposition: int, flags_and_attributes: int, template_file: int) -> int: ...
def CreateJunction(src_path: str, dest_path: str) -> None: ...
def CreateNamedPipe(name: str, open_mode: int, pipe_mode: int, max_instances: int, out_buffer_size: int, in_buffer_size: int, default_timeout: int, security_attributes: int) -> int: ...
Expand All @@ -63,13 +69,25 @@ def GetStdHandle(std_handle: int) -> int: ...
def GetVersion() -> int: ...
def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int) -> int: ...
def PeekNamedPipe(handle: int, size: int = ...) -> Union[Tuple[int, int], Tuple[bytes, int, int]]: ...
def ReadFile(handle: int, size: int, overlapped: Union[int, bool] = ...) -> Tuple[bytes, int]: ...

# TODO: once literal types are supported, overload with Literal[True/False]
@overload
def ReadFile(handle: int, size: int, overlapped: Union[int, bool]) -> Any: ...
@overload
def ReadFile(handle: int, size: int) -> Tuple[int, int]: ...

def SetNamedPipeHandleState(named_pipe: int, mode: Optional[int], max_collection_count: Optional[int], collect_data_timeout: Optional[int]) -> None: ...
def TerminateProcess(handle: int, exit_code: int) -> None: ...
def WaitForMultipleObjects(handle_seq: Sequence[int], wait_flag: bool, milliseconds: int = ...) -> int: ...
def WaitForSingleObject(handle: int, milliseconds: int) -> int: ...
def WaitNamedPipe(name: str, timeout: int) -> None: ...
def WriteFile(handle: int, buffer: bytes, overlapped: Union[int, bool] = ...): ...

# TODO: once literal types are supported, overload with Literal[True/False]
@overload
def WriteFile(handle: int, buffer: bytes, overlapped: Union[int, bool]) -> Any: ...
@overload
def WriteFile(handle: int, buffer: bytes) -> Tuple[bytes, int]: ...


class Overlapped:
event: int = ...
Expand Down