attempting to upgrade to proto 3.5
This commit is contained in:
1 parent
eb1b42a5e8
commit
cc3510c6c2
368 files changed
+35764
-24867
No files matched your search
@@ -114,72 +114,37 @@ MapFieldGenerator::~MapFieldGenerator() {}
|
||||
|
||||
void MapFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
||||
printer->Print(
|
||||
variables_,
|
||||
"public:\n"
|
||||
"class $map_classname$ : public "
|
||||
"::google::protobuf::internal::MapEntry<$map_classname$, \n"
|
||||
" $key_cpp$, $val_cpp$,\n"
|
||||
" $key_wire_type$,\n"
|
||||
" $val_wire_type$,\n"
|
||||
" $default_enum_value$ > {\n"
|
||||
"public:\n"
|
||||
" typedef ::google::protobuf::internal::MapEntry<$map_classname$, \n"
|
||||
" $key_cpp$, $val_cpp$,\n"
|
||||
" $key_wire_type$,\n"
|
||||
" $val_wire_type$,\n"
|
||||
" $default_enum_value$ > SuperType;\n"
|
||||
" $map_classname$();\n"
|
||||
" $map_classname$(::google::protobuf::Arena* arena);\n"
|
||||
" void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL;\n"
|
||||
" void MergeFrom(const $map_classname$& other);\n"
|
||||
" static const Message* internal_default_instance() { return "
|
||||
"reinterpret_cast<const "
|
||||
"Message*>(&_$map_classname$_default_instance_); }\n"
|
||||
" ::google::protobuf::Metadata GetMetadata() const;\n"
|
||||
"};\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"public:\n"
|
||||
"typedef ::google::protobuf::internal::MapEntryLite<\n"
|
||||
" $key_cpp$, $val_cpp$,\n"
|
||||
" $key_wire_type$,\n"
|
||||
" $val_wire_type$,\n"
|
||||
" $default_enum_value$ >\n"
|
||||
" $map_classname$;\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::MapField$lite$<\n"
|
||||
" $map_classname$,\n"
|
||||
" $key_cpp$, $val_cpp$,\n"
|
||||
" $key_wire_type$,\n"
|
||||
" $val_wire_type$,\n"
|
||||
" $default_enum_value$ > $name$_;\n"
|
||||
"private:\n");
|
||||
" $default_enum_value$ > $name$_;\n");
|
||||
}
|
||||
|
||||
void MapFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
printer->Print(
|
||||
variables_,
|
||||
"$deprecated_attr$const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n"
|
||||
" $name$() const;\n"
|
||||
"$deprecated_attr$::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n"
|
||||
" mutable_$name$();\n");
|
||||
" $name$() const;\n");
|
||||
printer->Annotate("name", descriptor_);
|
||||
printer->Print(variables_,
|
||||
"$deprecated_attr$::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n"
|
||||
" ${$mutable_$name$$}$();\n");
|
||||
printer->Annotate("{", "}", descriptor_);
|
||||
}
|
||||
|
||||
void MapFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer,
|
||||
bool is_inline) const {
|
||||
std::map<string, string> variables(variables_);
|
||||
variables["inline"] = is_inline ? "inline" : "";
|
||||
printer->Print(variables,
|
||||
"$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n"
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n"
|
||||
"$classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_map:$full_name$)\n"
|
||||
" return $name$_.GetMap();\n"
|
||||
"}\n"
|
||||
"$inline$ ::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n"
|
||||
"inline ::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\n"
|
||||
"$classname$::mutable_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_mutable_map:$full_name$)\n"
|
||||
" return $name$_.MutableMap();\n"
|
||||
@@ -188,9 +153,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
|
||||
|
||||
void MapFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
std::map<string, string> variables(variables_);
|
||||
variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : "";
|
||||
printer->Print(variables, "$this_message$$name$_.Clear();\n");
|
||||
printer->Print(variables_, "$name$_.Clear();\n");
|
||||
}
|
||||
|
||||
void MapFieldGenerator::
|
||||
@@ -256,7 +219,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" unknown_fields_stream.WriteVarint32($tag$u);\n"
|
||||
" unknown_fields_stream.WriteVarint32(data.size());\n"
|
||||
" unknown_fields_stream.WriteVarint32(\n"
|
||||
" static_cast< ::google::protobuf::uint32>(data.size()));\n"
|
||||
" unknown_fields_stream.WriteString(data);\n");
|
||||
}
|
||||
|
||||
@@ -267,12 +231,16 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
|
||||
if (key_field->type() == FieldDescriptor::TYPE_STRING) {
|
||||
GenerateUtf8CheckCodeForString(
|
||||
key_field, options_, true, variables_,
|
||||
StrCat(key, ".data(), ", key, ".length(),\n").data(), printer);
|
||||
key_field, options_, true, variables_,
|
||||
StrCat(key, ".data(), static_cast<int>(", key, ".length()),\n").data(),
|
||||
printer);
|
||||
}
|
||||
if (value_field->type() == FieldDescriptor::TYPE_STRING) {
|
||||
GenerateUtf8CheckCodeForString(value_field, options_, true, variables_,
|
||||
StrCat(value, ".data(), ", value, ".length(),\n").data(), printer);
|
||||
GenerateUtf8CheckCodeForString(
|
||||
value_field, options_, true, variables_,
|
||||
StrCat(value, ".data(), static_cast<int>(", value, ".length()),\n")
|
||||
.data(),
|
||||
printer);
|
||||
}
|
||||
|
||||
// If entry is allocated by arena, its desctructor should be avoided.
|
||||
@@ -376,14 +344,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes(
|
||||
printer->Indent();
|
||||
printer->Indent();
|
||||
if (string_key) {
|
||||
GenerateUtf8CheckCodeForString(key_field, options_, false, variables,
|
||||
"p->first.data(), p->first.length(),\n",
|
||||
printer);
|
||||
GenerateUtf8CheckCodeForString(
|
||||
key_field, options_, false, variables,
|
||||
"p->first.data(), static_cast<int>(p->first.length()),\n", printer);
|
||||
}
|
||||
if (string_value) {
|
||||
GenerateUtf8CheckCodeForString(value_field, options_, false, variables,
|
||||
"p->second.data(), p->second.length(),\n",
|
||||
printer);
|
||||
GenerateUtf8CheckCodeForString(
|
||||
value_field, options_, false, variables,
|
||||
"p->second.data(), static_cast<int>(p->second.length()),\n", printer);
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Outdent();
|
||||
@@ -404,13 +372,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes(
|
||||
" for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
|
||||
" it = this->$name$().begin();\n"
|
||||
" it != this->$name$().end(); ++it, ++n) {\n"
|
||||
" items[n] = SortItem(&*it);\n"
|
||||
" items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n"
|
||||
" }\n"
|
||||
" ::std::sort(&items[0], &items[n], Less());\n");
|
||||
" ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n");
|
||||
printer->Indent();
|
||||
GenerateSerializationLoop(printer, variables, SupportsArenas(descriptor_),
|
||||
utf8_check, "for (size_type i = 0; i < n; i++)",
|
||||
string_key ? "items[i]" : "items[i].second", false);
|
||||
utf8_check, "for (size_type i = 0; i < n; i++)",
|
||||
string_key ? "items[static_cast<ptrdiff_t>(i)]" :
|
||||
"items[static_cast<ptrdiff_t>(i)].second", false);
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
"} else {\n");
|
||||
|
||||
Reference in new issue
Block a user