Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26843b3

Browse files
zhangskzcopybara-github
authored andcommitted
Enable edition 2024 support in protoc and language generators for cpp, hpb, java, kotlin, objectivec, php, python, pyi, rust.
PiperOrigin-RevId: 776765229
1 parent6a3b9aa commit26843b3

File tree

14 files changed

+100
-75
lines changed

14 files changed

+100
-75
lines changed

‎hpb_generator/generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class Generator : public protoc::CodeGenerator {
3434
Feature::FEATURE_SUPPORTS_EDITIONS;
3535
}
3636
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
37-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
37+
EditionGetMaximumEdition()constoverride {
38+
return Edition::EDITION_2024;
39+
}
3840
};
3941

4042
}// namespace protobuf

‎src/google/protobuf/compiler/code_generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ class PROTOC_EXPORT CodeGenerator {
179179
// The minimum edition supported by protoc.
180180
constexprautoProtocMinimumEdition() {return Edition::EDITION_PROTO2; }
181181
// The maximum edition supported by protoc.
182-
constexprautoProtocMaximumEdition() {return Edition::EDITION_2023; }
182+
constexprautoProtocMaximumEdition() {
183+
return Edition::EDITION_2024;
184+
}
183185

184186
// The maximum edition known to protoc, which may or may not be officially
185187
// supported yet. During development of a new edition, this will typically be

‎src/google/protobuf/compiler/command_line_interface_unittest.cc‎

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ TEST_F(CommandLineInterfaceTest, InvalidMaximumEditionError) {
15781578
Run("protocol_compiler --proto_path=$tmpdir --test_out=$tmpdir foo.proto");
15791579
ExpectErrorSubstring(
15801580
"generator --test_out specifies a maximum edition 99999_TEST_ONLY which"
1581-
"is not the protoc maximum 2023");
1581+
"is not the protoc maximum");
15821582
}
15831583

15841584
TEST_F(CommandLineInterfaceTest, InvalidFeatureExtensionError) {
@@ -2009,21 +2009,6 @@ TEST_F(CommandLineInterfaceTest, PluginErrorAndNoEditionsSupport) {
20092009
"--plug_out: foo.proto: Saw message type MockCodeGenerator_Error.");
20102010
}
20112011

