_CField as a generic descriptor protocol (#10595)

This commit is contained in:
Jun Komoda
2023-09-01 23:23:33 +09:00
committed by GitHub
parent e04c440571
commit 4009efa349
4 changed files with 124 additions and 109 deletions

View File

@@ -122,15 +122,23 @@ class CFuncPtr(_PointerLike, _CData):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class _CField:
_GetT = TypeVar("_GetT")
_SetT = TypeVar("_SetT")
class _CField(Generic[_CT, _GetT, _SetT]):
offset: int
size: int
@overload
def __get__(self, __instance: None, __owner: type[Any] | None) -> Self: ...
@overload
def __get__(self, __instance: Any, __owner: type[Any] | None) -> _GetT: ...
def __set__(self, __instance: Any, __value: _SetT) -> None: ...
class _StructUnionMeta(_CDataMeta):
_fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]]
_pack_: int
_anonymous_: Sequence[str]
def __getattr__(self, name: str) -> _CField: ...
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
class _StructUnionBase(_CData, metaclass=_StructUnionMeta):
def __init__(self, *args: Any, **kw: Any) -> None: ...