stdc.pyi 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from typing import overload, Self
  2. intptr = int
  3. def malloc(size: int) -> intptr: ...
  4. def free(ptr: intptr) -> None: ...
  5. def memcpy(dst: intptr, src: intptr, n: int) -> None: ...
  6. def memset(s: intptr, c: int, n: int) -> None: ...
  7. def memcmp(s1: intptr, s2: intptr, n: int) -> int: ...
  8. def addressof(obj: Memory) -> intptr: ...
  9. def sizeof(obj: type[Memory]) -> int: ...
  10. def read_cstr(p: intptr) -> str: ...
  11. def read_bytes(p: intptr, n: int) -> bytes: ...
  12. def write_cstr(p: intptr, data: str) -> None: ...
  13. def write_bytes(p: intptr, data: bytes) -> None: ...
  14. class Memory: ...
  15. class _BuiltinMemory[T](Memory):
  16. value: T
  17. def __new__(cls, value: T | None = None) -> None: ...
  18. @staticmethod
  19. def read(p: intptr, offset: int) -> T: ...
  20. @staticmethod
  21. def write(p: intptr, offset: int, value: T) -> None: ...
  22. @staticmethod
  23. def array(length: int) -> Self: ...
  24. @property
  25. def size(self) -> int: ...
  26. def __getitem__(self, index: int) -> T: ...
  27. def __setitem__(self, index: int, value: T) -> None: ...
  28. class Char(_BuiltinMemory[int]): ...
  29. class UChar(_BuiltinMemory[int]): ...
  30. class Short(_BuiltinMemory[int]): ...
  31. class UShort(_BuiltinMemory[int]): ...
  32. class Int(_BuiltinMemory[int]): ...
  33. class UInt(_BuiltinMemory[int]): ...
  34. class Long(_BuiltinMemory[int]): ...
  35. class ULong(_BuiltinMemory[int]): ...
  36. class LongLong(_BuiltinMemory[int]): ...
  37. class Float(_BuiltinMemory[float]): ...
  38. class Double(_BuiltinMemory[float]): ...
  39. class Pointer(_BuiltinMemory[intptr]): ...
  40. class Bool(_BuiltinMemory[bool]): ...
  41. INT8: _BuiltinMemory[int]
  42. UINT8: _BuiltinMemory[int]
  43. INT16: _BuiltinMemory[int]
  44. UINT16: _BuiltinMemory[int]
  45. INT32: _BuiltinMemory[int]
  46. UINT32: _BuiltinMemory[int]
  47. INT64: _BuiltinMemory[int]
  48. UINT64: _BuiltinMemory[int]