Skip to content

Commit b8c8613

Browse files
committed
Updates for Protobuf 30+ C++ API changes
1 parent e22e9da commit b8c8613

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

protoc/CppFileGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FileGenerator::FileGenerator(const FileDescriptor *file,
5959
const string &output_name)
6060
: m_file(file),
6161
m_output_name(output_name) {
62-
SplitStringUsing(file->package(), ".", &package_parts_);
62+
SplitStringUsing(string(file->package()), ".", &package_parts_);
6363

6464
ServiceGenerator::Options options;
6565
for (int i = 0; i < file->service_count(); i++) {
@@ -79,7 +79,7 @@ void FileGenerator::GenerateHeader(Printer *printer) {
7979
const string filename_identifier = FilenameIdentifier(m_output_name);
8080

8181
std::map<string, string> var_map;
82-
var_map["basename"] = StripProto(m_file->name());
82+
var_map["basename"] = StripProto(string(m_file->name()));
8383
var_map["filename"] = m_file->name();
8484
var_map["filename_identifier"] = filename_identifier;
8585

protoc/CppGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool CppGenerator::Generate(const FileDescriptor *file,
4343
const string&,
4444
OutputDirectory *generator_context,
4545
string*) const {
46-
string basename = StripProto(file->name()) + "Service";
46+
string basename = StripProto(string(file->name())) + "Service";
4747

4848
string header_name = basename + ".pb.h";
4949
string code_name = basename + ".pb.cpp";

protoc/GeneratorHelpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ string ClassName(const Descriptor* descriptor, bool qualified) {
6969
const Descriptor* outer = descriptor;
7070
while (outer->containing_type() != NULL) outer = outer->containing_type();
7171

72-
const string& outer_name = outer->full_name();
73-
string inner_name = descriptor->full_name().substr(outer_name.size());
72+
const string& outer_name = string(outer->full_name());
73+
string inner_name = string(descriptor->full_name()).substr(outer_name.size());
7474

7575
if (qualified) {
7676
return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name);
7777
} else {
78-
return outer->name() + DotsToUnderscores(inner_name);
78+
return string(outer->name()) + DotsToUnderscores(inner_name);
7979
}
8080
}
8181

protoc/ServiceGenerator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,16 @@ void ServiceGenerator::GenerateCallMethod(Printer* printer) {
327327
" const $input_type$*>(request),\n"
328328
" ::google::protobuf::down_cast<\n"
329329
" $output_type$*>(response),\n"
330-
#else
330+
#elif GOOGLE_PROTOBUF_VERSION < 6030000
331331
" ::google::protobuf::internal::DownCast<\n"
332332
" const $input_type$*>(request),\n"
333333
" ::google::protobuf::internal::DownCast<\n"
334334
" $output_type$*>(response),\n"
335+
#else
336+
" ::google::protobuf::DownCastMessage<\n"
337+
" $input_type$>(request),\n"
338+
" ::google::protobuf::DownCastMessage<\n"
339+
" $output_type$>(response),\n"
335340
#endif
336341
" done);\n"
337342
" break;\n");

0 commit comments

Comments
 (0)