Re: templater

Hi Peter,

Wouldn’t it be better to just design the file and dirs traversal so that the same file is not checked twice? If a module is being checked, then let’s only check Module.h, Module.cpp and ModuleTest.cpp. If a package is being checked, then check all contained modules and the Imports in both the package and the Testing subpackage.

Yes, I perfectly see your point. I’ll try to explain why it’s done the way it’s done.

When I was writing the original templater script (generating templates), I was thinking whether I should generate Imports.{cpp,h} files for each package or for each module. Because I wanted to make it extensible and “generic” as much as possible I decided to treat packages as directories and everything else will be considered as a module part (actually, the main reason was that if one has a hierarchy like A::B::C::D then there would be Imports.{cpp,h} file in each of these directories and I thought that it would be superfluous - like Protocols/BitTorrent/…). Now I’ve realized that there might be some problems when one needs a specific file in each package (even without modules), but nothing is perfect, both approaches have their advantages and disadvantages - “absolutely generic” solution would take a lot of more time.

So now it’s implemented this way. For example, lets have this input: A/B/C (packages A,B and module C). The script first creates directory A, then directory B and then it copies all files/directories in the Templates directory and with every file it performs substitutions (file name/content patterns). This way you can add another file/directory into the Templates directory and it will be copied there the same way as Imports{cpp,h} are. The best approach maybe would be to have different lists of files/directories that must be in every package and different one for modules.

The checker works in a similar way - packages are also treated only as directories. So if there is a package it simply checks it’s existence (directory) and if there is a module it compares all files/directories in the Template directory and if some file is missing or there is some other problem, it reports it.

As for the solution, I can either left it the way it is (if that’s not a problem that there is currently no way how to put some specific file into every package without modules - more specifically, no “generic” way) or I can try to rewrite the code that there will be some way to tell the checker/compiler which files should be in every package and what files with every module.

Btw, I just checked your revno 142 and I saw you added empty test modules. I think it would be better not to add the modules unless they have some tests. This way we are fooling the checker to think everything is fine and we are thus potentially fooling ourselves that no further work is required in that package - very much like with compiler warnings. What is your opinion?

Indeed, you’re right. Now I’ve realized that we would need to add many other (”dummy”) files just to comply the checker script output. I agree that it’s basicly the same as with compiler warnings. Thanks for checking this!

Petr

Would you like to post a relpy?


This post is a reply to:
Re: templater
Hi Petr, You’re right - for each module its Imports.{cpp,h} files are checked again. I’ve implemented a warnings buffer, so each warning message will be displayed only once. Wouldn't it be better (more...)

Follow-ups:
Re: templater
Hi Petr, Now that I understand the current implementation I think we should leave the templater as it is. It's working quite nice already and I think it is not worth (more...)