Add "string_type" to CppFeatures.

PiperOrigin-RevId: 603514708
pull/15653/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 8b46b56467
commit 2a28082df3
  1. 2
      src/google/protobuf/cpp_edition_defaults.h
  2. 125
      src/google/protobuf/cpp_features.pb.cc
  3. 110
      src/google/protobuf/cpp_features.pb.h
  4. 15
      src/google/protobuf/cpp_features.proto
  5. 295
      src/google/protobuf/descriptor_unittest.cc
  6. 2
      src/google/protobuf/editions/generated_files_test.cc

@ -5,7 +5,7 @@
// the C++ runtime. This is used for feature resolution under Editions. // the C++ runtime. This is used for feature resolution under Editions.
// NOLINTBEGIN // NOLINTBEGIN
// clang-format off // clang-format off
#define PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS "\n\026\022\021\010\001\020\002\030\002 \003(\0010\002\302>\002\010\001\030\346\007\n\026\022\021\010\002\020\001\030\001 \002(\0010\001\302>\002\010\000\030\347\007\n\026\022\021\010\001\020\001\030\001 \002(\0010\001\302>\002\010\000\030\350\007 \346\007(\350\007" #define PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS "\n\030\022\023\010\001\020\002\030\002 \003(\0010\002\302>\004\010\001\020\003\030\346\007\n\030\022\023\010\002\020\001\030\001 \002(\0010\001\302>\004\010\000\020\003\030\347\007\n\030\022\023\010\001\020\001\030\001 \002(\0010\001\302>\004\010\000\020\003\030\350\007 \346\007(\350\007"
// clang-format on // clang-format on
// NOLINTEND // NOLINTEND

