pkpy.pyi 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from typing import Self, Literal
  2. from vmath import vec2, vec2i
  3. class TValue[T]:
  4. def __new__(cls, value: T) -> Self: ...
  5. @property
  6. def value(self) -> T: ...
  7. # TValue_int = TValue[int]
  8. # TValue_float = TValue[float]
  9. # TValue_vec2i = TValue[vec2i]
  10. # TValue_vec2 = TValue[vec2]
  11. configmacros: dict[str, int]
  12. def memory_usage() -> str:
  13. """Return a summary of the memory usage."""
  14. def is_user_defined_type(t: type) -> bool:
  15. """Check if a type is user-defined. This means the type was created by executing python `class` statement."""
  16. def enable_full_buffering_mode() -> None:
  17. """Enable full buffering mode for ASCII drawings."""
  18. def currentvm() -> int:
  19. """Return the current VM index."""
  20. def watchdog_begin(timeout: int):
  21. """
  22. Begin the watchdog with `timeout` in milliseconds.
  23. `PK_ENABLE_WATCHDOG` must be defined to `1` to use this feature.
  24. You need to call `watchdog_end()` later.
  25. If `timeout` is reached, `TimeoutError` will be raised.
  26. """
  27. def watchdog_end():
  28. """Reset the watchdog."""
  29. class ComputeThread:
  30. def __init__(self, vm_index: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]): ...
  31. @property
  32. def is_done(self) -> bool:
  33. """Check if the current job is done."""
  34. def wait_for_done(self) -> None:
  35. """Wait for the current job to finish."""
  36. def last_error(self) -> str | None: ...
  37. def last_retval(self): ...
  38. def submit_exec(self, source: str) -> None:
  39. """Submit a job to execute some source code."""
  40. def submit_eval(self, source: str) -> None:
  41. """Submit a job to evaluate some source code."""
  42. def submit_call(self, eval_src: str, *args, **kwargs) -> None:
  43. """Submit a job to call a function with arguments."""
  44. def exec(self, source: str) -> None:
  45. """Directly execute some source code."""
  46. def eval(self, source: str):
  47. """Directly evaluate some source code."""