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.
Files changed (149) hide show
  1. {comtypes-1.4.7 → comtypes-1.4.9}/CHANGES.txt +39 -0
  2. {comtypes-1.4.7/comtypes.egg-info → comtypes-1.4.9}/PKG-INFO +6 -4
  3. {comtypes-1.4.7 → comtypes-1.4.9}/README.md +5 -3
  4. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/GUID.py +6 -5
  5. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/__init__.py +16 -5
  6. comtypes-1.4.9/comtypes/_comobject.py +507 -0
  7. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_memberspec.py +81 -9
  8. comtypes-1.4.9/comtypes/_meta.py +95 -0
  9. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_npsupport.py +2 -1
  10. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/__init__.py +1 -0
  11. comtypes-1.4.9/comtypes/_post_coinit/_cominterface_meta_patcher.py +153 -0
  12. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/misc.py +21 -40
  13. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/unknwn.py +88 -209
  14. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_safearray.py +1 -2
  15. comtypes-1.4.9/comtypes/_vtbl.py +448 -0
  16. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/automation.py +36 -45
  17. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/__init__.py +21 -31
  18. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_code_cache.py +5 -4
  19. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_constants.py +1 -1
  20. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_events.py +1 -2
  21. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_generate.py +9 -13
  22. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/lazybind.py +2 -7
  23. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/errorinfo.py +3 -3
  24. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/git.py +2 -2
  25. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hints.pyi +11 -19
  26. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/persist.py +7 -7
  27. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/safearray.py +12 -6
  28. comtypes-1.4.9/comtypes/server/__init__.py +86 -0
  29. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/inprocserver.py +22 -17
  30. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/localserver.py +28 -16
  31. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/register.py +62 -73
  32. comtypes-1.4.9/comtypes/server/w_getopt.py +48 -0
  33. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/shelllink.py +49 -67
  34. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.py +1 -1
  35. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.py +1 -1
  36. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/__init__.py +9 -12
  37. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/find_memleak.py +0 -1
  38. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_BSTR.py +4 -7
  39. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_agilent.py +0 -1
  40. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_avmc.py +1 -1
  41. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_casesensitivity.py +3 -5
  42. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_clear_cache.py +1 -0
  43. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_collections.py +3 -3
  44. comtypes-1.4.9/comtypes/test/test_comobject.py +146 -0
  45. comtypes-1.4.9/comtypes/test/test_comserver.py +319 -0
  46. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_createwrappers.py +2 -6
  47. comtypes-1.4.9/comtypes/test/test_dispinterface.py +153 -0
  48. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_excel.py +22 -13
  49. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ie.py +2 -5
  50. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_inout_args.py +8 -5
  51. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_midl_safearray_create.py +9 -1
  52. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_outparam.py +17 -10
  53. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_safearray.py +1 -90
  54. comtypes-1.4.9/comtypes/test/test_server.py +350 -0
  55. comtypes-1.4.9/comtypes/test/test_server_register.py +536 -0
  56. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_shelllink.py +10 -14
  57. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_showevents.py +7 -17
  58. comtypes-1.4.9/comtypes/test/test_stream.py +131 -0
  59. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeannotator.py +1 -1
  60. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_urlhistory.py +1 -0
  61. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_variant.py +0 -19
  62. comtypes-1.4.9/comtypes/test/test_w_getopt.py +29 -0
  63. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_win32com_interop.py +80 -36
  64. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_wmi.py +0 -3
  65. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/codegenerator.py +62 -68
  66. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/helpers.py +8 -8
  67. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/namespaces.py +97 -27
  68. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/packing.py +4 -4
  69. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/typeannotator.py +9 -11
  70. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/tlbparser.py +33 -32
  71. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc.py +3 -8
  72. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/typeinfo.py +32 -47
  73. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/util.py +1 -0
  74. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/viewobject.py +1 -5
  75. {comtypes-1.4.7 → comtypes-1.4.9/comtypes.egg-info}/PKG-INFO +6 -4
  76. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/SOURCES.txt +6 -3
  77. comtypes-1.4.9/pyproject.toml +55 -0
  78. comtypes-1.4.7/comtypes/_comobject.py +0 -834
  79. comtypes-1.4.7/comtypes/_idl_stuff.py +0 -67
  80. comtypes-1.4.7/comtypes/_meta.py +0 -70
  81. comtypes-1.4.7/comtypes/server/__init__.py +0 -69
  82. comtypes-1.4.7/comtypes/server/w_getopt.py +0 -75
  83. comtypes-1.4.7/comtypes/test/test_comserver.py +0 -239
  84. comtypes-1.4.7/comtypes/test/test_dispinterface.py +0 -138
  85. comtypes-1.4.7/comtypes/test/test_propputref.py +0 -40
  86. comtypes-1.4.7/comtypes/test/test_server.py +0 -348
  87. comtypes-1.4.7/comtypes/test/test_stream.py +0 -53
  88. comtypes-1.4.7/pyproject.toml +0 -3
  89. {comtypes-1.4.7 → comtypes-1.4.9}/LICENSE.txt +0 -0
  90. {comtypes-1.4.7 → comtypes-1.4.9}/MANIFEST.in +0 -0
  91. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/bstr.py +0 -0
  92. /comtypes-1.4.7/comtypes/_py_instance_method.py → /comtypes-1.4.9/comtypes/_post_coinit/instancemethod.py +0 -0
  93. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_tlib_version_checker.py +0 -0
  94. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/clear_cache.py +0 -0
  95. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/dynamic.py +0 -0
  96. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/connectionpoints.py +0 -0
  97. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hresult.py +0 -0
  98. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/logutil.py +0 -0
  99. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/messageloop.py +0 -0
  100. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/patcher.py +0 -0
  101. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/automation.py +0 -0
  102. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/connectionpoints.py +0 -0
  103. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/stream.py +0 -0
  104. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.idl +0 -0
  105. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.tlb +0 -0
  106. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.idl +0 -0
  107. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.tlb +0 -0
  108. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.idl +0 -0
  109. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.tlb +0 -0
  110. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mytypelib.idl +0 -0
  111. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/runtests.py +0 -0
  112. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/setup.py +0 -0
  113. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_DISPPARAMS.py +0 -0
  114. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_GUID.py +0 -0
  115. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_QueryService.py +0 -0
  116. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_basic.py +0 -0
  117. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client.py +0 -0
  118. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_dynamic.py +0 -0
  119. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_regenerate_modules.py +0 -0
  120. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dict.py +0 -0
  121. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_records.py +0 -0
  122. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_safearrays.py +0 -0
  123. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dyndispatch.py +0 -0
  124. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_findgendir.py +0 -0
  125. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_getactiveobj.py +0 -0
  126. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ienum.py +0 -0
  127. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_imfattributes.py +0 -0
  128. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_jscript.js +0 -0
  129. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_monikers.py +0 -0
  130. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_msscript.py +0 -0
  131. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_npsupport.py +0 -0
  132. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_persist.py +0 -0
  133. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_pump_events.py +0 -0
  134. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_recordinfo.py +0 -0
  135. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_sapi.py +0 -0
  136. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_storage.py +0 -0
  137. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_subinterface.py +0 -0
  138. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeinfo.py +0 -0
  139. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_word.py +0 -0
  140. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/urlhist.tlb +0 -0
  141. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/__init__.py +0 -0
  142. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/__init__.py +0 -0
  143. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  144. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc_base.py +0 -0
  145. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/dependency_links.txt +0 -0
  146. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/entry_points.txt +0 -0
  147. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/top_level.txt +0 -0
  148. {comtypes-1.4.7 → comtypes-1.4.9}/setup.cfg +0 -0
  149. {comtypes-1.4.7 → comtypes-1.4.9}/setup.py +0 -0
