Flip the names of edition_enum and edition.

We will be using the enum edition from now on, and the string field will be removed ASAP.

PiperOrigin-RevId: 568554147
pull/14209/head
Mike Kruskal 1 year ago committed by Copybara-Service
parent d5ec12e9a8
commit 65419eef0d
  1. 8
      java/core/src/main/java/com/google/protobuf/Descriptors.java
  2. 6
      src/google/protobuf/compiler/code_generator_unittest.cc
  3. 30
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  4. 2
      src/google/protobuf/compiler/parser.cc
  5. 12
      src/google/protobuf/compiler/parser_unittest.cc
  6. 4
      src/google/protobuf/cpp_features.proto
  7. 12
      src/google/protobuf/descriptor.cc
  8. 1035
      src/google/protobuf/descriptor.pb.cc
  9. 732
      src/google/protobuf/descriptor.pb.h
  10. 32
      src/google/protobuf/descriptor.proto
  11. 173
      src/google/protobuf/descriptor_unittest.cc
  12. 36
      src/google/protobuf/feature_resolver.cc
  13. 72
      src/google/protobuf/feature_resolver_test.cc
  14. 48
      src/google/protobuf/unittest_features.proto
  15. 2
      src/google/protobuf/unittest_invalid_features.proto
  16. 2
      src/google/protobuf/util/type_resolver_util_test.cc
  17. 2
      upb/upb/reflection/file_def.c
  18. 8
      upb/upb/reflection/stage0/google/protobuf/descriptor.upb.c
  19. 131
      upb/upb/reflection/stage0/google/protobuf/descriptor.upb.h
  20. 2
      upb/upb/util/def_to_proto.c

@ -169,15 +169,15 @@ public final class Descriptors {
/** Get the edition of the .proto file. */
public Edition getEdition() {
return proto.getEditionEnum();
return proto.getEdition();
}
/** Gets the name of the edition as specified in the .proto file. */
public String getEditionName() {
if (proto.getEditionEnum().equals(Edition.EDITION_UNKNOWN)) {
if (proto.getEdition().equals(Edition.EDITION_UNKNOWN)) {
return "";
}
return proto.getEditionEnum().name().substring("EDITION_".length());
return proto.getEdition().name().substring("EDITION_".length());
}
public void copyHeadingTo(FileDescriptorProto.Builder protoBuilder) {
@ -187,7 +187,7 @@ public final class Descriptors {
}
if (getSyntax().equals(Syntax.EDITIONS)) {
protoBuilder.setEditionEnum(getEdition());
protoBuilder.setEdition(getEdition());
}
if (!getOptions().equals(FileOptions.getDefaultInstance())) {

@ -264,7 +264,7 @@ TEST_F(CodeGeneratorTest, BuildFeatureSetDefaults) {
EXPECT_THAT(generator.BuildFeatureSetDefaults(),
IsOkAndHolds(EqualsProto(R"pb(
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {
field_presence: EXPLICIT
enum_type: OPEN
@ -273,8 +273,8 @@ TEST_F(CodeGeneratorTest, BuildFeatureSetDefaults) {
json_format: ALLOW
}
}
minimum_edition_enum: EDITION_99997_TEST_ONLY
maximum_edition_enum: EDITION_99999_TEST_ONLY
minimum_edition: EDITION_99997_TEST_ONLY
maximum_edition: EDITION_99999_TEST_ONLY
)pb")));
}

@ -1406,7 +1406,7 @@ TEST_F(CommandLineInterfaceTest, FeatureExtensions) {
optional int32 int_feature = 1 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition: "2023", value: "3" }
edition_defaults = { edition: EDITION_2023, value: "3" }
];
})schema");
CreateTempFile("foo.proto",
@ -1748,7 +1748,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaults) {
FeatureSetDefaults defaults = ReadEditionDefaults("defaults");
EXPECT_THAT(defaults, EqualsProto(R"pb(
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {
field_presence: EXPLICIT
enum_type: OPEN
@ -1757,8 +1757,8 @@ TEST_F(CommandLineInterfaceTest, EditionDefaults) {
json_format: ALLOW
}
}
minimum_edition_enum: EDITION_2023
maximum_edition_enum: EDITION_2023
minimum_edition: EDITION_2023
maximum_edition: EDITION_2023
)pb"));
}
@ -1774,7 +1774,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMaximum) {
FeatureSetDefaults defaults = ReadEditionDefaults("defaults");
EXPECT_THAT(defaults, EqualsProto(R"pb(
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {
field_presence: EXPLICIT
enum_type: OPEN
@ -1783,8 +1783,8 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMaximum) {
json_format: ALLOW
}
}
minimum_edition_enum: EDITION_2023
maximum_edition_enum: EDITION_99997_TEST_ONLY
minimum_edition: EDITION_2023
maximum_edition: EDITION_99997_TEST_ONLY
)pb"));
}
@ -1801,7 +1801,7 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMinimum) {
FeatureSetDefaults defaults = ReadEditionDefaults("defaults");
EXPECT_THAT(defaults, EqualsProto(R"pb(
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {
field_presence: EXPLICIT
enum_type: OPEN
@ -1810,8 +1810,8 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMinimum) {
json_format: ALLOW
}
}
minimum_edition_enum: EDITION_99997_TEST_ONLY
maximum_edition_enum: EDITION_99999_TEST_ONLY
minimum_edition: EDITION_99997_TEST_ONLY
maximum_edition: EDITION_99999_TEST_ONLY
)pb"));
}
@ -1827,12 +1827,12 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithExtension) {
ExpectNoErrors();
FeatureSetDefaults defaults = ReadEditionDefaults("defaults");
EXPECT_EQ(defaults.minimum_edition_enum(), EDITION_2023);
EXPECT_EQ(defaults.maximum_edition_enum(), EDITION_99999_TEST_ONLY);
EXPECT_EQ(defaults.minimum_edition(), EDITION_2023);
EXPECT_EQ(defaults.maximum_edition(), EDITION_99999_TEST_ONLY);
ASSERT_EQ(defaults.defaults_size(), 3);
EXPECT_EQ(defaults.defaults(0).edition_enum(), EDITION_2023);
EXPECT_EQ(defaults.defaults(1).edition_enum(), EDITION_99997_TEST_ONLY);
EXPECT_EQ(defaults.defaults(2).edition_enum(), EDITION_99998_TEST_ONLY);
EXPECT_EQ(defaults.defaults(0).edition(), EDITION_2023);
EXPECT_EQ(defaults.defaults(1).edition(), EDITION_99997_TEST_ONLY);
EXPECT_EQ(defaults.defaults(2).edition(), EDITION_99998_TEST_ONLY);
EXPECT_EQ(
defaults.defaults(0).features().GetExtension(pb::test).int_file_feature(),
1);

@ -671,7 +671,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
if (file != nullptr) {
file->set_syntax(syntax_identifier_);
if (syntax_identifier_ == "editions") {
file->set_edition_enum(edition_);
file->set_edition(edition_);
}
}
} else if (!stop_after_syntax_identifier_) {

@ -868,7 +868,7 @@ TEST_F(ParseMessageTest, ReservedIdentifiers) {
"}\n",
"syntax: \"editions\" "
"edition_enum: EDITION_2023 "
"edition: EDITION_2023 "
"message_type {"
" name: \"TestMessage\""
" reserved_name: \"foo\""
@ -1256,7 +1256,7 @@ TEST_F(ParseEnumTest, ReservedIdentifiers) {
"}\n",
"syntax: \"editions\" "
"edition_enum: EDITION_2023 "
"edition: EDITION_2023 "
"enum_type {"
" name: \"TestEnum\""
" value { name:\"FOO\" number:0 }"
@ -4058,7 +4058,7 @@ TEST_F(ParseEditionsTest, Editions) {
" }"
"}"
"syntax: \"editions\""
"edition_enum: EDITION_2023\n");
"edition: EDITION_2023\n");
}
TEST_F(ParseEditionsTest, TestEdition) {
@ -4067,7 +4067,7 @@ TEST_F(ParseEditionsTest, TestEdition) {
edition = "99998_TEST_ONLY";
)schema",
"syntax: \"editions\""
"edition_enum: EDITION_99998_TEST_ONLY\n");
"edition: EDITION_99998_TEST_ONLY\n");
}
TEST_F(ParseEditionsTest, ExtensionsParse) {
@ -4093,7 +4093,7 @@ TEST_F(ParseEditionsTest, ExtensionsParse) {
" type: TYPE_STRING"
"}"
"syntax: \"editions\""
"edition_enum: EDITION_2023\n");
"edition: EDITION_2023\n");
}
TEST_F(ParseEditionsTest, MapFeatures) {
@ -4152,7 +4152,7 @@ TEST_F(ParseEditionsTest, MapFeatures) {
}
}
syntax: "editions"
edition_enum: EDITION_2023)pb");
edition: EDITION_2023)pb");
}
TEST_F(ParseEditionsTest, EmptyEdition) {

@ -24,7 +24,7 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "false" }
edition_defaults = { edition: EDITION_2023, value: "false" }
];
// The UTF8 validation strategy to use. See go/editions-utf8-validation for
@ -45,6 +45,6 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "VERIFY_PARSE" }
edition_defaults = { edition: EDITION_2023, value: "VERIFY_PARSE" }
];
}

