comtypes icon indicating copy to clipboard operation
comtypes copied to clipboard

Fix cross import between `tools` and `client`

Open junkmd opened this issue 3 years ago • 2 comments

Currently there are no problems at runtime, but complex imports tend to cause strange bugs that occur when the code is changed.

Modification policies

Make client dependent on tools. So that client is not imported from tools, except to use as workarounds when there is nothing else to do.

junkmd avatar Jul 21 '22 14:07 junkmd

Generating modules in codegenerator

https://github.com/enthought/comtypes/blob/944e279890e3a4918e7661a8e268e6e2bddf57ae/comtypes/tools/codegenerator.py#L669-L679

The codegenerator is responsible for writing code to file I/O, but when generate_code is called, it generates the dependency modules.

Generating modules in the generating code process seems to be out of scope.

Generator is called by the client.

If generating dependency modules are necessary, I think that the Parser or Generator should have a method or attribute to obtain those COM libraries, and the process of generating modules should be done in the client.

junkmd avatar Jul 21 '22 14:07 junkmd

move tlbparser.generate_module to client._generate

https://github.com/enthought/comtypes/blob/944e279890e3a4918e7661a8e268e6e2bddf57ae/comtypes/tools/tlbparser.py#L737-L767

When I first saw the implementation of this library, I wondered why there was a generate_module in tools.tlbparser and not in tools.codegenerator or client._generate.

https://github.com/enthought/comtypes/blob/944e279890e3a4918e7661a8e268e6e2bddf57ae/comtypes/tools/codegenerator.py#L1284-L1287

I think the role of module generation should be in client._generate.

junkmd avatar Jul 21 '22 14:07 junkmd

this issue was closed since merging #342 and #348.

junkmd avatar Sep 18 '22 00:09 junkmd