googleapis / googleapis/google-cloud-cpp
Consider unteaching `ServiceCodeGenerator` about sources vs. headers
- Lenguaje dominante
- C++
- Estrellas
- 659
- Forks
- 462
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 89
Descripción
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`.
Guía de contribución
Línea de trabajo
Comienza leyendo ServiceCodeGenerator y make_generators.cc, centrándote en la inicialización compartida, SetMethods(), methods_ y async_methods_. Determina cómo las funciones actuales CcFoo()/HeaderFoo() y los Printers independientes coordinan la salida del código fuente y de los headers. Se considera terminado cuando la estructura del generador refleja la separación propuesta por archivo sin perder el comportamiento compartido de los generadores de cliente y de conexión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp
- Área
- tooling
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100