| 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 | |
| 97 | class CoClassHeadWriter: |