Jelajahi Sumber

Merge pull request #6032 from haon4/objectivec

Replace SimpleItoa with StrCat in ObjectiveC compiler codes
Hao Nguyen 6 tahun lalu
induk
melakukan
42bab121fd

+ 1 - 1
src/google/protobuf/compiler/objectivec/objectivec_enum.cc

@@ -142,7 +142,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
         "$name$$deprecated_attribute$ = $value$,\n",
         "$name$$deprecated_attribute$ = $value$,\n",
         "name", EnumValueName(all_values_[i]),
         "name", EnumValueName(all_values_[i]),
         "deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]),
         "deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]),
-        "value", SimpleItoa(all_values_[i]->number()));
+        "value", StrCat(all_values_[i]->number()));
   }
   }
   printer->Outdent();
   printer->Outdent();
   printer->Print(
   printer->Print(

+ 1 - 1
src/google/protobuf/compiler/objectivec/objectivec_extension.cc

@@ -85,7 +85,7 @@ void ExtensionGenerator::GenerateStaticVariablesInitialization(
   std::map<string, string> vars;
   std::map<string, string> vars;
   vars["root_class_and_method_name"] = root_class_and_method_name_;
   vars["root_class_and_method_name"] = root_class_and_method_name_;
   vars["extended_type"] = ClassName(descriptor_->containing_type());
   vars["extended_type"] = ClassName(descriptor_->containing_type());
-  vars["number"] = SimpleItoa(descriptor_->number());
+  vars["number"] = StrCat(descriptor_->number());
 
 
   std::vector<string> options;
   std::vector<string> options;
   if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated");
   if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated");

+ 3 - 3
src/google/protobuf/compiler/objectivec/objectivec_field.cc

@@ -75,7 +75,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
   (*variables)["raw_field_name"] = raw_field_name;
   (*variables)["raw_field_name"] = raw_field_name;
   (*variables)["field_number_name"] =
   (*variables)["field_number_name"] =
       classname + "_FieldNumber_" + capitalized_name;
       classname + "_FieldNumber_" + capitalized_name;
-  (*variables)["field_number"] = SimpleItoa(descriptor->number());
+  (*variables)["field_number"] = StrCat(descriptor->number());
   (*variables)["field_type"] = GetCapitalizedType(descriptor);
   (*variables)["field_type"] = GetCapitalizedType(descriptor);
   (*variables)["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor);
   (*variables)["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor);
   std::vector<string> field_flags;
   std::vector<string> field_flags;
@@ -213,7 +213,7 @@ void FieldGenerator::GenerateFieldDescription(
 }
 }
 
 
 void FieldGenerator::SetRuntimeHasBit(int has_index) {
 void FieldGenerator::SetRuntimeHasBit(int has_index) {
-  variables_["has_index"] = SimpleItoa(has_index);
+  variables_["has_index"] = StrCat(has_index);
 }
 }
 
 
 void FieldGenerator::SetNoHasBit(void) {
 void FieldGenerator::SetNoHasBit(void) {
@@ -236,7 +236,7 @@ void FieldGenerator::SetOneofIndexBase(int index_base) {
   if (descriptor_->containing_oneof() != NULL) {
   if (descriptor_->containing_oneof() != NULL) {
     int index = descriptor_->containing_oneof()->index() + index_base;
     int index = descriptor_->containing_oneof()->index() + index_base;
     // Flip the sign to mark it as a oneof.
     // Flip the sign to mark it as a oneof.
-    variables_["has_index"] = SimpleItoa(-index);
+    variables_["has_index"] = StrCat(-index);
   }
   }
 }
 }
 
 

+ 1 - 1
src/google/protobuf/compiler/objectivec/objectivec_file.cc

@@ -241,7 +241,7 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
       "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n"
       "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n"
       "#endif\n"
       "#endif\n"
       "\n",
       "\n",
-      "google_protobuf_objc_version", SimpleItoa(GOOGLE_PROTOBUF_OBJC_VERSION));
+      "google_protobuf_objc_version", StrCat(GOOGLE_PROTOBUF_OBJC_VERSION));
 
 
   // #import any headers for "public imports" in the proto file.
   // #import any headers for "public imports" in the proto file.
   {
   {

+ 5 - 5
src/google/protobuf/compiler/objectivec/objectivec_helpers.cc

@@ -805,17 +805,17 @@ string DefaultValue(const FieldDescriptor* field) {
       if (field->default_value_int32() == INT_MIN) {
       if (field->default_value_int32() == INT_MIN) {
         return "-0x80000000";
         return "-0x80000000";
       }
       }
-      return SimpleItoa(field->default_value_int32());
+      return StrCat(field->default_value_int32());
     case FieldDescriptor::CPPTYPE_UINT32:
     case FieldDescriptor::CPPTYPE_UINT32:
-      return SimpleItoa(field->default_value_uint32()) + "U";
+      return StrCat(field->default_value_uint32()) + "U";
     case FieldDescriptor::CPPTYPE_INT64:
     case FieldDescriptor::CPPTYPE_INT64:
       // gcc and llvm reject the decimal form of kint32min and kint64min.
       // gcc and llvm reject the decimal form of kint32min and kint64min.
       if (field->default_value_int64() == LLONG_MIN) {
       if (field->default_value_int64() == LLONG_MIN) {
         return "-0x8000000000000000LL";
         return "-0x8000000000000000LL";
       }
       }
-      return SimpleItoa(field->default_value_int64()) + "LL";
+      return StrCat(field->default_value_int64()) + "LL";
     case FieldDescriptor::CPPTYPE_UINT64:
     case FieldDescriptor::CPPTYPE_UINT64:
-      return SimpleItoa(field->default_value_uint64()) + "ULL";
+      return StrCat(field->default_value_uint64()) + "ULL";
     case FieldDescriptor::CPPTYPE_DOUBLE:
     case FieldDescriptor::CPPTYPE_DOUBLE:
       return HandleExtremeFloatingPoint(
       return HandleExtremeFloatingPoint(
           SimpleDtoa(field->default_value_double()), false);
           SimpleDtoa(field->default_value_double()), false);
@@ -1547,7 +1547,7 @@ bool ParseSimpleFile(
     if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len))) {
     if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len))) {
       *out_error =
       *out_error =
           string("error: ") + path +
           string("error: ") + path +
-          " Line " + SimpleItoa(parser.last_line()) + ", " + parser.error_str();
+          " Line " + StrCat(parser.last_line()) + ", " + parser.error_str();
       return false;
       return false;
     }
     }
   }
   }

