mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
move and rename from ctypes._FuncPointer to _ctypes.CFuncPtr (#10140)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Iterable, Iterator, Mapping, Sequence
|
||||
from ctypes import CDLL
|
||||
from typing import Any, Generic, TypeVar, overload
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
||||
from ctypes import CDLL, c_int
|
||||
from typing import Any, ClassVar, Generic, TypeVar, overload
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -93,6 +93,24 @@ class _CArgObject: ...
|
||||
|
||||
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||
|
||||
_ECT: TypeAlias = Callable[[type[_CData] | None, CFuncPtr, tuple[_CData, ...]], _CData]
|
||||
_PF: TypeAlias = tuple[int] | tuple[int, str] | tuple[int, str, Any]
|
||||
|
||||
class CFuncPtr(_PointerLike, _CData):
|
||||
restype: type[_CData] | Callable[[int], Any] | None
|
||||
argtypes: Sequence[type[_CData]]
|
||||
errcheck: _ECT
|
||||
_flags_: ClassVar[int] # Abstract attribute that must be defined on subclasses
|
||||
@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 _CField:
|
||||
offset: int
|
||||
size: int
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,7 @@ _collections_abc.Set.__rsub__
|
||||
_collections_abc.Set.__rxor__
|
||||
|
||||
_csv.Dialect.__init__ # C __init__ signature is inaccurate
|
||||
_ctypes.CFuncPtr # stubtest erroneously thinks it can't be subclassed
|
||||
_threading_local.local.__new__
|
||||
_weakref.ref.* # Alias for _weakref.ReferenceType, problems should be fixed there
|
||||
_weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy
|
||||
@@ -334,7 +335,6 @@ turtle.ScrolledCanvas.onResize
|
||||
wave.Wave_read.initfp
|
||||
wave.Wave_write.initfp
|
||||
|
||||
_ctypes.CFuncPtr
|
||||
_ctypes.PyObj_FromPtr
|
||||
_ctypes.Py_DECREF
|
||||
_ctypes.Py_INCREF
|
||||
|
||||
Reference in New Issue
Block a user