comtypes 1.4.8__zip → 1.4.10__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 (154) hide show
  1. {comtypes-1.4.8 → comtypes-1.4.10}/CHANGES.txt +40 -0
  2. {comtypes-1.4.8/comtypes.egg-info → comtypes-1.4.10}/PKG-INFO +4 -3
  3. {comtypes-1.4.8 → comtypes-1.4.10}/README.md +1 -1
  4. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/GUID.py +38 -16
  5. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/__init__.py +36 -16
  6. comtypes-1.4.10/comtypes/_comobject.py +562 -0
  7. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_memberspec.py +93 -13
  8. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_meta.py +1 -0
  9. comtypes-1.4.10/comtypes/_post_coinit/_cominterface_meta_patcher.py +152 -0
  10. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/bstr.py +12 -5
  11. comtypes-1.4.8/comtypes/_py_instance_method.py → comtypes-1.4.10/comtypes/_post_coinit/instancemethod.py +1 -2
  12. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/misc.py +60 -25
  13. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/unknwn.py +26 -176
  14. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_safearray.py +3 -4
  15. comtypes-1.4.10/comtypes/_vtbl.py +448 -0
  16. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/automation.py +46 -49
  17. comtypes-1.4.10/comtypes/client/__init__.py +42 -0
  18. comtypes-1.4.10/comtypes/client/_activeobj.py +46 -0
  19. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_code_cache.py +10 -5
  20. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_constants.py +1 -1
  21. comtypes-1.4.10/comtypes/client/_create.py +147 -0
  22. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_events.py +58 -13
  23. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_generate.py +7 -11
  24. comtypes-1.4.10/comtypes/client/_managing.py +114 -0
  25. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/dynamic.py +2 -3
  26. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/lazybind.py +12 -13
  27. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/connectionpoints.py +2 -1
  28. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/errorinfo.py +22 -9
  29. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/git.py +5 -5
  30. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hints.pyi +7 -15
  31. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/logutil.py +15 -3
  32. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/messageloop.py +1 -1
  33. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/persist.py +3 -5
  34. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/safearray.py +17 -5
  35. comtypes-1.4.10/comtypes/server/__init__.py +104 -0
  36. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/automation.py +1 -2
  37. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/connectionpoints.py +5 -5
  38. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/inprocserver.py +25 -17
  39. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/localserver.py +49 -19
  40. comtypes-1.4.10/comtypes/server/register.py +478 -0
  41. comtypes-1.4.10/comtypes/server/w_getopt.py +48 -0
  42. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/shelllink.py +16 -33
  43. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/stream.py +7 -4
  44. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.py +6 -7
  45. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.py +4 -2
  46. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/__init__.py +10 -12
  47. comtypes-1.4.10/comtypes/test/find_memleak.py +72 -0
  48. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/runtests.py +1 -0
  49. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/setup.py +2 -1
  50. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_BSTR.py +10 -23
  51. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_GUID.py +1 -0
  52. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_QueryService.py +1 -0
  53. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_agilent.py +4 -3
  54. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_avmc.py +1 -1
  55. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_basic.py +12 -6
  56. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_casesensitivity.py +3 -5
  57. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_clear_cache.py +1 -1
  58. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client.py +2 -2
  59. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_dynamic.py +2 -2
  60. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_regenerate_modules.py +2 -2
  61. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_collections.py +4 -4
  62. comtypes-1.4.10/comtypes/test/test_comobject.py +146 -0
  63. comtypes-1.4.10/comtypes/test/test_comserver.py +349 -0
  64. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_createwrappers.py +2 -4
  65. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_records.py +1 -1
  66. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_safearrays.py +1 -1
  67. comtypes-1.4.10/comtypes/test/test_dispinterface.py +153 -0
  68. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dyndispatch.py +1 -0
  69. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_excel.py +22 -12
  70. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_findgendir.py +1 -2
  71. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_getactiveobj.py +4 -4
  72. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ie.py +19 -9
  73. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ienum.py +2 -2
  74. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_imfattributes.py +13 -3
  75. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_inout_args.py +8 -5
  76. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_midl_safearray_create.py +14 -4
  77. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_monikers.py +23 -9
  78. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_msscript.py +2 -1
  79. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_npsupport.py +4 -4
  80. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_outparam.py +37 -14
  81. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_persist.py +2 -4
  82. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_recordinfo.py +1 -1
  83. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_safearray.py +1 -90
  84. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_sapi.py +4 -1
  85. comtypes-1.4.10/comtypes/test/test_server.py +350 -0
  86. comtypes-1.4.10/comtypes/test/test_server_register.py +524 -0
  87. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_shelllink.py +2 -3
  88. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_showevents.py +7 -17
  89. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_storage.py +12 -6
  90. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_stream.py +16 -5
  91. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_subinterface.py +4 -2
  92. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeannotator.py +1 -2
  93. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeinfo.py +19 -7
  94. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_urlhistory.py +7 -4
  95. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_variant.py +3 -19
  96. comtypes-1.4.10/comtypes/test/test_w_getopt.py +29 -0
  97. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_win32com_interop.py +80 -36
  98. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_wmi.py +0 -3
  99. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_word.py +1 -1
  100. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/codegenerator.py +166 -440
  101. comtypes-1.4.10/comtypes/tools/codegenerator/comments.py +79 -0
  102. comtypes-1.4.10/comtypes/tools/codegenerator/heads.py +192 -0
  103. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/helpers.py +11 -14
  104. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/namespaces.py +13 -5
  105. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/packing.py +4 -4
  106. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/typeannotator.py +19 -9
  107. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/tlbparser.py +22 -23
  108. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc.py +4 -8
  109. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc_base.py +2 -2
  110. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/typeinfo.py +159 -63
  111. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/viewobject.py +3 -9
  112. {comtypes-1.4.8 → comtypes-1.4.10/comtypes.egg-info}/PKG-INFO +4 -3
  113. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/SOURCES.txt +11 -3
  114. {comtypes-1.4.8 → comtypes-1.4.10}/pyproject.toml +12 -19
  115. comtypes-1.4.8/comtypes/_comobject.py +0 -833
  116. comtypes-1.4.8/comtypes/_idl_stuff.py +0 -67
  117. comtypes-1.4.8/comtypes/client/__init__.py +0 -323
  118. comtypes-1.4.8/comtypes/server/__init__.py +0 -70
  119. comtypes-1.4.8/comtypes/server/register.py +0 -431
  120. comtypes-1.4.8/comtypes/server/w_getopt.py +0 -75
  121. comtypes-1.4.8/comtypes/test/find_memleak.py +0 -76
  122. comtypes-1.4.8/comtypes/test/test_comserver.py +0 -239
  123. comtypes-1.4.8/comtypes/test/test_dispinterface.py +0 -137
  124. comtypes-1.4.8/comtypes/test/test_propputref.py +0 -40
  125. comtypes-1.4.8/comtypes/test/test_server.py +0 -354
  126. {comtypes-1.4.8 → comtypes-1.4.10}/LICENSE.txt +0 -0
  127. {comtypes-1.4.8 → comtypes-1.4.10}/MANIFEST.in +0 -0
  128. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_npsupport.py +0 -0
  129. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/__init__.py +0 -0
  130. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_tlib_version_checker.py +0 -0
  131. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/clear_cache.py +0 -0
  132. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hresult.py +0 -0
  133. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/patcher.py +0 -0
  134. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.idl +0 -0
  135. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.tlb +0 -0
  136. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.idl +0 -0
  137. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.tlb +0 -0
  138. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.idl +0 -0
  139. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.tlb +0 -0
  140. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mytypelib.idl +0 -0
  141. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_DISPPARAMS.py +0 -0
  142. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dict.py +0 -0
  143. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_jscript.js +0 -0
  144. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_pump_events.py +0 -0
  145. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/urlhist.tlb +0 -0
  146. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/__init__.py +0 -0
  147. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/__init__.py +0 -0
  148. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  149. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/util.py +0 -0
  150. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/dependency_links.txt +0 -0
  151. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/entry_points.txt +0 -0
  152. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/top_level.txt +0 -0
  153. {comtypes-1.4.8 → comtypes-1.4.10}/setup.cfg +0 -0
  154. {comtypes-1.4.8 → comtypes-1.4.10}/setup.py +0 -0
