Internal change.

PiperOrigin-RevId: 694519266
pull/19178/head
Protobuf Team Bot 2 weeks ago committed by Copybara-Service
parent 3e0f10e0de
commit 543169bd55
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 31
      src/google/protobuf/compiler/cpp/field_generators/message_field.cc
  3. 8
      src/google/protobuf/compiler/cpp/field_generators/string_field.cc
  4. 10
      src/google/protobuf/compiler/cpp/field_generators/string_view_field.cc
  5. 10
      src/google/protobuf/repeated_ptr_field.h

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -783,26 +783,17 @@ void RepeatedMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
return _internal_mutable_$name_internal$();
}
)cc");
p->Emit(
{
{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
{"GetExtraArg",
[&] {
p->Emit(opts_->safe_boundary_check
? ", reinterpret_cast<const $Submsg$&>($kDefault$)"
: "");
}},
},
R"cc(
inline const $Submsg$& $Msg$::$name$(int index) const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$)
$StrongRef$;
return _internal_$name_internal$().$Get$(index$GetExtraArg$);
}
)cc");
p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"}},
R"cc(
inline const $Submsg$& $Msg$::$name$(int index) const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$)
$StrongRef$;
return _internal_$name_internal$().$Get$(index);
}
)cc");
p->Emit(R"cc(
inline $Submsg$* $Msg$::add_$name$() ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;

@ -851,12 +851,6 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
p->Emit(
{
{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
{"GetExtraArg",
[&] {
p->Emit(opts_->safe_boundary_check
? ", $pbi$::GetEmptyStringAlreadyInited()"
: "");
}},
{"bytes_tag",
[&] {
if (bytes) {
@ -878,7 +872,7 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
$WeakDescriptorSelfPin$;
$annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$)
return _internal_$name_internal$().$Get$(index$GetExtraArg$);
return _internal_$name_internal$().$Get$(index);
}
inline std::string* $Msg$::mutable_$name$(int index)
ABSL_ATTRIBUTE_LIFETIME_BOUND {

@ -666,20 +666,14 @@ void RepeatedStringView::GenerateAccessorDeclarations(io::Printer* p) const {
void RepeatedStringView::GenerateInlineAccessorDefinitions(
io::Printer* p) const {
p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
{"GetExtraArg",
[&] {
p->Emit(opts_->safe_boundary_check
? ", $pbi$::GetEmptyStringAlreadyInited()"
: "");
}}},
p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"}},
R"cc(
inline absl::string_view $Msg$::$name$(int index) const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$)
return _internal_$name_internal$().$Get$(index$GetExtraArg$);
return _internal_$name_internal$().$Get$(index);
}
inline void $Msg$::set_$name$(int index, const std::string& value) {
$WeakDescriptorSelfPin$;

@ -117,6 +117,8 @@ class GenericTypeHandler;
//
// // Only needs to be implemented if SpaceUsedExcludingSelf() is called.
// static int SpaceUsedLong(const Type&);
//
// static const Type& default_instance();
// };
class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
@ -839,6 +841,11 @@ class GenericTypeHandler {
static inline size_t SpaceUsedLong(const Type& value) {
return value.SpaceUsedLong();
}
static const Type& default_instance() {
return *static_cast<const GenericType*>(
MessageTraits<Type>::default_instance());
}
};
template <>
@ -875,6 +882,9 @@ class GenericTypeHandler<std::string> {
static size_t SpaceUsedLong(const Type& value) {
return sizeof(value) + StringSpaceUsedExcludingSelfLong(value);
}
static const Type& default_instance() {
return GetEmptyStringAlreadyInited();
}
};
} // namespace internal

Loading…
Cancel
Save