浏览代码

Added an anonymous namespace and removed unused code.

Joshua Haberman 5 年之前
父节点
当前提交
b414077041
共有 1 个文件被更改,包括 4 次插入39 次删除
  1. 4 39
      src/google/protobuf/compiler/php/php_generator.cc

+ 4 - 39
src/google/protobuf/compiler/php/php_generator.cc

@@ -78,15 +78,14 @@ namespace protobuf {
 namespace compiler {
 namespace php {
 
+namespace {
+
 // Forward decls.
 std::string PhpName(const std::string& full_name, bool is_descriptor);
-std::string DefaultForField(FieldDescriptor* field);
 std::string IntToString(int32 value);
 std::string FilenameToClassname(const string& filename);
 std::string GeneratedMetadataFileName(const FileDescriptor* file,
                                       bool is_descriptor);
-std::string LabelForField(FieldDescriptor* field);
-std::string TypeName(FieldDescriptor* field);
 std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter);
 std::string BinaryToHex(const string& binary);
 void Indent(io::Printer* printer);
@@ -178,18 +177,6 @@ std::string GeneratedClassNameImpl(const ServiceDescriptor* desc) {
   return ClassNamePrefix(classname, desc) + classname;
 }
 
-std::string GeneratedClassName(const Descriptor* desc) {
-  return GeneratedClassNameImpl(desc);
-}
-
-std::string GeneratedClassName(const EnumDescriptor* desc) {
-  return GeneratedClassNameImpl(desc);
-}
-
-std::string GeneratedClassName(const ServiceDescriptor* desc) {
-  return GeneratedClassNameImpl(desc);
-}
-
 template <typename DescriptorType>
 std::string LegacyGeneratedClassName(const DescriptorType* desc) {
   std::string classname = desc->name();
@@ -435,30 +422,6 @@ std::string LabelForField(const FieldDescriptor* field) {
   }
 }
 
-std::string TypeName(const FieldDescriptor* field) {
-  switch (field->type()) {
-    case FieldDescriptor::TYPE_INT32: return "int32";
-    case FieldDescriptor::TYPE_INT64: return "int64";
-    case FieldDescriptor::TYPE_UINT32: return "uint32";
-    case FieldDescriptor::TYPE_UINT64: return "uint64";
-    case FieldDescriptor::TYPE_SINT32: return "sint32";
-    case FieldDescriptor::TYPE_SINT64: return "sint64";
-    case FieldDescriptor::TYPE_FIXED32: return "fixed32";
-    case FieldDescriptor::TYPE_FIXED64: return "fixed64";
-    case FieldDescriptor::TYPE_SFIXED32: return "sfixed32";
-    case FieldDescriptor::TYPE_SFIXED64: return "sfixed64";
-    case FieldDescriptor::TYPE_DOUBLE: return "double";
-    case FieldDescriptor::TYPE_FLOAT: return "float";
-    case FieldDescriptor::TYPE_BOOL: return "bool";
-    case FieldDescriptor::TYPE_ENUM: return "enum";
-    case FieldDescriptor::TYPE_STRING: return "string";
-    case FieldDescriptor::TYPE_BYTES: return "bytes";
-    case FieldDescriptor::TYPE_MESSAGE: return "message";
-    case FieldDescriptor::TYPE_GROUP: return "group";
-    default: assert(false); return "";
-  }
-}
-
 std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) {
   if (field->is_map()) {
     return "array|\\Google\\Protobuf\\Internal\\MapField";
@@ -1816,6 +1779,8 @@ void GenerateServiceMethodDocComment(io::Printer* printer,
     "return_type", EscapePhpdoc(FullClassName(method->output_type(), false)));
 }
 
+}  // namespace
+
 bool Generator::Generate(const FileDescriptor* file, const string& parameter,
                          GeneratorContext* generator_context,
                          string* error) const {