Skip to content

Generalize most return type strings in generator #14650

@dbolduc

Description

@dbolduc

The generator has a lot of code that looks (essentially) like:

if (IsResponseTypeEmpty()) {
  Print(R"""(
  Status
  FooClient::Foo(...) { ...}
)""");
} else {
  Print(R"""(
  StatusOr<$response_type$>
  FooClient::Foo(...) { ...}
)""");
}

Where the body of the function is identical. Only the return type is different.

We could move the if statements into something like descriptor_utils: and define some new variable: $return_type$ = IsResponseTypeEmpty() ? "Status" : "StatusOr<" + response_type + ">". Basically, have one branch in descriptor_utils instead of having N branches across all the service code generators.

Metadata

Metadata

Assignees

Labels

cpp: generatorIssues related to the C++ micro-generatortype: cleanupAn internal cleanup or hygiene concern.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions