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,31 +1,29 @@
1
1
  # Code generator to generate code for everything contained in COM type
2
2
  # libraries.
3
+ import contextlib
4
+ import io
3
5
  import keyword
4
6
  import logging
5
7
  import os
6
8
  import textwrap
7
- from typing import Any
8
- from typing import Dict, List, Tuple
9
- from typing import Sequence
10
- from typing import Optional, Union as _UnionT
11
- import io
9
+ import warnings
10
+ from typing import Any, Dict, Iterator, List, Literal, Optional, Sequence, Tuple
11
+ from typing import Union as _UnionT
12
12
 
13
13
  import comtypes
14
14
  from comtypes import typeinfo
15
15
  from comtypes.tools import tlbparser, typedesc
16
- from comtypes.tools.codegenerator import namespaces
17
- from comtypes.tools.codegenerator import packing
18
- from comtypes.tools.codegenerator.modulenamer import name_wrapper_module
16
+ from comtypes.tools.codegenerator import heads, namespaces, packing
17
+ from comtypes.tools.codegenerator.comments import ComInterfaceBodyImplCommentWriter
19
18
  from comtypes.tools.codegenerator.helpers import (
20
- get_real_type,
21
19
  ASSUME_STRINGS,
22
20
  ComMethodGenerator,
23
21
  DispMethodGenerator,
24
22
  DispPropertyGenerator,
25
23
  TypeNamer,
24
+ get_real_type,
26
25
  )
27
- from comtypes.tools.codegenerator import typeannotator
28
-
26
+ from comtypes.tools.codegenerator.modulenamer import name_wrapper_module
29
27
 
30
28
  version = comtypes.__version__
31
29
 
@@ -59,7 +57,29 @@ class CodeGenerator(object):
59
57
  self.names = set() # names that have been generated
60
58
  self.externals = [] # typelibs imported to generated module
61
59
  self.enum_aliases: Dict[str, str] = {}
62
- self.last_item_class = False
60
+ self.last_item = "attribute"
61
+
62
+ @contextlib.contextmanager
63
+ def adjust_blank(
64
+ self, item: Literal["assert", "attribute", "class", "comment", "variable"]
65
+ ) -> Iterator[io.StringIO]:
66
+ if self.last_item == "class":
67
+ print(file=self.stream)
68
+ print(file=self.stream)
69
+ elif self.last_item == "attribute":
70
+ print(file=self.stream)
71
+ if item == "class":
72
+ print(file=self.stream)
73
+ elif self.last_item in ("variable", "assert", "comment"):
74
+ if item == "class":
75
+ print(file=self.stream)
76
+ print(file=self.stream)
77
+ elif item == "attribute":
78
+ print(file=self.stream)
79
+ else:
80
+ raise TypeError
81
+ yield self.stream
82
+ self.last_item = item
63
83
 
64
84
  def generate(self, item):
65
85
  if item in self.done:
@@ -130,7 +150,7 @@ class CodeGenerator(object):
130
150
  definition = (
131
151
  "os.path.normpath(\n"
132
152
  " os.path.abspath(os.path.join(os.path.dirname(__file__),\n"
133
- " %r)))" % path
153
+ f" {path!r})))"
134
154
  )
135
155
  self.declarations.add("typelib_path", definition)
