Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider unteaching ServiceCodeGenerator about sources vs. headers #14198

Open
dbolduc opened this issue May 9, 2024 · 0 comments
Open

Consider unteaching ServiceCodeGenerator about sources vs. headers #14198

dbolduc opened this issue May 9, 2024 · 0 comments
Labels
cpp: generator Issues related to the C++ micro-generator type: cleanup An internal cleanup or hygiene concern.

Comments

@dbolduc
Copy link
Member

dbolduc commented May 9, 2024

We could have one ServiceCodeGenerator per file, instead of one ServiceCodeGenerator per potential pairs of files.

ServiceCodeGenerator writes files. It takes care to distinguish between headers and sources. It has a separate Printer for source and header. It has many CcFoo() / HeaderFoo() member functions. But the implementation of these member functions are basically the same.

Why we would do this:

  • I am about to introduce a hacky overload because I want a ServiceCodeGenerator that only writes a source file.
  • Simplify the class. I suspect it will be easier to navigate. (I often forget whether I am in GenerateHeader() or GenerateCc())
  • We could parallelize writing headers and sources. The savings, if any, would be negligible.

Why we wouldn't do this:
If there was a ton of common code shared between headers and sources, then having one class to control both makes sense.

  • The client generators have a shared initialization for {get,set}_iam_policy_extension_.
  • The connection generators share a ConnectionFactoryFunctionArguments()

We could always factor this stuff out. The processing could happen in make_generators.cc, instead of inside the generator. e.g. Each ServiceCodeGenerator calls SetMethods() which does the same work to produce its methods_, async_methods_. That could also happen once outside of the ServiceCodeGenerators.

@dbolduc dbolduc added type: cleanup An internal cleanup or hygiene concern. cpp: generator Issues related to the C++ micro-generator labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp: generator Issues related to the C++ micro-generator type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

1 participant