mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
ctypes: allow cast() 1st argument to be int and 2nd argument to be Type[py_object] (#4311)
This commit is contained in:
@@ -96,7 +96,8 @@ class _CData(metaclass=_CDataMeta):
|
||||
@classmethod
|
||||
def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ...
|
||||
|
||||
class _PointerLike(_CData): ...
|
||||
class _CanCastTo(_CData): ...
|
||||
class _PointerLike(_CanCastTo): ...
|
||||
|
||||
_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData]
|
||||
_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]]
|
||||
@@ -143,9 +144,9 @@ def addressof(obj: _CData) -> int: ...
|
||||
def alignment(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
|
||||
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||
|
||||
_PT = TypeVar("_PT", bound=_PointerLike)
|
||||
_CastT = TypeVar("_CastT", bound=_CanCastTo)
|
||||
|
||||
def cast(obj: _UnionT[_CData, _CArgObject], type: Type[_PT]) -> _PT: ...
|
||||
def cast(obj: _UnionT[_CData, _CArgObject, int], type: Type[_CastT]) -> _CastT: ...
|
||||
def create_string_buffer(init_or_size: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ...
|
||||
|
||||
c_buffer = create_string_buffer
|
||||
@@ -247,7 +248,7 @@ class c_bool(_SimpleCData[bool]):
|
||||
if sys.platform == "win32":
|
||||
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
|
||||
|
||||
class py_object(_SimpleCData[_T]): ...
|
||||
class py_object(_CanCastTo, _SimpleCData[_T]): ...
|
||||
|
||||
class _CField:
|
||||
offset: int = ...
|
||||
|
||||
Reference in New Issue
Block a user