|
|
@ -54,7 +54,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "google/protobuf/stubs/logging.h" |
|
|
|
#include "google/protobuf/stubs/logging.h" |
|
|
|
#include "google/protobuf/stubs/common.h" |
|
|
|
#include "google/protobuf/stubs/common.h" |
|
|
|
#include "absl/container/flat_hash_map.h" |
|
|
|
|
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
#include "absl/strings/str_cat.h" |
|
|
|
#include "absl/strings/str_cat.h" |
|
|
@ -434,7 +433,7 @@ void Generator::PrintImports() const { |
|
|
|
|
|
|
|
|
|
|
|
// Prints the single file descriptor for this file.
|
|
|
|
// Prints the single file descriptor for this file.
|
|
|
|
void Generator::PrintFileDescriptor() const { |
|
|
|
void Generator::PrintFileDescriptor() const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["name"] = file_->name(); |
|
|
|
m["name"] = file_->name(); |
|
|
|
m["package"] = file_->package(); |
|
|
|
m["package"] = file_->package(); |
|
|
@ -509,7 +508,7 @@ void Generator::PrintAllNestedEnumsInFile() const { |
|
|
|
// enum name to a Python EnumDescriptor object equivalent to
|
|
|
|
// enum name to a Python EnumDescriptor object equivalent to
|
|
|
|
// enum_descriptor.
|
|
|
|
// enum_descriptor.
|
|
|
|
void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { |
|
|
|
void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
std::string module_level_descriptor_name = |
|
|
|
std::string module_level_descriptor_name = |
|
|
|
ModuleLevelDescriptorName(enum_descriptor); |
|
|
|
ModuleLevelDescriptorName(enum_descriptor); |
|
|
|
m["descriptor_name"] = module_level_descriptor_name; |
|
|
|
m["descriptor_name"] = module_level_descriptor_name; |
|
|
@ -584,7 +583,7 @@ void Generator::PrintServices() const { |
|
|
|
|
|
|
|
|
|
|
|
void Generator::PrintServiceDescriptor( |
|
|
|
void Generator::PrintServiceDescriptor( |
|
|
|
const ServiceDescriptor& descriptor) const { |
|
|
|
const ServiceDescriptor& descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["service_name"] = ModuleLevelServiceDescriptorName(descriptor); |
|
|
|
m["service_name"] = ModuleLevelServiceDescriptorName(descriptor); |
|
|
|
m["name"] = descriptor.name(); |
|
|
|
m["name"] = descriptor.name(); |
|
|
|
m["file"] = kDescriptorKey; |
|
|
|
m["file"] = kDescriptorKey; |
|
|
@ -634,7 +633,7 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const { |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Mutually recursive with PrintNestedDescriptors().
|
|
|
|
// Mutually recursive with PrintNestedDescriptors().
|
|
|
|
void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { |
|
|
|
void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["name"] = message_descriptor.name(); |
|
|
|
m["name"] = message_descriptor.name(); |
|
|
|
m["full_name"] = message_descriptor.full_name(); |
|
|
|
m["full_name"] = message_descriptor.full_name(); |
|
|
|
m["file"] = kDescriptorKey; |
|
|
|
m["file"] = kDescriptorKey; |
|
|
@ -785,7 +784,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, |
|
|
|
to_register->push_back(qualified_name); |
|
|
|
to_register->push_back(qualified_name); |
|
|
|
|
|
|
|
|
|
|
|
PrintNestedMessages(message_descriptor, qualified_name, to_register); |
|
|
|
PrintNestedMessages(message_descriptor, qualified_name, to_register); |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_key"] = kDescriptorKey; |
|
|
|
m["descriptor_key"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); |
|
|
|
m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); |
|
|
|
printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n"); |
|
|
|
printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n"); |
|
|
@ -840,7 +839,7 @@ void Generator::FixForeignFieldsInDescriptor( |
|
|
|
FixContainingTypeInDescriptor(enum_descriptor, &descriptor); |
|
|
|
FixContainingTypeInDescriptor(enum_descriptor, &descriptor); |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < descriptor.oneof_decl_count(); ++i) { |
|
|
|
for (int i = 0; i < descriptor.oneof_decl_count(); ++i) { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
const OneofDescriptor* oneof = descriptor.oneof_decl(i); |
|
|
|
const OneofDescriptor* oneof = descriptor.oneof_decl(i); |
|
|
|
m["descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
|
m["descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
|
m["oneof_name"] = oneof->name(); |
|
|
|
m["oneof_name"] = oneof->name(); |
|
|
@ -859,7 +858,7 @@ void Generator::FixForeignFieldsInDescriptor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { |
|
|
|
void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["message_name"] = descriptor.name(); |
|
|
|
m["message_name"] = descriptor.name(); |
|
|
|
m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
|
m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
@ -871,7 +870,7 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { |
|
|
|
|
|
|
|
|
|
|
|
void Generator::AddServiceToFileDescriptor( |
|
|
|
void Generator::AddServiceToFileDescriptor( |
|
|
|
const ServiceDescriptor& descriptor) const { |
|
|
|
const ServiceDescriptor& descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["service_name"] = descriptor.name(); |
|
|
|
m["service_name"] = descriptor.name(); |
|
|
|
m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor); |
|
|
|
m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor); |
|
|
@ -883,7 +882,7 @@ void Generator::AddServiceToFileDescriptor( |
|
|
|
|
|
|
|
|
|
|
|
void Generator::AddEnumToFileDescriptor( |
|
|
|
void Generator::AddEnumToFileDescriptor( |
|
|
|
const EnumDescriptor& descriptor) const { |
|
|
|
const EnumDescriptor& descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["enum_name"] = descriptor.name(); |
|
|
|
m["enum_name"] = descriptor.name(); |
|
|
|
m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
|
m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor); |
|
|
@ -895,7 +894,7 @@ void Generator::AddEnumToFileDescriptor( |
|
|
|
|
|
|
|
|
|
|
|
void Generator::AddExtensionToFileDescriptor( |
|
|
|
void Generator::AddExtensionToFileDescriptor( |
|
|
|
const FieldDescriptor& descriptor) const { |
|
|
|
const FieldDescriptor& descriptor) const { |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["descriptor_name"] = kDescriptorKey; |
|
|
|
m["field_name"] = descriptor.name(); |
|
|
|
m["field_name"] = descriptor.name(); |
|
|
|
m["resolved_name"] = ResolveKeyword(descriptor.name()); |
|
|
|
m["resolved_name"] = ResolveKeyword(descriptor.name()); |
|
|
@ -919,7 +918,7 @@ void Generator::FixForeignFieldsInField( |
|
|
|
const std::string& python_dict_name) const { |
|
|
|
const std::string& python_dict_name) const { |
|
|
|
const std::string field_referencing_expression = |
|
|
|
const std::string field_referencing_expression = |
|
|
|
FieldReferencingExpression(containing_type, field, python_dict_name); |
|
|
|
FieldReferencingExpression(containing_type, field, python_dict_name); |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["field_ref"] = field_referencing_expression; |
|
|
|
m["field_ref"] = field_referencing_expression; |
|
|
|
const Descriptor* foreign_message_type = field.message_type(); |
|
|
|
const Descriptor* foreign_message_type = field.message_type(); |
|
|
|
if (foreign_message_type) { |
|
|
|
if (foreign_message_type) { |
|
|
@ -1015,7 +1014,7 @@ void Generator::FixForeignFieldsInExtension( |
|
|
|
const FieldDescriptor& extension_field) const { |
|
|
|
const FieldDescriptor& extension_field) const { |
|
|
|
GOOGLE_CHECK(extension_field.is_extension()); |
|
|
|
GOOGLE_CHECK(extension_field.is_extension()); |
|
|
|
|
|
|
|
|
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
// Confusingly, for FieldDescriptors that happen to be extensions,
|
|
|
|
// Confusingly, for FieldDescriptors that happen to be extensions,
|
|
|
|
// containing_type() means "extended type."
|
|
|
|
// containing_type() means "extended type."
|
|
|
|
// On the other hand, extension_scope() will give us what we normally
|
|
|
|
// On the other hand, extension_scope() will give us what we normally
|
|
|
@ -1047,7 +1046,7 @@ void Generator::PrintEnumValueDescriptor( |
|
|
|
// More circular references. ::sigh::
|
|
|
|
// More circular references. ::sigh::
|
|
|
|
std::string options_string; |
|
|
|
std::string options_string; |
|
|
|
descriptor.options().SerializeToString(&options_string); |
|
|
|
descriptor.options().SerializeToString(&options_string); |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["name"] = descriptor.name(); |
|
|
|
m["name"] = descriptor.name(); |
|
|
|
m["index"] = absl::StrCat(descriptor.index()); |
|
|
|
m["index"] = absl::StrCat(descriptor.index()); |
|
|
|
m["number"] = absl::StrCat(descriptor.number()); |
|
|
|
m["number"] = absl::StrCat(descriptor.number()); |
|
|
@ -1075,7 +1074,7 @@ void Generator::PrintFieldDescriptor(const FieldDescriptor& field, |
|
|
|
bool is_extension) const { |
|
|
|
bool is_extension) const { |
|
|
|
std::string options_string; |
|
|
|
std::string options_string; |
|
|
|
field.options().SerializeToString(&options_string); |
|
|
|
field.options().SerializeToString(&options_string); |
|
|
|
absl::flat_hash_map<std::string, std::string> m; |
|
|
|
std::map<std::string, std::string> m; |
|
|
|
m["name"] = field.name(); |
|
|
|
m["name"] = field.name(); |
|
|
|
m["full_name"] = field.full_name(); |
|
|
|
m["full_name"] = field.full_name(); |
|
|
|
m["index"] = absl::StrCat(field.index()); |
|
|
|
m["index"] = absl::StrCat(field.index()); |
|
|
|