From 8234e3ec567dc83e4c3c4aacc691662e8c39b8d1 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Fri, 12 May 2023 15:59:22 -0700 Subject: [PATCH] Internal changes PiperOrigin-RevId: 531626077 --- src/google/protobuf/descriptor.cc | 18 ++++++++++++------ src/google/protobuf/descriptor.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index ce1674f90e..8e0b163078 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -6456,9 +6456,12 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, BUILD_ARRAY(proto, result, method, BuildMethod, result); // Copy options. - result->options_ = AllocateOptions( - proto, result, ServiceDescriptorProto::kOptionsFieldNumber, - "google.protobuf.ServiceOptions", alloc); + { + ServiceOptions* options = AllocateOptions( + proto, result, ServiceDescriptorProto::kOptionsFieldNumber, + "google.protobuf.ServiceOptions", alloc); + result->options_ = options; + } AddSymbol(result->full_name(), nullptr, result->name(), proto, Symbol(result)); @@ -6479,9 +6482,12 @@ void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto, result->output_type_.Init(); // Copy options. - result->options_ = - AllocateOptions(proto, result, MethodDescriptorProto::kOptionsFieldNumber, - "google.protobuf.MethodOptions", alloc); + { + MethodOptions* options = AllocateOptions( + proto, result, MethodDescriptorProto::kOptionsFieldNumber, + "google.protobuf.MethodOptions", alloc); + result->options_ = options; + } result->client_streaming_ = proto.client_streaming(); result->server_streaming_ = proto.server_streaming(); diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index a2d6386ffb..95204c7c09 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -1486,6 +1486,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { // available extensions of that message. const ServiceOptions& options() const; + // The number of methods this service defines. int method_count() const; // Gets a MethodDescriptor by index, where 0 <= index < method_count(). @@ -1587,6 +1588,7 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { // descriptor.proto, and any available extensions of that message. const MethodOptions& options() const; + // See Descriptor::CopyTo(). void CopyTo(MethodDescriptorProto* proto) const;