2012-
TEST_F(CommandLineInterfaceTest, AfterProtocMaximumEditionError) {
2013-
CreateTempFile("foo.proto",
2014-
R"schema(
2015-
edition = "2024";
2016-
package foo;
2017-
message Foo {
2018-
}
2019-
)schema");
2020-
2021-
Run("protocol_compiler --proto_path=$tmpdir --test_out=$tmpdir foo.proto");
2022-
ExpectErrorSubstring(
2023-
"foo.proto: is a file using edition 2024, which is later than the protoc"
2024-
"maximum supported edition 2023.");
2025-
}
2026-
20272012
TEST_F(CommandLineInterfaceTest, AfterProtocMaximumEditionAllowlisted) {
20282013
constexpr absl::string_view path ="google/protobuf";
20292014
CreateTempFile(absl::StrCat(path,"/foo.proto"),
@@ -2083,52 +2068,66 @@ TEST_F(CommandLineInterfaceTest, EditionDefaults) {
20832068

20842069
FeatureSetDefaults defaults =ReadEditionDefaults("defaults");
20852070
EXPECT_THAT(defaults,EqualsProto(R"pb(
2086-
defaults {
2087-
edition: EDITION_LEGACY
2088-
overridable_features {}
2089-
fixed_features {
2090-
field_presence: EXPLICIT
2091-
enum_type: CLOSED
2092-
repeated_field_encoding: EXPANDED
2093-
utf8_validation: NONE
2094-
message_encoding: LENGTH_PREFIXED
2095-
json_format: LEGACY_BEST_EFFORT
2096-
enforce_naming_style: STYLE_LEGACY
2097-
default_symbol_visibility: EXPORT_ALL
2098-
}
2099-
}
2100-
defaults {
2101-
edition: EDITION_PROTO3
2102-
overridable_features {}
2103-
fixed_features {
2104-
field_presence: IMPLICIT
2105-
enum_type: OPEN
2106-
repeated_field_encoding: PACKED
2107-
utf8_validation: VERIFY
2108-
message_encoding: LENGTH_PREFIXED
2109-
json_format: ALLOW
2110-
enforce_naming_style: STYLE_LEGACY
2111-
default_symbol_visibility: EXPORT_ALL
2112-
}
2113-
}
2114-
defaults {
2115-
edition: EDITION_2023
2116-
overridable_features {
2117-
field_presence: EXPLICIT
2118-
enum_type: OPEN
2119-
repeated_field_encoding: PACKED
2120-
utf8_validation: VERIFY
2121-
message_encoding: LENGTH_PREFIXED
2122-
json_format: ALLOW
2123-
}
2124-
fixed_features {
2125-
enforce_naming_style: STYLE_LEGACY
2126-
default_symbol_visibility: EXPORT_ALL
2127-
}
2128-
}
2129-
minimum_edition: EDITION_PROTO2
2130-
maximum_edition: EDITION_2023
2131-
)pb"));
2071+
defaults {
2072+
edition: EDITION_LEGACY
2073+
overridable_features {}
2074+
fixed_features {
2075+
field_presence: EXPLICIT
2076+
enum_type: CLOSED
2077+
repeated_field_encoding: EXPANDED
2078+
utf8_validation: NONE
2079+
message_encoding: LENGTH_PREFIXED
2080+
json_format: LEGACY_BEST_EFFORT
2081+
enforce_naming_style: STYLE_LEGACY
2082+
default_symbol_visibility: EXPORT_ALL
2083+
}
2084+
}
2085+
defaults {
2086+
edition: EDITION_PROTO3
2087+
overridable_features {}
2088+
fixed_features {
2089+
field_presence: IMPLICIT
2090+
enum_type: OPEN
2091+
repeated_field_encoding: PACKED
2092+
utf8_validation: VERIFY
2093+
message_encoding: LENGTH_PREFIXED
2094+
json_format: ALLOW
2095+
enforce_naming_style: STYLE_LEGACY
2096+
default_symbol_visibility: EXPORT_ALL
2097+
}
2098+
}
2099+
defaults {
2100+
edition: EDITION_2023
2101+
overridable_features {
2102+
field_presence: EXPLICIT
2103+
enum_type: OPEN
2104+
repeated_field_encoding: PACKED
2105+
utf8_validation: VERIFY
2106+
message_encoding: LENGTH_PREFIXED
2107+
json_format: ALLOW
2108+
}
2109+
fixed_features {
2110+
enforce_naming_style: STYLE_LEGACY
2111+
default_symbol_visibility: EXPORT_ALL
2112+
}
2113+
}
2114+
defaults {
2115+
edition: EDITION_2024
2116+
overridable_features {
2117+
field_presence: EXPLICIT
2118+
enum_type: OPEN
2119+
repeated_field_encoding: PACKED
2120+
utf8_validation: VERIFY
2121+
message_encoding: LENGTH_PREFIXED
2122+
json_format: ALLOW
2123+
enforce_naming_style: STYLE2024
2124+
default_symbol_visibility: EXPORT_TOP_LEVEL
2125+
}
2126+
fixed_features {}
2127+
}
2128+
minimum_edition: EDITION_PROTO2
2129+
maximum_edition: EDITION_2024
2130+
)pb"));
21322131
}
21332132

21342133
TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMaximum) {

‎src/google/protobuf/compiler/cpp/generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class PROTOC_EXPORT CppGenerator final : public CodeGenerator {
8484
}
8585

8686
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
87-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
87+
EditionGetMaximumEdition()constoverride {
88+
return Edition::EDITION_2024;
89+
}
8890

8991
std::vector<const FieldDescriptor*>GetFeatureExtensions()constoverride {
9092
return {GetExtensionReflection(pb::cpp)};

‎src/google/protobuf/compiler/csharp/csharp_generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
3636
std::string* error)constoverride;
3737
uint64_tGetSupportedFeatures()constoverride;
3838
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
39-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
39+
EditionGetMaximumEdition()constoverride {
40+
return Edition::EDITION_2024;
41+
}
4042
using CodeGenerator::GetEdition;
4143
};
4244

‎src/google/protobuf/compiler/java/generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
4949
uint64_tGetSupportedFeatures()constoverride;
5050

5151
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
52-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
52+
EditionGetMaximumEdition()constoverride {
53+
return Edition::EDITION_2024;
54+
}
5355

5456
std::vector<const FieldDescriptor*>GetFeatureExtensions()constoverride {
5557
return {GetExtensionReflection(pb::java)};

‎src/google/protobuf/compiler/java/plugin_unittest.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class TestGenerator : public CodeGenerator {
5757
}
5858

5959
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
60-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
60+
EditionGetMaximumEdition()constoverride {
61+
return Edition::EDITION_2024;
62+
}
6163
};
6264

6365
// This test verifies that all the expected insertion points exist. It does

‎src/google/protobuf/compiler/kotlin/generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
4444
uint64_tGetSupportedFeatures()constoverride;
4545

4646
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
47-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
47+
EditionGetMaximumEdition()constoverride {
48+
return Edition::EDITION_2024;
49+
}
4850

4951
std::vector<const FieldDescriptor*>GetFeatureExtensions()constoverride {
5052
return {GetExtensionReflection(pb::java)};

‎src/google/protobuf/compiler/objectivec/generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class PROTOC_EXPORT ObjectiveCGenerator final : public CodeGenerator {
4949
return (FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS);
5050
}
5151
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
52-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
52+
EditionGetMaximumEdition()constoverride {
53+
return Edition::EDITION_2024;
54+
}
5355
};
5456

5557
}// namespace objectivec

‎src/google/protobuf/compiler/php/php_generator.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
3939
}
4040

4141
EditionGetMinimumEdition()constoverride {return Edition::EDITION_PROTO2; }
42-
EditionGetMaximumEdition()constoverride {return Edition::EDITION_2023; }
42+
EditionGetMaximumEdition()constoverride {
43+
return Edition::EDITION_2024;
44+
}
4345
std::vector<const FieldDescriptor*>GetFeatureExtensions()constoverride {
4446
return {};
4547
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp