diff options
author | Stanley Cheung <stanleycheung@google.com> | 2017-07-20 00:59:03 -0700 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2017-08-10 11:01:35 -0700 |
commit | 5fd85b58e6412a28e640d63d362c4b626a9d3e41 (patch) | |
tree | 6cef0a3c64fa4e8b66d391ee29a362e4dc9bf19e /src/compiler/php_plugin.cc | |
parent | faef8bcc6533ac5fbc6a8efa4ff964fe897f2b5c (diff) |
PHP: update codegen plugin to support php_namespace option
Diffstat (limited to 'src/compiler/php_plugin.cc')
-rw-r--r-- | src/compiler/php_plugin.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/php_plugin.cc b/src/compiler/php_plugin.cc index bbe91656d5..7b0da87eb2 100644 --- a/src/compiler/php_plugin.cc +++ b/src/compiler/php_plugin.cc @@ -26,6 +26,7 @@ using grpc_php_generator::GenerateFile; using grpc_php_generator::GetPHPServiceFilename; +using google::protobuf::compiler::ParseGeneratorParameter; class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { public: @@ -40,12 +41,25 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } + std::vector<std::pair<grpc::string, grpc::string> > options; + ParseGeneratorParameter(parameter, &options); + + grpc::string class_suffix; + for (size_t i = 0; i < options.size(); ++i) { + if (options[i].first == "class_suffix") { + class_suffix = options[i].second; + } else { + *error = "unsupported options: " + options[i].first; + return false; + } + } + for (int i = 0; i < file->service_count(); i++) { - grpc::string code = GenerateFile(file, file->service(i), parameter); + grpc::string code = GenerateFile(file, file->service(i), class_suffix); // Get output file name grpc::string file_name = - GetPHPServiceFilename(file, file->service(i), parameter); + GetPHPServiceFilename(file, file->service(i), class_suffix); std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( context->Open(file_name)); |