···
1
-
diff --git a/protoc-c/c_file.cc b/protoc-c/c_file.cc
2
-
index ca0ad34..c6d8a24 100644
3
-
--- a/protoc-c/c_file.cc
4
-
+++ b/protoc-c/c_file.cc
5
-
@@ -117,14 +117,7 @@ FileGenerator::~FileGenerator() {}
6
-
void FileGenerator::GenerateHeader(io::Printer* printer) {
7
-
std::string filename_identifier = FilenameIdentifier(file_->name());
9
-
- int min_header_version = 1000000;
10
-
-#if GOOGLE_PROTOBUF_VERSION >= 4023000
11
-
- if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) {
13
-
- if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) {
15
-
- min_header_version = 1003000;
17
-
+ const int min_header_version = 1003000;
19
-
// Generate top of header.
21
-
diff --git a/protoc-c/c_generator.h b/protoc-c/c_generator.h
22
-
index b8b44aa..4aeb579 100644
23
-
--- a/protoc-c/c_generator.h
24
-
+++ b/protoc-c/c_generator.h
25
-
@@ -93,6 +93,12 @@ class PROTOC_C_EXPORT CGenerator : public CodeGenerator {
26
-
const std::string& parameter,
27
-
OutputDirectory* output_directory,
28
-
std::string* error) const;
30
-
+#if GOOGLE_PROTOBUF_VERSION >= 5026000
31
-
+ uint64_t GetSupportedFeatures() const { return CodeGenerator::FEATURE_SUPPORTS_EDITIONS; }
32
-
+ Edition GetMinimumEdition() const { return Edition::EDITION_PROTO2; }
33
-
+ Edition GetMaximumEdition() const { return Edition::EDITION_PROTO3; }
38
-
diff --git a/protoc-c/c_helpers.h b/protoc-c/c_helpers.h
39
-
index 062d330..be28b60 100644
40
-
--- a/protoc-c/c_helpers.h
41
-
+++ b/protoc-c/c_helpers.h
43
-
#include <protobuf-c/protobuf-c.pb.h>
44
-
#include <google/protobuf/io/printer.h>
46
-
-#if GOOGLE_PROTOBUF_VERSION >= 4023000
47
-
-# include <google/protobuf/descriptor_legacy.h>
51
-
namespace protobuf {
52
-
namespace compiler {
53
-
@@ -173,13 +169,21 @@ struct NameIndex
54
-
int compare_name_indices_by_name(const void*, const void*);
56
-
// Return the syntax version of the file containing the field.
57
-
-// This wrapper is needed to be able to compile against protobuf2.
58
-
inline int FieldSyntax(const FieldDescriptor* field) {
59
-
-#if GOOGLE_PROTOBUF_VERSION >= 4023000
60
-
- return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2;
62
-
- return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
64
-
+ auto proto = FileDescriptorProto();
65
-
+ field->file()->CopyTo(&proto);
67
-
+ if (proto.has_syntax()) {
68
-
+ auto syntax = proto.syntax();
69
-
+ assert(syntax == "proto2" || syntax == "proto3");
70
-
+ if (syntax == "proto2") {
72
-
+ } else if (syntax == "proto3") {
80
-
// Work around changes in protobuf >= 22.x without breaking compilation against