MCPcopy Create free account
hub / github.com/enthought/comtypes / write

Method write

comtypes/tools/codegenerator/heads.py:75–94  ·  view source on GitHub ↗
(self, lib: typedesc.TypeLib)

Source from the content-addressed store, hash-verified

73 self.stream = stream
74
75 def write(self, lib: typedesc.TypeLib) -> None:
76 # Hm, in user code we have to write:
77 # class MyServer(COMObject, ...):
78 # _com_interfaces_ = [MyTypeLib.IInterface]
79 # _reg_typelib_ = MyTypeLib.Library._reg_typelib_
80 # ^^^^^^^
81 # Should the '_reg_typelib_' attribute be at top-level in the
82 # generated code, instead as being an attribute of the
83 # 'Library' symbol?
84 print("class Library(object):", file=self.stream)
85 if lib.doc:
86 print(_to_docstring(lib.doc), file=self.stream)
87
88 if lib.name:
89 print(f" name = {lib.name!r}", file=self.stream)
90
91 print(
92 f" _reg_typelib_ = ({lib.guid!r}, {lib.major!r}, {lib.minor!r})",
93 file=self.stream,
94 )
95
96
97class CoClassHeadWriter:

Callers 13

StructureHeadMethod · 0.45
TypeLibMethod · 0.45
CoClassMethod · 0.45
ComInterfaceHeadMethod · 0.45
ComInterfaceBodyMethod · 0.45
DispInterfaceHeadMethod · 0.45
testMethod · 0.45
runMethod · 0.45
test_fileMethod · 0.45
compileMethod · 0.45

Calls 1

_to_docstringFunction · 0.85

Tested by 4

testMethod · 0.36
test_fileMethod · 0.36
compileMethod · 0.36