136
156
  p = os.path.normpath(
@@ -218,7 +238,7 @@ class CodeGenerator(object):
218
238
  print(self._make_dunder_all_part(), file=output)
219
239
  print(file=output)
220
240
  if tlib_mtime is not None:
221
- print("_check_version(%r, %f)" % (version, tlib_mtime), file=output)
241
+ print(f"_check_version({version!r}, {tlib_mtime:f})", file=output)
222
242
  return output.getvalue()
223
243
 
224
244
  def generate_friendly_code(self, modname: str) -> str:
@@ -288,19 +308,11 @@ class CodeGenerator(object):
288
308
  if "datetime.datetime(" in text:
289
309
  self.imports.add("datetime")
290
310
 
291
- def _to_docstring(self, orig: str, depth: int = 1) -> str:
292
- # increasing `depth` by one increases indentation by one
293
- indent = " " * depth
294
- # some chars are replaced to avoid causing a `SyntaxError`
295
- repled = orig.replace("\\", r"\\").replace('"', r"'")
296
- return '%s"""%s"""' % (indent, repled)
297
-
298
311
  def ArrayType(self, tp: typedesc.ArrayType) -> None:
299
312
  self.generate(get_real_type(tp.typ))
300
313
  self.generate(tp.typ)
301
314
 
302
315
  def EnumValue(self, tp: typedesc.EnumValue) -> None:
303
- self.last_item_class = False
304
316
  value = int(tp.value)
305
317
  if keyword.iskeyword(tp.name):
306
318
  # XXX use logging!
@@ -314,7 +326,6 @@ class CodeGenerator(object):
314
326
  self.names.add(tp_name)
315
327
 
316
328
  def Enumeration(self, tp: typedesc.Enumeration) -> None:
317
- self.last_item_class = False
318
329
  for item in tp.values:
319
330
  self.generate(item)
320
331
  if tp.name:
@@ -334,8 +345,8 @@ class CodeGenerator(object):
334
345
  if isinstance(tp.typ, typedesc.Enumeration):
335
346
  self.enum_aliases[tp.name] = definition
336
347
  else:
337
- print(f"{tp.name} = {definition}", file=self.stream)
338
- self.last_item_class = False
348
+ with self.adjust_blank("variable") as ofi:
349
+ print(f"{tp.name} = {definition}", file=ofi)
339
350
  self.names.add(tp.name)
340
351
 
341
352
  def FundamentalType(self, item: typedesc.FundamentalType) -> None:
@@ -345,90 +356,12 @@ class CodeGenerator(object):
345
356
  for struct in head.struct.bases:
346
357
  self.generate(struct.get_head())
347
358
  self.more.add(struct)
348
- if head.struct.location:
349
- self.last_item_class = False
350
- print("# %s %s" % head.struct.location, file=self.stream)
351
359
  basenames = [self._to_type_name(b) for b in head.struct.bases]
352
360
  if basenames:
353
361
  self.imports.add("comtypes", "GUID")
354
362
 
355
- if not self.last_item_class:
356
- print(file=self.stream)
357
- print(file=self.stream)
358
-
359
- self.last_item_class = True
360
-
361
- method_names = [
362
- m.name for m in head.struct.members if type(m) is typedesc.Method
363
- ]
364
- print(
365
- "class %s(%s):" % (head.struct.name, ", ".join(basenames)),
366
- file=self.stream,
367
- )
368
- print(
369
- " _iid_ = GUID('{}') # please look up iid and fill in!",
370
- file=self.stream,
371
- )
372
- if "Enum" in method_names:
373
- print(" def __iter__(self):", file=self.stream)
374
- print(" return self.Enum()", file=self.stream)
375
- elif method_names == "Next Skip Reset Clone".split():
376
- print(" def __iter__(self):", file=self.stream)
377
- print(" return self", file=self.stream)
378
- print(file=self.stream)
379
- print(" def next(self):", file=self.stream)
380
- print(" arr, fetched = self.Next(1)", file=self.stream)
381
- print(" if fetched == 0:", file=self.stream)
382
- print(" raise StopIteration", file=self.stream)
383
- print(" return arr[0]", file=self.stream)
384
-
385
- print(file=self.stream)
386
- print(file=self.stream)
387
-
388
- else:
389
- methods = [m for m in head.struct.members if type(m) is typedesc.Method]
390
-
391
- if methods:
392
- # Hm. We cannot generate code for IUnknown...
393
- if not self.last_item_class:
394
- print(file=self.stream)
395
-
396
- self.last_item_class = True
397
- print("assert 0, 'cannot generate code for IUnknown'", file=self.stream)
398
- print(file=self.stream)
399
- print(file=self.stream)
400
- print("class %s(_com_interface):" % head.struct.name, file=self.stream)
401
- print(" pass", file=self.stream)
402
- print(file=self.stream)
403
- print(file=self.stream)
404
- elif type(head.struct) == typedesc.Structure:
405
- if not self.last_item_class:
406
- print(file=self.stream)
407
- print(file=self.stream)
408
-
409
- self.last_item_class = True
410
-
411
- print("class %s(Structure):" % head.struct.name, file=self.stream)
412
- if hasattr(head.struct, "_recordinfo_"):
413
- print(
414
- " _recordinfo_ = %r" % (head.struct._recordinfo_,),
415
- file=self.stream,
416
- )
417
- else:
418
- print(" pass", file=self.stream)
419
- print(file=self.stream)
420
- print(file=self.stream)
421
- elif type(head.struct) == typedesc.Union:
422
- if not self.last_item_class:
423
- print(file=self.stream)
424
- print(file=self.stream)
425
-
426
- self.last_item_class = True
427
-
428
- print("class %s(Union):" % head.struct.name, file=self.stream)
429
- print(" pass", file=self.stream)
430
- print(file=self.stream)
431
- print(file=self.stream)
363
+ with self.adjust_blank("class") as ofi:
364
+ heads.StructureHeadWriter(ofi).write(head, basenames)
432
365
  self.names.add(head.struct.name)
433
366
 
434
367
  def Structure(self, struct: typedesc.Structure) -> None:
@@ -461,110 +394,99 @@ class CodeGenerator(object):
461
394
  try:
462
395
  pack = packing.calc_packing(body.struct, fields)
463
396
  if pack is not None:
464
- self.last_item_class = False
465
- print("%s._pack_ = %s" % (body.struct.name, pack), file=self.stream)
397
+ with self.adjust_blank("attribute") as ofi:
398
+ print(f"{body.struct.name}._pack_ = {pack}", file=ofi)
466
399
  except packing.PackingError as details:
467
400
  # if packing fails, write a warning comment to the output.
468
- import warnings
469
-
470
- message = "Structure %s: %s" % (body.struct.name, details)
401
+ message = f"Structure {body.struct.name}: {details}"
471
402
  warnings.warn(message, UserWarning)
472
- print("# WARNING: %s" % details, file=self.stream)
473
- self.last_item_class = False
474
-
403
+ with self.adjust_blank("comment") as ofi:
404
+ print(f"# WARNING: {details}", file=ofi)
475
405
  if fields:
476
406
  if body.struct.bases:
477
407
  assert len(body.struct.bases) == 1
478
408
  self.generate(body.struct.bases[0].get_body())
479
-
480
- if not self.last_item_class:
481
- print(file=self.stream)
482
-
483
- self.last_item_class = False
484
-
485
- print("%s._fields_ = [" % body.struct.name, file=self.stream)
486
- if body.struct.location:
487
- print(" # %s %s" % body.struct.location, file=self.stream)
488
- # unnamed fields will get autogenerated names "_", "_1". "_2", "_3", ...
489
- unnamed_index = 0
490
- for f in fields:
491
- if not f.name:
492
- if unnamed_index:
493
- fieldname = "_%d" % unnamed_index
494
- else:
495
- fieldname = "_"
496
- unnamed_index += 1
497
- print(
498
- " # Unnamed field renamed to '%s'" % fieldname,
499
- file=self.stream,
500
- )
501
- else:
502
- fieldname = f.name
503
- if f.bits is None:
504
- print(
505
- " ('%s', %s)," % (fieldname, self._to_type_name(f.typ)),
506
- file=self.stream,
507
- )
508
- else:
509
- print(
510
- " ('%s', %s, %s),"
511
- % (fieldname, self._to_type_name(f.typ), f.bits),
512
- file=self.stream,
513
- )
514
- print("]", file=self.stream)
515
-
409
+ with self.adjust_blank("attribute") as ofi:
410
+ self._write_structbody_fields(body, fields, ofi)
516
411
  if body.struct.size is None:
517
- print(file=self.stream)
518
- msg = (
519
- "# The size provided by the typelib is incorrect.\n"
520
- "# The size and alignment check for %s is skipped."
521
- )
522
- print(msg % body.struct.name, file=self.stream)
412
+ with self.adjust_blank("comment") as ofi:
413
+ self._write_structbody_size_comments(body, ofi)
523
414
  elif body.struct.name not in packing.dont_assert_size:
524
- print(file=self.stream)
525
- size = body.struct.size // 8
526
- print(
527
- "assert sizeof(%s) == %s, sizeof(%s)"
528
- % (body.struct.name, size, body.struct.name),
529
- file=self.stream,
530
- )
531
- align = body.struct.align // 8
532
- print(
533
- "assert alignment(%s) == %s, alignment(%s)"
534
- % (body.struct.name, align, body.struct.name),
535
- file=self.stream,
536
- )
537
-
415
+ with self.adjust_blank("assert") as ofi:
416
+ self._write_structbody_size_assertion(body, ofi)
538
417
  if methods:
539
418
  self.imports.add("comtypes", "COMMETHOD")
540
-
541
- if not self.last_item_class:
542
- print(file=self.stream)
543
-
544
- self.last_item_class = False
545
- print("%s._methods_ = [" % body.struct.name, file=self.stream)
546
- if body.struct.location:
547
- print("# %s %s" % body.struct.location, file=self.stream)
548
-
549
- for m in methods:
550
- if m.location:
551
- print(" # %s %s" % m.location, file=self.stream)
552
- print(
553
- (
554
- " COMMETHOD(\n"
555
- " [], \n"
556
- " %s,\n"
557
- " '%s',\n"
558
- )
559
- % (self._to_type_name(m.returns), m.name),
560
- file=self.stream,
561
- )
562
- for a in m.iterArgTypes():
563
- print(
564
- " ([], %s),\n" % self._to_type_name(a), file=self.stream
565
- )
566
- print(" ),", file=self.stream)
567
- print("]", file=self.stream)
419
+ with self.adjust_blank("attribute") as ofi:
420
+ self._write_structbody_commethods(body, methods, ofi)
421
+
422
+ def _write_structbody_fields(
423
+ self,
424
+ body: typedesc.StructureBody,
425
+ fields: List[typedesc.Field],
426
+ ofi: io.StringIO,
427
+ ) -> None:
428
+ print(f"{body.struct.name}._fields_ = [", file=ofi)
429
+ if body.struct.location:
430
+ print(f" # {body.struct.location}", file=ofi)
431
+ # unnamed fields will get autogenerated names "_", "_1". "_2", "_3", ...
432
+ unnamed_index = 0
433
+ for f in fields:
434
+ if not f.name:
435
+ fieldname = "_" if not unnamed_index else f"_{unnamed_index:d}"
436
+ unnamed_index += 1
437
+ print(f" # Unnamed field renamed to '{fieldname}'", file=ofi)
438
+ else:
439
+ fieldname = f.name
440
+ typename = self._to_type_name(f.typ)
441
+ if f.bits is None:
442
+ print(f" ('{fieldname}', {typename}),", file=ofi)
443
+ else:
444
+ print(f" ('{fieldname}', {typename}, {f.bits}),", file=ofi)
445
+ print("]", file=ofi)
446
+
447
+ def _write_structbody_size_comments(
448
+ self, body: typedesc.StructureBody, ofi: io.StringIO
449
+ ) -> None:
450
+ msg1 = "# The size provided by the typelib is incorrect."
451
+ msg2 = f"# The size and alignment check for {body.struct.name} is skipped."
452
+ print(msg1, file=ofi)
453
+ print(msg2, file=ofi)
454
+
455
+ def _write_structbody_size_assertion(
456
+ self, body: typedesc.StructureBody, ofi: io.StringIO
457
+ ) -> None:
458
+ name = body.struct.name
459
+ assert body.struct.size is not None
460
+ size = body.struct.size // 8
461
+ print(f"assert sizeof({name}) == {size}, sizeof({name})", file=ofi)
462
+ align = body.struct.align // 8
463
+ print(f"assert alignment({name}) == {align}, alignment({name})", file=ofi)
464
+
465
+ def _write_structbody_commethods(
466
+ self,
467
+ body: typedesc.StructureBody,
468
+ methods: List[typedesc.Method],
469
+ ofi: io.StringIO,
470
+ ) -> None:
471
+ print(f"{body.struct.name}._methods_ = [", file=ofi)
472
+ if body.struct.location:
473
+ print(f"# {body.struct.location}", file=ofi)
474
+ for m in methods:
475
+ if m.location:
476
+ print(f" # {m.location}", file=ofi)
477
+ print(
478
+ (
479
+ " COMMETHOD(\n"
480
+ " [],\n"
481
+ f" {self._to_type_name(m.returns)},\n"
482
+ f" '{m.name}',\n"
483
+ ),
484
+ file=ofi,
485
+ )
486
+ for a in m.iterArgTypes():
487
+ print(f" ([], {self._to_type_name(a)}),\n", file=ofi)
488
+ print(" ),", file=ofi)
489
+ print("]", file=ofi)
568
490
 
569
491
  ################################################################
570
492
  # top-level typedesc generators
@@ -578,25 +500,9 @@ class CodeGenerator(object):
578
500
  # Should the '_reg_typelib_' attribute be at top-level in the
579
501
  # generated code, instead as being an attribute of the
580
502
  # 'Library' symbol?
581
- if not self.last_item_class:
582
- print(file=self.stream)
583
- print(file=self.stream)
584
-
585
- self.last_item_class = True
586
-
587
- print("class Library(object):", file=self.stream)
588
- if lib.doc:
589
- print(self._to_docstring(lib.doc), file=self.stream)
590
503
 
591
- if lib.name:
592
- print(" name = %r" % lib.name, file=self.stream)
593
-
594
- print(
595
- " _reg_typelib_ = (%r, %r, %r)" % (lib.guid, lib.major, lib.minor),
596
- file=self.stream,
597
- )
598
- print(file=self.stream)
599
- print(file=self.stream)
504
+ with self.adjust_blank("class") as ofi:
505
+ heads.LibraryHeadWriter(ofi).write(lib)
600
506
  self.names.add("Library")
601
507
 
602
508
  def External(self, ext: typedesc.External) -> None:
@@ -606,12 +512,10 @@ class CodeGenerator(object):
606
512
  self.imports.add(modname)
607
513
 
608
514
  def Constant(self, tp: typedesc.Constant) -> None:
609
- self.last_item_class = False
610
- print(
611
- "%s = %r # Constant %s" % (tp.name, tp.value, self._to_type_name(tp.typ)),
612
- file=self.stream,
613
- )
614
- self.names.add(tp.name)
515
+ with self.adjust_blank("variable") as ofi:
516
+ type_name = self._to_type_name(tp.typ)
517
+ print(f"{tp.name} = {tp.value!r} # Constant {type_name}", file=ofi)
518
+ self.names.add(tp.name)
615
519
 
616
520
  def SAFEARRAYType(self, sa: typedesc.SAFEARRAYType) -> None:
617
521
  self.generate(sa.typ)
@@ -644,30 +548,8 @@ class CodeGenerator(object):
644
548
  def CoClass(self, coclass: typedesc.CoClass) -> None:
645
549
  self.imports.add("comtypes", "GUID")
646
550
  self.imports.add("comtypes", "CoClass")
647
- if not self.last_item_class:
648
- print(file=self.stream)
649
- print(file=self.stream)
650
-
651
- self.last_item_class = True
652
-
653
- print("class %s(CoClass):" % coclass.name, file=self.stream)
654
- if coclass.doc:
655
- print(self._to_docstring(coclass.doc), file=self.stream)
656
- print(" _reg_clsid_ = GUID(%r)" % coclass.clsid, file=self.stream)
657
- print(" _idlflags_ = %s" % coclass.idlflags, file=self.stream)
658
- if self.filename is not None:
659
- print(" _typelib_path_ = typelib_path", file=self.stream)
660
- # X print
661
- # >> self.stream, "POINTER(%s).__ctypes_from_outparam__ = wrap" % coclass.name
662
-
663
- libid = coclass.tlibattr.guid
664
- wMajor, wMinor = coclass.tlibattr.wMajorVerNum, coclass.tlibattr.wMinorVerNum
665
- print(
666
- " _reg_typelib_ = (%r, %s, %s)" % (str(libid), wMajor, wMinor),
667
- file=self.stream,
668
- )
669
- print(file=self.stream)
670
- print(file=self.stream)
551
+ with self.adjust_blank("class") as ofi:
552
+ heads.CoClassHeadWriter(ofi, self.filename).write(coclass)
671
553
 
672
554
  for itf, _ in coclass.interfaces:
673
555
  self.generate(itf.get_head())
@@ -675,18 +557,13 @@ class CodeGenerator(object):
675
557
  implemented = [self._to_type_name(itf) for itf in impl]
676
558
  sources = [self._to_type_name(itf) for itf in src]
677
559
 
678
- if implemented:
679
- self.last_item_class = False
680
- print(
681
- "%s._com_interfaces_ = [%s]" % (coclass.name, ", ".join(implemented)),
682
- file=self.stream,
683
- )
684
- if sources:
685
- self.last_item_class = False
686
- print(
687
- "%s._outgoing_interfaces_ = [%s]" % (coclass.name, ", ".join(sources)),
688
- file=self.stream,
689
- )
560
+ with self.adjust_blank("attribute") as ofi:
561
+ if implemented:
562
+ itfs = ", ".join(implemented)
563
+ print(f"{coclass.name}._com_interfaces_ = [{itfs}]", file=ofi)
564
+ if sources:
565
+ itfs = ", ".join(sources)
566
+ print(f"{coclass.name}._outgoing_interfaces_ = [{itfs}]", file=ofi)
690
567
 
691
568
  self.names.add(coclass.name)
692
569
 
@@ -747,16 +624,6 @@ class CodeGenerator(object):
747
624
  return self.known_interfaces[item.name] == item.iid
748
625
  return False
749
626
 
750
- def _is_enuminterface(self, itf: typedesc.ComInterface) -> bool:
751
- # Check if this is an IEnumXXX interface
752
- if not itf.name.startswith("IEnum"):
753
- return False
754
- member_names = [mth.name for mth in itf.members]
755
- for name in ("Next", "Skip", "Reset", "Clone"):
756
- if name not in member_names:
757
- return False
758
- return True
759
-
760
627
  def ComInterfaceHead(self, head: typedesc.ComInterfaceHead) -> None:
761
628
  if head.itf.base is None:
762
629
  # we don't beed to generate IUnknown
@@ -767,49 +634,8 @@ class CodeGenerator(object):
767
634
 
768
635
  self.imports.add("comtypes", "GUID")
769
636
 
770
- if not self.last_item_class:
771
- print(file=self.stream)
772
- print(file=self.stream)
773
-
774
- self.last_item_class = True
775
-
776
- print("class %s(%s):" % (head.itf.name, basename), file=self.stream)
777
- if head.itf.doc:
778
- print(self._to_docstring(head.itf.doc), file=self.stream)
779
-
780
- print(" _case_insensitive_ = True", file=self.stream)
781
- print(" _iid_ = GUID(%r)" % head.itf.iid, file=self.stream)
782
- print(" _idlflags_ = %s" % head.itf.idlflags, file=self.stream)
783
-
784
- if self._is_enuminterface(head.itf):
785
- print(file=self.stream)
786
- print(" def __iter__(self):", file=self.stream)
787
- print(" return self", file=self.stream)
788
- print(file=self.stream)
789
-
790
- print(" def __next__(self):", file=self.stream)
791
- print(" item, fetched = self.Next(1)", file=self.stream)
792
- print(" if fetched:", file=self.stream)
793
- print(" return item", file=self.stream)
794
- print(" raise StopIteration", file=self.stream)
795
- print(file=self.stream)
796
-
797
- print(" def __getitem__(self, index):", file=self.stream)
798
- print(" self.Reset()", file=self.stream)
799
- print(" self.Skip(index)", file=self.stream)
800
- print(" item, fetched = self.Next(1)", file=self.stream)
801
- print(" if fetched:", file=self.stream)
802
- print(" return item", file=self.stream)
803
- print(" raise IndexError(index)", file=self.stream)
804
-
805
- annotations = typeannotator.ComInterfaceMembersAnnotator(head.itf).generate()
806
- if annotations:
807
- print(file=self.stream)
808
- print(" if TYPE_CHECKING: # commembers", file=self.stream)
809
- print(annotations, file=self.stream)
810
-
811
- print(file=self.stream)
812
- print(file=self.stream)
637
+ with self.adjust_blank("class") as ofi:
638
+ heads.ComInterfaceHeadWriter(ofi).write(head, basename)
813
639
 
814
640
  def ComInterfaceBody(self, body: typedesc.ComInterfaceBody) -> None:
815
641
  # The base class must be fully generated, including the
@@ -822,88 +648,19 @@ class CodeGenerator(object):
822
648
  self.generate(a[0])
823
649
  self.generate(m.returns)
824
650
 
825
- if not self.last_item_class:
826
- print(file=self.stream)
827
-
828
- self.last_item_class = False
829
- print("%s._methods_ = [" % body.itf.name, file=self.stream)
830
- for m in body.itf.members:
831
- if isinstance(m, typedesc.ComMethod):
832
- self.make_ComMethod(m, "dual" in body.itf.idlflags)
833
- else:
834
- raise TypeError("what's this?")
835
-
836
- print("]", file=self.stream)
837
- print(file=self.stream)
838
- print(
839
- "################################################################",
840
- file=self.stream,
841
- )
842
- print("# code template for %s implementation" % body.itf.name, file=self.stream)
843
- print("# class %s_Impl(object):" % body.itf.name, file=self.stream)
844
-
845
- methods = {}
846
- for m in body.itf.members:
847
- if isinstance(m, typedesc.ComMethod):
848
- # m.arguments is a sequence of tuples:
849
- # (argtype, argname, idlflags, docstring)
850
- # Some typelibs have unnamed method parameters!
851
- inargs = [a[1] or "<unnamed>" for a in m.arguments if not "out" in a[2]]
852
- outargs = [a[1] or "<unnamed>" for a in m.arguments if "out" in a[2]]
853
- if "propget" in m.idlflags:
854
- methods.setdefault(m.name, [0, inargs, outargs, m.doc])[0] |= 1
855
- elif "propput" in m.idlflags:
856
- methods.setdefault(m.name, [0, inargs[:-1], inargs[-1:], m.doc])[
857
- 0
858
- ] |= 2
651
+ with self.adjust_blank("attribute") as ofi:
652
+ print(f"{body.itf.name}._methods_ = [", file=ofi)
653
+ for m in body.itf.members:
654
+ if isinstance(m, typedesc.ComMethod):
655
+ isdual = "dual" in body.itf.idlflags
656
+ print(ComMethodGenerator(m, isdual).generate(), file=ofi)
657
+ self.add_ComMth_requirements(m, isdual)
859
658
  else:
860
- methods[m.name] = [0, inargs, outargs, m.doc]
659
+ raise TypeError("what's this?")
861
660
 
862
- for name, (typ, inargs, outargs, doc) in methods.items():
863
- if typ == 0: # method
864
- print(
865
- "# def %s(%s):" % (name, ", ".join(["self"] + inargs)),
866
- file=self.stream,
867
- )
868
- print("# %r" % (doc or "-no docstring-"), file=self.stream)
869
- print("# #return %s" % (", ".join(outargs)), file=self.stream)
870
- elif typ == 1: # propget
871
- print("# @property", file=self.stream)
872
- print(
873
- "# def %s(%s):" % (name, ", ".join(["self"] + inargs)),
874
- file=self.stream,
875
- )
876
- print("# %r" % (doc or "-no docstring-"), file=self.stream)
877
- print("# #return %s" % (", ".join(outargs)), file=self.stream)
878
- elif typ == 2: # propput
879
- print(
880
- "# def _set(%s):" % ", ".join(["self"] + inargs + outargs),
881
- file=self.stream,
882
- )
883
- print("# %r" % (doc or "-no docstring-"), file=self.stream)
884
- print(
885
- "# %s = property(fset = _set, doc = _set.__doc__)" % name,
886
- file=self.stream,
887
- )
888
- elif typ == 3: # propget + propput
889
- print(
890
- "# def _get(%s):" % ", ".join(["self"] + inargs),
891
- file=self.stream,
892
- )
893
- print("# %r" % (doc or "-no docstring-"), file=self.stream)
894
- print("# #return %s" % (", ".join(outargs)), file=self.stream)
895
- print(
896
- "# def _set(%s):" % ", ".join(["self"] + inargs + outargs),
897
- file=self.stream,
898
- )
899
- print("# %r" % (doc or "-no docstring-"), file=self.stream)
900
- print(
901
- "# %s = property(_get, _set, doc = _set.__doc__)" % name,
902
- file=self.stream,
903
- )
904
- else:
905
- raise RuntimeError("BUG")
906
- print("#", file=self.stream)
661
+ print("]", file=ofi)
662
+ print(file=self.stream)
663
+ ComInterfaceBodyImplCommentWriter(self.stream).write(body)
907
664
 
908
665
  def DispInterface(self, itf: typedesc.DispInterface) -> None:
909
666
  self.generate(itf.get_head())
@@ -915,28 +672,9 @@ class CodeGenerator(object):
915
672
  basename = self._to_type_name(head.itf.base)
916
673
 
917
674
  self.imports.add("comtypes", "GUID")
918
- if not self.last_item_class:
919
- print(file=self.stream)
920
- print(file=self.stream)
921
-
922
- self.last_item_class = True
923
675
 
924
- print("class %s(%s):" % (head.itf.name, basename), file=self.stream)
925
- if head.itf.doc:
926
- print(self._to_docstring(head.itf.doc), file=self.stream)
927
- print(" _case_insensitive_ = True", file=self.stream)
928
- print(" _iid_ = GUID(%r)" % head.itf.iid, file=self.stream)
929
- print(" _idlflags_ = %s" % head.itf.idlflags, file=self.stream)
930
- print(" _methods_ = []", file=self.stream)
931
-
932
- annotations = typeannotator.DispInterfaceMembersAnnotator(head.itf).generate()
933
- if annotations:
934
- print(file=self.stream)
935
- print(" if TYPE_CHECKING: # dispmembers", file=self.stream)
936
- print(annotations, file=self.stream)
937
-
938
- print(file=self.stream)
939
- print(file=self.stream)
676
+ with self.adjust_blank("class") as ofi:
677
+ heads.DispInterfaceHeadWriter(ofi).write(head, basename)
940
678
 
941
679
  def DispInterfaceBody(self, body: typedesc.DispInterfaceBody) -> None:
942
680
  # make sure we can generate the body
@@ -949,34 +687,28 @@ class CodeGenerator(object):
949
687
  self.generate(m.typ)
950
688
  else:
951
689
  raise TypeError(m)
952
-
953
- if not self.last_item_class:
954
- print(file=self.stream)
955
-
956
- self.last_item_class = False
957
-
958
- print("%s._disp_methods_ = [" % body.itf.name, file=self.stream)
959
- for m in body.itf.members:
960
- if isinstance(m, typedesc.DispMethod):
961
- self.make_DispMethod(m)
962
- elif isinstance(m, typedesc.DispProperty):
963
- self.make_DispProperty(m)
964
- else:
965
- raise TypeError(m)
966
- print("]", file=self.stream)
690
+ with self.adjust_blank("attribute") as ofi:
691
+ print(f"{body.itf.name}._disp_methods_ = [", file=ofi)
692
+ for m in body.itf.members:
693
+ if isinstance(m, typedesc.DispMethod):
694
+ print(DispMethodGenerator(m).generate(), file=ofi)
695
+ self.add_DispMth_requirements(m)
696
+ elif isinstance(m, typedesc.DispProperty):
697
+ print(DispPropertyGenerator(m).generate(), file=ofi)
698
+ self.add_DispProp_requirements(m)
699
+ else:
700
+ raise TypeError(m)
701
+ print("]", file=ofi)
967
702
 
968
703
  ################################################################
969
- # non-toplevel method generators
704
+ # non-toplevel method requirements
970
705
  #
971
- def make_ComMethod(self, m: typedesc.ComMethod, isdual: bool) -> None:
706
+ def add_ComMth_requirements(self, m: typedesc.ComMethod, isdual: bool) -> None:
972
707
  self.imports.add("comtypes", "COMMETHOD")
973
708
  if isdual:
974
709
  self.imports.add("comtypes", "dispid")
975
710
  if __debug__ and m.doc:
976
711
  self.imports.add("comtypes", "helpstring")
977
- gen = ComMethodGenerator(m, isdual)
978
- print(gen.generate(), file=self.stream)
979
- self.last_item_class = False
980
712
  for typ, _, _, default in m.arguments:
981
713
  if isinstance(typ, typedesc.ComInterface):
982
714
  self.declarations.add(
@@ -987,23 +719,17 @@ class CodeGenerator(object):
987
719
  if default is not None:
988
720
  self.need_VARIANT_imports(default)
989
721
 
990
- def make_DispMethod(self, m: typedesc.DispMethod) -> None:
722
+ def add_DispMth_requirements(self, m: typedesc.DispMethod) -> None:
991
723
  self.imports.add("comtypes", "DISPMETHOD")
992
724
  self.imports.add("comtypes", "dispid")
993
725
  if __debug__ and m.doc:
994
726
  self.imports.add("comtypes", "helpstring")
995
- gen = DispMethodGenerator(m)
996
- print(gen.generate(), file=self.stream)
997
- self.last_item_class = False
998
727
  for _, _, _, default in m.arguments:
999
728
  if default is not None:
1000
729
  self.need_VARIANT_imports(default)
1001
730
 
1002
- def make_DispProperty(self, prop: typedesc.DispProperty) -> None:
731
+ def add_DispProp_requirements(self, prop: typedesc.DispProperty) -> None:
1003
732
  self.imports.add("comtypes", "DISPPROPERTY")
1004
733
  self.imports.add("comtypes", "dispid")
1005
734
  if __debug__ and prop.doc:
1006
735
  self.imports.add("comtypes", "helpstring")
1007
- gen = DispPropertyGenerator(prop)
1008
- print(gen.generate(), file=self.stream)
1009
- self.last_item_class = False