+ 3 - 3
src/google/protobuf/compiler/objectivec/objectivec_message.cc

@@ -461,7 +461,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
         "typedef struct $classname$__storage_ {\n"
         "typedef struct $classname$__storage_ {\n"
         "  uint32_t _has_storage_[$sizeof_has_storage$];\n",
         "  uint32_t _has_storage_[$sizeof_has_storage$];\n",
         "classname", class_name_,
         "classname", class_name_,
-        "sizeof_has_storage", SimpleItoa(sizeof_has_storage));
+        "sizeof_has_storage", StrCat(sizeof_has_storage));
     printer->Indent();
     printer->Indent();
 
 
     for (int i = 0; i < descriptor_->field_count(); i++) {
     for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -582,8 +582,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
           "    static const GPBExtensionRange ranges[] = {\n");
           "    static const GPBExtensionRange ranges[] = {\n");
       for (int i = 0; i < sorted_extensions.size(); i++) {
       for (int i = 0; i < sorted_extensions.size(); i++) {
         printer->Print("      { .start = $start$, .end = $end$ },\n",
         printer->Print("      { .start = $start$, .end = $end$ },\n",
-                       "start", SimpleItoa(sorted_extensions[i]->start),
-                       "end", SimpleItoa(sorted_extensions[i]->end));
+                       "start", StrCat(sorted_extensions[i]->start),
+                       "end", StrCat(sorted_extensions[i]->end));
       }
       }
       printer->Print(
       printer->Print(
           "    };\n"
           "    };\n"

+ 3 - 3
src/google/protobuf/compiler/objectivec/objectivec_oneof.cc

@@ -46,7 +46,7 @@ OneofGenerator::OneofGenerator(const OneofDescriptor* descriptor)
   variables_["enum_name"] = OneofEnumName(descriptor_);
   variables_["enum_name"] = OneofEnumName(descriptor_);
   variables_["name"] = OneofName(descriptor_);
   variables_["name"] = OneofName(descriptor_);
   variables_["capitalized_name"] = OneofNameCapitalized(descriptor_);
   variables_["capitalized_name"] = OneofNameCapitalized(descriptor_);
-  variables_["raw_index"] = SimpleItoa(descriptor_->index());
+  variables_["raw_index"] = StrCat(descriptor_->index());
   const Descriptor* msg_descriptor = descriptor_->containing_type();
   const Descriptor* msg_descriptor = descriptor_->containing_type();
   variables_["owning_message_class"] = ClassName(msg_descriptor);
   variables_["owning_message_class"] = ClassName(msg_descriptor);
 
 
@@ -65,7 +65,7 @@ OneofGenerator::~OneofGenerator() {}
 void OneofGenerator::SetOneofIndexBase(int index_base) {
 void OneofGenerator::SetOneofIndexBase(int index_base) {
   int index = descriptor_->index() + index_base;
   int index = descriptor_->index() + index_base;
   // Flip the sign to mark it as a oneof.
   // Flip the sign to mark it as a oneof.
-  variables_["index"] = SimpleItoa(-index);
+  variables_["index"] = StrCat(-index);
 }
 }
 
 
 void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
 void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
@@ -84,7 +84,7 @@ void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
         "$enum_name$_$field_name$ = $field_number$,\n",
         "$enum_name$_$field_name$ = $field_number$,\n",
         "enum_name", enum_name,
         "enum_name", enum_name,
         "field_name", field_name,
         "field_name", field_name,
-        "field_number", SimpleItoa(field->number()));
+        "field_number", StrCat(field->number()));
   }
   }
   printer->Outdent();
   printer->Outdent();
   printer->Print(
   printer->Print(

+ 1 - 1
src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc

@@ -152,7 +152,7 @@ int PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
 void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) {
 void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) {
   if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {
   if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {
     // Set into the offset the has bit to use for the actual value.
     // Set into the offset the has bit to use for the actual value.
-    variables_["storage_offset_value"] = SimpleItoa(has_base);
+    variables_["storage_offset_value"] = StrCat(has_base);
     variables_["storage_offset_comment"] =
     variables_["storage_offset_comment"] =
         "  // Stored in _has_storage_ to save space.";
         "  // Stored in _has_storage_ to save space.";
   }
   }