diff options
author | thegeorg <thegeorg@yandex-team.com> | 2022-11-09 12:13:47 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2022-11-09 12:13:47 +0300 |
commit | 80f5c1d76c74f49e72bece723f9c1b7a25852e70 (patch) | |
tree | d00038bca499594f3b058936272dea3b69bf822e /contrib/libs/grpc/src/compiler | |
parent | 41fc4a8aaa393fbb516c9e0edb6ffe98ab7097e5 (diff) | |
download | ydb-80f5c1d76c74f49e72bece723f9c1b7a25852e70.tar.gz |
Update contrib/libs/grpc to 1.44.0
Diffstat (limited to 'contrib/libs/grpc/src/compiler')
-rw-r--r-- | contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h index cc8aa8d124..ce1e47aeaf 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h @@ -36,10 +36,30 @@ inline TString MessageHeaderName(const FileDescriptor* file) { return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; } -inline TString ServiceClassName(const ServiceDescriptor* service) { +inline bool AsciiIsUpper(char c) { return c >= 'A' && c <= 'Z'; } + +inline ::TString ServiceClassName(const ServiceDescriptor* service) { const FileDescriptor* file = service->file(); - TString prefix = google::protobuf::compiler::objectivec::FileClassPrefix(file); - return prefix + service->name(); + ::TString prefix = + google::protobuf::compiler::objectivec::FileClassPrefix(file); + ::TString class_name = service->name(); + // We add the prefix in the cases where the string is missing a prefix. + // We define "missing a prefix" as where 'input': + // a) Doesn't start with the prefix or + // b) Isn't equivalent to the prefix or + // c) Has the prefix, but the letter after the prefix is lowercase + // This is the same semantics as the Objective-C protoc. + // https://github.com/protocolbuffers/protobuf/blob/c160ae52a91ca4c76936531d68cc846f8230dbb1/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc#L389 + if (class_name.rfind(prefix, 0) == 0) { + if (class_name.length() == prefix.length() || + !AsciiIsUpper(class_name[prefix.length()])) { + return prefix + class_name; + } else { + return class_name; + } + } else { + return prefix + class_name; + } } inline ::TString LocalImport(const ::TString& import) { |