diff options
author | Stanley Cheung <stanleycheung@google.com> | 2017-01-30 20:39:17 -0800 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2017-01-30 20:39:22 -0800 |
commit | 1a3f4a55c26c36f3ccc0bc8001cf2138af8a065e (patch) | |
tree | c534ccd69019bd406ca3ecb8e4f6955310b3e19c /src/compiler/php_plugin.cc | |
parent | c88834ba996084db5f530706a09892bdd900e7dc (diff) |
PHP: make tests runnable on both protobuf 3.1 and 3.2
Diffstat (limited to 'src/compiler/php_plugin.cc')
-rw-r--r-- | src/compiler/php_plugin.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/php_plugin.cc b/src/compiler/php_plugin.cc index 88acad6524..00d4cd5a85 100644 --- a/src/compiler/php_plugin.cc +++ b/src/compiler/php_plugin.cc @@ -51,18 +51,22 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { const grpc::string ¶meter, grpc::protobuf::compiler::GeneratorContext *context, grpc::string *error) const { - grpc::string code = GenerateFile(file); - if (code.size() == 0) { + if (file->service_count() == 0) { return true; } - // Get output file name - grpc::string file_name = GetPHPServiceFilename(file->name()); + for (int i = 0; i < file->service_count(); i++) { + grpc::string code = GenerateFile(file, file->service(i)); + + // Get output file name + grpc::string file_name = GetPHPServiceFilename(file, file->service(i)); + + std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( + context->Open(file_name)); + grpc::protobuf::io::CodedOutputStream coded_out(output.get()); + coded_out.WriteRaw(code.data(), code.size()); + } - std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( - context->Open(file_name)); - grpc::protobuf::io::CodedOutputStream coded_out(output.get()); - coded_out.WriteRaw(code.data(), code.size()); return true; } }; |