aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
commit3af881c7e2db0553207876acbdb91c6e77974e44 (patch)
tree35e2a96cce802d4235bd29afa396e28ead892fa2 /src/google/protobuf/compiler/cpp/cpp_enum_field.cc
parent86975301f1876ce1934612777b8ca6c76520f5cc (diff)
parent942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff)
Merge master into 3.4.x
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_enum_field.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index e99e7e55..08a635fa 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -145,12 +145,14 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
"} else {\n"
- " mutable_unknown_fields()->AddVarint($number$, value);\n");
+ " mutable_unknown_fields()->AddVarint(\n"
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32($tag$u);\n"
- " unknown_fields_stream.WriteVarint32(value);\n",
+ " unknown_fields_stream.WriteVarint32(\n"
+ " static_cast< ::google::protobuf::uint32>(value));\n",
"tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));
}
printer->Print(variables_,
@@ -356,12 +358,14 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
"} else {\n"
- " mutable_unknown_fields()->AddVarint($number$, value);\n");
+ " mutable_unknown_fields()->AddVarint(\n"
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32(tag);\n"
- " unknown_fields_stream.WriteVarint32(value);\n");
+ " unknown_fields_stream.WriteVarint32(\n"
+ " static_cast< ::google::protobuf::uint32>(value));\n");
}
printer->Print("}\n");
}
@@ -403,7 +407,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
"::google::protobuf::uint32 length;\n"
"DO_(input->ReadVarint32(&length));\n"
"::google::protobuf::io::CodedInputStream::Limit limit = "
- "input->PushLimit(length);\n"
+ "input->PushLimit(static_cast<int>(length));\n"
"while (input->BytesUntilLimit() > 0) {\n"
" int value;\n"
" DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
@@ -419,11 +423,13 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
" } else {\n");
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
- " mutable_unknown_fields()->AddVarint($number$, value);\n");
+ " mutable_unknown_fields()->AddVarint(\n"
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(variables_,
" unknown_fields_stream.WriteVarint32(tag);\n"
- " unknown_fields_stream.WriteVarint32(value);\n");
+ " unknown_fields_stream.WriteVarint32(\n"
+ " static_cast< ::google::protobuf::uint32>(value));\n");
}
printer->Print(
" }\n");
@@ -444,7 +450,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
" $number$,\n"
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" output);\n"
- " output->WriteVarint32(_$name$_cached_byte_size_);\n"
+ " output->WriteVarint32(\n"
+ " static_cast< ::google::protobuf::uint32>(_$name$_cached_byte_size_));\n"
"}\n");
}
printer->Print(variables_,
@@ -472,7 +479,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray("
- " _$name$_cached_byte_size_, target);\n"
+ " static_cast< ::google::protobuf::uint32>(\n"
+ " _$name$_cached_byte_size_), target);\n"
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
" this->$name$_, target);\n"
"}\n");
@@ -488,19 +496,20 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_,
"{\n"
" size_t data_size = 0;\n"
- " unsigned int count = this->$name$_size();");
+ " unsigned int count = static_cast<unsigned int>(this->$name$_size());");
printer->Indent();
printer->Print(variables_,
"for (unsigned int i = 0; i < count; i++) {\n"
" data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n"
- " this->$name$(i));\n"
+ " this->$name$(static_cast<int>(i)));\n"
"}\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
- " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n"
+ " ::google::protobuf::internal::WireFormatLite::Int32Size(\n"
+ " static_cast< ::google::protobuf::int32>(data_size));\n"
"}\n"
"int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"