Skip to content

Commit 0ec814f

Browse files
authored
impl(mixin): add mixin support in code generators (#14738)
* code changes and generate code for datamigration * remove code generated for datamigration * recover quickstart * recover quickstart * recover quickstart * fix * fix * fix following comments
1 parent b0bac64 commit 0ec814f

File tree

66 files changed

+469
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+469
-215
lines changed

generator/internal/auth_decorator_generator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ AuthDecoratorGenerator::AuthDecoratorGenerator(
2828
google::protobuf::ServiceDescriptor const* service_descriptor,
2929
VarsDictionary service_vars,
3030
std::map<std::string, VarsDictionary> service_method_vars,
31-
google::protobuf::compiler::GeneratorContext* context)
31+
google::protobuf::compiler::GeneratorContext* context,
32+
std::vector<MixinMethod> const& mixin_methods)
3233
: StubGeneratorBase("auth_header_path", "auth_cc_path", service_descriptor,
3334
std::move(service_vars), std::move(service_method_vars),
34-
context) {}
35+
context, mixin_methods) {}
3536

3637
Status AuthDecoratorGenerator::GenerateHeader() {
3738
HeaderPrint(CopyrightLicenseFileHeader());

generator/internal/auth_decorator_generator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class AuthDecoratorGenerator : public StubGeneratorBase {
3737
google::protobuf::ServiceDescriptor const* service_descriptor,
3838
VarsDictionary service_vars,
3939
std::map<std::string, VarsDictionary> service_method_vars,
40-
google::protobuf::compiler::GeneratorContext* context);
40+
google::protobuf::compiler::GeneratorContext* context,
41+
std::vector<MixinMethod> const& mixin_methods);
4142

4243
~AuthDecoratorGenerator() override = default;
4344

generator/internal/client_generator.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ ClientGenerator::ClientGenerator(
3232
google::protobuf::ServiceDescriptor const* service_descriptor,
3333
VarsDictionary service_vars,
3434
std::map<std::string, VarsDictionary> service_method_vars,
35-
google::protobuf::compiler::GeneratorContext* context)
35+
google::protobuf::compiler::GeneratorContext* context,
36+
std::vector<MixinMethod> const& mixin_methods)
3637
: ServiceCodeGenerator("client_header_path", "client_cc_path",
3738
service_descriptor, std::move(service_vars),
38-
std::move(service_method_vars), context) {
39+
std::move(service_method_vars), context,
40+
mixin_methods) {
3941
// Remember if there are methods from google.iam.v1.GetIamPolicyRequest and
4042
// google.iam.v1.SetIamPolicyRequest to google.iam.v1.Policy with signature
4143
// extensions. If so, we'll generate a "set" wrapper method to help prevent

generator/internal/client_generator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ClientGenerator : public ServiceCodeGenerator {
3636
ClientGenerator(google::protobuf::ServiceDescriptor const* service_descriptor,
3737
VarsDictionary service_vars,
3838
std::map<std::string, VarsDictionary> service_method_vars,
39-
google::protobuf::compiler::GeneratorContext* context);
39+
google::protobuf::compiler::GeneratorContext* context,
40+
std::vector<MixinMethod> const& mixin_methods);
4041

4142
~ClientGenerator() override = default;
4243

generator/internal/connection_generator.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "generator/internal/pagination.h"
2020
#include "generator/internal/predicate_utils.h"
2121
#include "generator/internal/printer.h"
22+
#include "absl/strings/str_split.h"
2223
#include <google/protobuf/descriptor.h>
2324

2425
namespace google {
@@ -29,10 +30,12 @@ ConnectionGenerator::ConnectionGenerator(
2930
google::protobuf::ServiceDescriptor const* service_descriptor,
3031
VarsDictionary service_vars,
3132
std::map<std::string, VarsDictionary> service_method_vars,
32-
google::protobuf::compiler::GeneratorContext* context)
33+
google::protobuf::compiler::GeneratorContext* context,
34+
std::vector<MixinMethod> const& mixin_methods)
3335
: ServiceCodeGenerator("connection_header_path", "connection_cc_path",
3436
service_descriptor, std::move(service_vars),
35-
std::move(service_method_vars), context) {}
37+
std::move(service_method_vars), context,
38+
mixin_methods) {}
3639

