comtypes
comtypes copied to clipboard
carve out `CodeGenerator.type_name` method to `TypeNamer` class
As a result of previous refactoring, CodeGenerator.type_name no longer references self except recursively using self.type_name.
Therefore, it is now possible to carve out a process into a separate class without having to consider side-effects or callbacks.
Only one concrete class TypeNamer is defined in this change.
For use in creating stubs, these may in the future be a base abstract class and multiple derived classes.
@vasily-v-ryabov
If this PR is merged, the next step is to create derived classes for generating runtime code and for generating type hint stub.
The first would be to make the External conditional branch an abstract method.
- For runtime code generation, the symbol of wrapper-module (e.g.
_xxxxxxxxxx_xxxxxx_xxxxxx_xxxxxx_xxxxxxxxxxxxxxxxxx.ExternalSymbol) will be returned. - For type hint stub generation, the symbol of friendly-named-module (e.g.
friendly.ExternalSymbol) will be returned.
@vasily-v-ryabov
Welcome back!
Passing the instance-bound method is indeed complicated, so I think your suggestion was an appropriate one.