@@ -1,354 +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
-
129
- # test
130
- def test_Name(self):
131
- p = wrap(self.create())
132
- self.assertEqual((p.Name, p.name, p.nAME), ("foo",) * 3)
133
- p.NAME = "spam"
134
- self.assertEqual((p.Name, p.name, p.nAME), ("spam",) * 3)
135
-
136
- ################
137
- # definition
138
- itf.add(
139
- "[id(101)] HRESULT MixedInOut([in] int a, [out] int *b, [in] int c, [out] int *d);"
140
- )
141
-
142
- # implementation
143
- def MixedInOut(self, a, c):
144
- return a + 1, c + 1
145
-
146
- # test
147
- def test_MixedInOut(self):
148
- p = wrap(self.create())
149
- self.assertEqual(p.MixedInOut(1, 2), (2, 3))
150
-
151
- ################
152
- # definition
153
- itf.add(
154
- "[id(102)] HRESULT MultiInOutArgs([in, out] int *pa, [in, out] int *pb);"
155
- )
156
-
157
- # implementation
158
- def MultiInOutArgs(self, pa, pb):
159
- return pa[0] * 3, pb[0] * 4
160
-
161
- # test
162
- def test_MultiInOutArgs(self):
163
- p = wrap(self.create())
164
- self.assertEqual(p.MultiInOutArgs(1, 2), (3, 8))
165
-
166
- ################
167
- # definition
168
- itf.add("HRESULT MultiInOutArgs2([in, out] int *pa, [out] int *pb);")
169
- ## # implementation
170
- ## def MultiInOutArgs2(self, pa):
171
- ## return pa[0] * 3, pa[0] * 4
172
- ## # test
173
- ## def test_MultiInOutArgs2(self):
174
- ## p = wrap(self.create())
175
- ## self.assertEqual(p.MultiInOutArgs2(42), (126, 168))
176
-
177
- ################
178
- # definition
179
- itf.add("HRESULT MultiInOutArgs3([out] int *pa, [out] int *pb);")
180
-
181
- # implementation
182
- def MultiInOutArgs3(self):
183
- return 42, 43
184
-
185
- # test
186
- def test_MultiInOutArgs3(self):
187
- p = wrap(self.create())
188
- self.assertEqual(p.MultiInOutArgs3(), (42, 43))
189
-
190
- ################
191
- # definition
192
- itf.add("HRESULT MultiInOutArgs4([out] int *pa, [in, out] int *pb);")
193
-
194
- # implementation
195
- def MultiInOutArgs4(self, pb):
196
- return pb[0] + 3, pb[0] + 4
197
-
198
- # test
199
- def test_MultiInOutArgs4(self):
200
- p = wrap(self.create())
201
- res = p.MultiInOutArgs4(pb=32)
202
-
203
- ## print "MultiInOutArgs4", res
204
-
205
- itf.add(
206
- """HRESULT GetStackTrace([in] ULONG FrameOffset,
207
- [in, out] INT *Frames,
208
- [in] ULONG FramesSize,
209
- [out, optional] ULONG *FramesFilled);"""
210
- )
211
-
212
- def GetStackTrace(self, this, *args):
213
- ## print "GetStackTrace", args
214
- return 0
215
-
216
- def test_GetStackTrace(self):
217
- p = wrap(self.create())
218
- from ctypes import c_int, POINTER, pointer
219
-
220
- frames = (c_int * 5)()
221
- res = p.GetStackTrace(42, frames, 5)
222
- ## print "RES_1", res
223
-
224
- frames = pointer(c_int(5))
225
- res = p.GetStackTrace(42, frames, 0)
226
-
227
- ## print "RES_2", res
228
-
229
- # It is unlear to me if this is allowed or not. Apparently there
230
- # are typelibs that define such an argument type, but it may be
231
- # that these are buggy.
232
- #
233
- # Point is that SafeArrayCreateEx(VT_VARIANT|VT_BYREF, ..) fails.
234
- # The MSDN docs for SafeArrayCreate() have a notice that neither
235
- # VT_ARRAY not VT_BYREF may be set, this notice is missing however
236
- # for SafeArrayCreateEx().
237
- #
238
- # We have this code here to make sure that comtypes can import
239
- # such a typelib, although calling ths method will fail because
240
- # such an array cannot be created.
241
- itf.add("""HRESULT dummy([in] SAFEARRAY(VARIANT *) foo);""")
242
-
243
- # Test events.
244
- itf.add("""HRESULT DoSomething();""")
245
- outgoing.add("""[id(103)] HRESULT OnSomething();""")
246
-
247
- # implementation
248
- def DoSomething(self):
249
- "Implement the DoSomething method"
250
- self.Fire_Event(0, "OnSomething")
251
-
252
- # test
253
- def test_events(self):
254
- p = wrap(self.create())
255
-
256
- class Handler(object):
257
- called = 0
258
-
259
- def OnSomething(self, this):
260
- "Handles the OnSomething event"
261
- self.called += 1
262
-
263
- handler = Handler()
264
- ev = comtypes.client.GetEvents(p, handler)
265
- p.DoSomething()
266
- self.assertEqual(handler.called, 1)
267
-
268
- class Handler(object):
269
- called = 0
270
-
271
- def IMyEventInterface_OnSomething(self):
272
- "Handles the OnSomething event"
273
- self.called += 1
274
-
275
- handler = Handler()
276
- ev = comtypes.client.GetEvents(p, handler)
277
- p.DoSomething()
278
- self.assertEqual(handler.called, 1)
279
-
280
- # events with out-parameters (these are probably very unlikely...)
281
- itf.add("""HRESULT DoSomethingElse();""")
282
- outgoing.add("""[id(104)] HRESULT OnSomethingElse([out, retval] int *px);""")
283
-
284
- def DoSomethingElse(self):
285
- "Implement the DoSomething method"
286
- self.Fire_Event(0, "OnSomethingElse")
287
-
288
- def test_DoSomethingElse(self):
289
- p = wrap(self.create())
290
-
291
- class Handler(object):
292
- called = 0
293
-
294
- def OnSomethingElse(self):
295
- "Handles the OnSomething event"
296
- self.called += 1
297
- return 42
298
-
299
- handler = Handler()
300
- ev = comtypes.client.GetEvents(p, handler)
301
- p.DoSomethingElse()
302
- self.assertEqual(handler.called, 1)
303
-
304
- class Handler(object):
305
- called = 0
306
-
307
- def OnSomethingElse(self, this, presult):
308
- "Handles the OnSomething event"
309
- self.called += 1
310
- presult[0] = 42
311
-
312
- handler = Handler()
313
- ev = comtypes.client.GetEvents(p, handler)
314
- p.DoSomethingElse()
315
- self.assertEqual(handler.called, 1)
316
-
317
- ################################################################
318
-
319
- path = tlb.compile()
320
- from comtypes.gen import TestLib
321
- from comtypes.typeinfo import IProvideClassInfo, IProvideClassInfo2
322
- from comtypes.connectionpoints import IConnectionPointContainer
323
-
324
- MyServer._com_interfaces_ = [
325
- TestLib.IMyInterface,
326
- IProvideClassInfo2,
327
- IConnectionPointContainer,
328
- ]
329
- MyServer._outgoing_interfaces_ = [TestLib.IMyEventInterface]
330
-
331
- ################################################################
332
-
333
- class Test(unittest.TestCase, MyServer):
334
- def __init__(self, *args):
335
- unittest.TestCase.__init__(self, *args)
336
- MyServer.__init__(self)
337
-
338
- def create(self):
339
- obj = MyServer()
340
- return obj.QueryInterface(comtypes.IUnknown)
341
-
342
- except:
343
- import unittest
344
-
345
- class TestSkipped(unittest.TestCase):
346
- @unittest.skip(
347
- "This file causes a WindowsError. Needs investigated and fixed."
348
- )
349
- def test_server_module_skipped(self):
350
- pass
351
-
352
-
353
- if __name__ == "__main__":
354
- unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes