comtypes 1.4.7__zip → 1.4.9__zip
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.
- {comtypes-1.4.7 → comtypes-1.4.9}/CHANGES.txt +39 -0
- {comtypes-1.4.7/comtypes.egg-info → comtypes-1.4.9}/PKG-INFO +6 -4
- {comtypes-1.4.7 → comtypes-1.4.9}/README.md +5 -3
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/GUID.py +6 -5
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/__init__.py +16 -5
- comtypes-1.4.9/comtypes/_comobject.py +507 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_memberspec.py +81 -9
- comtypes-1.4.9/comtypes/_meta.py +95 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_npsupport.py +2 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/__init__.py +1 -0
- comtypes-1.4.9/comtypes/_post_coinit/_cominterface_meta_patcher.py +153 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/misc.py +21 -40
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/unknwn.py +88 -209
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_safearray.py +1 -2
- comtypes-1.4.9/comtypes/_vtbl.py +448 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/automation.py +36 -45
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/__init__.py +21 -31
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_code_cache.py +5 -4
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_constants.py +1 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_events.py +1 -2
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_generate.py +9 -13
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/lazybind.py +2 -7
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/errorinfo.py +3 -3
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/git.py +2 -2
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hints.pyi +11 -19
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/persist.py +7 -7
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/safearray.py +12 -6
- comtypes-1.4.9/comtypes/server/__init__.py +86 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/inprocserver.py +22 -17
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/localserver.py +28 -16
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/register.py +62 -73
- comtypes-1.4.9/comtypes/server/w_getopt.py +48 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/shelllink.py +49 -67
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.py +1 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.py +1 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/__init__.py +9 -12
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/find_memleak.py +0 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_BSTR.py +4 -7
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_agilent.py +0 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_avmc.py +1 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_casesensitivity.py +3 -5
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_clear_cache.py +1 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_collections.py +3 -3
- comtypes-1.4.9/comtypes/test/test_comobject.py +146 -0
- comtypes-1.4.9/comtypes/test/test_comserver.py +319 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_createwrappers.py +2 -6
- comtypes-1.4.9/comtypes/test/test_dispinterface.py +153 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_excel.py +22 -13
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ie.py +2 -5
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_inout_args.py +8 -5
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_midl_safearray_create.py +9 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_outparam.py +17 -10
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_safearray.py +1 -90
- comtypes-1.4.9/comtypes/test/test_server.py +350 -0
- comtypes-1.4.9/comtypes/test/test_server_register.py +536 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_shelllink.py +10 -14
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_showevents.py +7 -17
- comtypes-1.4.9/comtypes/test/test_stream.py +131 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeannotator.py +1 -1
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_urlhistory.py +1 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_variant.py +0 -19
- comtypes-1.4.9/comtypes/test/test_w_getopt.py +29 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_win32com_interop.py +80 -36
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_wmi.py +0 -3
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/codegenerator.py +62 -68
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/helpers.py +8 -8
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/namespaces.py +97 -27
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/packing.py +4 -4
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/typeannotator.py +9 -11
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/tlbparser.py +33 -32
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc.py +3 -8
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/typeinfo.py +32 -47
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/util.py +1 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/viewobject.py +1 -5
- {comtypes-1.4.7 → comtypes-1.4.9/comtypes.egg-info}/PKG-INFO +6 -4
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/SOURCES.txt +6 -3
- comtypes-1.4.9/pyproject.toml +55 -0
- comtypes-1.4.7/comtypes/_comobject.py +0 -834
- comtypes-1.4.7/comtypes/_idl_stuff.py +0 -67
- comtypes-1.4.7/comtypes/_meta.py +0 -70
- comtypes-1.4.7/comtypes/server/__init__.py +0 -69
- comtypes-1.4.7/comtypes/server/w_getopt.py +0 -75
- comtypes-1.4.7/comtypes/test/test_comserver.py +0 -239
- comtypes-1.4.7/comtypes/test/test_dispinterface.py +0 -138
- comtypes-1.4.7/comtypes/test/test_propputref.py +0 -40
- comtypes-1.4.7/comtypes/test/test_server.py +0 -348
- comtypes-1.4.7/comtypes/test/test_stream.py +0 -53
- comtypes-1.4.7/pyproject.toml +0 -3
- {comtypes-1.4.7 → comtypes-1.4.9}/LICENSE.txt +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/MANIFEST.in +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/bstr.py +0 -0
- /comtypes-1.4.7/comtypes/_py_instance_method.py → /comtypes-1.4.9/comtypes/_post_coinit/instancemethod.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hresult.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/logutil.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/messageloop.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/patcher.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/stream.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_records.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_safearrays.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_monikers.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_persist.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_recordinfo.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_storage.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/setup.cfg +0 -0
- {comtypes-1.4.7 → comtypes-1.4.9}/setup.py +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# comtypes._meta helper module
|
|
2
|
+
from ctypes import POINTER, c_void_p, cast
|
|
3
|
+
import comtypes
|
|
4
|
+
|
|
5
|
+
################################################################
|
|
6
|
+
# metaclass for CoClass (in comtypes/__init__.py)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _wrap_coclass(self):
|
|
10
|
+
# We are an IUnknown pointer, represented as a c_void_p instance,
|
|
11
|
+
# but we really want this interface:
|
|
12
|
+
itf = self._com_interfaces_[0]
|
|
13
|
+
punk = cast(self, POINTER(itf))
|
|
14
|
+
result = punk.QueryInterface(itf)
|
|
15
|
+
result.__dict__["__clsid"] = str(self._reg_clsid_)
|
|
16
|
+
return result
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _coclass_from_param(cls, obj):
|
|
20
|
+
if isinstance(obj, (cls._com_interfaces_[0], cls)):
|
|
21
|
+
return obj
|
|
22
|
+
raise TypeError(obj)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# The mro() of a POINTER(App) type, where class App is a subclass of CoClass:
|
|
27
|
+
#
|
|
28
|
+
# POINTER(App)
|
|
29
|
+
# App
|
|
30
|
+
# CoClass
|
|
31
|
+
# c_void_p
|
|
32
|
+
# _SimpleCData
|
|
33
|
+
# _CData
|
|
34
|
+
# object
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _coclass_meta(type):
|
|
38
|
+
# metaclass for CoClass
|
|
39
|
+
#
|
|
40
|
+
# When a CoClass subclass is created, create a POINTER(...) type
|
|
41
|
+
# for that class, with bases <coclass> and c_void_p. Also, the
|
|
42
|
+
# POINTER(...) type gets a __ctypes_from_outparam__ method which
|
|
43
|
+
# will QueryInterface for the default interface: the first one on
|
|
44
|
+
# the coclass' _com_interfaces_ list.
|
|
45
|
+
def __new__(cls, name, bases, namespace):
|
|
46
|
+
self = type.__new__(cls, name, bases, namespace)
|
|
47
|
+
if bases == (object,):
|
|
48
|
+
# HACK: Could this conditional branch be removed since it is never reached?
|
|
49
|
+
# Since definition is `class CoClass(COMObject, metaclass=_coclass_meta)`,
|
|
50
|
+
# the `bases` parameter passed to the `_coclass_meta.__new__` would be
|
|
51
|
+
# `(COMObject,)`.
|
|
52
|
+
# Moreover, since the `COMObject` derives from `object` and does not specify
|
|
53
|
+
# a metaclass, `(object,)` will not be passed as the `bases` parameter
|
|
54
|
+
# to the `_coclass_meta.__new__`.
|
|
55
|
+
# The reason for this implementation might be a remnant of the differences
|
|
56
|
+
# in how metaclasses work between Python 3.x and Python 2.x.
|
|
57
|
+
# If there are no problems with the versions of Python that `comtypes`
|
|
58
|
+
# supports, this removal could make the process flow easier to understand.
|
|
59
|
+
return self
|
|
60
|
+
# XXX We should insist that a _reg_clsid_ is present.
|
|
61
|
+
if "_reg_clsid_" in namespace:
|
|
62
|
+
clsid = namespace["_reg_clsid_"]
|
|
63
|
+
comtypes.com_coclass_registry[str(clsid)] = self
|
|
64
|
+
|
|
65
|
+
# `_coclass_pointer_meta` is a subclass inherited from `_coclass_meta`.
|
|
66
|
+
# In other words, when the `__new__` method of this metaclass is called, an
|
|
67
|
+
# instance of `_coclass_pointer_meta` might be created and assigned to `self`.
|
|
68
|
+
if isinstance(self, _coclass_pointer_meta):
|
|
69
|
+
# `self` is the `_coclass_pointer_meta` type or a `POINTER(coclass)` type.
|
|
70
|
+
# Prevent creating/registering a pointer to a pointer (to a pointer...),
|
|
71
|
+
# or specifying the metaclass type instance in the `bases` parameter when
|
|
72
|
+
# instantiating it, which would lead to infinite recursion.
|
|
73
|
+
# Depending on a version or revision of Python, this may be essential.
|
|
74
|
+
return self
|
|
75
|
+
|
|
76
|
+
PTR = _coclass_pointer_meta(
|
|
77
|
+
f"POINTER({self.__name__})",
|
|
78
|
+
(self, c_void_p),
|
|
79
|
+
{
|
|
80
|
+
"__ctypes_from_outparam__": _wrap_coclass,
|
|
81
|
+
"from_param": classmethod(_coclass_from_param),
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
from ctypes import _pointer_type_cache # type: ignore
|
|
85
|
+
|
|
86
|
+
_pointer_type_cache[self] = PTR
|
|
87
|
+
|
|
88
|
+
return self
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# will not work if we change the order of the two base classes!
|
|
92
|
+
class _coclass_pointer_meta(type(c_void_p), _coclass_meta):
|
|
93
|
+
# metaclass for CoClass pointer
|
|
94
|
+
|
|
95
|
+
pass # no functionality, but needed to avoid a metaclass conflict
|
|
@@ -12,4 +12,5 @@ This subpackage is called simultaneously with the initialization of `comtypes`.
|
|
|
12
12
|
So it is necessary to maintain minimal settings to keep the lightweight action
|
|
13
13
|
when the package is initialized.
|
|
14
14
|
"""
|
|
15
|
+
|
|
15
16
|
from comtypes._post_coinit.unknwn import _shutdown # noqa
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import types
|
|
2
|
+
from _ctypes import COMError
|
|
3
|
+
from typing import Type
|
|
4
|
+
|
|
5
|
+
from comtypes import patcher
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
_all_slice = slice(None, None, None)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def case_insensitive(p: Type) -> None:
|
|
12
|
+
@patcher.Patch(p)
|
|
13
|
+
class CaseInsensitive(object):
|
|
14
|
+
# case insensitive attributes for COM methods and properties
|
|
15
|
+
def __getattr__(self, name):
|
|
16
|
+
"""Implement case insensitive access to methods and properties"""
|
|
17
|
+
try:
|
|
18
|
+
fixed_name = self.__map_case__[name.lower()]
|
|
19
|
+
except KeyError:
|
|
20
|
+
raise AttributeError(name) # Should we use exception-chaining?
|
|
21
|
+
if fixed_name != name: # prevent unbounded recursion
|
|
22
|
+
return getattr(self, fixed_name)
|
|
23
|
+
raise AttributeError(name)
|
|
24
|
+
|
|
25
|
+
# __setattr__ is pretty heavy-weight, because it is called for
|
|
26
|
+
# EVERY attribute assignment. Settings a non-com attribute
|
|
27
|
+
# through this function takes 8.6 usec, while without this
|
|
28
|
+
# function it takes 0.7 sec - 12 times slower.
|
|
29
|
+
#
|
|
30
|
+
# How much faster would this be if implemented in C?
|
|
31
|
+
def __setattr__(self, name, value):
|
|
32
|
+
"""Implement case insensitive access to methods and properties"""
|
|
33
|
+
object.__setattr__(self, self.__map_case__.get(name.lower(), name), value)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def reference_fix(pp: Type) -> None:
|
|
37
|
+
@patcher.Patch(pp)
|
|
38
|
+
class ReferenceFix(object):
|
|
39
|
+
def __setitem__(self, index, value):
|
|
40
|
+
# We override the __setitem__ method of the
|
|
41
|
+
# POINTER(POINTER(interface)) type, so that the COM
|
|
42
|
+
# reference count is managed correctly.
|
|
43
|
+
#
|
|
44
|
+
# This is so that we can implement COM methods that have to
|
|
45
|
+
# return COM pointers more easily and consistent. Instead of
|
|
46
|
+
# using CopyComPointer in the method implementation, we can
|
|
47
|
+
# simply do:
|
|
48
|
+
#
|
|
49
|
+
# def GetTypeInfo(self, this, ..., pptinfo):
|
|
50
|
+
# if not pptinfo: return E_POINTER
|
|
51
|
+
# pptinfo[0] = a_com_interface_pointer
|
|
52
|
+
# return S_OK
|
|
53
|
+
if index != 0:
|
|
54
|
+
# CopyComPointer, which is in _ctypes, does only
|
|
55
|
+
# handle an index of 0. This code does what
|
|
56
|
+
# CopyComPointer should do if index != 0.
|
|
57
|
+
if bool(value):
|
|
58
|
+
value.AddRef()
|
|
59
|
+
super(pp, self).__setitem__(index, value) # type: ignore
|
|
60
|
+
return
|
|
61
|
+
from _ctypes import CopyComPointer
|
|
62
|
+
|
|
63
|
+
CopyComPointer(value, self) # type: ignore
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def sized(itf: Type) -> None:
|
|
67
|
+
@patcher.Patch(itf)
|
|
68
|
+
class _(object):
|
|
69
|
+
def __len__(self):
|
|
70
|
+
"Return the the 'self.Count' property."
|
|
71
|
+
return self.Count
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def callable_and_subscriptable(itf: Type) -> None:
|
|
75
|
+
@patcher.Patch(itf)
|
|
76
|
+
class _(object):
|
|
77
|
+
# 'Item' is the 'default' value. Make it available by
|
|
78
|
+
# calling the instance (Not sure this makes sense, but
|
|
79
|
+
# win32com does this also).
|
|
80
|
+
def __call__(self, *args, **kw):
|
|
81
|
+
"Return 'self.Item(*args, **kw)'"
|
|
82
|
+
return self.Item(*args, **kw)
|
|
83
|
+
|
|
84
|
+
# does this make sense? It seems that all standard typelibs I've
|
|
85
|
+
# seen so far that support .Item also support ._NewEnum
|
|
86
|
+
@patcher.no_replace
|
|
87
|
+
def __getitem__(self, index):
|
|
88
|
+
"Return 'self.Item(index)'"
|
|
89
|
+
# Handle tuples and all-slice
|
|
90
|
+
if isinstance(index, tuple):
|
|
91
|
+
args = index
|
|
92
|
+
elif index == _all_slice:
|
|
93
|
+
args = ()
|
|
94
|
+
else:
|
|
95
|
+
args = (index,)
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
result = self.Item(*args)
|
|
99
|
+
except COMError as err:
|
|
100
|
+
(hresult, text, details) = err.args
|
|
101
|
+
if hresult == -2147352565: # DISP_E_BADINDEX
|
|
102
|
+
raise IndexError("invalid index")
|
|
103
|
+
else:
|
|
104
|
+
raise
|
|
105
|
+
|
|
106
|
+
# Note that result may be NULL COM pointer. There is no way
|
|
107
|
+
# to interpret this properly, so it is returned as-is.
|
|
108
|
+
|
|
109
|
+
# Hm, should we call __ctypes_from_outparam__ on the
|
|
110
|
+
# result?
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
@patcher.no_replace
|
|
114
|
+
def __setitem__(self, index, value):
|
|
115
|
+
"Attempt 'self.Item[index] = value'"
|
|
116
|
+
try:
|
|
117
|
+
self.Item[index] = value
|
|
118
|
+
except COMError as err:
|
|
119
|
+
(hresult, text, details) = err.args
|
|
120
|
+
if hresult == -2147352565: # DISP_E_BADINDEX
|
|
121
|
+
raise IndexError("invalid index")
|
|
122
|
+
else:
|
|
123
|
+
raise
|
|
124
|
+
except TypeError:
|
|
125
|
+
msg = f"{type(self)!r} object does not support item assignment"
|
|
126
|
+
raise TypeError(msg)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def iterator(itf: Type) -> None:
|
|
130
|
+
@patcher.Patch(itf)
|
|
131
|
+
class _(object):
|
|
132
|
+
def __iter__(self):
|
|
133
|
+
"Return an iterator over the _NewEnum collection."
|
|
134
|
+
# This method returns a pointer to _some_ _NewEnum interface.
|
|
135
|
+
# It relies on the fact that the code generator creates next()
|
|
136
|
+
# methods for them automatically.
|
|
137
|
+
#
|
|
138
|
+
# Better would maybe to return an object that
|
|
139
|
+
# implements the Python iterator protocol, and
|
|
140
|
+
# forwards the calls to the COM interface.
|
|
141
|
+
enum = self._NewEnum
|
|
142
|
+
if isinstance(enum, types.MethodType):
|
|
143
|
+
# _NewEnum should be a propget property, with dispid -4.
|
|
144
|
+
#
|
|
145
|
+
# Sometimes, however, it is a method.
|
|
146
|
+
enum = enum()
|
|
147
|
+
if hasattr(enum, "Next"):
|
|
148
|
+
return enum
|
|
149
|
+
# _NewEnum returns an IUnknown pointer, QueryInterface() it to
|
|
150
|
+
# IEnumVARIANT
|
|
151
|
+
from comtypes.automation import IEnumVARIANT
|
|
152
|
+
|
|
153
|
+
return enum.QueryInterface(IEnumVARIANT)
|
|
@@ -16,9 +16,9 @@ if TYPE_CHECKING:
|
|
|
16
16
|
from comtypes import hints as hints # noqa # type: ignore
|
|
17
17
|
|
|
18
18
|
from comtypes import GUID
|
|
19
|
-
from comtypes._idl_stuff import COMMETHOD # noqa
|
|
20
19
|
from comtypes import CLSCTX_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER
|
|
21
20
|
from comtypes import _ole32, oledll, DWORD
|
|
21
|
+
from comtypes._memberspec import COMMETHOD
|
|
22
22
|
from comtypes._post_coinit.unknwn import IUnknown
|
|
23
23
|
|
|
24
24
|
|
|
@@ -88,15 +88,9 @@ class IServiceProvider(IUnknown):
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
@overload
|
|
91
|
-
def CoGetObject(displayname: str, interface: None) -> IUnknown:
|
|
92
|
-
...
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
def CoGetObject(displayname: str, interface: None) -> IUnknown: ...
|
|
95
92
|
@overload
|
|
96
|
-
def CoGetObject(displayname: str, interface: Type[_T_IUnknown]) -> _T_IUnknown:
|
|
97
|
-
...
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
def CoGetObject(displayname: str, interface: Type[_T_IUnknown]) -> _T_IUnknown: ...
|
|
100
94
|
def CoGetObject(displayname: str, interface: Optional[Type[IUnknown]]) -> IUnknown:
|
|
101
95
|
"""Convert a displayname to a moniker, then bind and return the object
|
|
102
96
|
identified by the moniker."""
|
|
@@ -117,20 +111,14 @@ def CoCreateInstance(
|
|
|
117
111
|
interface: None = None,
|
|
118
112
|
clsctx: Optional[int] = None,
|
|
119
113
|
punkouter: Optional[_pUnkOuter] = None,
|
|
120
|
-
) -> IUnknown:
|
|
121
|
-
...
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
) -> IUnknown: ...
|
|
124
115
|
@overload
|
|
125
116
|
def CoCreateInstance(
|
|
126
117
|
clsid: GUID,
|
|
127
118
|
interface: Type[_T_IUnknown],
|
|
128
119
|
clsctx: Optional[int] = None,
|
|
129
120
|
punkouter: Optional[_pUnkOuter] = None,
|
|
130
|
-
) -> _T_IUnknown:
|
|
131
|
-
...
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
) -> _T_IUnknown: ...
|
|
134
122
|
def CoCreateInstance(
|
|
135
123
|
clsid: GUID,
|
|
136
124
|
interface: Optional[Type[IUnknown]] = None,
|
|
@@ -153,14 +141,19 @@ def CoCreateInstance(
|
|
|
153
141
|
if TYPE_CHECKING:
|
|
154
142
|
|
|
155
143
|
@overload
|
|
156
|
-
def CoGetClassObject(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
def CoGetClassObject(
|
|
145
|
+
clsid: GUID,
|
|
146
|
+
clsctx: Optional[int] = None,
|
|
147
|
+
pServerInfo: "Optional[COSERVERINFO]" = None,
|
|
148
|
+
interface: None = None,
|
|
149
|
+
) -> hints.IClassFactory: ...
|
|
160
150
|
@overload
|
|
161
|
-
def CoGetClassObject(
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
def CoGetClassObject(
|
|
152
|
+
clsid: GUID,
|
|
153
|
+
clsctx: Optional[int] = None,
|
|
154
|
+
pServerInfo: "Optional[COSERVERINFO]" = None,
|
|
155
|
+
interface: Type[_T_IUnknown] = hints.IClassFactory,
|
|
156
|
+
) -> _T_IUnknown: ...
|
|
164
157
|
|
|
165
158
|
|
|
166
159
|
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
@@ -177,15 +170,9 @@ def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
|
177
170
|
|
|
178
171
|
|
|
179
172
|
@overload
|
|
180
|
-
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown:
|
|
181
|
-
...
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown: ...
|
|
184
174
|
@overload
|
|
185
|
-
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown:
|
|
186
|
-
...
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown: ...
|
|
189
176
|
def GetActiveObject(
|
|
190
177
|
clsid: GUID, interface: Optional[Type[IUnknown]] = None
|
|
191
178
|
) -> IUnknown:
|
|
@@ -335,10 +322,7 @@ def CoCreateInstanceEx(
|
|
|
335
322
|
clsctx: Optional[int] = None,
|
|
336
323
|
machine: Optional[str] = None,
|
|
337
324
|
pServerInfo: Optional[COSERVERINFO] = None,
|
|
338
|
-
) -> IUnknown:
|
|
339
|
-
...
|
|
340
|
-
|
|
341
|
-
|
|
325
|
+
) -> IUnknown: ...
|
|
342
326
|
@overload
|
|
343
327
|
def CoCreateInstanceEx(
|
|
344
328
|
clsid: GUID,
|
|
@@ -346,10 +330,7 @@ def CoCreateInstanceEx(
|
|
|
346
330
|
clsctx: Optional[int] = None,
|
|
347
331
|
machine: Optional[str] = None,
|
|
348
332
|
pServerInfo: Optional[COSERVERINFO] = None,
|
|
349
|
-
) -> _T_IUnknown:
|
|
350
|
-
...
|
|
351
|
-
|
|
352
|
-
|
|
333
|
+
) -> _T_IUnknown: ...
|
|
353
334
|
def CoCreateInstanceEx(
|
|
354
335
|
clsid: GUID,
|
|
355
336
|
interface: Optional[Type[IUnknown]] = None,
|