mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
Merge pull request #673 from protobuf-c/edmonds/new-google-support
Support for new Google protobuf 22.x, 23.x releases
This commit is contained in:
commit
69fc2f13bb
@ -96,7 +96,7 @@ if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
endif (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
|
||||
IF(BUILD_PROTOC)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||
ADD_CUSTOM_COMMAND(OUTPUT protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h
|
||||
|
@ -75,13 +75,8 @@ AC_ARG_ENABLE([protoc],
|
||||
AS_HELP_STRING([--disable-protoc], [Disable building protoc_c (also disables tests)]))
|
||||
if test "x$enable_protoc" != "xno"; then
|
||||
AC_LANG_PUSH([C++])
|
||||
|
||||
AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
|
||||
|
||||
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0],
|
||||
[proto3_supported=yes],
|
||||
[PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])]
|
||||
)
|
||||
AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
|
||||
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0], [proto3_supported=yes])
|
||||
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS"
|
||||
|
@ -87,8 +87,6 @@ class BytesFieldGenerator : public FieldGenerator {
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator);
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,8 +106,6 @@ class EnumGenerator {
|
||||
private:
|
||||
const EnumDescriptor* descriptor_;
|
||||
std::string dllexport_decl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -85,8 +85,6 @@ class EnumFieldGenerator : public FieldGenerator {
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
|
||||
};
|
||||
|
||||
|
||||
|
@ -98,8 +98,6 @@ class ExtensionGenerator {
|
||||
const FieldDescriptor* descriptor_;
|
||||
std::string type_traits_;
|
||||
std::string dllexport_decl_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -103,9 +103,6 @@ class FieldGenerator {
|
||||
const std::string &type_macro,
|
||||
const std::string &descriptor_addr) const;
|
||||
const FieldDescriptor *descriptor_;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
|
||||
};
|
||||
|
||||
// Convenience class which constructs FieldGenerators for a Descriptor.
|
||||
@ -121,8 +118,6 @@ class FieldGeneratorMap {
|
||||
std::unique_ptr<std::unique_ptr<FieldGenerator>[]> field_generators_;
|
||||
|
||||
static FieldGenerator* MakeGenerator(const FieldDescriptor* field);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -119,7 +119,11 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
|
||||
|
||||
int min_header_version = 1000000;
|
||||
#if defined(HAVE_PROTO3)
|
||||
# if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) {
|
||||
# else
|
||||
if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) {
|
||||
#endif
|
||||
min_header_version = 1003000;
|
||||
}
|
||||
#endif
|
||||
|
@ -103,8 +103,6 @@ class FileGenerator {
|
||||
std::unique_ptr<std::unique_ptr<EnumGenerator>[]> enum_generators_;
|
||||
std::unique_ptr<std::unique_ptr<ServiceGenerator>[]> service_generators_;
|
||||
std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -93,9 +93,6 @@ class PROTOC_C_EXPORT CGenerator : public CodeGenerator {
|
||||
const std::string& parameter,
|
||||
OutputDirectory* output_directory,
|
||||
std::string* error) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -70,6 +70,10 @@
|
||||
#include <protobuf-c/protobuf-c.pb.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
# include <google/protobuf/descriptor_legacy.h>
|
||||
#endif
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
@ -172,12 +176,26 @@ int compare_name_indices_by_name(const void*, const void*);
|
||||
// This wrapper is needed to be able to compile against protobuf2.
|
||||
inline int FieldSyntax(const FieldDescriptor* field) {
|
||||
#ifdef HAVE_PROTO3
|
||||
# if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2;
|
||||
# else
|
||||
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
|
||||
# endif
|
||||
#else
|
||||
return 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Work around changes in protobuf >= 22.x without breaking compilation against
|
||||
// older protobuf versions.
|
||||
#if GOOGLE_PROTOBUF_VERSION >= 4022000
|
||||
# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
|
||||
# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
|
||||
# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
|
||||
# define GOOGLE_DCHECK_GE ABSL_DCHECK_GE
|
||||
# define GOOGLE_LOG ABSL_LOG
|
||||
#endif
|
||||
|
||||
} // namespace c
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
@ -499,7 +499,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
|
||||
// NOTE: not supported by protobuf
|
||||
vars["maybe_static"] = "";
|
||||
vars["field_dv_ctype"] = "{ ... }";
|
||||
GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
|
||||
GOOGLE_LOG(FATAL) << "Messages can't have default values!";
|
||||
break;
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes())
|
||||
@ -521,7 +521,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GOOGLE_LOG(DFATAL) << "Unknown CPPTYPE";
|
||||
GOOGLE_LOG(FATAL) << "Unknown CPPTYPE";
|
||||
break;
|
||||
}
|
||||
if (!already_defined)
|
||||
|
@ -136,8 +136,6 @@ class MessageGenerator {
|
||||
std::unique_ptr<std::unique_ptr<MessageGenerator>[]> nested_generators_;
|
||||
std::unique_ptr<std::unique_ptr<EnumGenerator>[]> enum_generators_;
|
||||
std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -82,10 +82,6 @@ class MessageFieldGenerator : public FieldGenerator {
|
||||
void GenerateDescriptorInitializer(io::Printer* printer) const;
|
||||
std::string GetDefaultValue(void) const;
|
||||
void GenerateStaticInit(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
|
||||
};
|
||||
|
||||
|
||||
|
@ -143,7 +143,7 @@ std::string PrimitiveFieldGenerator::GetDefaultValue() const
|
||||
case FieldDescriptor::CPPTYPE_BOOL:
|
||||
return descriptor_->default_value_bool() ? "1" : "0";
|
||||
default:
|
||||
GOOGLE_LOG(DFATAL) << "unexpected CPPTYPE in c_primitive_field";
|
||||
GOOGLE_LOG(FATAL) << "unexpected CPPTYPE in c_primitive_field";
|
||||
return "UNEXPECTED_CPPTYPE";
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,6 @@ class PrimitiveFieldGenerator : public FieldGenerator {
|
||||
void GenerateDescriptorInitializer(io::Printer* printer) const;
|
||||
std::string GetDefaultValue(void) const;
|
||||
void GenerateStaticInit(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -100,8 +100,6 @@ class ServiceGenerator {
|
||||
|
||||
const ServiceDescriptor* descriptor_;
|
||||
std::map<std::string, std::string> vars_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
|
||||
};
|
||||
|
||||
} // namespace c
|
||||
|
@ -87,8 +87,6 @@ class StringFieldGenerator : public FieldGenerator {
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user