Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -221,86 +221,137 @@ class py_object(_CanCastTo, _SimpleCData[_T]):

class c_bool(_SimpleCData[bool]):
_type_: ClassVar[Literal["?"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]
def __init__(self, value: SupportsBool | SupportsLen | None = ...) -> None: ...

class c_byte(_SimpleCData[int]):
_type_: ClassVar[Literal["b"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_ubyte(_SimpleCData[int]):
_type_: ClassVar[Literal["B"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_short(_SimpleCData[int]):
_type_: ClassVar[Literal["h"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_ushort(_SimpleCData[int]):
_type_: ClassVar[Literal["H"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_long(_SimpleCData[int]):
_type_: ClassVar[Literal["l"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_ulong(_SimpleCData[int]):
_type_: ClassVar[Literal["L"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_int(_SimpleCData[int]): # can be an alias for c_long
_type_: ClassVar[Literal["i", "l"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_uint(_SimpleCData[int]): # can be an alias for c_ulong
_type_: ClassVar[Literal["I", "L"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_longlong(_SimpleCData[int]): # can be an alias for c_long
_type_: ClassVar[Literal["q", "l"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_ulonglong(_SimpleCData[int]): # can be an alias for c_ulong
_type_: ClassVar[Literal["Q", "L"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

c_int8 = c_byte
c_uint8 = c_ubyte

class c_int16(_SimpleCData[int]): # can be an alias for c_short or c_int
_type_: ClassVar[Literal["h", "i"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_uint16(_SimpleCData[int]): # can be an alias for c_ushort or c_uint
_type_: ClassVar[Literal["H", "I"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_int32(_SimpleCData[int]): # can be an alias for c_int or c_long
_type_: ClassVar[Literal["i", "l"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_uint32(_SimpleCData[int]): # can be an alias for c_uint or c_ulong
_type_: ClassVar[Literal["I", "L"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_int64(_SimpleCData[int]): # can be an alias for c_long or c_longlong
_type_: ClassVar[Literal["l", "q"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_uint64(_SimpleCData[int]): # can be an alias for c_ulong or c_ulonglong
_type_: ClassVar[Literal["L", "Q"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_ssize_t(_SimpleCData[int]): # alias for c_int, c_long, or c_longlong
_type_: ClassVar[Literal["i", "l", "q"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_size_t(_SimpleCData[int]): # alias for c_uint, c_ulong, or c_ulonglong
_type_: ClassVar[Literal["I", "L", "Q"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_float(_SimpleCData[float]):
_type_: ClassVar[Literal["f"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_double(_SimpleCData[float]):
_type_: ClassVar[Literal["d"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_longdouble(_SimpleCData[float]): # can be an alias for c_double
_type_: ClassVar[Literal["d", "g"]]

if sys.version_info >= (3, 14) and sys.platform != "win32":
# NOTE: currently (3.14.4) the `__ctype_{be,le}__` attributes of these complex types are missing at runtime:
# https://github.com/python/cpython/issues/148464

class c_double_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["D"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_float_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["F"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]

class c_longdouble_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["G"]]

class c_char(_SimpleCData[bytes]):
_type_: ClassVar[Literal["c"]]
__ctype_be__: ClassVar[type[Self]]
__ctype_le__: ClassVar[type[Self]]
def __init__(self, value: int | bytes | bytearray = ...) -> None: ...

class c_char_p(_PointerLike, _SimpleCData[bytes | None]):
Expand Down