3740
Status ConnectionGenerator::GenerateHeader() {
3841
HeaderPrint(CopyrightLicenseFileHeader());
@@ -68,11 +71,14 @@ Status ConnectionGenerator::GenerateHeader() {
6871
: "",
6972
IsExperimental() ? "google/cloud/experimental_tag.h" : "",
7073
"google/cloud/version.h"});
71-
HeaderSystemIncludes(
72-
{vars("proto_header_path"), vars("additional_pb_header_paths"),
73-
HasGRPCLongrunningOperation() ? "google/longrunning/operations.grpc.pb.h"
74-
: "",
75-
"memory"});
74+
std::vector<std::string> const additional_pb_header_paths =
75+
absl::StrSplit(vars("additional_pb_header_paths"), absl::ByChar(','));
76+
HeaderSystemIncludes(additional_pb_header_paths);
77+
HeaderSystemIncludes({vars("proto_header_path"),
78+
HasGRPCLongrunningOperation()
79+
? "google/longrunning/operations.grpc.pb.h"
80+
: "",
81+
"memory"});
7682
switch (endpoint_location_style) {
7783
case ServiceConfiguration::LOCATION_DEPENDENT:
7884
case ServiceConfiguration::LOCATION_DEPENDENT_COMPAT:

generator/internal/connection_generator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ConnectionGenerator : public ServiceCodeGenerator {
3838
google::protobuf::ServiceDescriptor const* service_descriptor,
3939
VarsDictionary service_vars,
4040
std::map<std::string, VarsDictionary> service_method_vars,
41-
google::protobuf::compiler::GeneratorContext* context);
41+
google::protobuf::compiler::GeneratorContext* context,
42+
std::vector<MixinMethod> const& mixin_methods);
4243

4344
~ConnectionGenerator() override = default;
4445

generator/internal/connection_impl_generator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ ConnectionImplGenerator::ConnectionImplGenerator(
3838
google::protobuf::ServiceDescriptor const* service_descriptor,
3939
VarsDictionary service_vars,
4040
std::map<std::string, VarsDictionary> service_method_vars,
41-
google::protobuf::compiler::GeneratorContext* context)
42-
: ServiceCodeGenerator("connection_impl_header_path",
43-
"connection_impl_cc_path", service_descriptor,
44-
std::move(service_vars),
45-
std::move(service_method_vars), context) {}
41+
google::protobuf::compiler::GeneratorContext* context,
42+
std::vector<MixinMethod> const& mixin_methods)
43+
: ServiceCodeGenerator(
44+
"connection_impl_header_path", "connection_impl_cc_path",
45+
service_descriptor, std::move(service_vars),
46+
std::move(service_method_vars), context, mixin_methods) {}
4647

4748
Status ConnectionImplGenerator::GenerateHeader() {
4849
HeaderPrint(CopyrightLicenseFileHeader());

generator/internal/connection_impl_generator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ConnectionImplGenerator : public ServiceCodeGenerator {
3838
google::protobuf::ServiceDescriptor const* service_descriptor,
3939
VarsDictionary service_vars,
4040
std::map<std::string, VarsDictionary> service_method_vars,
41-
google::protobuf::compiler::GeneratorContext* context);
41+
google::protobuf::compiler::GeneratorContext* context,
42+
std::vector<MixinMethod> const& mixin_methods);
4243

4344
~ConnectionImplGenerator() override = default;
4445

generator/internal/connection_impl_rest_generator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ ConnectionImplRestGenerator::ConnectionImplRestGenerator(
3030
google::protobuf::ServiceDescriptor const* service_descriptor,
3131
VarsDictionary service_vars,
3232
std::map<std::string, VarsDictionary> service_method_vars,
33-
google::protobuf::compiler::GeneratorContext* context)
34-
: ServiceCodeGenerator("connection_impl_rest_header_path",
35-
"connection_impl_rest_cc_path", service_descriptor,
36-
std::move(service_vars),
37-
std::move(service_method_vars), context) {}
33+
google::protobuf::compiler::GeneratorContext* context,
34+
std::vector<MixinMethod> const& mixin_methods)
35+
: ServiceCodeGenerator(
36+
"connection_impl_rest_header_path", "connection_impl_rest_cc_path",
37+
service_descriptor, std::move(service_vars),
38+
std::move(service_method_vars), context, mixin_methods) {}
3839

3940
Status ConnectionImplRestGenerator::GenerateHeader() {
4041
HeaderPrint(CopyrightLicenseFileHeader());

generator/internal/connection_impl_rest_generator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ConnectionImplRestGenerator : public ServiceCodeGenerator {
3838
google::protobuf::ServiceDescriptor const* service_descriptor,
3939
VarsDictionary service_vars,
4040
std::map<std::string, VarsDictionary> service_method_vars,
41-
google::protobuf::compiler::GeneratorContext* context);
41+
google::protobuf::compiler::GeneratorContext* context,
42+
std::vector<MixinMethod> const& mixin_methods);
4243

4344
~ConnectionImplRestGenerator() override = default;
4445

0 commit comments

Comments
 (0)