|
|
|
@ -51,8 +51,9 @@ |
|
|
|
|
#include <utility> |
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
#include "google/protobuf/stubs/logging.h" |
|
|
|
|
#include "absl/container/flat_hash_map.h" |
|
|
|
|
#include "google/protobuf/stubs/logging.h" |
|
|
|
|
#include "google/protobuf/stubs/logging.h" |
|
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
|
#include "absl/strings/str_cat.h" |
|
|
|
@ -167,7 +168,7 @@ std::string StringifyDefaultValue(const FieldDescriptor& field) { |
|
|
|
|
} |
|
|
|
|
// (We could add a default case above but then we wouldn't get the nice
|
|
|
|
|
// compiler warning when a new type is added.)
|
|
|
|
|
GOOGLE_LOG(FATAL) << "Not reached."; |
|
|
|
|
GOOGLE_ABSL_LOG(FATAL) << "Not reached."; |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -179,8 +180,9 @@ std::string StringifySyntax(FileDescriptor::Syntax syntax) { |
|
|
|
|
return "proto3"; |
|
|
|
|
case FileDescriptor::SYNTAX_UNKNOWN: |
|
|
|
|
default: |
|
|
|
|
GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 " |
|
|
|
|
"and proto3 syntax."; |
|
|
|
|
GOOGLE_ABSL_LOG(FATAL) |
|
|
|
|
<< "Unsupported syntax; this generator only supports proto2 " |
|
|
|
|
"and proto3 syntax."; |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -290,7 +292,7 @@ bool Generator::Generate(const FileDescriptor* file, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); |
|
|
|
|
GOOGLE_CHECK(output.get()); |
|
|
|
|
GOOGLE_ABSL_CHECK(output.get()); |
|
|
|
|
io::Printer printer(output.get(), '$'); |
|
|
|
|
printer_ = &printer; |
|
|
|
|
|
|
|
|
@ -947,7 +949,7 @@ std::string Generator::FieldReferencingExpression( |
|
|
|
|
const std::string& python_dict_name) const { |
|
|
|
|
// We should only ever be looking up fields in the current file.
|
|
|
|
|
// The only things we refer to from other files are message descriptors.
|
|
|
|
|
GOOGLE_CHECK_EQ(field.file(), file_) |
|
|
|
|
GOOGLE_ABSL_CHECK_EQ(field.file(), file_) |
|
|
|
|
<< field.file()->name() << " vs. " << file_->name(); |
|
|
|
|
if (!containing_type) { |
|
|
|
|
return ResolveKeyword(field.name()); |
|
|
|
@ -1013,7 +1015,7 @@ void Generator::FixForeignFieldsInExtensions() const { |
|
|
|
|
|
|
|
|
|
void Generator::FixForeignFieldsInExtension( |
|
|
|
|
const FieldDescriptor& extension_field) const { |
|
|
|
|
GOOGLE_CHECK(extension_field.is_extension()); |
|
|
|
|
GOOGLE_ABSL_CHECK(extension_field.is_extension()); |
|
|
|
|
|
|
|
|
|
absl::flat_hash_map<absl::string_view, std::string> m; |
|
|
|
|
// Confusingly, for FieldDescriptors that happen to be extensions,
|
|
|
|
@ -1228,7 +1230,7 @@ void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor, |
|
|
|
|
std::string sp; |
|
|
|
|
proto.SerializeToString(&sp); |
|
|
|
|
int offset = file_descriptor_serialized_.find(sp); |
|
|
|
|
GOOGLE_CHECK_GE(offset, 0); |
|
|
|
|
GOOGLE_ABSL_CHECK_GE(offset, 0); |
|
|
|
|
|
|
|
|
|
printer_->Print( |
|
|
|
|
"_globals['$name$']._serialized_start=$serialized_start$\n" |
|
|
|
|