-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontext.pyi
102 lines (79 loc) · 3.15 KB
/
context.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from typing import Any, Dict, Final, List, Optional
from .objects import BaseNamespace, McdpObject
from .stream import Stream
from .exception import McdpRuntimeError
class Handler:
next: Handler
def __init__(self, next_hdl: Optional[Handler] = None) -> None: ...
def do_handler(self, ctx: "Context", code: Any) -> Any: ...
def next_handler(self, ctx: "Context", code: Any) -> Any: ...
def append(self, hdl: "Handler") -> None: ...
def link_to(self, new_head: "Handler") -> "Handler": ...
def __call__(self, code, *, ctx: Optional["Context"] = None) -> Any: ...
def __iter__(self) -> "HandlerIter": ...
class AnnotateHandler(Handler):
def do_handler(self, ctx: Context, code: Any) -> Any: ...
def link_to(self, new_head: Handler) -> Handler: ...
class HandlerIter:
cur: Final[Handler]
def __init__(self, hdl: Handler) -> None: ...
def __iter__(self) -> "HandlerIter": ...
def __next__(self) -> Handler: ...
class Context(McdpObject):
name: Final[str]
stream: Final[Stream]
namespace: Final[BaseNamespace]
back: Final["Context"]
def __init__(
self,
name: str,
back: Optional["Context"] = None,
*,
namespace: Optional[BaseNamespace] = None,
hdl_chain: Optional[Handler] = None
) -> None: ...
def set_back(self, back: "Context") -> None: ...
def join(self) -> None: ...
def activate(self) -> None: ...
def reactivate(self) -> None: ...
def deactivate(self) -> None: ...
def writable(self) -> bool: ...
def put(self, code: Any) -> None: ...
def get_handler(self) -> List[Handler]: ...
def add_handler(self, hdl: Handler) -> None: ...
def pop_handler(self, hdl: Optional[Handler] = None): ...
def __len__(self) -> int: ...
def __enter__(self) -> "Context": ...
def __exit__(self, exc_type, exc_obj, traceback) -> None: ...
class _AnnotateImpl:
"""
Magic method implement class for context.annotate
Usage:
@namespace.mcfunc
def test_annotate(frame: Frame) -> None:
# as function
annotate(
"This is a test function.",
"Use `annotate()` to add annotates."
)
# as context manager
with annotate:
insert("In this case, use `insert()` instead of `annotate()`.")
frame.var_int = 5
frame.var_int += 2 # This part of compiled mc command will turn into annotates too.
"""
def __init__(self) -> None: ...
def ensure(self) -> bool: ...
def __enter__(self) -> AnnotateHandler: ...
def __exit__(self, exc_type, exc_obj, traceback) -> None: ...
def __call__(self, *annotates: Any) -> None: ...
def init_context(nsp: BaseNamespace) -> Context: ...
def finalize_context() -> None: ...
def get_context() -> Context: ...
def insert(*codes: Any) -> None: ...
def newline(n_line: int = 1) -> None: ...
def _get_ctx_config() -> Dict[str, Any]: ...
def _set_ctx_config(*, max_open: int = ..., max_stack: int = ..., use_annotates: bool = ...) -> None: ...
annotate = _AnnotateImpl()
class McdpContextError(McdpRuntimeError):
context: Final[Context]