mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
ctypes: pointer is a function, not a class (#8446)
This commit is contained in:
@@ -100,7 +100,7 @@ class _FuncPointer(_PointerLike, _CData):
|
||||
@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 __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
class _NamedFuncPointer(_FuncPointer):
|
||||
@@ -156,14 +156,14 @@ if sys.platform == "win32":
|
||||
|
||||
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> int: ...
|
||||
def memset(dst: _CVoidPLike, c: int, count: int) -> int: ...
|
||||
def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ...
|
||||
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
|
||||
|
||||
# The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like
|
||||
# ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer,
|
||||
# it can be instantiated directly (to mimic the behavior of the real pointer function).
|
||||
class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
class _Pointer(Generic[_CT], _PointerLike, _CData):
|
||||
_type_: type[_CT]
|
||||
contents: _CT
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, arg: _CT) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, __i: int) -> _CT: ...
|
||||
@@ -174,6 +174,7 @@ class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
@overload
|
||||
def __setitem__(self, __s: slice, __o: Iterable[_CT]) -> None: ...
|
||||
|
||||
def pointer(__arg: _CT) -> _Pointer[_CT]: ...
|
||||
def resize(obj: _CData, size: int) -> None: ...
|
||||
def set_errno(value: int) -> int: ...
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from ctypes import (
|
||||
Array,
|
||||
Structure,
|
||||
_Pointer,
|
||||
_SimpleCData,
|
||||
c_byte,
|
||||
c_char,
|
||||
@@ -18,7 +19,6 @@ from ctypes import (
|
||||
c_void_p,
|
||||
c_wchar,
|
||||
c_wchar_p,
|
||||
pointer,
|
||||
)
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
@@ -181,55 +181,55 @@ class WIN32_FIND_DATAW(Structure):
|
||||
cFileName: Array[WCHAR]
|
||||
cAlternateFileName: Array[WCHAR]
|
||||
|
||||
# These pointer type definitions use pointer[...] instead of POINTER(...), to allow them
|
||||
# These pointer type definitions use _Pointer[...] instead of POINTER(...), to allow them
|
||||
# to be used in type annotations.
|
||||
PBOOL: TypeAlias = pointer[BOOL]
|
||||
LPBOOL: TypeAlias = pointer[BOOL]
|
||||
PBOOLEAN: TypeAlias = pointer[BOOLEAN]
|
||||
PBYTE: TypeAlias = pointer[BYTE]
|
||||
LPBYTE: TypeAlias = pointer[BYTE]
|
||||
PCHAR: TypeAlias = pointer[CHAR]
|
||||
LPCOLORREF: TypeAlias = pointer[COLORREF]
|
||||
PDWORD: TypeAlias = pointer[DWORD]
|
||||
LPDWORD: TypeAlias = pointer[DWORD]
|
||||
PFILETIME: TypeAlias = pointer[FILETIME]
|
||||
LPFILETIME: TypeAlias = pointer[FILETIME]
|
||||
PFLOAT: TypeAlias = pointer[FLOAT]
|
||||
PHANDLE: TypeAlias = pointer[HANDLE]
|
||||
LPHANDLE: TypeAlias = pointer[HANDLE]
|
||||
PHKEY: TypeAlias = pointer[HKEY]
|
||||
LPHKL: TypeAlias = pointer[HKL]
|
||||
PINT: TypeAlias = pointer[INT]
|
||||
LPINT: TypeAlias = pointer[INT]
|
||||
PLARGE_INTEGER: TypeAlias = pointer[LARGE_INTEGER]
|
||||
PLCID: TypeAlias = pointer[LCID]
|
||||
PLONG: TypeAlias = pointer[LONG]
|
||||
LPLONG: TypeAlias = pointer[LONG]
|
||||
PMSG: TypeAlias = pointer[MSG]
|
||||
LPMSG: TypeAlias = pointer[MSG]
|
||||
PPOINT: TypeAlias = pointer[POINT]
|
||||
LPPOINT: TypeAlias = pointer[POINT]
|
||||
PPOINTL: TypeAlias = pointer[POINTL]
|
||||
PRECT: TypeAlias = pointer[RECT]
|
||||
LPRECT: TypeAlias = pointer[RECT]
|
||||
PRECTL: TypeAlias = pointer[RECTL]
|
||||
LPRECTL: TypeAlias = pointer[RECTL]
|
||||
LPSC_HANDLE: TypeAlias = pointer[SC_HANDLE]
|
||||
PSHORT: TypeAlias = pointer[SHORT]
|
||||
PSIZE: TypeAlias = pointer[SIZE]
|
||||
LPSIZE: TypeAlias = pointer[SIZE]
|
||||
PSIZEL: TypeAlias = pointer[SIZEL]
|
||||
LPSIZEL: TypeAlias = pointer[SIZEL]
|
||||
PSMALL_RECT: TypeAlias = pointer[SMALL_RECT]
|
||||
PUINT: TypeAlias = pointer[UINT]
|
||||
LPUINT: TypeAlias = pointer[UINT]
|
||||
PULARGE_INTEGER: TypeAlias = pointer[ULARGE_INTEGER]
|
||||
PULONG: TypeAlias = pointer[ULONG]
|
||||
PUSHORT: TypeAlias = pointer[USHORT]
|
||||
PWCHAR: TypeAlias = pointer[WCHAR]
|
||||
PWIN32_FIND_DATAA: TypeAlias = pointer[WIN32_FIND_DATAA]
|
||||
LPWIN32_FIND_DATAA: TypeAlias = pointer[WIN32_FIND_DATAA]
|
||||
PWIN32_FIND_DATAW: TypeAlias = pointer[WIN32_FIND_DATAW]
|
||||
LPWIN32_FIND_DATAW: TypeAlias = pointer[WIN32_FIND_DATAW]
|
||||
PWORD: TypeAlias = pointer[WORD]
|
||||
LPWORD: TypeAlias = pointer[WORD]
|
||||
PBOOL: TypeAlias = _Pointer[BOOL]
|
||||
LPBOOL: TypeAlias = _Pointer[BOOL]
|
||||
PBOOLEAN: TypeAlias = _Pointer[BOOLEAN]
|
||||
PBYTE: TypeAlias = _Pointer[BYTE]
|
||||
LPBYTE: TypeAlias = _Pointer[BYTE]
|
||||
PCHAR: TypeAlias = _Pointer[CHAR]
|
||||
LPCOLORREF: TypeAlias = _Pointer[COLORREF]
|
||||
PDWORD: TypeAlias = _Pointer[DWORD]
|
||||
LPDWORD: TypeAlias = _Pointer[DWORD]
|
||||
PFILETIME: TypeAlias = _Pointer[FILETIME]
|
||||
LPFILETIME: TypeAlias = _Pointer[FILETIME]
|
||||
PFLOAT: TypeAlias = _Pointer[FLOAT]
|
||||
PHANDLE: TypeAlias = _Pointer[HANDLE]
|
||||
LPHANDLE: TypeAlias = _Pointer[HANDLE]
|
||||
PHKEY: TypeAlias = _Pointer[HKEY]
|
||||
LPHKL: TypeAlias = _Pointer[HKL]
|
||||
PINT: TypeAlias = _Pointer[INT]
|
||||
LPINT: TypeAlias = _Pointer[INT]
|
||||
PLARGE_INTEGER: TypeAlias = _Pointer[LARGE_INTEGER]
|
||||
PLCID: TypeAlias = _Pointer[LCID]
|
||||
PLONG: TypeAlias = _Pointer[LONG]
|
||||
LPLONG: TypeAlias = _Pointer[LONG]
|
||||
PMSG: TypeAlias = _Pointer[MSG]
|
||||
LPMSG: TypeAlias = _Pointer[MSG]
|
||||
PPOINT: TypeAlias = _Pointer[POINT]
|
||||
LPPOINT: TypeAlias = _Pointer[POINT]
|
||||
PPOINTL: TypeAlias = _Pointer[POINTL]
|
||||
PRECT: TypeAlias = _Pointer[RECT]
|
||||
LPRECT: TypeAlias = _Pointer[RECT]
|
||||
PRECTL: TypeAlias = _Pointer[RECTL]
|
||||
LPRECTL: TypeAlias = _Pointer[RECTL]
|
||||
LPSC_HANDLE: TypeAlias = _Pointer[SC_HANDLE]
|
||||
PSHORT: TypeAlias = _Pointer[SHORT]
|
||||
PSIZE: TypeAlias = _Pointer[SIZE]
|
||||
LPSIZE: TypeAlias = _Pointer[SIZE]
|
||||
PSIZEL: TypeAlias = _Pointer[SIZEL]
|
||||
LPSIZEL: TypeAlias = _Pointer[SIZEL]
|
||||
PSMALL_RECT: TypeAlias = _Pointer[SMALL_RECT]
|
||||
PUINT: TypeAlias = _Pointer[UINT]
|
||||
LPUINT: TypeAlias = _Pointer[UINT]
|
||||
PULARGE_INTEGER: TypeAlias = _Pointer[ULARGE_INTEGER]
|
||||
PULONG: TypeAlias = _Pointer[ULONG]
|
||||
PUSHORT: TypeAlias = _Pointer[USHORT]
|
||||
PWCHAR: TypeAlias = _Pointer[WCHAR]
|
||||
PWIN32_FIND_DATAA: TypeAlias = _Pointer[WIN32_FIND_DATAA]
|
||||
LPWIN32_FIND_DATAA: TypeAlias = _Pointer[WIN32_FIND_DATAA]
|
||||
PWIN32_FIND_DATAW: TypeAlias = _Pointer[WIN32_FIND_DATAW]
|
||||
LPWIN32_FIND_DATAW: TypeAlias = _Pointer[WIN32_FIND_DATAW]
|
||||
PWORD: TypeAlias = _Pointer[WORD]
|
||||
LPWORD: TypeAlias = _Pointer[WORD]
|
||||
|
||||
@@ -84,7 +84,6 @@ ctypes.Array._length_
|
||||
ctypes.CDLL._FuncPtr # None at class level but initialized in __init__ to this value
|
||||
ctypes.memmove # CFunctionType
|
||||
ctypes.memset # CFunctionType
|
||||
ctypes.pointer # imported C function
|
||||
ctypes.string_at # docstring argument name is wrong
|
||||
ctypes.wstring_at # docstring argument name is wrong
|
||||
distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment.
|
||||
|
||||
Reference in New Issue
Block a user