winrt-runtime 3.2.1__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- winrt/_winrt.cp314-win_amd64.pyd +0 -0
- winrt/_winrt.pyi +204 -0
- winrt/msvcp140.dll +0 -0
- winrt/py.typed +0 -0
- winrt/runtime/__init__.py +21 -0
- winrt/runtime/_internals.py +247 -0
- winrt/runtime/interop.py +3 -0
- winrt/runtime/py.typed +0 -0
- winrt/system/__init__.py +113 -0
- winrt/system/hresult.py +48 -0
- winrt/system/py.typed +0 -0
- winrt_runtime-3.2.1.dist-info/METADATA +20 -0
- winrt_runtime-3.2.1.dist-info/RECORD +15 -0
- winrt_runtime-3.2.1.dist-info/WHEEL +5 -0
- winrt_runtime-3.2.1.dist-info/top_level.txt +1 -0
|
Binary file
|
winrt/_winrt.pyi
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
import array
|
|
3
|
+
from datetime import datetime, timedelta
|
|
4
|
+
import types
|
|
5
|
+
from typing import (
|
|
6
|
+
Any,
|
|
7
|
+
Generic,
|
|
8
|
+
ItemsView,
|
|
9
|
+
Iterable,
|
|
10
|
+
Iterator,
|
|
11
|
+
KeysView,
|
|
12
|
+
List,
|
|
13
|
+
Optional,
|
|
14
|
+
Protocol,
|
|
15
|
+
SupportsIndex,
|
|
16
|
+
Tuple,
|
|
17
|
+
Type,
|
|
18
|
+
TypeVar,
|
|
19
|
+
Union,
|
|
20
|
+
ValuesView,
|
|
21
|
+
overload,
|
|
22
|
+
)
|
|
23
|
+
from uuid import UUID
|
|
24
|
+
|
|
25
|
+
from winrt.runtime import ApartmentType
|
|
26
|
+
|
|
27
|
+
MTA: int
|
|
28
|
+
STA: int
|
|
29
|
+
|
|
30
|
+
def init_apartment(apartment_type: ApartmentType) -> None: ...
|
|
31
|
+
def uninit_apartment() -> None: ...
|
|
32
|
+
def initialize_with_window(obj: Object, hwnd: int) -> None: ...
|
|
33
|
+
def add_dll_directory(path: str) -> int: ...
|
|
34
|
+
def remove_dll_directory(cookie: int) -> None: ...
|
|
35
|
+
def box_boolean(value: bool) -> Object: ...
|
|
36
|
+
def box_int8(value: int) -> Object: ...
|
|
37
|
+
def box_uint8(value: int) -> Object: ...
|
|
38
|
+
def box_int16(value: int) -> Object: ...
|
|
39
|
+
def box_uint16(value: int) -> Object: ...
|
|
40
|
+
def box_int32(value: int) -> Object: ...
|
|
41
|
+
def box_uint32(value: int) -> Object: ...
|
|
42
|
+
def box_int64(value: int) -> Object: ...
|
|
43
|
+
def box_uint64(value: int) -> Object: ...
|
|
44
|
+
def box_single(value: float) -> Object: ...
|
|
45
|
+
def box_double(value: float) -> Object: ...
|
|
46
|
+
def box_char16(value: str) -> Object: ...
|
|
47
|
+
def box_string(value: str) -> Object: ...
|
|
48
|
+
def box_guid(value: UUID) -> Object: ...
|
|
49
|
+
def box_date_time(value: datetime) -> Object: ...
|
|
50
|
+
def box_time_span(value: timedelta) -> Object: ...
|
|
51
|
+
def unbox_boolean(value: Object) -> bool: ...
|
|
52
|
+
def unbox_int8(value: Object) -> int: ...
|
|
53
|
+
def unbox_uint8(value: Object) -> int: ...
|
|
54
|
+
def unbox_int16(value: Object) -> int: ...
|
|
55
|
+
def unbox_uint16(value: Object) -> int: ...
|
|
56
|
+
def unbox_int32(value: Object) -> int: ...
|
|
57
|
+
def unbox_uint32(value: Object) -> int: ...
|
|
58
|
+
def unbox_int64(value: Object) -> int: ...
|
|
59
|
+
def unbox_uint64(value: Object) -> int: ...
|
|
60
|
+
def unbox_single(value: Object) -> float: ...
|
|
61
|
+
def unbox_double(value: Object) -> float: ...
|
|
62
|
+
def unbox_char16(value: Object) -> str: ...
|
|
63
|
+
def unbox_string(value: Object) -> str: ...
|
|
64
|
+
def unbox_guid(value: Object) -> UUID: ...
|
|
65
|
+
def unbox_date_time(value: Object) -> datetime: ...
|
|
66
|
+
def unbox_time_span(value: Object) -> timedelta: ...
|
|
67
|
+
|
|
68
|
+
_Self = TypeVar("_Self")
|
|
69
|
+
_T = TypeVar("_T")
|
|
70
|
+
_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers.
|
|
71
|
+
_KT = TypeVar("_KT")
|
|
72
|
+
_VT = TypeVar("_VT")
|
|
73
|
+
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
|
|
74
|
+
_TObject = TypeVar("_TObject", bound=IInspectable)
|
|
75
|
+
|
|
76
|
+
# these classes don't actually exist but are just used to simplify type checking
|
|
77
|
+
|
|
78
|
+
class IInspectable_Static(type):
|
|
79
|
+
def __instancecheck__(self, instance: Any) -> bool: ...
|
|
80
|
+
|
|
81
|
+
class IInspectable(metaclass=IInspectable_Static):
|
|
82
|
+
@abstractmethod
|
|
83
|
+
def as_(self, type: Type[_TObject], /) -> _TObject: ...
|
|
84
|
+
@property
|
|
85
|
+
@abstractmethod
|
|
86
|
+
def _iids_(self) -> Array[UUID]: ...
|
|
87
|
+
@property
|
|
88
|
+
@abstractmethod
|
|
89
|
+
def _runtime_class_name_(self) -> str: ...
|
|
90
|
+
|
|
91
|
+
class Sequence(Generic[_T_co]):
|
|
92
|
+
# collections.abc.Sequence mixin methods
|
|
93
|
+
def index(self, value: Any, start: int = 0, stop: int = ...) -> int: ...
|
|
94
|
+
def count(self, value: Any) -> int: ...
|
|
95
|
+
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
96
|
+
|
|
97
|
+
class MutableSequence(Sequence[_T]):
|
|
98
|
+
# alias for insert_at
|
|
99
|
+
def insert(self, index: SupportsIndex, value: _T) -> None: ...
|
|
100
|
+
# collections.abc.MutableSequence mixin methods
|
|
101
|
+
def extend(self, values: Iterable[_T]) -> None: ...
|
|
102
|
+
def reverse(self) -> None: ...
|
|
103
|
+
def pop(self, index: int = -1) -> _T: ...
|
|
104
|
+
def remove(self, value: _T) -> None: ...
|
|
105
|
+
def __iadd__(self: _Self, values: Iterable[_T]) -> _Self: ...
|
|
106
|
+
|
|
107
|
+
class Mapping(Generic[_KT, _VT_co]):
|
|
108
|
+
# collections.abc.Mapping mixin methods
|
|
109
|
+
@overload
|
|
110
|
+
def get(self, __key: _KT) -> Optional[_VT_co]: ...
|
|
111
|
+
@overload
|
|
112
|
+
def get(self, __key: _KT, default: _VT_co | _T) -> _VT_co | _T: ...
|
|
113
|
+
def items(self) -> ItemsView[_KT, _VT_co]: ...
|
|
114
|
+
def keys(self) -> KeysView[_KT]: ...
|
|
115
|
+
def values(self) -> ValuesView[_VT_co]: ...
|
|
116
|
+
def __eq__(self, __other: object) -> bool: ...
|
|
117
|
+
|
|
118
|
+
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
|
|
119
|
+
def keys(self) -> Iterable[_KT]: ...
|
|
120
|
+
def __getitem__(self, key: _KT, /) -> _VT_co: ...
|
|
121
|
+
|
|
122
|
+
class MutableMapping(Mapping[_KT, _VT]):
|
|
123
|
+
# collections.abc.MutableMapping mixin methods
|
|
124
|
+
@overload
|
|
125
|
+
def pop(self, __key: _KT) -> _VT: ...
|
|
126
|
+
@overload
|
|
127
|
+
def pop(self, __key: _KT, default: _VT) -> _VT: ...
|
|
128
|
+
@overload
|
|
129
|
+
def pop(self, __key: _KT, default: _T) -> _VT | _T: ...
|
|
130
|
+
def popitem(self) -> Tuple[_KT, _VT]: ...
|
|
131
|
+
@overload
|
|
132
|
+
def setdefault(
|
|
133
|
+
self: MutableMapping[_KT, Optional[_T]], __key: _KT, __default: None = None
|
|
134
|
+
) -> Optional[_T]: ...
|
|
135
|
+
@overload
|
|
136
|
+
def setdefault(self, __key: _KT, __default: _VT) -> _VT: ...
|
|
137
|
+
@overload
|
|
138
|
+
def update(self, m: SupportsKeysAndGetItem[_KT, _VT], /, **kwargs: _VT) -> None: ...
|
|
139
|
+
@overload
|
|
140
|
+
def update(self, m: Iterable[tuple[_KT, _VT]], /, **kwargs: _VT) -> None: ...
|
|
141
|
+
@overload
|
|
142
|
+
def update(self, **kwargs: _VT) -> None: ...
|
|
143
|
+
|
|
144
|
+
# actual runtime classes
|
|
145
|
+
|
|
146
|
+
class Object(IInspectable):
|
|
147
|
+
def as_(self, type: Type[_TObject], /) -> _TObject: ...
|
|
148
|
+
@property
|
|
149
|
+
def _iids_(self) -> Array[UUID]: ...
|
|
150
|
+
@property
|
|
151
|
+
def _runtime_class_name_(self) -> str: ...
|
|
152
|
+
|
|
153
|
+
class Array(MutableSequence[_T]):
|
|
154
|
+
_winrt_element_type_name_: str
|
|
155
|
+
def __class_getitem__(cls, key: Any) -> types.GenericAlias: ...
|
|
156
|
+
@overload
|
|
157
|
+
def __init__(
|
|
158
|
+
self,
|
|
159
|
+
type: Union[Type[_T], str],
|
|
160
|
+
size: int,
|
|
161
|
+
) -> None: ...
|
|
162
|
+
@overload
|
|
163
|
+
def __init__(
|
|
164
|
+
self,
|
|
165
|
+
type: Union[Type[_T], str],
|
|
166
|
+
initializer: memoryview,
|
|
167
|
+
) -> None: ...
|
|
168
|
+
@overload
|
|
169
|
+
def __init__(self, type: str, initializer: array.array) -> None: ...
|
|
170
|
+
@overload
|
|
171
|
+
def __init__(
|
|
172
|
+
self,
|
|
173
|
+
type: Union[Type[_T], str],
|
|
174
|
+
initializer: Array[_T],
|
|
175
|
+
) -> None: ...
|
|
176
|
+
@overload
|
|
177
|
+
def __init__(
|
|
178
|
+
self,
|
|
179
|
+
type: Union[Type[_T], str],
|
|
180
|
+
initializer: List[_T],
|
|
181
|
+
/,
|
|
182
|
+
) -> None: ...
|
|
183
|
+
@overload
|
|
184
|
+
def __init__(
|
|
185
|
+
self,
|
|
186
|
+
__type: Union[Type[_T], str],
|
|
187
|
+
__initializer: Tuple[_T],
|
|
188
|
+
) -> None: ...
|
|
189
|
+
def __buffer__(self, flags: int, /) -> memoryview: ...
|
|
190
|
+
def __release_buffer__(self, view: memoryview, /) -> None: ...
|
|
191
|
+
def __len__(self) -> int: ...
|
|
192
|
+
@overload
|
|
193
|
+
def __getitem__(self, index: SupportsIndex) -> _T: ...
|
|
194
|
+
@overload
|
|
195
|
+
def __getitem__(self, index: slice) -> MutableSequence[_T]: ...
|
|
196
|
+
@overload
|
|
197
|
+
def __setitem__(self, index: SupportsIndex, value: _T) -> None: ...
|
|
198
|
+
@overload
|
|
199
|
+
def __setitem__(self, index: slice, value: Iterable[_T]) -> None: ...
|
|
200
|
+
@overload
|
|
201
|
+
def __delitem__(self, index: SupportsIndex) -> None: ...
|
|
202
|
+
@overload
|
|
203
|
+
def __delitem__(self, index: slice) -> None: ...
|
|
204
|
+
def __iter__(self) -> Iterator[_T]: ...
|
winrt/msvcp140.dll
ADDED
|
Binary file
|
winrt/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
from winrt._winrt import init_apartment, uninit_apartment, STA, MTA
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
__all__ = ["ApartmentType", "init_apartment", "uninit_apartment"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ApartmentType(IntEnum):
|
|
10
|
+
"""
|
|
11
|
+
Enumeration of COM apartment types.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
SINGLE_THREADED = STA
|
|
15
|
+
"""
|
|
16
|
+
Single-threaded apartment.
|
|
17
|
+
"""
|
|
18
|
+
MULTI_THREADED = MTA
|
|
19
|
+
"""
|
|
20
|
+
Multi-threaded apartment.
|
|
21
|
+
"""
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
from collections.abc import (
|
|
4
|
+
Awaitable,
|
|
5
|
+
Callable,
|
|
6
|
+
Mapping,
|
|
7
|
+
MutableMapping,
|
|
8
|
+
MutableSequence,
|
|
9
|
+
Sequence,
|
|
10
|
+
)
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import sys
|
|
13
|
+
from typing import Any, TypeVar, Protocol, TYPE_CHECKING
|
|
14
|
+
|
|
15
|
+
from typing_extensions import Self
|
|
16
|
+
|
|
17
|
+
# NB: have to import Object from here instead of winrt.system to avoid circular import issues.
|
|
18
|
+
from winrt._winrt import add_dll_directory, remove_dll_directory, Object
|
|
19
|
+
|
|
20
|
+
# Unfortunately, we can't import at runtime because of circular imports.
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from winrt.windows.foundation import HResult, AsyncStatus
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _DllCookie:
|
|
26
|
+
def __init__(self, cookie: int) -> None:
|
|
27
|
+
self.cookie = cookie
|
|
28
|
+
|
|
29
|
+
def close(self):
|
|
30
|
+
if self.cookie:
|
|
31
|
+
remove_dll_directory(self.cookie)
|
|
32
|
+
self.cookie = None
|
|
33
|
+
|
|
34
|
+
def __del__(self):
|
|
35
|
+
self.close()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def register_dll_search_path(module_path: str) -> _DllCookie:
|
|
39
|
+
"""
|
|
40
|
+
Register a module's directory as a DLL search path.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
module_path: The path to a module file (i.e. ``__file__``)
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
An cookie object that will remove the search path when closed.
|
|
47
|
+
"""
|
|
48
|
+
return _DllCookie(add_dll_directory(os.fspath(Path(module_path).parent.resolve())))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# NB: The types implemented in C cannot inherit from abc.ABC since Python 3.12
|
|
52
|
+
# so we have to implement the protocols like this instead.
|
|
53
|
+
# https://github.com/python/cpython/issues/103968#issuecomment-1589928055
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def mixin_sequence(typ: type) -> None:
|
|
57
|
+
"""
|
|
58
|
+
Adds missing Python mapping methods to types that implement IVectorView and
|
|
59
|
+
registers the type as a Sequence.
|
|
60
|
+
"""
|
|
61
|
+
# mixin methods
|
|
62
|
+
if not hasattr(typ, "index"):
|
|
63
|
+
typ.index = Sequence.index # type: ignore
|
|
64
|
+
|
|
65
|
+
if not hasattr(typ, "count"):
|
|
66
|
+
typ.count = Sequence.count # type: ignore
|
|
67
|
+
|
|
68
|
+
if not hasattr(typ, "__contains__"):
|
|
69
|
+
typ.__contains__ = Sequence.__contains__ # type: ignore
|
|
70
|
+
|
|
71
|
+
if not hasattr(typ, "__iter__"):
|
|
72
|
+
typ.__iter__ = Sequence.__iter__ # type: ignore
|
|
73
|
+
|
|
74
|
+
if not hasattr(typ, "__reversed__"):
|
|
75
|
+
typ.__reversed__ = Sequence.__reversed__ # type: ignore
|
|
76
|
+
|
|
77
|
+
Sequence.register(typ)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def mixin_mutable_sequence(typ: type) -> None:
|
|
81
|
+
"""
|
|
82
|
+
Adds missing Python mapping methods to types that implement IVector and
|
|
83
|
+
registers the type as a MutableSequence.
|
|
84
|
+
"""
|
|
85
|
+
mixin_sequence(typ)
|
|
86
|
+
|
|
87
|
+
if not hasattr(typ, "insert") and hasattr(typ, "insert_at"):
|
|
88
|
+
|
|
89
|
+
def insert(self: Any, index: int, value: object) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Alias for ``insert_at`` for compatibility with Python Sequence protocol.
|
|
92
|
+
"""
|
|
93
|
+
self.insert_at(index, value)
|
|
94
|
+
|
|
95
|
+
typ.insert = insert # type: ignore
|
|
96
|
+
|
|
97
|
+
# mixin methods
|
|
98
|
+
if not hasattr(typ, "append"):
|
|
99
|
+
typ.append = MutableSequence.append # type: ignore
|
|
100
|
+
|
|
101
|
+
if not hasattr(typ, "clear"):
|
|
102
|
+
typ.clear = MutableSequence.clear # type: ignore
|
|
103
|
+
|
|
104
|
+
if not hasattr(typ, "extend"):
|
|
105
|
+
typ.extend = MutableSequence.extend # type: ignore
|
|
106
|
+
|
|
107
|
+
if not hasattr(typ, "reverse"):
|
|
108
|
+
typ.reverse = MutableSequence.reverse # type: ignore
|
|
109
|
+
|
|
110
|
+
if not hasattr(typ, "pop"):
|
|
111
|
+
typ.pop = MutableSequence.pop # type: ignore
|
|
112
|
+
|
|
113
|
+
if not hasattr(typ, "remove"):
|
|
114
|
+
typ.remove = MutableSequence.remove # type: ignore
|
|
115
|
+
|
|
116
|
+
if not hasattr(typ, "__iadd__"):
|
|
117
|
+
typ.__iadd__ = MutableSequence.__iadd__ # type: ignore
|
|
118
|
+
|
|
119
|
+
MutableSequence.register(typ)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def mixin_mapping(typ: type) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Adds missing Python mapping methods to types that implement IMapView and
|
|
125
|
+
registers the type as a Mapping.
|
|
126
|
+
"""
|
|
127
|
+
# mixin methods
|
|
128
|
+
if not hasattr(typ, "keys"):
|
|
129
|
+
typ.keys = Mapping.keys # type: ignore
|
|
130
|
+
|
|
131
|
+
if not hasattr(typ, "items"):
|
|
132
|
+
typ.items = Mapping.items # type: ignore
|
|
133
|
+
|
|
134
|
+
if not hasattr(typ, "values"):
|
|
135
|
+
typ.values = Mapping.values # type: ignore
|
|
136
|
+
|
|
137
|
+
if not hasattr(typ, "get"):
|
|
138
|
+
typ.get = Mapping.get # type: ignore
|
|
139
|
+
|
|
140
|
+
if not hasattr(typ, "__contains__"):
|
|
141
|
+
typ.__contains__ = Mapping.__contains__ # type: ignore
|
|
142
|
+
|
|
143
|
+
# HACK: Version check works around inheritance anomaly caused by hacky
|
|
144
|
+
# metaclass inheritance implementation in runtime.cpp. This works as long
|
|
145
|
+
# as we don't change the projection to implement rich comparison methods
|
|
146
|
+
# on mapping types.
|
|
147
|
+
|
|
148
|
+
if (
|
|
149
|
+
typ.__eq__ == object.__eq__
|
|
150
|
+
or typ.__eq__ == Object.__eq__
|
|
151
|
+
or sys.version_info < (3, 12)
|
|
152
|
+
):
|
|
153
|
+
typ.__eq__ = Mapping.__eq__ # type: ignore
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
typ.__ne__ == object.__ne__
|
|
157
|
+
or typ.__ne__ == Object.__ne__
|
|
158
|
+
or sys.version_info < (3, 12)
|
|
159
|
+
):
|
|
160
|
+
typ.__ne__ = Mapping.__ne__ # type: ignore
|
|
161
|
+
|
|
162
|
+
Mapping.register(typ)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def mixin_mutable_mapping(typ: type) -> None:
|
|
166
|
+
"""
|
|
167
|
+
Adds missing Python mapping methods to types that implement IMap and
|
|
168
|
+
registers the type as a MutableMapping.
|
|
169
|
+
"""
|
|
170
|
+
mixin_mapping(typ)
|
|
171
|
+
|
|
172
|
+
# mixin methods
|
|
173
|
+
if not hasattr(typ, "clear"):
|
|
174
|
+
typ.clear = MutableMapping.clear # type: ignore
|
|
175
|
+
|
|
176
|
+
if not hasattr(typ, "pop"):
|
|
177
|
+
typ.pop = MutableMapping.pop # type: ignore
|
|
178
|
+
# private-name-mangled attribute :-(
|
|
179
|
+
typ._MutableMapping__marker = MutableMapping._MutableMapping__marker # type: ignore
|
|
180
|
+
|
|
181
|
+
if not hasattr(typ, "popitem"):
|
|
182
|
+
typ.popitem = MutableMapping.popitem # type: ignore
|
|
183
|
+
|
|
184
|
+
if not hasattr(typ, "setdefault"):
|
|
185
|
+
typ.setdefault = MutableMapping.setdefault # type: ignore
|
|
186
|
+
|
|
187
|
+
if not hasattr(typ, "update"):
|
|
188
|
+
typ.update = MutableMapping.update # type: ignore
|
|
189
|
+
|
|
190
|
+
MutableMapping.register(typ)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
T = TypeVar("T")
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# MyPy wants covariant T but Pylance wants invariant. Invariant seems correct.
|
|
197
|
+
class AsyncOp(Protocol[T]): # type: ignore [misc]
|
|
198
|
+
"""
|
|
199
|
+
Protocol that matches both IAsyncAction and IAsyncOperation.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
def cancel(self) -> None: ...
|
|
203
|
+
@property
|
|
204
|
+
def error_code(self) -> "HResult": ...
|
|
205
|
+
@property
|
|
206
|
+
def status(self) -> "AsyncStatus": ...
|
|
207
|
+
def get_results(self) -> T: ...
|
|
208
|
+
@property
|
|
209
|
+
def completed(self) -> Callable[[Self, "AsyncStatus"], None]: ...
|
|
210
|
+
@completed.setter
|
|
211
|
+
def completed(self, value: Callable[[Self, "AsyncStatus"], None]) -> None: ...
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def wrap_async(op: AsyncOp[T]) -> Awaitable[T]:
|
|
215
|
+
"""
|
|
216
|
+
Wraps a WinRT async operation in a Python Awaitable.
|
|
217
|
+
|
|
218
|
+
This is used by the runtime to implement ``__await__`` on async operations.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
op: The WinRT async operation to wrap.
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
An asyncio Awaitable that will be completed when the WinRT operation
|
|
225
|
+
completes.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
async def wait() -> T:
|
|
229
|
+
loop = asyncio.get_running_loop()
|
|
230
|
+
event = asyncio.Event()
|
|
231
|
+
|
|
232
|
+
def on_complete(op: AsyncOp[T], status: "AsyncStatus") -> None:
|
|
233
|
+
loop.call_soon_threadsafe(event.set)
|
|
234
|
+
|
|
235
|
+
op.completed = on_complete
|
|
236
|
+
|
|
237
|
+
try:
|
|
238
|
+
await event.wait()
|
|
239
|
+
except asyncio.CancelledError:
|
|
240
|
+
op.cancel()
|
|
241
|
+
# REVISIT: what if it is cancelled again?
|
|
242
|
+
await event.wait()
|
|
243
|
+
raise
|
|
244
|
+
|
|
245
|
+
return op.get_results()
|
|
246
|
+
|
|
247
|
+
return wait()
|
winrt/runtime/interop.py
ADDED
winrt/runtime/py.typed
ADDED
|
File without changes
|
winrt/system/__init__.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
from typing import Annotated
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Buffer, TypeAlias
|
|
4
|
+
|
|
5
|
+
from winrt._winrt import (
|
|
6
|
+
Array,
|
|
7
|
+
Object,
|
|
8
|
+
box_boolean,
|
|
9
|
+
box_char16,
|
|
10
|
+
box_date_time,
|
|
11
|
+
box_double,
|
|
12
|
+
box_guid,
|
|
13
|
+
box_int8,
|
|
14
|
+
box_int16,
|
|
15
|
+
box_int32,
|
|
16
|
+
box_int64,
|
|
17
|
+
box_single,
|
|
18
|
+
box_string,
|
|
19
|
+
box_time_span,
|
|
20
|
+
box_uint8,
|
|
21
|
+
box_uint16,
|
|
22
|
+
box_uint32,
|
|
23
|
+
box_uint64,
|
|
24
|
+
unbox_boolean,
|
|
25
|
+
unbox_char16,
|
|
26
|
+
unbox_date_time,
|
|
27
|
+
unbox_double,
|
|
28
|
+
unbox_guid,
|
|
29
|
+
unbox_int8,
|
|
30
|
+
unbox_int16,
|
|
31
|
+
unbox_int32,
|
|
32
|
+
unbox_int64,
|
|
33
|
+
unbox_single,
|
|
34
|
+
unbox_string,
|
|
35
|
+
unbox_time_span,
|
|
36
|
+
unbox_uint8,
|
|
37
|
+
unbox_uint16,
|
|
38
|
+
unbox_uint32,
|
|
39
|
+
unbox_uint64,
|
|
40
|
+
)
|
|
41
|
+
import winrt.runtime._internals
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# type aliases with struct format string annotation
|
|
45
|
+
Int8 = Annotated[int, "b"]
|
|
46
|
+
UInt8 = Annotated[int, "B"]
|
|
47
|
+
Int16 = Annotated[int, "h"]
|
|
48
|
+
UInt16 = Annotated[int, "H"]
|
|
49
|
+
Int32 = Annotated[int, "i"]
|
|
50
|
+
UInt32 = Annotated[int, "I"]
|
|
51
|
+
Int64 = Annotated[int, "q"]
|
|
52
|
+
UInt64 = Annotated[int, "Q"]
|
|
53
|
+
Single = Annotated[float, "f"]
|
|
54
|
+
Double = Annotated[float, "d"]
|
|
55
|
+
Char16 = Annotated[str, "u"]
|
|
56
|
+
|
|
57
|
+
winrt.runtime._internals.mixin_mutable_sequence(Array)
|
|
58
|
+
|
|
59
|
+
# Type hints for Python buffer protocol - can use standard Python types in
|
|
60
|
+
# addition to the WinRT Array.
|
|
61
|
+
ReadableBuffer: TypeAlias = Buffer # WinRT PassArray
|
|
62
|
+
WriteableBuffer: TypeAlias = Buffer # WinRT FillArray
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"Int8",
|
|
67
|
+
"UInt8",
|
|
68
|
+
"Int16",
|
|
69
|
+
"UInt16",
|
|
70
|
+
"Int32",
|
|
71
|
+
"UInt32",
|
|
72
|
+
"Int64",
|
|
73
|
+
"UInt64",
|
|
74
|
+
"Single",
|
|
75
|
+
"Double",
|
|
76
|
+
"Char16",
|
|
77
|
+
"Object",
|
|
78
|
+
"Array",
|
|
79
|
+
"ReadableBuffer",
|
|
80
|
+
"WriteableBuffer",
|
|
81
|
+
"box_boolean",
|
|
82
|
+
"box_int8",
|
|
83
|
+
"box_uint8",
|
|
84
|
+
"box_int16",
|
|
85
|
+
"box_uint16",
|
|
86
|
+
"box_int32",
|
|
87
|
+
"box_uint32",
|
|
88
|
+
"box_int64",
|
|
89
|
+
"box_uint64",
|
|
90
|
+
"box_single",
|
|
91
|
+
"box_double",
|
|
92
|
+
"box_char16",
|
|
93
|
+
"box_string",
|
|
94
|
+
"box_guid",
|
|
95
|
+
"box_date_time",
|
|
96
|
+
"box_time_span",
|
|
97
|
+
"unbox_boolean",
|
|
98
|
+
"unbox_int8",
|
|
99
|
+
"unbox_uint8",
|
|
100
|
+
"unbox_int16",
|
|
101
|
+
"unbox_uint16",
|
|
102
|
+
"unbox_int32",
|
|
103
|
+
"unbox_uint32",
|
|
104
|
+
"unbox_int64",
|
|
105
|
+
"unbox_uint64",
|
|
106
|
+
"unbox_single",
|
|
107
|
+
"unbox_double",
|
|
108
|
+
"unbox_char16",
|
|
109
|
+
"unbox_string",
|
|
110
|
+
"unbox_guid",
|
|
111
|
+
"unbox_date_time",
|
|
112
|
+
"unbox_time_span",
|
|
113
|
+
]
|
winrt/system/hresult.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from ctypes import HRESULT as _HRESULT
|
|
2
|
+
|
|
3
|
+
"""Common HRESULT error codes."""
|
|
4
|
+
|
|
5
|
+
# NB: have to use ctypes.HRESULT to convert unsigned values to signed int
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
|
|
9
|
+
_ERROR_FILE_NOT_FOUND = 2
|
|
10
|
+
|
|
11
|
+
# https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-
|
|
12
|
+
_ERROR_CANCELLED = 1223
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# https://learn.microsoft.com/en-us/windows/win32/api/winerror/nf-winerror-hresult_facility
|
|
16
|
+
_FACILITY_WIN32 = 7
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# https://learn.microsoft.com/en-us/windows/win32/api/winerror/nf-winerror-hresult_from_win32
|
|
20
|
+
def _HRESULT_FROM_WIN32(error_code: int) -> _HRESULT:
|
|
21
|
+
x = _HRESULT(error_code).value
|
|
22
|
+
return _HRESULT(
|
|
23
|
+
x if x <= 0 else ((x & 0x0000FFFF) | (_FACILITY_WIN32 << 16) | 0x80000000)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# common errors from CppWinRT
|
|
28
|
+
S_OK = 0
|
|
29
|
+
E_FAIL = _HRESULT(0x80004005).value
|
|
30
|
+
E_ACCESSDENIED = _HRESULT(0x80070005).value
|
|
31
|
+
E_NOTIMPL = _HRESULT(0x80004001).value
|
|
32
|
+
E_INVALIDARG = _HRESULT(0x80070057).value
|
|
33
|
+
E_BOUNDS = _HRESULT(0x8000000B).value
|
|
34
|
+
E_NOINTERFACE = _HRESULT(0x80004002).value
|
|
35
|
+
E_CHANGED_STATE = _HRESULT(0x8000000C).value
|
|
36
|
+
E_ILLEGAL_METHOD_CALL = _HRESULT(0x8000000E).value
|
|
37
|
+
E_ILLEGAL_STATE_CHANGE = _HRESULT(0x8000000D).value
|
|
38
|
+
E_ILLEGAL_DELEGATE_ASSIGNMENT = _HRESULT(0x80000018).value
|
|
39
|
+
E_OUTOFMEMORY = _HRESULT(0x8007000E).value
|
|
40
|
+
CLASS_E_CLASSNOTAVAILABLE = _HRESULT(0x80040111).value
|
|
41
|
+
CO_E_NOTINITIALIZED = _HRESULT(0x800401F0).value
|
|
42
|
+
REGDB_E_CLASSNOTREG = _HRESULT(0x80040154).value
|
|
43
|
+
RPC_E_WRONG_THREAD = _HRESULT(0x8001010E).value
|
|
44
|
+
WIN32_ERROR_FILE_NOT_FOUND = _HRESULT_FROM_WIN32(_ERROR_FILE_NOT_FOUND).value
|
|
45
|
+
WIN32_ERROR_CANCELLED = _HRESULT_FROM_WIN32(_ERROR_CANCELLED).value
|
|
46
|
+
|
|
47
|
+
# Errors defined by PyWinRT
|
|
48
|
+
PYWINRT_E_UNRAISABLE_PYTHON_EXCEPTION = _HRESULT(0xA0EE4005).value
|
winrt/system/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winrt-runtime
|
|
3
|
+
Version: 3.2.1
|
|
4
|
+
Summary: Python projection of Windows Runtime (WinRT) APIs
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Documentation, https://pywinrt.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/pywinrt/pywinrt
|
|
8
|
+
Project-URL: Changelog, https://github.com/pywinrt/pywinrt/blob/main/CHANGELOG.md
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
Requires-Dist: typing_extensions>=4.12.2
|
|
16
|
+
|
|
17
|
+
# winrt-runtime
|
|
18
|
+
|
|
19
|
+
This package provides the PyWinRT runtime including the `winrt.system` module.
|
|
20
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
winrt/_winrt.cp314-win_amd64.pyd,sha256=WiCsPsLQXzNhCxE4Ri4OgaNxEDqBRtqaHKCpNYDyFXM,136192
|
|
2
|
+
winrt/_winrt.pyi,sha256=VXsxaX7eY1WXXET8YAgICfSC241dPdKBIOLWQX5ZekE,6719
|
|
3
|
+
winrt/msvcp140.dll,sha256=dYcsQmVVrIr1W1p_bUrqiDGvdDU7ImEoUKK_xA47Z-E,567352
|
|
4
|
+
winrt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
winrt/runtime/__init__.py,sha256=wooCBSTk7sHWfJQTc0p7VtYfn5R5MCMrR1BmEd6amDc,395
|
|
6
|
+
winrt/runtime/_internals.py,sha256=ridFxQhjmTg69mA5PenYbj0o75jc84pwSTKHmtGEwos,7092
|
|
7
|
+
winrt/runtime/interop.py,sha256=N5os9rMKR-HeLPJiS2XTm7fJcZckL5jXr8l_cWk5D9k,86
|
|
8
|
+
winrt/runtime/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
winrt/system/__init__.py,sha256=vJmG-bSJ3Z48y7PAz6th5cTYwjATIHMTpmlaBRN6qVI,2190
|
|
10
|
+
winrt/system/hresult.py,sha256=hpK6pRSVRc8qk1JfRkwelnpkUDtvJ8MZrB6vfCc7c7k,1757
|
|
11
|
+
winrt/system/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
winrt_runtime-3.2.1.dist-info/METADATA,sha256=AVwSmar_KVyrisTxjNlGsFLZ6pyCxYt5X7pUh3fK0K4,780
|
|
13
|
+
winrt_runtime-3.2.1.dist-info/WHEEL,sha256=7k6Wcy588iJYe5lf5K095NLg-uoBTnE-T8eHJ92G4_4,101
|
|
14
|
+
winrt_runtime-3.2.1.dist-info/top_level.txt,sha256=BzwQb4dZRt0NxCXi10ARjWsox7Asmtf_lXrw_KR-D_E,6
|
|
15
|
+
winrt_runtime-3.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
winrt
|