diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2018-05-29 21:51:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 21:51:54 -0700 |
commit | 6b5fb0727a6a775be6ec306e2c69e9e4dc10bd68 (patch) | |
tree | 35667146811d23e838bbc6d1ba98d512d5b733fb /src | |
parent | 7d1a8fff1b424e63f6bbdd1f9f828f6f9f40e84f (diff) |
Move methods out of class (#4697)
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/php/php_generator.cc | 20 | ||||
-rw-r--r-- | src/google/protobuf/compiler/php/php_generator.h | 21 |
2 files changed, 26 insertions, 15 deletions
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index cdb2f509..a58e1754 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -157,7 +157,7 @@ std::string ClassNamePrefix(const string& classname, } template <typename DescriptorType> -std::string GeneratedClassName(const DescriptorType* desc) { +std::string GeneratedClassNameImpl(const DescriptorType* desc) { std::string classname = ClassNamePrefix(desc->name(), desc) + desc->name(); const Descriptor* containing = desc->containing_type(); while (containing != NULL) { @@ -168,11 +168,23 @@ std::string GeneratedClassName(const DescriptorType* desc) { return classname; } -std::string GeneratedClassName(const ServiceDescriptor* desc) { +std::string GeneratedClassNameImpl(const ServiceDescriptor* desc) { std::string classname = desc->name(); 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(); @@ -242,7 +254,7 @@ std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) { template <typename DescriptorType> std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { - string classname = GeneratedClassName(desc); + string classname = GeneratedClassNameImpl(desc); string php_namespace = RootPhpNamespace(desc, is_descriptor); if (php_namespace != "") { return php_namespace + "\\" + classname; @@ -1074,7 +1086,7 @@ void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* d Outdent(&printer); printer.Print("}\n"); printer.Print("class_exists(^new^::class);\n", - "new", GeneratedClassName(desc)); + "new", GeneratedClassNameImpl(desc)); printer.Print("@trigger_error('^old^ is deprecated and will be removed in " "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", "old", LegacyFullClassName(desc, is_descriptor), diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h index 82109ec4..b851d9b4 100644 --- a/src/google/protobuf/compiler/php/php_generator.h +++ b/src/google/protobuf/compiler/php/php_generator.h @@ -48,19 +48,18 @@ class LIBPROTOC_EXPORT Generator const string& parameter, GeneratorContext* generator_context, string* error) const; - - // To skip reserved keywords in php, some generated classname are prefixed. - // Other code generators may need following API to figure out the actual - // classname. - LIBPROTOC_EXPORT std::string GeneratedClassName( - const google::protobuf::Descriptor* desc); - LIBPROTOC_EXPORT std::string GeneratedClassName( - const google::protobuf::EnumDescriptor* desc); - LIBPROTOC_EXPORT std::string GeneratedClassName( - const google::protobuf::ServiceDescriptor* desc); - }; +// To skip reserved keywords in php, some generated classname are prefixed. +// Other code generators may need following API to figure out the actual +// classname. +LIBPROTOC_EXPORT std::string GeneratedClassName( + const google::protobuf::Descriptor* desc); +LIBPROTOC_EXPORT std::string GeneratedClassName( + const google::protobuf::EnumDescriptor* desc); +LIBPROTOC_EXPORT std::string GeneratedClassName( + const google::protobuf::ServiceDescriptor* desc); + } // namespace php } // namespace compiler } // namespace protobuf |