move and rename from ctypes._FuncPointer to _ctypes.CFuncPtr (#10140)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Jun Komoda
2023-05-07 02:17:34 +09:00
committed by GitHub
parent 853d01d55e
commit a6ecf564b5
3 changed files with 25 additions and 22 deletions

View File

@@ -5,6 +5,7 @@ from _ctypes import (
RTLD_LOCAL as RTLD_LOCAL,
ArgumentError as ArgumentError,
Array as Array,
CFuncPtr as _CFuncPtr,
Structure as Structure,
Union as Union,
_CanCastTo as _CanCastTo,
@@ -26,8 +27,7 @@ from _ctypes import (
set_errno as set_errno,
sizeof as sizeof,
)
from collections.abc import Callable, Sequence
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing import Any, ClassVar, Generic, TypeVar
from typing_extensions import TypeAlias
if sys.platform == "win32":
@@ -91,22 +91,7 @@ if sys.platform == "win32":
pydll: LibraryLoader[PyDLL]
pythonapi: PyDLL
_ECT: TypeAlias = Callable[[type[_CData] | None, _FuncPointer, tuple[_CData, ...]], _CData]
_PF: TypeAlias = tuple[int] | tuple[int, str] | tuple[int, str, Any]
class _FuncPointer(_PointerLike, _CData):
restype: type[_CData] | Callable[[int], Any] | None
argtypes: Sequence[type[_CData]]
errcheck: _ECT
@overload
def __init__(self, address: int) -> None: ...
@overload
def __init__(self, callable: Callable[..., Any]) -> None: ...
@overload
def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ...
@overload
def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class _FuncPointer(_CFuncPtr): ...
class _NamedFuncPointer(_FuncPointer):
__name__: str