@@ -1,348 +0,0 @@
1
- try:
2
- # Force module to raise. We catch this error later. Yes, a dirty hack for python2.7.
3
- raise WindowsError("This test module cannot run as-is. Investigate why")
4
- import atexit, os, unittest
5
-
6
- import comtypes.typeinfo, comtypes.client
7
-
8
- class TypeLib(object):
9
- """This class collects IDL code fragments and eventually writes
10
- them into a .IDL file. The compile() method compiles the IDL file
11
- into a typelibrary and registers it. A function is also
12
- registered with atexit that will unregister the typelib at program
13
- exit.
14
- """
15
-
16
- def __init__(self, lib):
17
- self.lib = lib
18
- self.interfaces = []
19
- self.coclasses = []
20
-
21
- def interface(self, header):
22
- itf = Interface(header)
23
- self.interfaces.append(itf)
24
- return itf
25
-
26
- def coclass(self, definition):
27
- self.coclasses.append(definition)
28
-
29
- def __str__(self):
30
- header = (
31
- """import "oaidl.idl";
32
- import "ocidl.idl";
33
- %s {"""
34
- % self.lib
35
- )
36
- body = "\n".join([str(itf) for itf in self.interfaces])
37
- footer = "\n".join(self.coclasses) + "}"
38
- return "\n".join((header, body, footer))
39
-
40
- def compile(self):
41
- """Compile and register the typelib"""
42
- code = str(self)
43
- curdir = os.path.dirname(__file__)
44
- idl_path = os.path.join(curdir, "mylib.idl")
45
- tlb_path = os.path.join(curdir, "mylib.tlb")
46
- if not os.path.isfile(idl_path) or open(idl_path, "r").read() != code:
47
- open(idl_path, "w").write(code)
48
- os.system(
49
- r'call "%%VS71COMNTOOLS%%vsvars32.bat" && '
50
- r"midl /nologo %s /tlb %s" % (idl_path, tlb_path)
51
- )
52
- # Register the typelib...
53
- tlib = comtypes.typeinfo.LoadTypeLib(tlb_path)
54
- # create the wrapper module...
55
- comtypes.client.GetModule(tlb_path)
56
- # Unregister the typelib at interpreter exit...
57
- attr = tlib.GetLibAttr()
58
- guid, major, minor = attr.guid, attr.wMajorVerNum, attr.wMinorVerNum
59
- ## atexit.register(comtypes.typeinfo.UnRegisterTypeLib,
60
- ## guid, major, minor)
61
- return tlb_path
62
-
63
- class Interface(object):
64
- def __init__(self, header):
65
- self.header = header
66
- self.code = ""
67
-
68
- def add(self, text):
69
- self.code += text + "\n"
70
- return self
71
-
72
- def __str__(self):
73
- return self.header + " {\n" + self.code + "}\n"
74
-
75
- ################################################################
76
- import comtypes
77
- from comtypes.client import wrap
78
-
79
- tlb = TypeLib("[uuid(f4f74946-4546-44bd-a073-9ea6f9fe78cb)] library TestLib")
80
-
81
- itf = tlb.interface(
82
- """[object,
83
- oleautomation,
84
- dual,
85
- uuid(ed978f5f-cc45-4fcc-a7a6-751ffa8dfedd)]
86
- interface IMyInterface : IDispatch"""
87
- )
88
-
89
- outgoing = tlb.interface(
90
- """[object,
91
- oleautomation,
92
- dual,
93
- uuid(f7c48a90-64ea-4bb8-abf1-b3a3aa996848)]
94
- interface IMyEventInterface : IDispatch"""
95
- )
96
-
97
- tlb.coclass(
98
- """
99
- [uuid(fa9de8f4-20de-45fc-b079-648572428817)]
100
- coclass MyServer {
101
- [default] interface IMyInterface;
102
- [default, source] interface IMyEventInterface;
103
- };
104
- """
105
- )
106
-
107
- # The purpose of the MyServer class is to locate three separate code
108
- # section snippets closely together:
109
- #
110
- # 1. The IDL method definition for a COM interface method
111
- # 2. The Python implementation of the COM method
112
- # 3. The unittest(s) for the COM method.
113
- #
114
- from comtypes.server.connectionpoints import ConnectableObjectMixin
115
-
116
- class MyServer(comtypes.CoClass, ConnectableObjectMixin):
117
- _reg_typelib_ = ("{f4f74946-4546-44bd-a073-9ea6f9fe78cb}", 0, 0)
118
- _reg_clsid_ = comtypes.GUID("{fa9de8f4-20de-45fc-b079-648572428817}")
119
-
120
- ################
121
- # definition
122
- itf.add(
123
- """[id(100), propget] HRESULT Name([out, retval] BSTR *pname);
124
- [id(100), propput] HRESULT Name([in] BSTR name);"""
125
- )
126
- # implementation
127
- Name = "foo"
128
- # test
129
- def test_Name(self):
130
- p = wrap(self.create())
131
- self.assertEqual((p.Name, p.name, p.nAME), ("foo",) * 3)
132
- p.NAME = "spam"
133
- self.assertEqual((p.Name, p.name, p.nAME), ("spam",) * 3)
134
-
135
- ################
136
- # definition
137
- itf.add(
138
- "[id(101)] HRESULT MixedInOut([in] int a, [out] int *b, [in] int c, [out] int *d);"
139
- )
140
- # implementation
141
- def MixedInOut(self, a, c):
142
- return a + 1, c + 1
143
-
144
- # test
145
- def test_MixedInOut(self):
146
- p = wrap(self.create())
147
- self.assertEqual(p.MixedInOut(1, 2), (2, 3))
148
-
149
- ################
150
- # definition
151
- itf.add(
152
- "[id(102)] HRESULT MultiInOutArgs([in, out] int *pa, [in, out] int *pb);"
153
- )
154
- # implementation
155
- def MultiInOutArgs(self, pa, pb):
156
- return pa[0] * 3, pb[0] * 4
157
-
158
- # test
159
- def test_MultiInOutArgs(self):
160
- p = wrap(self.create())
161
- self.assertEqual(p.MultiInOutArgs(1, 2), (3, 8))
162
-
163
- ################
164
- # definition
165
- itf.add("HRESULT MultiInOutArgs2([in, out] int *pa, [out] int *pb);")
166
- ## # implementation
167
- ## def MultiInOutArgs2(self, pa):
168
- ## return pa[0] * 3, pa[0] * 4
169
- ## # test
170
- ## def test_MultiInOutArgs2(self):
171
- ## p = wrap(self.create())
172
- ## self.assertEqual(p.MultiInOutArgs2(42), (126, 168))
173
-
174
- ################
175
- # definition
176
- itf.add("HRESULT MultiInOutArgs3([out] int *pa, [out] int *pb);")
177
- # implementation
178
- def MultiInOutArgs3(self):
179
- return 42, 43
180
-
181
- # test
182
- def test_MultiInOutArgs3(self):
183
- p = wrap(self.create())
184
- self.assertEqual(p.MultiInOutArgs3(), (42, 43))
185
-
186
- ################
187
- # definition
188
- itf.add("HRESULT MultiInOutArgs4([out] int *pa, [in, out] int *pb);")
189
- # implementation
190
- def MultiInOutArgs4(self, pb):
191
- return pb[0] + 3, pb[0] + 4
192
-
193
- # test
194
- def test_MultiInOutArgs4(self):
195
- p = wrap(self.create())
196
- res = p.MultiInOutArgs4(pb=32)
197
-
198
- ## print "MultiInOutArgs4", res
199
-
200
- itf.add(
201
- """HRESULT GetStackTrace([in] ULONG FrameOffset,
202
- [in, out] INT *Frames,
203
- [in] ULONG FramesSize,
204
- [out, optional] ULONG *FramesFilled);"""
205
- )
206
-
207
- def GetStackTrace(self, this, *args):
208
- ## print "GetStackTrace", args
209
- return 0
210
-
211
- def test_GetStackTrace(self):
212
- p = wrap(self.create())
213
- from ctypes import c_int, POINTER, pointer
214
-
215
- frames = (c_int * 5)()
216
- res = p.GetStackTrace(42, frames, 5)
217
- ## print "RES_1", res
218
-
219
- frames = pointer(c_int(5))
220
- res = p.GetStackTrace(42, frames, 0)
221
-
222
- ## print "RES_2", res
223
-
224
- # It is unlear to me if this is allowed or not. Apparently there
225
- # are typelibs that define such an argument type, but it may be
226
- # that these are buggy.
227
- #
228
- # Point is that SafeArrayCreateEx(VT_VARIANT|VT_BYREF, ..) fails.
229
- # The MSDN docs for SafeArrayCreate() have a notice that neither
230
- # VT_ARRAY not VT_BYREF may be set, this notice is missing however
231
- # for SafeArrayCreateEx().
232
- #
233
- # We have this code here to make sure that comtypes can import
234
- # such a typelib, although calling ths method will fail because
235
- # such an array cannot be created.
236
- itf.add("""HRESULT dummy([in] SAFEARRAY(VARIANT *) foo);""")
237
-
238
- # Test events.
239
- itf.add("""HRESULT DoSomething();""")
240
- outgoing.add("""[id(103)] HRESULT OnSomething();""")
241
- # implementation
242
- def DoSomething(self):
243
- "Implement the DoSomething method"
244
- self.Fire_Event(0, "OnSomething")
245
-
246
- # test
247
- def test_events(self):
248
- p = wrap(self.create())
249
-
250
- class Handler(object):
251
- called = 0
252
-
253
- def OnSomething(self, this):
254
- "Handles the OnSomething event"
255
- self.called += 1
256
-
257
- handler = Handler()
258
- ev = comtypes.client.GetEvents(p, handler)
259
- p.DoSomething()
260
- self.assertEqual(handler.called, 1)
261
-
262
- class Handler(object):
263
- called = 0
264
-
265
- def IMyEventInterface_OnSomething(self):
266
- "Handles the OnSomething event"
267
- self.called += 1
268
-
269
- handler = Handler()
270
- ev = comtypes.client.GetEvents(p, handler)
271
- p.DoSomething()
272
- self.assertEqual(handler.called, 1)
273
-
274
- # events with out-parameters (these are probably very unlikely...)
275
- itf.add("""HRESULT DoSomethingElse();""")
276
- outgoing.add("""[id(104)] HRESULT OnSomethingElse([out, retval] int *px);""")
277
-
278
- def DoSomethingElse(self):
279
- "Implement the DoSomething method"
280
- self.Fire_Event(0, "OnSomethingElse")
281
-
282
- def test_DoSomethingElse(self):
283
- p = wrap(self.create())
284
-
285
- class Handler(object):
286
- called = 0
287
-
288
- def OnSomethingElse(self):
289
- "Handles the OnSomething event"
290
- self.called += 1
291
- return 42
292
-
293
- handler = Handler()
294
- ev = comtypes.client.GetEvents(p, handler)
295
- p.DoSomethingElse()
296
- self.assertEqual(handler.called, 1)
297
-
298
- class Handler(object):
299
- called = 0
300
-
301
- def OnSomethingElse(self, this, presult):
302
- "Handles the OnSomething event"
303
- self.called += 1
304
- presult[0] = 42
305
-
306
- handler = Handler()
307
- ev = comtypes.client.GetEvents(p, handler)
308
- p.DoSomethingElse()
309
- self.assertEqual(handler.called, 1)
310
-
311
- ################################################################
312
-
313
- path = tlb.compile()
314
- from comtypes.gen import TestLib
315
- from comtypes.typeinfo import IProvideClassInfo, IProvideClassInfo2
316
- from comtypes.connectionpoints import IConnectionPointContainer
317
-
318
- MyServer._com_interfaces_ = [
319
- TestLib.IMyInterface,
320
- IProvideClassInfo2,
321
- IConnectionPointContainer,
322
- ]
323
- MyServer._outgoing_interfaces_ = [TestLib.IMyEventInterface]
324
-
325
- ################################################################
326
-
327
- class Test(unittest.TestCase, MyServer):
328
- def __init__(self, *args):
329
- unittest.TestCase.__init__(self, *args)
330
- MyServer.__init__(self)
331
-
332
- def create(self):
333
- obj = MyServer()
334
- return obj.QueryInterface(comtypes.IUnknown)
335
-
336
- except:
337
- import unittest
338
-
339
- class TestSkipped(unittest.TestCase):
340
- @unittest.skip(
341
- "This file causes a WindowsError. Needs investigated and fixed."
342
- )
343
- def test_server_module_skipped(self):
344
- pass
345
-
346
-
347
- if __name__ == "__main__":
348
- unittest.main()
@@ -1,53 +0,0 @@
1
- import unittest as ut
2
-
3
- from ctypes import POINTER, byref, c_bool, c_ubyte
4
- import comtypes
5
- import comtypes.client
6
-
7
- comtypes.client.GetModule("portabledeviceapi.dll")
8
- from comtypes.gen.PortableDeviceApiLib import IStream
9
-
10
-
11
- def _create_stream() -> IStream:
12
- # Create an IStream
13
- stream = POINTER(IStream)() # type: ignore
14
- comtypes._ole32.CreateStreamOnHGlobal(None, c_bool(True), byref(stream))
15
- return stream # type: ignore
16
-
17
-
18
- class Test_RemoteWrite(ut.TestCase):
19
- def test_RemoteWrite(self):
20
- stream = _create_stream()
21
- test_data = "Some data".encode("utf-8")
22
- pv = (c_ubyte * len(test_data)).from_buffer(bytearray(test_data))
23
-
24
- written = stream.RemoteWrite(pv, len(test_data))
25
-
26
- # Verification
27
- self.assertEqual(written, len(test_data))
28
-
29
-
30
- class Test_RemoteRead(ut.TestCase):
31
- def test_RemoteRead(self):
32
- stream = _create_stream()
33
- test_data = "Some data".encode("utf-8")
34
- pv = (c_ubyte * len(test_data)).from_buffer(bytearray(test_data))
35
- stream.RemoteWrite(pv, len(test_data))
36
-
37
- # Make sure the data actually gets written before trying to read back
38
- stream.Commit(0)
39
- # Move the stream back to the beginning
40
- STREAM_SEEK_SET = 0
41
- stream.RemoteSeek(0, STREAM_SEEK_SET)
42
-
43
- buffer_size = 1024
44
-
45
- read_buffer, data_read = stream.RemoteRead(buffer_size)
46
-
47
- # Verification
48
- self.assertEqual(data_read, len(test_data))
49
- self.assertEqual(bytearray(read_buffer)[0:data_read], test_data)
50
-
51
-
52
- if __name__ == "__main__":
53
- ut.main()
@@ -1,3 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.2"]
3
- build-backend = "setuptools.build_meta"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes