diff options
Diffstat (limited to 'src/google/protobuf/compiler/php/php_generator.cc')
-rw-r--r-- | src/google/protobuf/compiler/php/php_generator.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index cbddee9e..78252817 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -145,6 +145,15 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { } classname = ClassNamePrefix(classname, desc) + classname; + if (desc->file()->options().has_php_namespace()) { + const string& php_namespace = desc->file()->options().php_namespace(); + if (php_namespace != "") { + return php_namespace + '\\' + classname; + } else { + return classname; + } + } + if (desc->file()->package() == "") { return classname; } else { @@ -822,7 +831,14 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, std::string fullname = FilenameToClassname(filename); int lastindex = fullname.find_last_of("\\"); - if (!file->package().empty()) { + if (file->options().has_php_namespace()) { + const string& php_namespace = file->options().php_namespace(); + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + } else if (!file->package().empty()) { printer.Print( "namespace ^name^;\n\n", "name", fullname.substr(0, lastindex)); @@ -874,7 +890,14 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, std::string fullname = FilenameToClassname(filename); int lastindex = fullname.find_last_of("\\"); - if (!file->package().empty()) { + if (file->options().has_php_namespace()) { + const string& php_namespace = file->options().php_namespace(); + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + } else if (!file->package().empty()) { printer.Print( "namespace ^name^;\n\n", "name", fullname.substr(0, lastindex)); |