@ -26,7 +26,8 @@ namespace pb {
inline constexpr CppFeatures::Impl_::Impl_( inline constexpr CppFeatures::Impl_::Impl_(
::_pbi::ConstantInitialized) noexcept ::_pbi::ConstantInitialized) noexcept
: _cached_size_{0}, : _cached_size_{0},
legacy_closed_enum_{false} {} legacy_closed_enum_{false},
string_type_{static_cast< ::pb::CppFeatures_StringType >(0)} {}
template <typename> template <typename>
PROTOBUF_CONSTEXPR CppFeatures::CppFeatures(::_pbi::ConstantInitialized) PROTOBUF_CONSTEXPR CppFeatures::CppFeatures(::_pbi::ConstantInitialized)
@ -42,8 +43,7 @@ struct CppFeaturesDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_EXPORT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CppFeaturesDefaultTypeInternal _CppFeatures_default_instance_; PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CppFeaturesDefaultTypeInternal _CppFeatures_default_instance_;
} // namespace pb } // namespace pb
static constexpr const ::_pb::EnumDescriptor** static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto[1];
file_level_enum_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto = nullptr;
static constexpr const ::_pb::ServiceDescriptor** static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto = nullptr; file_level_service_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto = nullptr;
const ::uint32_t const ::uint32_t
@ -58,12 +58,14 @@ const ::uint32_t
~0u, // no _split_ ~0u, // no _split_
~0u, // no sizeof(Split) ~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::pb::CppFeatures, _impl_.legacy_closed_enum_), PROTOBUF_FIELD_OFFSET(::pb::CppFeatures, _impl_.legacy_closed_enum_),
PROTOBUF_FIELD_OFFSET(::pb::CppFeatures, _impl_.string_type_),
0, 0,
1,
}; };
static const ::_pbi::MigrationSchema static const ::_pbi::MigrationSchema
schemas[] ABSL_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { schemas[] ABSL_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
{0, 9, -1, sizeof(::pb::CppFeatures)}, {0, 10, -1, sizeof(::pb::CppFeatures)},
}; };
static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {
&::pb::_CppFeatures_default_instance_._instance, &::pb::_CppFeatures_default_instance_._instance,
@ -71,11 +73,15 @@ static const ::_pb::Message* const file_default_instances[] = {
const char descriptor_table_protodef_google_2fprotobuf_2fcpp_5ffeatures_2eproto[] ABSL_ATTRIBUTE_SECTION_VARIABLE( const char descriptor_table_protodef_google_2fprotobuf_2fcpp_5ffeatures_2eproto[] ABSL_ATTRIBUTE_SECTION_VARIABLE(
protodesc_cold) = { protodesc_cold) = {
"\n\"google/protobuf/cpp_features.proto\022\002pb" "\n\"google/protobuf/cpp_features.proto\022\002pb"
"\032 google/protobuf/descriptor.proto\"M\n\013Cp" "\032 google/protobuf/descriptor.proto\"\352\001\n\013C"
"pFeatures\022>\n\022legacy_closed_enum\030\001 \001(\010B\"\210" "ppFeatures\022>\n\022legacy_closed_enum\030\001 \001(\010B\""
"\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\346\007\242\001\n\022\005false\030\347\007::\n\003cpp" "\210\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\346\007\242\001\n\022\005false\030\347\007\022T\n\013st"
"\022\033.google.protobuf.FeatureSet\030\350\007 \001(\0132\017.p" "ring_type\030\002 \001(\0162\032.pb.CppFeatures.StringT"
"b.CppFeatures" "ypeB#\210\001\001\230\001\004\230\001\001\242\001\013\022\006STRING\030\346\007\242\001\t\022\004VIEW\030\351\007"
"\"E\n\nStringType\022\027\n\023STRING_TYPE_UNKNOWN\020\000\022"
"\010\n\004VIEW\020\001\022\010\n\004CORD\020\002\022\n\n\006STRING\020\003::\n\003cpp\022\033"
".google.protobuf.FeatureSet\030\350\007 \001(\0132\017.pb."
"CppFeatures"
}; };
static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_deps[1] = static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_deps[1] =
{ {
@ -85,7 +91,7 @@ static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2ep
PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto = { PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto = {
false, false,
false, false,
213, 371,
descriptor_table_protodef_google_2fprotobuf_2fcpp_5ffeatures_2eproto, descriptor_table_protodef_google_2fprotobuf_2fcpp_5ffeatures_2eproto,
"google/protobuf/cpp_features.proto", "google/protobuf/cpp_features.proto",
&descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_once, &descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_once,
@ -99,6 +105,28 @@ PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fproto
file_level_service_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto,
}; };
namespace pb { namespace pb {
const ::google::protobuf::EnumDescriptor* CppFeatures_StringType_descriptor() {
::google::protobuf::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto[0];
}
PROTOBUF_CONSTINIT const uint32_t CppFeatures_StringType_internal_data_[] = {
262144u, 0u, };
bool CppFeatures_StringType_IsValid(int value) {
return 0 <= value && value <= 3;
}
#if (__cplusplus < 201703) && \
(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr CppFeatures_StringType CppFeatures::STRING_TYPE_UNKNOWN;
constexpr CppFeatures_StringType CppFeatures::VIEW;
constexpr CppFeatures_StringType CppFeatures::CORD;
constexpr CppFeatures_StringType CppFeatures::STRING;
constexpr CppFeatures_StringType CppFeatures::StringType_MIN;
constexpr CppFeatures_StringType CppFeatures::StringType_MAX;
constexpr int CppFeatures::StringType_ARRAYSIZE;
#endif // (__cplusplus < 201703) &&
// (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
// =================================================================== // ===================================================================
class CppFeatures::_Internal { class CppFeatures::_Internal {
@ -125,7 +153,12 @@ inline PROTOBUF_NDEBUG_INLINE CppFeatures::Impl_::Impl_(
inline void CppFeatures::SharedCtor(::_pb::Arena* arena) { inline void CppFeatures::SharedCtor(::_pb::Arena* arena) {
new (&_impl_) Impl_(internal_visibility(), arena); new (&_impl_) Impl_(internal_visibility(), arena);
_impl_.legacy_closed_enum_ = {}; ::memset(reinterpret_cast<char *>(&_impl_) +
offsetof(Impl_, legacy_closed_enum_),
0,
offsetof(Impl_, string_type_) -
offsetof(Impl_, legacy_closed_enum_) +
sizeof(Impl_::string_type_));
} }
CppFeatures::~CppFeatures() { CppFeatures::~CppFeatures() {
// @@protoc_insertion_point(destructor:pb.CppFeatures) // @@protoc_insertion_point(destructor:pb.CppFeatures)
@ -154,23 +187,26 @@ CppFeatures::GetClassData() const {
return _data_.base(); return _data_.base();
} }
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<0, 1, 0, 0, 2> CppFeatures::_table_ = { const ::_pbi::TcParseTable<1, 2, 1, 0, 2> CppFeatures::_table_ = {
{ {
PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_._has_bits_),
0, // no _extensions_ 0, // no _extensions_
1, 0, // max_field_number, fast_idx_mask 2, 8, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table), offsetof(decltype(_table_), field_lookup_table),
4294967294, // skipmap 4294967292, // skipmap
offsetof(decltype(_table_), field_entries), offsetof(decltype(_table_), field_entries),
1, // num_field_entries 2, // num_field_entries
0, // num_aux_entries 1, // num_aux_entries
offsetof(decltype(_table_), field_names), // no aux_entries offsetof(decltype(_table_), aux_entries),
&_CppFeatures_default_instance_._instance, &_CppFeatures_default_instance_._instance,
::_pbi::TcParser::GenericFallback, // fallback ::_pbi::TcParser::GenericFallback, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE #ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<::pb::CppFeatures>(), // to_prefetch ::_pbi::TcParser::GetTable<::pb::CppFeatures>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE #endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{ }, {{
// optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
{::_pbi::TcParser::FastEr0S1,
{16, 1, 3, PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.string_type_)}},
// optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = { // optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
{::_pbi::TcParser::SingularVarintNoZag1<bool, offsetof(CppFeatures, _impl_.legacy_closed_enum_), 0>(), {::_pbi::TcParser::SingularVarintNoZag1<bool, offsetof(CppFeatures, _impl_.legacy_closed_enum_), 0>(),
{8, 0, 0, PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.legacy_closed_enum_)}}, {8, 0, 0, PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.legacy_closed_enum_)}},
@ -180,9 +216,12 @@ const ::_pbi::TcParseTable<0, 1, 0, 0, 2> CppFeatures::_table_ = {
// optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = { // optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
{PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.legacy_closed_enum_), _Internal::kHasBitsOffset + 0, 0, {PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.legacy_closed_enum_), _Internal::kHasBitsOffset + 0, 0,
(0 | ::_fl::kFcOptional | ::_fl::kBool)}, (0 | ::_fl::kFcOptional | ::_fl::kBool)},
}}, // optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
// no aux_entries {PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.string_type_), _Internal::kHasBitsOffset + 1, 0,
{{ (0 | ::_fl::kFcOptional | ::_fl::kEnumRange)},
}}, {{
{0, 4},
}}, {{
}}, }},
}; };
@ -193,7 +232,12 @@ PROTOBUF_NOINLINE void CppFeatures::Clear() {
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits; (void) cached_has_bits;
_impl_.legacy_closed_enum_ = false; cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
::memset(&_impl_.legacy_closed_enum_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.string_type_) -
reinterpret_cast<char*>(&_impl_.legacy_closed_enum_)) + sizeof(_impl_.string_type_));
}
_impl_._has_bits_.Clear(); _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>(); _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
} }
@ -220,6 +264,13 @@ const char* CppFeatures::_InternalParse(
1, this->_internal_legacy_closed_enum(), target); 1, this->_internal_legacy_closed_enum(), target);
} }
// optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
2, this->_internal_string_type(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = target =
::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
@ -237,12 +288,20 @@ const char* CppFeatures::_InternalParse(
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits; (void) cached_has_bits;
// optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
cached_has_bits = _impl_._has_bits_[0]; cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000003u) {
total_size += 2; // optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
} if (cached_has_bits & 0x00000001u) {
total_size += 2;
}
// optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::_pbi::WireFormatLite::EnumSize(this->_internal_string_type());
}
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
} }
@ -256,8 +315,13 @@ void CppFeatures::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::goo
(void) cached_has_bits; (void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0]; cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000003u) {
_this->_impl_.legacy_closed_enum_ = from._impl_.legacy_closed_enum_; if (cached_has_bits & 0x00000001u) {
_this->_impl_.legacy_closed_enum_ = from._impl_.legacy_closed_enum_;
}
if (cached_has_bits & 0x00000002u) {
_this->_impl_.string_type_ = from._impl_.string_type_;
}
} }
_this->_impl_._has_bits_[0] |= cached_has_bits; _this->_impl_._has_bits_[0] |= cached_has_bits;
_this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_); _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
@ -278,7 +342,12 @@ void CppFeatures::InternalSwap(CppFeatures* PROTOBUF_RESTRICT other) {
using std::swap; using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_); _internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
swap(_impl_.legacy_closed_enum_, other->_impl_.legacy_closed_enum_); ::google::protobuf::internal::memswap<
PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.string_type_)
+ sizeof(CppFeatures::_impl_.string_type_)
- PROTOBUF_FIELD_OFFSET(CppFeatures, _impl_.legacy_closed_enum_)>(
reinterpret_cast<char*>(&_impl_.legacy_closed_enum_),
reinterpret_cast<char*>(&other->_impl_.legacy_closed_enum_));
} }
::google::protobuf::Metadata CppFeatures::GetMetadata() const { ::google::protobuf::Metadata CppFeatures::GetMetadata() const {

@ -27,6 +27,7 @@
#include "google/protobuf/message.h" #include "google/protobuf/message.h"
#include "google/protobuf/repeated_field.h" // IWYU pragma: export #include "google/protobuf/repeated_field.h" // IWYU pragma: export
#include "google/protobuf/extension_set.h" // IWYU pragma: export #include "google/protobuf/extension_set.h" // IWYU pragma: export
#include "google/protobuf/generated_enum_reflection.h"
#include "google/protobuf/unknown_field_set.h" #include "google/protobuf/unknown_field_set.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
// @@protoc_insertion_point(includes) // @@protoc_insertion_point(includes)
@ -61,6 +62,37 @@ namespace protobuf {
} // namespace google } // namespace google
namespace pb { namespace pb {
enum CppFeatures_StringType : int {
CppFeatures_StringType_STRING_TYPE_UNKNOWN = 0,
CppFeatures_StringType_VIEW = 1,
CppFeatures_StringType_CORD = 2,
CppFeatures_StringType_STRING = 3,
};
PROTOBUF_EXPORT bool CppFeatures_StringType_IsValid(int value);
PROTOBUF_EXPORT extern const uint32_t CppFeatures_StringType_internal_data_[];
constexpr CppFeatures_StringType CppFeatures_StringType_StringType_MIN = static_cast<CppFeatures_StringType>(0);
constexpr CppFeatures_StringType CppFeatures_StringType_StringType_MAX = static_cast<CppFeatures_StringType>(3);
constexpr int CppFeatures_StringType_StringType_ARRAYSIZE = 3 + 1;
PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor*
CppFeatures_StringType_descriptor();
template <typename T>
const std::string& CppFeatures_StringType_Name(T value) {
static_assert(std::is_same<T, CppFeatures_StringType>::value ||
std::is_integral<T>::value,
"Incorrect type passed to StringType_Name().");
return CppFeatures_StringType_Name(static_cast<CppFeatures_StringType>(value));
}
template <>
inline const std::string& CppFeatures_StringType_Name(CppFeatures_StringType value) {
return ::google::protobuf::internal::NameOfDenseEnum<CppFeatures_StringType_descriptor,
0, 3>(
static_cast<int>(value));
}
inline bool CppFeatures_StringType_Parse(absl::string_view name, CppFeatures_StringType* value) {
return ::google::protobuf::internal::ParseNamedEnum<CppFeatures_StringType>(
CppFeatures_StringType_descriptor(), name, value);
}
// =================================================================== // ===================================================================
@ -188,10 +220,32 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message
public: public:
::google::protobuf::Metadata GetMetadata() const; ::google::protobuf::Metadata GetMetadata() const;
// nested types ---------------------------------------------------- // nested types ----------------------------------------------------
using StringType = CppFeatures_StringType;
static constexpr StringType STRING_TYPE_UNKNOWN = CppFeatures_StringType_STRING_TYPE_UNKNOWN;
static constexpr StringType VIEW = CppFeatures_StringType_VIEW;
static constexpr StringType CORD = CppFeatures_StringType_CORD;
static constexpr StringType STRING = CppFeatures_StringType_STRING;
static inline bool StringType_IsValid(int value) {
return CppFeatures_StringType_IsValid(value);
}
static constexpr StringType StringType_MIN = CppFeatures_StringType_StringType_MIN;
static constexpr StringType StringType_MAX = CppFeatures_StringType_StringType_MAX;
static constexpr int StringType_ARRAYSIZE = CppFeatures_StringType_StringType_ARRAYSIZE;
static inline const ::google::protobuf::EnumDescriptor* StringType_descriptor() {
return CppFeatures_StringType_descriptor();
}
template <typename T>
static inline const std::string& StringType_Name(T value) {
return CppFeatures_StringType_Name(value);
}
static inline bool StringType_Parse(absl::string_view name, StringType* value) {
return CppFeatures_StringType_Parse(name, value);
}
// accessors ------------------------------------------------------- // accessors -------------------------------------------------------
enum : int { enum : int {
kLegacyClosedEnumFieldNumber = 1, kLegacyClosedEnumFieldNumber = 1,
kStringTypeFieldNumber = 2,
}; };
// optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = { // optional bool legacy_closed_enum = 1 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
bool has_legacy_closed_enum() const; bool has_legacy_closed_enum() const;
@ -203,13 +257,24 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message
bool _internal_legacy_closed_enum() const; bool _internal_legacy_closed_enum() const;
void _internal_set_legacy_closed_enum(bool value); void _internal_set_legacy_closed_enum(bool value);
public:
// optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
bool has_string_type() const;
void clear_string_type() ;
::pb::CppFeatures_StringType string_type() const;
void set_string_type(::pb::CppFeatures_StringType value);
private:
::pb::CppFeatures_StringType _internal_string_type() const;
void _internal_set_string_type(::pb::CppFeatures_StringType value);
public: public:
// @@protoc_insertion_point(class_scope:pb.CppFeatures) // @@protoc_insertion_point(class_scope:pb.CppFeatures)
private: private:
class _Internal; class _Internal;
friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable< static const ::google::protobuf::internal::TcParseTable<
0, 1, 0, 1, 2, 1,
0, 2> 0, 2>
_table_; _table_;
friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::MessageLite;
@ -228,6 +293,7 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message
::google::protobuf::internal::HasBits<1> _has_bits_; ::google::protobuf::internal::HasBits<1> _has_bits_;
mutable ::google::protobuf::internal::CachedSize _cached_size_; mutable ::google::protobuf::internal::CachedSize _cached_size_;
bool legacy_closed_enum_; bool legacy_closed_enum_;
int string_type_;
PROTOBUF_TSAN_DECLARE_MEMBER PROTOBUF_TSAN_DECLARE_MEMBER
}; };
union { Impl_ _impl_; }; union { Impl_ _impl_; };
@ -283,6 +349,35 @@ inline void CppFeatures::_internal_set_legacy_closed_enum(bool value) {
_impl_.legacy_closed_enum_ = value; _impl_.legacy_closed_enum_ = value;
} }
// optional .pb.CppFeatures.StringType string_type = 2 [retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, edition_defaults = {
inline bool CppFeatures::has_string_type() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline void CppFeatures::clear_string_type() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.string_type_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
inline ::pb::CppFeatures_StringType CppFeatures::string_type() const {
// @@protoc_insertion_point(field_get:pb.CppFeatures.string_type)
return _internal_string_type();
}
inline void CppFeatures::set_string_type(::pb::CppFeatures_StringType value) {
_internal_set_string_type(value);
_impl_._has_bits_[0] |= 0x00000002u;
// @@protoc_insertion_point(field_set:pb.CppFeatures.string_type)
}
inline ::pb::CppFeatures_StringType CppFeatures::_internal_string_type() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return static_cast<::pb::CppFeatures_StringType>(_impl_.string_type_);
}
inline void CppFeatures::_internal_set_string_type(::pb::CppFeatures_StringType value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
assert(::pb::CppFeatures_StringType_IsValid(value));
_impl_.string_type_ = value;
}
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif // __GNUC__ #endif // __GNUC__
@ -291,6 +386,19 @@ inline void CppFeatures::_internal_set_legacy_closed_enum(bool value) {
} // namespace pb } // namespace pb
namespace google {
namespace protobuf {
template <>
struct is_proto_enum<::pb::CppFeatures_StringType> : std::true_type {};
template <>
inline const EnumDescriptor* GetEnumDescriptor<::pb::CppFeatures_StringType>() {
return ::pb::CppFeatures_StringType_descriptor();
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc" #include "google/protobuf/port_undef.inc"

@ -27,4 +27,19 @@ message CppFeatures {
edition_defaults = { edition: EDITION_PROTO2, value: "true" }, edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" } edition_defaults = { edition: EDITION_PROTO3, value: "false" }
]; ];
enum StringType {
STRING_TYPE_UNKNOWN = 0;
VIEW = 1;
CORD = 2;
STRING = 3;
}
optional StringType string_type = 2 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition: EDITION_PROTO2, value: "STRING" },
edition_defaults = { edition: EDITION_2024, value: "VIEW" }
];
} }

