From bbd6dc6d4e94963735342a4968b3b4de03a1ff83 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Thu, 25 Apr 2019 13:15:38 -0700 Subject: [PATCH 1/2] Revert "Replaced all instances of Simple{IDF}toa with StrCat." This reverts commit 029f2c7cda91403038355e86e08c7319c08436d9. --- .../protobuf/compiler/cpp/cpp_helpers.cc | 4 +- .../protobuf/compiler/csharp/csharp_enum.cc | 4 +- .../compiler/csharp/csharp_field_base.cc | 38 +++++++++---------- .../compiler/csharp/csharp_message.cc | 18 ++++----- .../compiler/csharp/csharp_message_field.cc | 6 +-- .../compiler/csharp/csharp_primitive_field.cc | 2 +- .../protobuf/compiler/java/java_helpers.cc | 4 +- .../protobuf/compiler/js/js_generator.cc | 10 ++--- .../compiler/objectivec/objectivec_helpers.cc | 4 +- src/google/protobuf/compiler/parser.cc | 2 +- .../protobuf/compiler/php/php_generator.cc | 6 +-- .../compiler/python/python_generator.cc | 4 +- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index a86a13a4e..6a32c5647 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -643,7 +643,7 @@ std::string DefaultValue(const Options& options, const FieldDescriptor* field) { } else if (value != value) { return "std::numeric_limits::quiet_NaN()"; } else { - return StrCat(value); + return SimpleDtoa(value); } } case FieldDescriptor::CPPTYPE_FLOAT: { @@ -655,7 +655,7 @@ std::string DefaultValue(const Options& options, const FieldDescriptor* field) { } else if (value != value) { return "std::numeric_limits::quiet_NaN()"; } else { - std::string float_value = StrCat(value); + std::string float_value = SimpleFtoa(value); // If floating point value contains a period (.) or an exponent // (either E or e), then append suffix 'f' to make it a float // literal. diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 2baefd84e..f45709663 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -79,12 +79,12 @@ void EnumGenerator::Generate(io::Printer* printer) { printer->Print("[pbr::OriginalName(\"$original_name$\", PreferredAlias = false)] $name$ = $number$,\n", "original_name", original_name, "name", name, - "number", StrCat(number)); + "number", SimpleItoa(number)); } else { printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", "original_name", original_name, "name", name, - "number", StrCat(number)); + "number", SimpleItoa(number)); } } printer->Outdent(); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 8ac0d3ab0..02adfeae1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -62,14 +62,14 @@ void FieldGeneratorBase::SetCommonFieldVariables( uint tag = internal::WireFormat::MakeTag(descriptor_); uint8 tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); - string tag_bytes = StrCat(tag_array[0]); + string tag_bytes = SimpleItoa(tag_array[0]); for (int i = 1; i < tag_size; i++) { - tag_bytes += ", " + StrCat(tag_array[i]); + tag_bytes += ", " + SimpleItoa(tag_array[i]); } (*variables)["access_level"] = "public"; - (*variables)["tag"] = StrCat(tag); - (*variables)["tag_size"] = StrCat(tag_size); + (*variables)["tag"] = SimpleItoa(tag); + (*variables)["tag_size"] = SimpleItoa(tag_size); (*variables)["tag_bytes"] = tag_bytes; (*variables)["property_name"] = property_name(); @@ -91,8 +91,8 @@ void FieldGeneratorBase::SetCommonFieldVariables( (*variables)["has_not_property_check"] = "!" + (*variables)["has_property_check"]; (*variables)["other_has_not_property_check"] = "!" + (*variables)["other_has_property_check"]; if (presenceIndex_ != -1) { - string hasBitsNumber = StrCat(presenceIndex_ / 32); - string hasBitsMask = StrCat(1 << (presenceIndex_ % 32)); + string hasBitsNumber = SimpleItoa(presenceIndex_ / 32); + string hasBitsMask = SimpleItoa(1 << (presenceIndex_ % 32)); (*variables)["has_field_check"] = "(_hasBits" + hasBitsNumber + " & " + hasBitsMask + ") != 0"; (*variables)["set_has_field"] = "_hasBits" + hasBitsNumber + " |= " + hasBitsMask; (*variables)["clear_has_field"] = "_hasBits" + hasBitsNumber + " &= ~" + hasBitsMask; @@ -325,7 +325,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) } else if (std::isnan(value)) { return "double.NaN"; } - return StrCat(value) + "D"; + return SimpleDtoa(value) + "D"; } case FieldDescriptor::TYPE_FLOAT: { float value = descriptor->default_value_float(); @@ -336,18 +336,18 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) } else if (std::isnan(value)) { return "float.NaN"; } - return StrCat(value) + "F"; + return SimpleFtoa(value) + "F"; } case FieldDescriptor::TYPE_INT64: - return StrCat(descriptor->default_value_int64()) + "L"; + return SimpleItoa(descriptor->default_value_int64()) + "L"; case FieldDescriptor::TYPE_UINT64: - return StrCat(descriptor->default_value_uint64()) + "UL"; + return SimpleItoa(descriptor->default_value_uint64()) + "UL"; case FieldDescriptor::TYPE_INT32: - return StrCat(descriptor->default_value_int32()); + return SimpleItoa(descriptor->default_value_int32()); case FieldDescriptor::TYPE_FIXED64: - return StrCat(descriptor->default_value_uint64()) + "UL"; + return SimpleItoa(descriptor->default_value_uint64()) + "UL"; case FieldDescriptor::TYPE_FIXED32: - return StrCat(descriptor->default_value_uint32()); + return SimpleItoa(descriptor->default_value_uint32()); case FieldDescriptor::TYPE_BOOL: if (descriptor->default_value_bool()) { return "true"; @@ -359,15 +359,15 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) case FieldDescriptor::TYPE_BYTES: return GetBytesDefaultValueInternal(descriptor); case FieldDescriptor::TYPE_UINT32: - return StrCat(descriptor->default_value_uint32()); + return SimpleItoa(descriptor->default_value_uint32()); case FieldDescriptor::TYPE_SFIXED32: - return StrCat(descriptor->default_value_int32()); + return SimpleItoa(descriptor->default_value_int32()); case FieldDescriptor::TYPE_SFIXED64: - return StrCat(descriptor->default_value_int64()) + "L"; + return SimpleItoa(descriptor->default_value_int64()) + "L"; case FieldDescriptor::TYPE_SINT32: - return StrCat(descriptor->default_value_int32()); + return SimpleItoa(descriptor->default_value_int32()); case FieldDescriptor::TYPE_SINT64: - return StrCat(descriptor->default_value_int64()) + "L"; + return SimpleItoa(descriptor->default_value_int64()) + "L"; default: GOOGLE_LOG(FATAL)<< "Unknown field type."; return ""; @@ -375,7 +375,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) } std::string FieldGeneratorBase::number() { - return StrCat(descriptor_->number()); + return SimpleItoa(descriptor_->number()); } std::string FieldGeneratorBase::capitalized_type_name() { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 513f8e9d5..e365463bf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -137,7 +137,7 @@ void MessageGenerator::Generate(io::Printer* printer) { for (int i = 0; i < has_bit_field_count_; i++) { // don't use arrays since all arrays are heap allocated, saving allocations // use ints instead of bytes since bytes lack bitwise operators, saving casts - printer->Print("private int _hasBits$i$;\n", "i", StrCat(i)); + printer->Print("private int _hasBits$i$;\n", "i", SimpleItoa(i)); } WriteGeneratedCodeAttributes(printer); @@ -149,10 +149,10 @@ void MessageGenerator::Generate(io::Printer* printer) { // Access the message descriptor via the relevant file descriptor or containing message descriptor. if (!descriptor_->containing_type()) { vars["descriptor_accessor"] = GetReflectionClassName(descriptor_->file()) - + ".Descriptor.MessageTypes[" + StrCat(descriptor_->index()) + "]"; + + ".Descriptor.MessageTypes[" + SimpleItoa(descriptor_->index()) + "]"; } else { vars["descriptor_accessor"] = GetClassName(descriptor_->containing_type()) - + ".Descriptor.NestedTypes[" + StrCat(descriptor_->index()) + "]"; + + ".Descriptor.NestedTypes[" + SimpleItoa(descriptor_->index()) + "]"; } WriteGeneratedCodeAttributes(printer); @@ -198,7 +198,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "public const int $field_constant_name$ = $index$;\n", "field_name", fieldDescriptor->name(), "field_constant_name", GetFieldConstantName(fieldDescriptor), - "index", StrCat(fieldDescriptor->number())); + "index", SimpleItoa(fieldDescriptor->number())); std::unique_ptr generator( CreateFieldGeneratorInternal(fieldDescriptor)); generator->GenerateMembers(printer); @@ -221,7 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); printer->Print("$field_property_name$ = $index$,\n", "field_property_name", GetPropertyName(field), - "index", StrCat(field->number())); + "index", SimpleItoa(field->number())); } printer->Outdent(); printer->Print("}\n"); @@ -306,7 +306,7 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { "public $class_name$($class_name$ other) : this() {\n"); printer->Indent(); for (int i = 0; i < has_bit_field_count_; i++) { - printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", StrCat(i)); + printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", SimpleItoa(i)); } // Clone non-oneof fields first for (int i = 0; i < descriptor_->field_count(); i++) { @@ -545,7 +545,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( "$end_tag$:\n" " return;\n", - "end_tag", StrCat(end_tag_)); + "end_tag", SimpleItoa(end_tag_)); } } for (int i = 0; i < fields_by_number().size(); i++) { @@ -562,13 +562,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( "case $packed_tag$:\n", "packed_tag", - StrCat( + SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED))); } - printer->Print("case $tag$: {\n", "tag", StrCat(tag)); + printer->Print("case $tag$: {\n", "tag", SimpleItoa(tag)); printer->Indent(); std::unique_ptr generator( CreateFieldGeneratorInternal(field)); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index f774c236c..ab76552d1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -65,11 +65,11 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, internal::WireFormatLite::WIRETYPE_END_GROUP); uint8 tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); - string tag_bytes = StrCat(tag_array[0]); + string tag_bytes = SimpleItoa(tag_array[0]); for (int i = 1; i < tag_size; i++) { - tag_bytes += ", " + StrCat(tag_array[i]); + tag_bytes += ", " + SimpleItoa(tag_array[i]); } - variables_["end_tag"] = StrCat(tag); + variables_["end_tag"] = SimpleItoa(tag); variables_["end_tag_bytes"] = tag_bytes; } } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 9e4bb49db..0bf10f2e9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -186,7 +186,7 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { } else { printer->Print( "size += $tag_size$ + $fixed_size$;\n", - "fixed_size", StrCat(fixedSize), + "fixed_size", SimpleItoa(fixedSize), "tag_size", variables_["tag_size"]); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index 9755a0ea5..ac0e9cd3d 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -522,7 +522,7 @@ std::string DefaultValue(const FieldDescriptor* field, bool immutable, } else if (value != value) { return "Double.NaN"; } else { - return StrCat(value) + "D"; + return SimpleDtoa(value) + "D"; } } case FieldDescriptor::CPPTYPE_FLOAT: { @@ -534,7 +534,7 @@ std::string DefaultValue(const FieldDescriptor* field, bool immutable, } else if (value != value) { return "Float.NaN"; } else { - return StrCat(value) + "F"; + return SimpleFtoa(value) + "F"; } } case FieldDescriptor::CPPTYPE_BOOL: diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 81f6e6b42..7b12dde9b 100644 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -733,9 +733,9 @@ std::string EscapeBase64(const std::string& in) { return result; } -// Post-process the result of StrCat to *exactly* match the original codegen's -// formatting (which is just .toString() on java.lang.Double or -// java.lang.Float). +// Post-process the result of SimpleFtoa/SimpleDtoa to *exactly* match the +// original codegen's formatting (which is just .toString() on java.lang.Double +// or java.lang.Float). std::string PostProcessFloat(std::string result) { // If inf, -inf or nan, replace with +Infinity, -Infinity or NaN. if (result == "inf") { @@ -787,12 +787,12 @@ std::string PostProcessFloat(std::string result) { } std::string FloatToString(float value) { - std::string result = StrCat(value); + std::string result = SimpleFtoa(value); return PostProcessFloat(result); } std::string DoubleToString(double value) { - std::string result = StrCat(value); + std::string result = SimpleDtoa(value); return PostProcessFloat(result); } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index a652492d6..e8d6d9e1c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -818,10 +818,10 @@ string DefaultValue(const FieldDescriptor* field) { return StrCat(field->default_value_uint64()) + "ULL"; case FieldDescriptor::CPPTYPE_DOUBLE: return HandleExtremeFloatingPoint( - StrCat(field->default_value_double()), false); + SimpleDtoa(field->default_value_double()), false); case FieldDescriptor::CPPTYPE_FLOAT: return HandleExtremeFloatingPoint( - StrCat(field->default_value_float()), true); + SimpleFtoa(field->default_value_float()), true); case FieldDescriptor::CPPTYPE_BOOL: return field->default_value_bool() ? "YES" : "NO"; case FieldDescriptor::CPPTYPE_STRING: { diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 87a0f2fe5..235c10249 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -1267,7 +1267,7 @@ bool Parser::ParseDefaultAssignment( double value; DO(ConsumeNumber(&value, "Expected number.")); // And stringify it again. - default_value->append(StrCat(value)); + default_value->append(SimpleDtoa(value)); break; case FieldDescriptorProto::TYPE_BOOL: diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 2a1d14b87..d7e33b2c0 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -879,7 +879,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "field", field->name(), "key", ToUpper(key->type_name()), "value", ToUpper(val->type_name()), - "number", StrCat(field->number()), + "number", SimpleItoa(field->number()), "other", EnumOrMessageSuffix(val, true)); } else if (!field->containing_oneof()) { printer->Print( @@ -888,7 +888,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "field", field->name(), "label", LabelForField(field), "type", ToUpper(field->type_name()), - "number", StrCat(field->number()), + "number", SimpleItoa(field->number()), "other", EnumOrMessageSuffix(field, true)); } } @@ -906,7 +906,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "type", ToUpper(field->type_name()), - "number", StrCat(field->number()), + "number", SimpleItoa(field->number()), "other", EnumOrMessageSuffix(field, true)); } printer->Print("->finish()\n"); diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index cd5bc3c5d..cf5b7f657 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -250,7 +250,7 @@ std::string StringifyDefaultValue(const FieldDescriptor& field) { // infinity * 0 = nan return "(1e10000 * 0)"; } else { - return "float(" + StrCat(value) + ")"; + return "float(" + SimpleDtoa(value) + ")"; } } case FieldDescriptor::CPPTYPE_FLOAT: { @@ -266,7 +266,7 @@ std::string StringifyDefaultValue(const FieldDescriptor& field) { // infinity - infinity = nan return "(1e10000 * 0)"; } else { - return "float(" + StrCat(value) + ")"; + return "float(" + SimpleFtoa(value) + ")"; } } case FieldDescriptor::CPPTYPE_BOOL: From ded3c23eadccf641a963cbae599ab2e263970124 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Thu, 25 Apr 2019 13:21:39 -0700 Subject: [PATCH 2/2] Only replace SimpleItoa with StrCat --- .../protobuf/compiler/csharp/csharp_enum.cc | 4 +-- .../compiler/csharp/csharp_field_base.cc | 34 +++++++++---------- .../compiler/csharp/csharp_message.cc | 18 +++++----- .../compiler/csharp/csharp_message_field.cc | 6 ++-- .../compiler/csharp/csharp_primitive_field.cc | 2 +- .../protobuf/compiler/php/php_generator.cc | 6 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index f45709663..2baefd84e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -79,12 +79,12 @@ void EnumGenerator::Generate(io::Printer* printer) { printer->Print("[pbr::OriginalName(\"$original_name$\", PreferredAlias = false)] $name$ = $number$,\n", "original_name", original_name, "name", name, - "number", SimpleItoa(number)); + "number", StrCat(number)); } else { printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", "original_name", original_name, "name", name, - "number", SimpleItoa(number)); + "number", StrCat(number)); } } printer->Outdent(); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 02adfeae1..c480a8b0b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -62,14 +62,14 @@ void FieldGeneratorBase::SetCommonFieldVariables( uint tag = internal::WireFormat::MakeTag(descriptor_); uint8 tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); - string tag_bytes = SimpleItoa(tag_array[0]); + string tag_bytes = StrCat(tag_array[0]); for (int i = 1; i < tag_size; i++) { - tag_bytes += ", " + SimpleItoa(tag_array[i]); + tag_bytes += ", " + StrCat(tag_array[i]); } (*variables)["access_level"] = "public"; - (*variables)["tag"] = SimpleItoa(tag); - (*variables)["tag_size"] = SimpleItoa(tag_size); + (*variables)["tag"] = StrCat(tag); + (*variables)["tag_size"] = StrCat(tag_size); (*variables)["tag_bytes"] = tag_bytes; (*variables)["property_name"] = property_name(); @@ -91,8 +91,8 @@ void FieldGeneratorBase::SetCommonFieldVariables( (*variables)["has_not_property_check"] = "!" + (*variables)["has_property_check"]; (*variables)["other_has_not_property_check"] = "!" + (*variables)["other_has_property_check"]; if (presenceIndex_ != -1) { - string hasBitsNumber = SimpleItoa(presenceIndex_ / 32); - string hasBitsMask = SimpleItoa(1 << (presenceIndex_ % 32)); + string hasBitsNumber = StrCat(presenceIndex_ / 32); + string hasBitsMask = StrCat(1 << (presenceIndex_ % 32)); (*variables)["has_field_check"] = "(_hasBits" + hasBitsNumber + " & " + hasBitsMask + ") != 0"; (*variables)["set_has_field"] = "_hasBits" + hasBitsNumber + " |= " + hasBitsMask; (*variables)["clear_has_field"] = "_hasBits" + hasBitsNumber + " &= ~" + hasBitsMask; @@ -339,15 +339,15 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) return SimpleFtoa(value) + "F"; } case FieldDescriptor::TYPE_INT64: - return SimpleItoa(descriptor->default_value_int64()) + "L"; + return StrCat(descriptor->default_value_int64()) + "L"; case FieldDescriptor::TYPE_UINT64: - return SimpleItoa(descriptor->default_value_uint64()) + "UL"; + return StrCat(descriptor->default_value_uint64()) + "UL"; case FieldDescriptor::TYPE_INT32: - return SimpleItoa(descriptor->default_value_int32()); + return StrCat(descriptor->default_value_int32()); case FieldDescriptor::TYPE_FIXED64: - return SimpleItoa(descriptor->default_value_uint64()) + "UL"; + return StrCat(descriptor->default_value_uint64()) + "UL"; case FieldDescriptor::TYPE_FIXED32: - return SimpleItoa(descriptor->default_value_uint32()); + return StrCat(descriptor->default_value_uint32()); case FieldDescriptor::TYPE_BOOL: if (descriptor->default_value_bool()) { return "true"; @@ -359,15 +359,15 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) case FieldDescriptor::TYPE_BYTES: return GetBytesDefaultValueInternal(descriptor); case FieldDescriptor::TYPE_UINT32: - return SimpleItoa(descriptor->default_value_uint32()); + return StrCat(descriptor->default_value_uint32()); case FieldDescriptor::TYPE_SFIXED32: - return SimpleItoa(descriptor->default_value_int32()); + return StrCat(descriptor->default_value_int32()); case FieldDescriptor::TYPE_SFIXED64: - return SimpleItoa(descriptor->default_value_int64()) + "L"; + return StrCat(descriptor->default_value_int64()) + "L"; case FieldDescriptor::TYPE_SINT32: - return SimpleItoa(descriptor->default_value_int32()); + return StrCat(descriptor->default_value_int32()); case FieldDescriptor::TYPE_SINT64: - return SimpleItoa(descriptor->default_value_int64()) + "L"; + return StrCat(descriptor->default_value_int64()) + "L"; default: GOOGLE_LOG(FATAL)<< "Unknown field type."; return ""; @@ -375,7 +375,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) } std::string FieldGeneratorBase::number() { - return SimpleItoa(descriptor_->number()); + return StrCat(descriptor_->number()); } std::string FieldGeneratorBase::capitalized_type_name() { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index e365463bf..513f8e9d5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -137,7 +137,7 @@ void MessageGenerator::Generate(io::Printer* printer) { for (int i = 0; i < has_bit_field_count_; i++) { // don't use arrays since all arrays are heap allocated, saving allocations // use ints instead of bytes since bytes lack bitwise operators, saving casts - printer->Print("private int _hasBits$i$;\n", "i", SimpleItoa(i)); + printer->Print("private int _hasBits$i$;\n", "i", StrCat(i)); } WriteGeneratedCodeAttributes(printer); @@ -149,10 +149,10 @@ void MessageGenerator::Generate(io::Printer* printer) { // Access the message descriptor via the relevant file descriptor or containing message descriptor. if (!descriptor_->containing_type()) { vars["descriptor_accessor"] = GetReflectionClassName(descriptor_->file()) - + ".Descriptor.MessageTypes[" + SimpleItoa(descriptor_->index()) + "]"; + + ".Descriptor.MessageTypes[" + StrCat(descriptor_->index()) + "]"; } else { vars["descriptor_accessor"] = GetClassName(descriptor_->containing_type()) - + ".Descriptor.NestedTypes[" + SimpleItoa(descriptor_->index()) + "]"; + + ".Descriptor.NestedTypes[" + StrCat(descriptor_->index()) + "]"; } WriteGeneratedCodeAttributes(printer); @@ -198,7 +198,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "public const int $field_constant_name$ = $index$;\n", "field_name", fieldDescriptor->name(), "field_constant_name", GetFieldConstantName(fieldDescriptor), - "index", SimpleItoa(fieldDescriptor->number())); + "index", StrCat(fieldDescriptor->number())); std::unique_ptr generator( CreateFieldGeneratorInternal(fieldDescriptor)); generator->GenerateMembers(printer); @@ -221,7 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); printer->Print("$field_property_name$ = $index$,\n", "field_property_name", GetPropertyName(field), - "index", SimpleItoa(field->number())); + "index", StrCat(field->number())); } printer->Outdent(); printer->Print("}\n"); @@ -306,7 +306,7 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { "public $class_name$($class_name$ other) : this() {\n"); printer->Indent(); for (int i = 0; i < has_bit_field_count_; i++) { - printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", SimpleItoa(i)); + printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", StrCat(i)); } // Clone non-oneof fields first for (int i = 0; i < descriptor_->field_count(); i++) { @@ -545,7 +545,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( "$end_tag$:\n" " return;\n", - "end_tag", SimpleItoa(end_tag_)); + "end_tag", StrCat(end_tag_)); } } for (int i = 0; i < fields_by_number().size(); i++) { @@ -562,13 +562,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( "case $packed_tag$:\n", "packed_tag", - SimpleItoa( + StrCat( internal::WireFormatLite::MakeTag( field->number(), internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED))); } - printer->Print("case $tag$: {\n", "tag", SimpleItoa(tag)); + printer->Print("case $tag$: {\n", "tag", StrCat(tag)); printer->Indent(); std::unique_ptr generator( CreateFieldGeneratorInternal(field)); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index ab76552d1..f774c236c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -65,11 +65,11 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, internal::WireFormatLite::WIRETYPE_END_GROUP); uint8 tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); - string tag_bytes = SimpleItoa(tag_array[0]); + string tag_bytes = StrCat(tag_array[0]); for (int i = 1; i < tag_size; i++) { - tag_bytes += ", " + SimpleItoa(tag_array[i]); + tag_bytes += ", " + StrCat(tag_array[i]); } - variables_["end_tag"] = SimpleItoa(tag); + variables_["end_tag"] = StrCat(tag); variables_["end_tag_bytes"] = tag_bytes; } } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 0bf10f2e9..9e4bb49db 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -186,7 +186,7 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { } else { printer->Print( "size += $tag_size$ + $fixed_size$;\n", - "fixed_size", SimpleItoa(fixedSize), + "fixed_size", StrCat(fixedSize), "tag_size", variables_["tag_size"]); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index d7e33b2c0..2a1d14b87 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -879,7 +879,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "field", field->name(), "key", ToUpper(key->type_name()), "value", ToUpper(val->type_name()), - "number", SimpleItoa(field->number()), + "number", StrCat(field->number()), "other", EnumOrMessageSuffix(val, true)); } else if (!field->containing_oneof()) { printer->Print( @@ -888,7 +888,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "field", field->name(), "label", LabelForField(field), "type", ToUpper(field->type_name()), - "number", SimpleItoa(field->number()), + "number", StrCat(field->number()), "other", EnumOrMessageSuffix(field, true)); } } @@ -906,7 +906,7 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "type", ToUpper(field->type_name()), - "number", SimpleItoa(field->number()), + "number", StrCat(field->number()), "other", EnumOrMessageSuffix(field, true)); } printer->Print("->finish()\n");