| Index: third_party/protobuf/src/google/protobuf/compiler/plugin.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/plugin.cc b/third_party/protobuf/src/google/protobuf/compiler/plugin.cc
|
| index a4aedafbfe63a9918f4b4c1f108a96c60aa00a0d..727f942166331523737bbcd3a4d9dc93be4d8a55 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/plugin.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/plugin.cc
|
| @@ -59,13 +59,15 @@ namespace google {
|
| namespace protobuf {
|
| namespace compiler {
|
|
|
| -class GeneratorResponseOutputDirectory : public OutputDirectory {
|
| +class GeneratorResponseContext : public GeneratorContext {
|
| public:
|
| - GeneratorResponseOutputDirectory(CodeGeneratorResponse* response)
|
| - : response_(response) {}
|
| - virtual ~GeneratorResponseOutputDirectory() {}
|
| + GeneratorResponseContext(CodeGeneratorResponse* response,
|
| + const vector<const FileDescriptor*>& parsed_files)
|
| + : response_(response),
|
| + parsed_files_(parsed_files) {}
|
| + virtual ~GeneratorResponseContext() {}
|
|
|
| - // implements OutputDirectory --------------------------------------
|
| + // implements GeneratorContext --------------------------------------
|
|
|
| virtual io::ZeroCopyOutputStream* Open(const string& filename) {
|
| CodeGeneratorResponse::File* file = response_->add_file();
|
| @@ -81,8 +83,13 @@ class GeneratorResponseOutputDirectory : public OutputDirectory {
|
| return new io::StringOutputStream(file->mutable_content());
|
| }
|
|
|
| + void ListParsedFiles(vector<const FileDescriptor*>* output) {
|
| + *output = parsed_files_;
|
| + }
|
| +
|
| private:
|
| CodeGeneratorResponse* response_;
|
| + const vector<const FileDescriptor*>& parsed_files_;
|
| };
|
|
|
| int PluginMain(int argc, char* argv[], const CodeGenerator* generator) {
|
| @@ -112,22 +119,26 @@ int PluginMain(int argc, char* argv[], const CodeGenerator* generator) {
|
| }
|
| }
|
|
|
| - CodeGeneratorResponse response;
|
| - GeneratorResponseOutputDirectory output_directory(&response);
|
| -
|
| + vector<const FileDescriptor*> parsed_files;
|
| for (int i = 0; i < request.file_to_generate_size(); i++) {
|
| - const FileDescriptor* file =
|
| - pool.FindFileByName(request.file_to_generate(i));
|
| - if (file == NULL) {
|
| + parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));
|
| + if (parsed_files.back() == NULL) {
|
| cerr << argv[0] << ": protoc asked plugin to generate a file but "
|
| "did not provide a descriptor for the file: "
|
| << request.file_to_generate(i) << endl;
|
| return 1;
|
| }
|
| + }
|
| +
|
| + CodeGeneratorResponse response;
|
| + GeneratorResponseContext context(&response, parsed_files);
|
| +
|
| + for (int i = 0; i < parsed_files.size(); i++) {
|
| + const FileDescriptor* file = parsed_files[i];
|
|
|
| string error;
|
| bool succeeded = generator->Generate(
|
| - file, request.parameter(), &output_directory, &error);
|
| + file, request.parameter(), &context, &error);
|
|
|
| if (!succeeded && error.empty()) {
|
| error = "Code generator returned false but provided no error "
|
|
|