@ -7415,30 +7415,33 @@ TEST_F(FeaturesTest, Proto2Features) {
const FieldDescriptor* group = message->field(1); const FieldDescriptor* group = message->field(1);
EXPECT_THAT(file->options(), EqualsProto("")); EXPECT_THAT(file->options(), EqualsProto(""));
EXPECT_EQ(GetFeatures(file).GetExtension(pb::test).int_file_feature(), -2); EXPECT_EQ(GetFeatures(file).GetExtension(pb::test).int_file_feature(), -2);
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: CLOSED field_presence: EXPLICIT
repeated_field_encoding: EXPANDED enum_type: CLOSED
utf8_validation: NONE repeated_field_encoding: EXPANDED
message_encoding: LENGTH_PREFIXED utf8_validation: NONE
json_format: LEGACY_BEST_EFFORT message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: true })pb")); json_format: LEGACY_BEST_EFFORT
EXPECT_THAT(GetCoreFeatures(field), EqualsProto(R"pb( [pb.cpp] { legacy_closed_enum: true string_type: STRING })pb"));
field_presence: EXPLICIT EXPECT_THAT(
enum_type: CLOSED GetCoreFeatures(field), EqualsProto(R"pb(
repeated_field_encoding: EXPANDED field_presence: EXPLICIT
utf8_validation: NONE enum_type: CLOSED
message_encoding: LENGTH_PREFIXED repeated_field_encoding: EXPANDED
json_format: LEGACY_BEST_EFFORT utf8_validation: NONE
[pb.cpp] { legacy_closed_enum: true })pb")); message_encoding: LENGTH_PREFIXED
EXPECT_THAT(GetCoreFeatures(group), EqualsProto(R"pb( json_format: LEGACY_BEST_EFFORT
field_presence: EXPLICIT [pb.cpp] { legacy_closed_enum: true string_type: STRING })pb"));
enum_type: CLOSED EXPECT_THAT(
repeated_field_encoding: EXPANDED GetCoreFeatures(group), EqualsProto(R"pb(
utf8_validation: NONE field_presence: EXPLICIT
message_encoding: DELIMITED enum_type: CLOSED
json_format: LEGACY_BEST_EFFORT repeated_field_encoding: EXPANDED
[pb.cpp] { legacy_closed_enum: true })pb")); utf8_validation: NONE
message_encoding: DELIMITED
json_format: LEGACY_BEST_EFFORT
[pb.cpp] { legacy_closed_enum: true string_type: STRING })pb"));
EXPECT_TRUE(field->has_presence()); EXPECT_TRUE(field->has_presence());
EXPECT_FALSE(field->requires_utf8_validation()); EXPECT_FALSE(field->requires_utf8_validation());
EXPECT_EQ( EXPECT_EQ(
@ -7492,22 +7495,24 @@ TEST_F(FeaturesTest, Proto3Features) {
const FieldDescriptor* field = message->field(0); const FieldDescriptor* field = message->field(0);
EXPECT_THAT(file->options(), EqualsProto("")); EXPECT_THAT(file->options(), EqualsProto(""));
EXPECT_EQ(GetFeatures(file).GetExtension(pb::test).int_file_feature(), -3); EXPECT_EQ(GetFeatures(file).GetExtension(pb::test).int_file_feature(), -3);
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: IMPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: OPEN field_presence: IMPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
EXPECT_THAT(GetCoreFeatures(field), EqualsProto(R"pb( [pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
field_presence: IMPLICIT EXPECT_THAT(
enum_type: OPEN GetCoreFeatures(field), EqualsProto(R"pb(
repeated_field_encoding: PACKED field_presence: IMPLICIT
utf8_validation: VERIFY enum_type: OPEN
message_encoding: LENGTH_PREFIXED repeated_field_encoding: PACKED
json_format: ALLOW utf8_validation: VERIFY
[pb.cpp] { legacy_closed_enum: false })pb")); message_encoding: LENGTH_PREFIXED
json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
EXPECT_FALSE(field->has_presence()); EXPECT_FALSE(field->has_presence());
EXPECT_FALSE(field->requires_utf8_validation()); EXPECT_FALSE(field->requires_utf8_validation());
EXPECT_EQ( EXPECT_EQ(
@ -7646,7 +7651,7 @@ TEST_F(FeaturesTest, Edition2023Defaults) {
utf8_validation: VERIFY utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED message_encoding: LENGTH_PREFIXED
json_format: ALLOW json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false } [pb.cpp] { legacy_closed_enum: false string_type: STRING }
)pb")); )pb"));
// Since pb::test is registered in the pool, it should end up with defaults in // Since pb::test is registered in the pool, it should end up with defaults in
@ -7674,7 +7679,7 @@ TEST_F(FeaturesBaseTest, DefaultEdition2023Defaults) {
utf8_validation: VERIFY utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED message_encoding: LENGTH_PREFIXED
json_format: ALLOW json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false } [pb.cpp] { legacy_closed_enum: false string_type: STRING }
)pb")); )pb"));
EXPECT_FALSE(GetFeatures(file).HasExtension(pb::test)); EXPECT_FALSE(GetFeatures(file).HasExtension(pb::test));
} }
@ -7691,14 +7696,15 @@ TEST_F(FeaturesTest, ClearsOptions) {
} }
)pb"); )pb");
EXPECT_THAT(file->options(), EqualsProto("java_package: 'bar'")); EXPECT_THAT(file->options(), EqualsProto("java_package: 'bar'"));
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: IMPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: OPEN field_presence: IMPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, RestoresOptionsRoundTrip) { TEST_F(FeaturesTest, RestoresOptionsRoundTrip) {
@ -8055,14 +8061,15 @@ TEST_F(FeaturesTest, NoOptions) {
name: "foo.proto" syntax: "editions" edition: EDITION_2023 name: "foo.proto" syntax: "editions" edition: EDITION_2023
)pb"); )pb");
EXPECT_EQ(&file->options(), &FileOptions::default_instance()); EXPECT_EQ(&file->options(), &FileOptions::default_instance());
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, InvalidEdition) { TEST_F(FeaturesTest, InvalidEdition) {
@ -8084,14 +8091,15 @@ TEST_F(FeaturesTest, FileFeatures) {
options { features { field_presence: IMPLICIT } } options { features { field_presence: IMPLICIT } }
)pb"); )pb");
EXPECT_THAT(file->options(), EqualsProto("")); EXPECT_THAT(file->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: IMPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: OPEN field_presence: IMPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, FileFeaturesExtension) { TEST_F(FeaturesTest, FileFeaturesExtension) {
@ -8159,14 +8167,15 @@ TEST_F(FeaturesTest, MessageFeaturesDefault) {
)pb"); )pb");
const Descriptor* message = file->message_type(0); const Descriptor* message = file->message_type(0);
EXPECT_THAT(message->options(), EqualsProto("")); EXPECT_THAT(message->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(message), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(message), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, MessageFeaturesInherit) { TEST_F(FeaturesTest, MessageFeaturesInherit) {
@ -8264,14 +8273,15 @@ TEST_F(FeaturesTest, FieldFeaturesDefault) {
)pb"); )pb");
const FieldDescriptor* field = file->message_type(0)->field(0); const FieldDescriptor* field = file->message_type(0)->field(0);
EXPECT_THAT(field->options(), EqualsProto("")); EXPECT_THAT(field->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(field), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(field), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, FieldFeaturesInherit) { TEST_F(FeaturesTest, FieldFeaturesInherit) {
@ -8652,14 +8662,15 @@ TEST_F(FeaturesTest, EnumFeaturesDefault) {
)pb"); )pb");
const EnumDescriptor* enm = file->enum_type(0); const EnumDescriptor* enm = file->enum_type(0);
EXPECT_THAT(enm->options(), EqualsProto("")); EXPECT_THAT(enm->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(enm), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(enm), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, EnumFeaturesInherit) { TEST_F(FeaturesTest, EnumFeaturesInherit) {
@ -8759,14 +8770,15 @@ TEST_F(FeaturesTest, EnumValueFeaturesDefault) {
)pb"); )pb");
const EnumValueDescriptor* value = file->enum_type(0)->value(0); const EnumValueDescriptor* value = file->enum_type(0)->value(0);
EXPECT_THAT(value->options(), EqualsProto("")); EXPECT_THAT(value->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(value), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(value), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, EnumValueFeaturesInherit) { TEST_F(FeaturesTest, EnumValueFeaturesInherit) {
@ -8851,14 +8863,15 @@ TEST_F(FeaturesTest, OneofFeaturesDefault) {
)pb"); )pb");
const OneofDescriptor* oneof = file->message_type(0)->oneof_decl(0); const OneofDescriptor* oneof = file->message_type(0)->oneof_decl(0);
EXPECT_THAT(oneof->options(), EqualsProto("")); EXPECT_THAT(oneof->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(oneof), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(oneof), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, OneofFeaturesInherit) { TEST_F(FeaturesTest, OneofFeaturesInherit) {
@ -8950,14 +8963,15 @@ TEST_F(FeaturesTest, ExtensionRangeFeaturesDefault) {
const Descriptor::ExtensionRange* range = const Descriptor::ExtensionRange* range =
file->message_type(0)->extension_range(0); file->message_type(0)->extension_range(0);
EXPECT_THAT(range->options(), EqualsProto("")); EXPECT_THAT(range->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(range), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(range), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, ExtensionRangeFeaturesInherit) { TEST_F(FeaturesTest, ExtensionRangeFeaturesInherit) {
@ -9034,14 +9048,15 @@ TEST_F(FeaturesTest, ServiceFeaturesDefault) {
)pb"); )pb");
const ServiceDescriptor* service = file->service(0); const ServiceDescriptor* service = file->service(0);
EXPECT_THAT(service->options(), EqualsProto("")); EXPECT_THAT(service->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(service), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(service), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, ServiceFeaturesInherit) { TEST_F(FeaturesTest, ServiceFeaturesInherit) {
@ -9100,14 +9115,15 @@ TEST_F(FeaturesTest, MethodFeaturesDefault) {
)pb"); )pb");
const MethodDescriptor* method = file->service(0)->method(0); const MethodDescriptor* method = file->service(0)->method(0);
EXPECT_THAT(method->options(), EqualsProto("")); EXPECT_THAT(method->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(method), EqualsProto(R"pb( EXPECT_THAT(
field_presence: EXPLICIT GetCoreFeatures(method), EqualsProto(R"pb(
enum_type: OPEN field_presence: EXPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, MethodFeaturesInherit) { TEST_F(FeaturesTest, MethodFeaturesInherit) {
@ -9313,7 +9329,7 @@ TEST_F(FeaturesTest, EnumFeatureHelpers) {
type_name: "FooOpen" type_name: "FooOpen"
options { options {
features { features {
[pb.cpp] { legacy_closed_enum: true } [pb.cpp] { legacy_closed_enum: true string_type: STRING }
} }
} }
} }
@ -9931,14 +9947,15 @@ TEST_F(FeaturesTest, UninterpretedOptions) {
} }
)pb"); )pb");
EXPECT_THAT(file->options(), EqualsProto("")); EXPECT_THAT(file->options(), EqualsProto(""));
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb( EXPECT_THAT(
field_presence: IMPLICIT GetCoreFeatures(file), EqualsProto(R"pb(
enum_type: OPEN field_presence: IMPLICIT
repeated_field_encoding: PACKED enum_type: OPEN
utf8_validation: VERIFY repeated_field_encoding: PACKED
message_encoding: LENGTH_PREFIXED utf8_validation: VERIFY
json_format: ALLOW message_encoding: LENGTH_PREFIXED
[pb.cpp] { legacy_closed_enum: false })pb")); json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false string_type: STRING })pb"));
} }
TEST_F(FeaturesTest, UninterpretedOptionsMerge) { TEST_F(FeaturesTest, UninterpretedOptionsMerge) {

@ -146,7 +146,7 @@ TEST(Generated, EditionDefaults2023InternalFeatures) {
utf8_validation: VERIFY utf8_validation: VERIFY
message_encoding: LENGTH_PREFIXED message_encoding: LENGTH_PREFIXED
json_format: ALLOW json_format: ALLOW
[pb.cpp] { legacy_closed_enum: false } [pb.cpp] { legacy_closed_enum: false string_type: STRING }
)pb")); )pb"));
} }

Loading…
Cancel
Save