@ -2795,7 +2795,7 @@ void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const {
proto->set_syntax(FileDescriptorLegacy::SyntaxName(syntax));
}
if (syntax == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) {
proto->set_edition_enum(edition());
proto->set_edition(edition());
}
if (&options() != &FileOptions::default_instance()) {
@ -5573,7 +5573,7 @@ static void PlanAllocationSize(const FileDescriptorProto& proto,
alloc.PlanArray<FileDescriptorTables>(1);
alloc.PlanArray<std::string>(2); // name + package
if (proto.has_options()) alloc.PlanArray<FileOptions>(1);
if (proto.has_edition_enum()) {
if (proto.has_edition()) {
alloc.PlanArray<FeatureSet>(1);
if (HasFeatures(proto.options())) {
alloc.PlanArray<FeatureSet>(1);
@ -5680,14 +5680,14 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
FileDescriptor* result = alloc.AllocateArray<FileDescriptor>(1);
file_ = result;
if (proto.has_edition_enum()) {
if (proto.has_edition()) {
const FeatureSetDefaults& defaults =
pool_->feature_set_defaults_spec_ == nullptr
? GetCppFeatureSetDefaults()
: *pool_->feature_set_defaults_spec_;
absl::StatusOr<FeatureResolver> feature_resolver =
FeatureResolver::Create(proto.edition_enum(), defaults);
FeatureResolver::Create(proto.edition(), defaults);
if (!feature_resolver.ok()) {
AddError(
proto.name(), proto, DescriptorPool::ErrorCollector::EDITIONS,
@ -5730,8 +5730,8 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
return absl::StrCat("Unrecognized syntax: ", proto.syntax());
});
}
if (proto.has_edition_enum()) {
file_->edition_ = proto.edition_enum();
if (proto.has_edition()) {
file_->edition_ = proto.edition();
} else {
file_->edition_ = Edition::EDITION_UNKNOWN;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -109,12 +109,8 @@ message FileDescriptorProto {
// If `edition` is present, this value must be "editions".
optional string syntax = 12;
// The edition of the proto file, which is an opaque string.
// TODO Deprecate and remove this field in favor of enums.
optional string edition = 13;
// The edition of the proto file.
optional Edition edition_enum = 14;
optional Edition edition = 14;
}
// Describes a message type.
@ -744,9 +740,7 @@ message FieldOptions {
repeated OptionTargetType targets = 19;
message EditionDefault {
// TODO Deprecate and remove this field in favor of enums.
optional string edition = 1;
optional Edition edition_enum = 3;
optional Edition edition = 3;
optional string value = 2; // Textproto value.
}
repeated EditionDefault edition_defaults = 20;
@ -934,7 +928,7 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "EXPLICIT" }
edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
];
enum EnumType {
@ -946,7 +940,7 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_ENUM,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "OPEN" }
edition_defaults = { edition: EDITION_2023, value: "OPEN" }
];
enum RepeatedFieldEncoding {
@ -958,7 +952,7 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "PACKED" }
edition_defaults = { edition: EDITION_2023, value: "PACKED" }
];
enum MessageEncoding {
@ -970,7 +964,7 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "LENGTH_PREFIXED" }
edition_defaults = { edition: EDITION_2023, value: "LENGTH_PREFIXED" }
];
enum JsonFormat {
@ -983,7 +977,7 @@ message FeatureSet {
targets = TARGET_TYPE_MESSAGE,
targets = TARGET_TYPE_ENUM,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "ALLOW" }
edition_defaults = { edition: EDITION_2023, value: "ALLOW" }
];
reserved 4, 999;
@ -1004,24 +998,18 @@ message FeatureSetDefaults {
// the defaults at the closest matching edition ordered at or before it should
// be used. This field must be in strict ascending order by edition.
message FeatureSetEditionDefault {
// TODO Deprecate and remove this field in favor of enums.
optional string edition = 1;
optional Edition edition_enum = 3;
optional Edition edition = 3;
optional FeatureSet features = 2;
}
repeated FeatureSetEditionDefault defaults = 1;
// TODO Deprecate and remove these fields in favor of enums.
optional string minimum_edition = 2;
optional string maximum_edition = 3;
// The minimum supported edition (inclusive) when this was constructed.
// Editions before this will not have defaults.
optional Edition minimum_edition_enum = 4;
optional Edition minimum_edition = 4;
// The maximum known edition (inclusive) when this was constructed. Editions
// after this will not have reliable defaults.
optional Edition maximum_edition_enum = 5;
optional Edition maximum_edition = 5;
}
// ===================================================================

@ -496,7 +496,7 @@ TEST_F(FileDescriptorTest, Syntax) {
}
{
proto.set_syntax("editions");
proto.set_edition_enum(EDITION_2023);
proto.set_edition(EDITION_2023);
DescriptorPool pool;
const FileDescriptor* file = pool.BuildFile(proto);
ASSERT_TRUE(file != nullptr);
@ -506,7 +506,7 @@ TEST_F(FileDescriptorTest, Syntax) {
FileDescriptorProto other;
file->CopyTo(&other);
EXPECT_EQ("editions", other.syntax());
EXPECT_EQ(other.edition_enum(), EDITION_2023);
EXPECT_EQ(other.edition(), EDITION_2023);
}
}
@ -534,7 +534,7 @@ TEST_F(FileDescriptorTest, CopyHeadingTo) {
EXPECT_EQ(&other.options().features(), &FeatureSet::default_instance());
{
proto.set_syntax("editions");
proto.set_edition_enum(EDITION_2023);
proto.set_edition(EDITION_2023);
DescriptorPool pool;
const FileDescriptor* file = pool.BuildFile(proto);
@ -545,7 +545,7 @@ TEST_F(FileDescriptorTest, CopyHeadingTo) {
EXPECT_EQ(other.name(), "foo.proto");
EXPECT_EQ(other.package(), "foo.bar.baz");
EXPECT_EQ(other.syntax(), "editions");
EXPECT_EQ(other.edition_enum(), EDITION_2023);
EXPECT_EQ(other.edition(), EDITION_2023);
EXPECT_EQ(other.options().java_package(), "foo.bar.baz");
EXPECT_TRUE(other.message_type().empty());
EXPECT_EQ(&other.options().features(), &FeatureSet::default_instance());
@ -7533,7 +7533,7 @@ TEST_F(FeaturesTest, Edition2023Defaults) {
FileDescriptorProto file_proto = ParseTextOrDie(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
)pb");
BuildDescriptorMessagesInTestPool();
@ -7561,7 +7561,7 @@ TEST_F(FeaturesBaseTest, DefaultEdition2023Defaults) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
)pb");
ASSERT_NE(file, nullptr);
@ -7584,7 +7584,7 @@ TEST_F(FeaturesTest, ClearsOptions) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options {
java_package: "bar"
features { field_presence: IMPLICIT }
@ -7609,7 +7609,7 @@ TEST_F(FeaturesTest, RestoresOptionsRoundTrip) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
java_package: "bar"
@ -7756,7 +7756,7 @@ TEST_F(FeaturesTest, RestoresLabelRoundTrip) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -7786,7 +7786,7 @@ TEST_F(FeaturesTest, RestoresGroupRoundTrip) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
nested_type {
@ -7820,7 +7820,7 @@ TEST_F(FeaturesTest, OnlyMessagesInheritGroupEncoding) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { message_encoding: DELIMITED } }
message_type {
name: "Foo"
@ -7848,10 +7848,9 @@ TEST_F(FeaturesTest, OnlyMessagesInheritGroupEncoding) {
TEST_F(FeaturesTest, NoOptions) {
BuildDescriptorMessagesInTestPool();
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
const FileDescriptor* file =
BuildFile(R"pb(
name: "foo.proto" syntax: "editions" edition: EDITION_2023
)pb");
EXPECT_EQ(&file->options(), &FileOptions::default_instance());
EXPECT_THAT(GetCoreFeatures(file), EqualsProto(R"pb(
@ -7870,9 +7869,7 @@ TEST_F(FeaturesTest, InvalidEdition) {
BuildDescriptorMessagesInTestPool();
BuildFileWithErrors(
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_1_TEST_ONLY
name: "foo.proto" syntax: "editions" edition: EDITION_1_TEST_ONLY
)pb",
"foo.proto: foo.proto: EDITIONS: Edition 1_TEST_ONLY is earlier than the "
"minimum supported edition 2023\n");
@ -7883,7 +7880,7 @@ TEST_F(FeaturesTest, FileFeatures) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { field_presence: IMPLICIT } }
)pb");
EXPECT_THAT(file->options(), EqualsProto(""));
@ -7905,7 +7902,7 @@ TEST_F(FeaturesTest, FileFeaturesExtension) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_99998_TEST_ONLY
edition: EDITION_99998_TEST_ONLY
dependency: "google/protobuf/unittest_features.proto"
options { features { field_presence: IMPLICIT } }
)pb");
@ -7929,7 +7926,7 @@ TEST_F(FeaturesTest, FileFeaturesExtensionOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_99998_TEST_ONLY
edition: EDITION_99998_TEST_ONLY
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -7959,7 +7956,7 @@ TEST_F(FeaturesTest, MessageFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type { name: "Foo" }
)pb");
const Descriptor* message = file->message_type(0);
@ -7981,7 +7978,7 @@ TEST_F(FeaturesTest, MessageFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { field_presence: IMPLICIT } }
message_type { name: "Foo" }
)pb");
@ -7996,7 +7993,7 @@ TEST_F(FeaturesTest, MessageFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8024,7 +8021,7 @@ TEST_F(FeaturesTest, NestedMessageFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8063,7 +8060,7 @@ TEST_F(FeaturesTest, FieldFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field { name: "bar" number: 1 label: LABEL_REPEATED type: TYPE_INT64 }
@ -8089,7 +8086,7 @@ TEST_F(FeaturesTest, FieldFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8120,7 +8117,7 @@ TEST_F(FeaturesTest, FieldFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8164,7 +8161,7 @@ TEST_F(FeaturesTest, OneofFieldFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8209,7 +8206,7 @@ TEST_F(FeaturesTest, OneofFieldFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8318,7 +8315,7 @@ TEST_F(FeaturesTest, RootExtensionFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8359,7 +8356,7 @@ TEST_F(FeaturesTest, MessageExtensionFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8407,7 +8404,7 @@ TEST_F(FeaturesTest, EnumFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "Foo"
value { name: "BAR" number: 0 }
@ -8432,7 +8429,7 @@ TEST_F(FeaturesTest, EnumFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { enum_type: CLOSED } }
enum_type {
name: "Foo"
@ -8450,7 +8447,7 @@ TEST_F(FeaturesTest, EnumFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8478,7 +8475,7 @@ TEST_F(FeaturesTest, NestedEnumFeatures) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8516,7 +8513,7 @@ TEST_F(FeaturesTest, EnumValueFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "Foo"
value { name: "BAR" number: 0 }
@ -8541,7 +8538,7 @@ TEST_F(FeaturesTest, EnumValueFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { enum_type: CLOSED } }
enum_type {
name: "Foo"
@ -8565,7 +8562,7 @@ TEST_F(FeaturesTest, EnumValueFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8603,7 +8600,7 @@ TEST_F(FeaturesTest, OneofFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -8635,7 +8632,7 @@ TEST_F(FeaturesTest, OneofFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { enum_type: CLOSED } }
message_type {
name: "Foo"
@ -8666,7 +8663,7 @@ TEST_F(FeaturesTest, OneofFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8710,7 +8707,7 @@ TEST_F(FeaturesTest, ExtensionRangeFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
extension_range { start: 1 end: 100 }
@ -8736,7 +8733,7 @@ TEST_F(FeaturesTest, ExtensionRangeFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { enum_type: CLOSED } }
message_type {
name: "Foo"
@ -8761,7 +8758,7 @@ TEST_F(FeaturesTest, ExtensionRangeFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8800,7 +8797,7 @@ TEST_F(FeaturesTest, ServiceFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
service { name: "Foo" }
)pb");
const ServiceDescriptor* service = file->service(0);
@ -8822,7 +8819,7 @@ TEST_F(FeaturesTest, ServiceFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options { features { enum_type: CLOSED } }
service { name: "Foo" }
)pb");
@ -8837,7 +8834,7 @@ TEST_F(FeaturesTest, ServiceFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -8864,7 +8861,7 @@ TEST_F(FeaturesTest, MethodFeaturesDefault) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type { name: "EmptyMsg" }
service {
name: "Foo"
@ -8891,7 +8888,7 @@ TEST_F(FeaturesTest, MethodFeaturesInherit) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
message_type { name: "EmptyMsg" }
options { features { enum_type: CLOSED } }
@ -8918,7 +8915,7 @@ TEST_F(FeaturesTest, MethodFeaturesOverride) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
message_type { name: "EmptyMsg" }
options {
@ -8962,7 +8959,7 @@ TEST_F(FeaturesTest, FieldFeatureHelpers) {
name: "foo.proto"
syntax: "editions"
dependency: "google/protobuf/cpp_features.proto"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field { name: "def" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING }
@ -9073,7 +9070,7 @@ TEST_F(FeaturesTest, EnumFeatureHelpers) {
name: "foo.proto"
syntax: "editions"
dependency: "google/protobuf/cpp_features.proto"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "FooOpen"
value { name: "BAR" number: 0 }
@ -9137,7 +9134,7 @@ TEST_F(FeaturesTest, MergeFeatureValidationFailed) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options { features { field_presence: FIELD_PRESENCE_UNKNOWN } }
)pb",
@ -9166,7 +9163,7 @@ TEST_F(FeaturesTest, InvalidFieldPacked) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9190,7 +9187,7 @@ TEST_F(FeaturesTest, InvalidFieldImplicitDefault) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9213,7 +9210,7 @@ TEST_F(FeaturesTest, InvalidFieldImplicitOpen) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9241,7 +9238,7 @@ TEST_F(FeaturesTest, InvalidFieldRequiredExtension) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
extension_range { start: 1 end: 100 }
@ -9264,7 +9261,7 @@ TEST_F(FeaturesTest, InvalidFieldImplicitExtension) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
extension_range { start: 1 end: 100 }
@ -9287,7 +9284,7 @@ TEST_F(FeaturesTest, InvalidFieldMessageImplicit) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9310,7 +9307,7 @@ TEST_F(FeaturesTest, InvalidFieldRepeatedImplicit) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9360,7 +9357,7 @@ TEST_F(FeaturesTest, InvalidFieldOneofImplicit) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9383,7 +9380,7 @@ TEST_F(FeaturesTest, InvalidFieldRepeatedRequired) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9405,7 +9402,7 @@ TEST_F(FeaturesTest, InvalidFieldOneofRequired) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9428,7 +9425,7 @@ TEST_F(FeaturesTest, InvalidFieldNonRepeatedWithRepeatedEncoding) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9450,7 +9447,7 @@ TEST_F(FeaturesTest, InvalidFieldNonPackableWithPackedRepeatedEncoding) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9472,7 +9469,7 @@ TEST_F(FeaturesTest, InvalidFieldNonMessageWithMessageEncoding) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9523,7 +9520,7 @@ TEST_F(FeaturesTest, InvalidOpenEnumNonZeroFirstValue) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "Enum"
value { name: "BAR" number: 1 }
@ -9540,7 +9537,7 @@ TEST_F(FeaturesTest, ClosedEnumNonZeroFirstValue) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "Enum"
value { name: "BAR" number: 9 }
@ -9557,7 +9554,7 @@ TEST_F(FeaturesTest, CopyToIncludesFeatures) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
java_package: "pkg"
@ -9598,7 +9595,7 @@ TEST_F(FeaturesTest, UninterpretedOptions) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options {
uninterpreted_option {
name { name_part: "features" is_extension: false }
@ -9625,7 +9622,7 @@ TEST_F(FeaturesTest, UninterpretedOptionsMerge) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
options {
uninterpreted_option {
name { name_part: "features" is_extension: false }
@ -9663,7 +9660,7 @@ TEST_F(FeaturesTest, UninterpretedOptionsMergeExtension) {
const FileDescriptor* file = BuildFile(R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
uninterpreted_option {
@ -9731,7 +9728,7 @@ TEST_F(FeaturesTest, InvalidJsonUniquenessDefaultWarning) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9758,7 +9755,7 @@ TEST_F(FeaturesTest, InvalidJsonUniquenessDefaultError) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9785,7 +9782,7 @@ TEST_F(FeaturesTest, InvalidJsonUniquenessCustomError) {
R"pb(
name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9865,13 +9862,13 @@ INSTANTIATE_TEST_SUITE_P(
testing::Values(
std::make_tuple("Empty", R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
)pb"),
std::make_tuple(
"FileFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
options {
features {
@ -9882,7 +9879,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple("FieldFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9899,7 +9896,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple("Required",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
field {
@ -9916,7 +9913,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple("Group",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
nested_type {
@ -9943,7 +9940,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple("MessageFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
message_type {
name: "Foo"
options {
@ -9955,7 +9952,7 @@ INSTANTIATE_TEST_SUITE_P(
"OneofFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
message_type {
name: "Foo"
@ -9979,7 +9976,7 @@ INSTANTIATE_TEST_SUITE_P(
"ExtensionRangeFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
message_type {
name: "Foo"
@ -9997,7 +9994,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple("EnumFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
enum_type {
name: "Foo"
value { name: "BAR" number: 1 }
@ -10008,7 +10005,7 @@ INSTANTIATE_TEST_SUITE_P(
"EnumValueFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
enum_type {
name: "Foo"
@ -10028,7 +10025,7 @@ INSTANTIATE_TEST_SUITE_P(
"ServiceFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
service {
name: "FooService"
@ -10043,7 +10040,7 @@ INSTANTIATE_TEST_SUITE_P(
"MethodFeature",
R"pb(name: "foo.proto"
syntax: "editions"
edition_enum: EDITION_2023
edition: EDITION_2023
dependency: "google/protobuf/unittest_features.proto"
message_type { name: "EmptyMessage" }
service {

@ -115,8 +115,8 @@ void CollectEditions(const Descriptor& descriptor, Edition maximum_edition,
absl::btree_set<Edition>& editions) {
for (int i = 0; i < descriptor.field_count(); ++i) {
for (const auto& def : descriptor.field(i)->options().edition_defaults()) {
if (maximum_edition < def.edition_enum()) continue;
editions.insert(def.edition_enum());
if (maximum_edition < def.edition()) continue;
editions.insert(def.edition());
}
}
}
@ -126,10 +126,10 @@ absl::Status FillDefaults(Edition edition, Message& msg) {
auto comparator = [](const FieldOptions::EditionDefault& a,
const FieldOptions::EditionDefault& b) {
return a.edition_enum() < b.edition_enum();
return a.edition() < b.edition();
};
FieldOptions::EditionDefault edition_lookup;
edition_lookup.set_edition_enum(edition);
edition_lookup.set_edition(edition);
for (int i = 0; i < descriptor.field_count(); ++i) {
const FieldDescriptor& field = *descriptor.field(i);
@ -228,8 +228,8 @@ absl::StatusOr<FeatureSetDefaults> FeatureResolver::CompileDefaults(
// Fill the default spec.
FeatureSetDefaults defaults;
defaults.set_minimum_edition_enum(minimum_edition);
defaults.set_maximum_edition_enum(maximum_edition);
defaults.set_minimum_edition(minimum_edition);
defaults.set_maximum_edition(maximum_edition);
auto message_factory = absl::make_unique<DynamicMessageFactory>();
for (const auto& edition : editions) {
auto defaults_dynamic =
@ -241,7 +241,7 @@ absl::StatusOr<FeatureSetDefaults> FeatureResolver::CompileDefaults(
defaults_dynamic.get(), extension)));
}
auto* edition_defaults = defaults.mutable_defaults()->Add();
edition_defaults->set_edition_enum(edition);
edition_defaults->set_edition(edition);
edition_defaults->mutable_features()->MergeFromString(
defaults_dynamic->SerializeAsString());
}
@ -250,41 +250,41 @@ absl::StatusOr<FeatureSetDefaults> FeatureResolver::CompileDefaults(
absl::StatusOr<FeatureResolver> FeatureResolver::Create(
Edition edition, const FeatureSetDefaults& compiled_defaults) {
if (edition < compiled_defaults.minimum_edition_enum()) {
if (edition < compiled_defaults.minimum_edition()) {
return Error("Edition ", edition,
" is earlier than the minimum supported edition ",
compiled_defaults.minimum_edition_enum());
compiled_defaults.minimum_edition());
}
if (compiled_defaults.maximum_edition_enum() < edition) {
if (compiled_defaults.maximum_edition() < edition) {
return Error("Edition ", edition,
" is later than the maximum supported edition ",
compiled_defaults.maximum_edition_enum());
compiled_defaults.maximum_edition());
}
// Validate compiled defaults.
Edition prev_edition = EDITION_UNKNOWN;
for (const auto& edition_default : compiled_defaults.defaults()) {
if (edition_default.edition_enum() == EDITION_UNKNOWN) {
return Error("Invalid edition ", edition_default.edition_enum(),
if (edition_default.edition() == EDITION_UNKNOWN) {
return Error("Invalid edition ", edition_default.edition(),
" specified.");
}
if (prev_edition != EDITION_UNKNOWN) {
if (edition_default.edition_enum() <= prev_edition) {
if (edition_default.edition() <= prev_edition) {
return Error(
"Feature set defaults are not strictly increasing. Edition ",
prev_edition, " is greater than or equal to edition ",
edition_default.edition_enum(), ".");
edition_default.edition(), ".");
}
}
prev_edition = edition_default.edition_enum();
prev_edition = edition_default.edition();
}
// Select the matching edition defaults.
auto comparator = [](const auto& a, const auto& b) {
return a.edition_enum() < b.edition_enum();
return a.edition() < b.edition();
};
FeatureSetDefaults::FeatureSetEditionDefault search;
search.set_edition_enum(edition);
search.set_edition(edition);
auto first_nonmatch =
absl::c_upper_bound(compiled_defaults.defaults(), search, comparator);
if (first_nonmatch == compiled_defaults.defaults().begin()) {

@ -217,7 +217,7 @@ TEST(FeatureResolverTest, DefaultsGeneratedPoolCustom) {
{pool.FindExtensionByName("pb.test")}, EDITION_2023, EDITION_2023);
ASSERT_OK(defaults);
ASSERT_EQ(defaults->defaults().size(), 1);
ASSERT_EQ(defaults->defaults().at(0).edition_enum(), EDITION_2023);
ASSERT_EQ(defaults->defaults().at(0).edition(), EDITION_2023);
FeatureSet merged = defaults->defaults().at(0).features();
EXPECT_EQ(merged.field_presence(), FeatureSet::EXPLICIT);
@ -232,7 +232,7 @@ TEST(FeatureResolverTest, DefaultsTooEarly) {
{GetExtension(pb::test)}, EDITION_2023,
EDITION_2023);
ASSERT_OK(defaults);
defaults->set_minimum_edition_enum(EDITION_1_TEST_ONLY);
defaults->set_minimum_edition(EDITION_1_TEST_ONLY);
absl::StatusOr<FeatureSet> merged =
GetDefaults(EDITION_1_TEST_ONLY, *defaults);
EXPECT_THAT(merged, HasError(AllOf(HasSubstr("No valid default found"),
@ -299,18 +299,18 @@ TEST(FeatureResolverTest, DefaultsMessageMerge) {
TEST(FeatureResolverTest, CreateFromUnsortedDefaults) {
FeatureSetDefaults defaults = ParseTextOrDie(R"pb(
minimum_edition_enum: EDITION_2_TEST_ONLY
maximum_edition_enum: EDITION_99997_TEST_ONLY
minimum_edition: EDITION_2_TEST_ONLY
maximum_edition: EDITION_99997_TEST_ONLY
defaults {
edition_enum: EDITION_2_TEST_ONLY
edition: EDITION_2_TEST_ONLY
features {}
}
defaults {
edition_enum: EDITION_99997_TEST_ONLY
edition: EDITION_99997_TEST_ONLY
features {}
}
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {}
}
)pb");
@ -322,10 +322,10 @@ TEST(FeatureResolverTest, CreateFromUnsortedDefaults) {
TEST(FeatureResolverTest, CreateUnknownEdition) {
FeatureSetDefaults defaults = ParseTextOrDie(R"pb(
minimum_edition_enum: EDITION_UNKNOWN
maximum_edition_enum: EDITION_99999_TEST_ONLY
minimum_edition: EDITION_UNKNOWN
maximum_edition: EDITION_99999_TEST_ONLY
defaults {
edition_enum: EDITION_UNKNOWN
edition: EDITION_UNKNOWN
features {}
}
)pb");
@ -335,8 +335,8 @@ TEST(FeatureResolverTest, CreateUnknownEdition) {
TEST(FeatureResolverTest, CreateMissingEdition) {
FeatureSetDefaults defaults = ParseTextOrDie(R"pb(
minimum_edition_enum: EDITION_UNKNOWN
maximum_edition_enum: EDITION_99999_TEST_ONLY
minimum_edition: EDITION_UNKNOWN
maximum_edition: EDITION_99999_TEST_ONLY
defaults { features {} }
)pb");
EXPECT_THAT(FeatureResolver::Create(EDITION_2023, defaults),
@ -644,7 +644,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidWithExtensions) {
extend Foo {
optional Foo bar2 = 1 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "" }
edition_defaults = { edition: EDITION_2023, value: "" }
];
}
)schema");
@ -670,11 +670,11 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidWithOneof) {
oneof x {
int32 int_field = 1 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
string string_field = 2 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "'hello'" }
edition_defaults = { edition: EDITION_2023, value: "'hello'" }
];
}
}
@ -700,7 +700,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidWithRequired) {
message Foo {
required int32 required_field = 1 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "" }
edition_defaults = { edition: EDITION_2023, value: "" }
];
}
)schema");
@ -725,7 +725,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidWithRepeated) {
message Foo {
repeated int32 repeated_field = 1 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
}
)schema");
@ -749,7 +749,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidWithMissingTarget) {
}
message Foo {
optional int32 int_field = 1 [
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
}
)schema");
@ -778,7 +778,7 @@ TEST_F(FeatureResolverPoolTest,
}
optional MessageFeature message_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "9987" }
edition_defaults = { edition: EDITION_2023, value: "9987" }
];
}
)schema");
@ -807,9 +807,9 @@ TEST_F(FeatureResolverPoolTest,
}
optional MessageFeature message_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_99998_TEST_ONLY, value: "int_field: 2" },
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "int_field: 1" },
edition_defaults = { edition_enum: EDITION_2023, value: "9987" }
edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "int_field: 2" },
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "int_field: 1" },
edition_defaults = { edition: EDITION_2023, value: "9987" }
];
}
)schema");
@ -838,9 +838,9 @@ TEST_F(FeatureResolverPoolTest,
}
optional MessageFeature message_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "int_field: 2" },
edition_defaults = { edition_enum: EDITION_2023, value: "int_field: 1" },
edition_defaults = { edition_enum: EDITION_99998_TEST_ONLY, value: "9987" }
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "int_field: 2" },
edition_defaults = { edition: EDITION_2023, value: "int_field: 1" },
edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "9987" }
];
}
)schema");
@ -870,7 +870,7 @@ TEST_F(FeatureResolverPoolTest,
message Foo {
optional int32 int_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1.23" }
edition_defaults = { edition: EDITION_2023, value: "1.23" }
];
}
)schema");
@ -896,8 +896,8 @@ TEST_F(FeatureResolverPoolTest,
message Foo {
optional int32 int_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "1.5" },
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "1.5" },
edition_defaults = { edition: EDITION_2023, value: "1" }
];
}
)schema");
@ -926,7 +926,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsInvalidDefaultsTooEarly) {
message Foo {
optional int32 int_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2_TEST_ONLY, value: "1" }
edition_defaults = { edition: EDITION_2_TEST_ONLY, value: "1" }
];
}
)schema");
@ -951,7 +951,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumTooEarly) {
message Foo {
optional int32 int_field_feature = 12 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
}
)schema");
@ -976,8 +976,8 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
message Foo {
optional int32 int_file_feature = 1 [
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_99998_TEST_ONLY, value: "2" },
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "2" },
edition_defaults = { edition: EDITION_2023, value: "1" }
];
}
)schema");
@ -989,10 +989,10 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
ASSERT_OK(defaults);
EXPECT_THAT(*defaults, EqualsProto(R"pb(
minimum_edition_enum: EDITION_99997_TEST_ONLY
maximum_edition_enum: EDITION_99999_TEST_ONLY
minimum_edition: EDITION_99997_TEST_ONLY
maximum_edition: EDITION_99999_TEST_ONLY
defaults {
edition_enum: EDITION_2023
edition: EDITION_2023
features {
field_presence: EXPLICIT
enum_type: OPEN
@ -1003,7 +1003,7 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
}
}
defaults {
edition_enum: EDITION_99998_TEST_ONLY
edition: EDITION_99998_TEST_ONLY
features {
field_presence: EXPLICIT
enum_type: OPEN

@ -30,49 +30,49 @@ message TestFeatures {
optional int32 int_file_feature = 1 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" },
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "2" },
edition_defaults = { edition_enum: EDITION_99998_TEST_ONLY, value: "3" }
edition_defaults = { edition: EDITION_2023, value: "1" },
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "2" },
edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "3" }
];
optional int32 int_extension_range_feature = 2 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_EXTENSION_RANGE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_message_feature = 3 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_MESSAGE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_field_feature = 4 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_oneof_feature = 5 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_ONEOF,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_enum_feature = 6 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_ENUM,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_enum_entry_feature = 7 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_ENUM_ENTRY,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_service_feature = 8 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_SERVICE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_method_feature = 9 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_METHOD,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional int32 int_multiple_feature = 10 [
retention = RETENTION_RUNTIME,
@ -85,20 +85,20 @@ message TestFeatures {
targets = TARGET_TYPE_METHOD,
targets = TARGET_TYPE_ONEOF,
targets = TARGET_TYPE_EXTENSION_RANGE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional bool bool_field_feature = 11 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "false" },
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "true" }
edition_defaults = { edition: EDITION_2023, value: "false" },
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "true" }
];
optional float float_field_feature = 12 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "1.1" },
edition_defaults = { edition_enum: EDITION_99997_TEST_ONLY, value: "1.2" }
edition_defaults = { edition: EDITION_2023, value: "1.1" },
edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "1.2" }
];
message MessageFeature {
@ -111,15 +111,15 @@ message TestFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = {
edition_enum: EDITION_99997_TEST_ONLY,
edition: EDITION_99997_TEST_ONLY,
value: "int_field: 2"
},
edition_defaults = {
edition_enum: EDITION_99998_TEST_ONLY,
edition: EDITION_99998_TEST_ONLY,
value: "string_field: '2024'"
},
edition_defaults = {
edition_enum: EDITION_2023,
edition: EDITION_2023,
value: "bool_field: true int_field: 1 float_field: 1.5 string_field: '2023'"
}
];
@ -135,13 +135,13 @@ message TestFeatures {
optional EnumFeature enum_field_feature = 14 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "ENUM_VALUE1" },
edition_defaults = { edition: EDITION_2023, value: "ENUM_VALUE1" },
edition_defaults = {
edition_enum: EDITION_99997_TEST_ONLY,
edition: EDITION_99997_TEST_ONLY,
value: "ENUM_VALUE2"
},
edition_defaults = {
edition_enum: EDITION_99998_TEST_ONLY,
edition: EDITION_99998_TEST_ONLY,
value: "ENUM_VALUE3"
}
];
@ -157,7 +157,7 @@ message TestFeatures {
targets = TARGET_TYPE_METHOD,
targets = TARGET_TYPE_ONEOF,
targets = TARGET_TYPE_EXTENSION_RANGE,
edition_defaults = { edition_enum: EDITION_2023, value: "1" }
edition_defaults = { edition: EDITION_2023, value: "1" }
];
optional string string_source_feature = 16 [
@ -171,6 +171,6 @@ message TestFeatures {
targets = TARGET_TYPE_METHOD,
targets = TARGET_TYPE_ONEOF,
targets = TARGET_TYPE_EXTENSION_RANGE,
edition_defaults = { edition_enum: EDITION_2023, value: "'2023'" }
edition_defaults = { edition: EDITION_2023, value: "'2023'" }
];
}

@ -19,6 +19,6 @@ message TestInvalidFeatures {
repeated int32 repeated_feature = 1 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
edition_defaults = { edition_enum: EDITION_2023, value: "3" }
edition_defaults = { edition: EDITION_2023, value: "3" }
];
}

@ -429,7 +429,7 @@ class DescriptorPoolTypeResolverSyntaxTest : public testing::Test {
proto.set_name("foo");
proto.set_syntax(syntax);
if (edition.has_value()) {
proto.set_edition_enum(*edition);
proto.set_edition(*edition);
}
DescriptorProto* message = proto.add_message_type();
message->set_name("MyMessage");

@ -226,7 +226,7 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
}
// TODO: How should we validate this?
file->edition = UPB_DESC(FileDescriptorProto_edition_enum)(file_proto);
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);

@ -21,7 +21,7 @@ const upb_MiniTable* google_protobuf_FileDescriptorSet_msg_init() {
const upb_MiniTable* google_protobuf_FileDescriptorProto_msg_init() {
static upb_MiniTable* mini_table = NULL;
static const char* mini_descriptor = "$11EGGGG33<<114";
static const char* mini_descriptor = "$11EGGGG33<<1a4";
if (mini_table) return mini_table;
mini_table =
upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor),
@ -224,7 +224,7 @@ const upb_MiniTable* google_protobuf_FieldOptions_msg_init() {
const upb_MiniTable* google_protobuf_FieldOptions_EditionDefault_msg_init() {
static upb_MiniTable* mini_table = NULL;
static const char* mini_descriptor = "$114";
static const char* mini_descriptor = "$a14";
if (mini_table) return mini_table;
mini_table =
upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor),
@ -332,7 +332,7 @@ const upb_MiniTable* google_protobuf_FeatureSet_msg_init() {
const upb_MiniTable* google_protobuf_FeatureSetDefaults_msg_init() {
static upb_MiniTable* mini_table = NULL;
static const char* mini_descriptor = "$G1144";
static const char* mini_descriptor = "$Gb44";
if (mini_table) return mini_table;
mini_table =
upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor),
@ -345,7 +345,7 @@ const upb_MiniTable* google_protobuf_FeatureSetDefaults_msg_init() {
const upb_MiniTable* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init() {
static upb_MiniTable* mini_table = NULL;
static const char* mini_descriptor = "$134";
static const char* mini_descriptor = "$a34";
if (mini_table) return mini_table;
mini_table =
upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor),

@ -694,32 +694,17 @@ UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_prot
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto* msg) {
upb_StringView default_val = upb_StringView_FromString("");
upb_StringView ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition_enum(google_protobuf_FileDescriptorProto* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 14);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE int32_t google_protobuf_FileDescriptorProto_edition_enum(const google_protobuf_FileDescriptorProto* msg) {
UPB_INLINE int32_t google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto* msg) {
int32_t default_val = 0;
int32_t ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 14);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition_enum(const google_protobuf_FileDescriptorProto* msg) {
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 14);
return _upb_Message_HasNonExtensionField(msg, &field);
}
@ -936,11 +921,7 @@ UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_F
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 12);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition_enum(google_protobuf_FileDescriptorProto *msg, int32_t value) {
UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, int32_t value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 14);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
@ -4323,21 +4304,6 @@ UPB_INLINE char* google_protobuf_FieldOptions_EditionDefault_serialize_ex(const
(void)upb_Encode(msg, google_protobuf_FieldOptions_EditionDefault_msg_init(), options, arena, &ptr, len);
return ptr;
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_edition(google_protobuf_FieldOptions_EditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 1);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE upb_StringView google_protobuf_FieldOptions_EditionDefault_edition(const google_protobuf_FieldOptions_EditionDefault* msg) {
upb_StringView default_val = upb_StringView_FromString("");
upb_StringView ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 1);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_edition(const google_protobuf_FieldOptions_EditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 1);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_value(google_protobuf_FieldOptions_EditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 2);
_upb_Message_ClearNonExtensionField(msg, &field);
@ -4353,31 +4319,27 @@ UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_value(const goog
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 2);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_edition_enum(google_protobuf_FieldOptions_EditionDefault* msg) {
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_edition(google_protobuf_FieldOptions_EditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 3);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE int32_t google_protobuf_FieldOptions_EditionDefault_edition_enum(const google_protobuf_FieldOptions_EditionDefault* msg) {
UPB_INLINE int32_t google_protobuf_FieldOptions_EditionDefault_edition(const google_protobuf_FieldOptions_EditionDefault* msg) {
int32_t default_val = 0;
int32_t ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 3);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_edition_enum(const google_protobuf_FieldOptions_EditionDefault* msg) {
UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_edition(const google_protobuf_FieldOptions_EditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 3);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_edition(google_protobuf_FieldOptions_EditionDefault *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 1);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_value(google_protobuf_FieldOptions_EditionDefault *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 2);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_edition_enum(google_protobuf_FieldOptions_EditionDefault *msg, int32_t value) {
UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_edition(google_protobuf_FieldOptions_EditionDefault *msg, int32_t value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_EditionDefault_msg_init(), 3);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
@ -5663,62 +5625,32 @@ UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_defaults(const google_pro
return size != 0;
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_minimum_edition(google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 2);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE upb_StringView google_protobuf_FeatureSetDefaults_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) {
upb_StringView default_val = upb_StringView_FromString("");
upb_StringView ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 2);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 2);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_maximum_edition(google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 3);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE upb_StringView google_protobuf_FeatureSetDefaults_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) {
upb_StringView default_val = upb_StringView_FromString("");
upb_StringView ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 3);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 3);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_minimum_edition_enum(google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 4);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_minimum_edition_enum(const google_protobuf_FeatureSetDefaults* msg) {
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) {
int32_t default_val = 0;
int32_t ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 4);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_minimum_edition_enum(const google_protobuf_FeatureSetDefaults* msg) {
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_minimum_edition(const google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 4);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_maximum_edition_enum(google_protobuf_FeatureSetDefaults* msg) {
UPB_INLINE void google_protobuf_FeatureSetDefaults_clear_maximum_edition(google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 5);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_maximum_edition_enum(const google_protobuf_FeatureSetDefaults* msg) {
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) {
int32_t default_val = 0;
int32_t ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 5);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_maximum_edition_enum(const google_protobuf_FeatureSetDefaults* msg) {
UPB_INLINE bool google_protobuf_FeatureSetDefaults_has_maximum_edition(const google_protobuf_FeatureSetDefaults* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 5);
return _upb_Message_HasNonExtensionField(msg, &field);
}
@ -5749,19 +5681,11 @@ UPB_INLINE struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* g
_upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub));
return sub;
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_minimum_edition(google_protobuf_FeatureSetDefaults *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 2);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_maximum_edition(google_protobuf_FeatureSetDefaults *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 3);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_minimum_edition_enum(google_protobuf_FeatureSetDefaults *msg, int32_t value) {
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_minimum_edition(google_protobuf_FeatureSetDefaults *msg, int32_t value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 4);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_maximum_edition_enum(google_protobuf_FeatureSetDefaults *msg, int32_t value) {
UPB_INLINE void google_protobuf_FeatureSetDefaults_set_maximum_edition(google_protobuf_FeatureSetDefaults *msg, int32_t value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_msg_init(), 5);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
@ -5801,21 +5725,6 @@ UPB_INLINE char* google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_ser
(void)upb_Encode(msg, google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), options, arena, &ptr, len);
return ptr;
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 1);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE upb_StringView google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
upb_StringView default_val = upb_StringView_FromString("");
upb_StringView ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 1);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 1);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 2);
_upb_Message_ClearNonExtensionField(msg, &field);
@ -5831,26 +5740,22 @@ UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 2);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_edition_enum(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_clear_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 3);
_upb_Message_ClearNonExtensionField(msg, &field);
}
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_edition_enum(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
UPB_INLINE int32_t google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
int32_t default_val = 0;
int32_t ret;
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 3);
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret;
}
UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_edition_enum(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
UPB_INLINE bool google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_has_edition(const google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault* msg) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 3);
return _upb_Message_HasNonExtensionField(msg, &field);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, upb_StringView value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 1);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_features(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, google_protobuf_FeatureSet* value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 2);
_upb_Message_SetNonExtensionField(msg, &field, &value);
@ -5863,7 +5768,7 @@ UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FeatureSetDefaults
}
return sub;
}
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_edition_enum(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, int32_t value) {
UPB_INLINE void google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_set_edition(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault *msg, int32_t value) {
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_msg_init(), 3);
_upb_Message_SetNonExtensionField(msg, &field, &value);
}

@ -506,7 +506,7 @@ static google_protobuf_FileDescriptorProto* filedef_toproto(upb_ToProto_Context*
}
if (upb_FileDef_Syntax(f) == kUpb_Syntax_Editions) {
google_protobuf_FileDescriptorProto_set_edition_enum(proto, upb_FileDef_Edition(f));
google_protobuf_FileDescriptorProto_set_edition(proto, upb_FileDef_Edition(f));
}
if (upb_FileDef_Syntax(f) == kUpb_Syntax_Proto3) {

Loading…
Cancel
Save