pkpy.pyi 1.9 KB

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