| Index: third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| index 82bb342747c888cdaa4a602d74fa9d267c75ea9e..e82e6ae160bbeb0646457858291aa2e79abc04e8 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| @@ -40,6 +40,7 @@
|
| #endif
|
| #include <vector>
|
|
|
| +#include <google/protobuf/compiler/plugin.pb.h>
|
| #include <google/protobuf/stubs/logging.h>
|
| #include <google/protobuf/stubs/common.h>
|
| #include <google/protobuf/testing/file.h>
|
| @@ -59,9 +60,9 @@ namespace compiler {
|
|
|
| // Returns the list of the names of files in all_files in the form of a
|
| // comma-separated string.
|
| -string CommaSeparatedList(const vector<const FileDescriptor*> all_files) {
|
| - vector<string> names;
|
| - for (int i = 0; i < all_files.size(); i++) {
|
| +string CommaSeparatedList(const std::vector<const FileDescriptor*> all_files) {
|
| + std::vector<string> names;
|
| + for (size_t i = 0; i < all_files.size(); i++) {
|
| names.push_back(all_files[i]->name());
|
| }
|
| return Join(names, ",");
|
| @@ -92,16 +93,17 @@ void MockCodeGenerator::ExpectGenerated(
|
| File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
|
| &content, true));
|
|
|
| - vector<string> lines = Split(content, "\n", true);
|
| + std::vector<string> lines =
|
| + Split(content, "\n", true);
|
|
|
| while (!lines.empty() && lines.back().empty()) {
|
| lines.pop_back();
|
| }
|
| - for (int i = 0; i < lines.size(); i++) {
|
| + for (size_t i = 0; i < lines.size(); i++) {
|
| lines[i] += "\n";
|
| }
|
|
|
| - vector<string> insertion_list;
|
| + std::vector<string> insertion_list;
|
| if (!insertions.empty()) {
|
| SplitStringUsing(insertions, ",", &insertion_list);
|
| }
|
| @@ -114,7 +116,7 @@ void MockCodeGenerator::ExpectGenerated(
|
| EXPECT_EQ(kFirstInsertionPoint, lines[1 + insertion_list.size()]);
|
| EXPECT_EQ(kSecondInsertionPoint, lines[2 + insertion_list.size() * 2]);
|
|
|
| - for (int i = 0; i < insertion_list.size(); i++) {
|
| + for (size_t i = 0; i < insertion_list.size(); i++) {
|
| EXPECT_EQ(GetOutputFileContent(insertion_list[i], "first_insert",
|
| file, file, first_message_name),
|
| lines[1 + i]);
|
| @@ -159,6 +161,15 @@ bool MockCodeGenerator::Generate(
|
| std::cerr << "Saw json_name: "
|
| << field_descriptor_proto.has_json_name() << std::endl;
|
| abort();
|
| + } else if (command == "ShowVersionNumber") {
|
| + Version compiler_version;
|
| + context->GetCompilerVersion(&compiler_version);
|
| + std::cerr << "Saw compiler_version: "
|
| + << compiler_version.major() * 1000000 +
|
| + compiler_version.minor() * 1000 +
|
| + compiler_version.patch()
|
| + << " " << compiler_version.suffix() << std::endl;
|
| + abort();
|
| } else {
|
| GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command;
|
| }
|
| @@ -166,11 +177,11 @@ bool MockCodeGenerator::Generate(
|
| }
|
|
|
| if (HasPrefixString(parameter, "insert=")) {
|
| - vector<string> insert_into;
|
| + std::vector<string> insert_into;
|
| SplitStringUsing(StripPrefixString(parameter, "insert="),
|
| ",", &insert_into);
|
|
|
| - for (int i = 0; i < insert_into.size(); i++) {
|
| + for (size_t i = 0; i < insert_into.size(); i++) {
|
| {
|
| google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->OpenForInsert(
|
| GetOutputFileName(insert_into[i], file), kFirstInsertionPointName));
|
| @@ -230,7 +241,7 @@ string MockCodeGenerator::GetOutputFileContent(
|
| const string& parameter,
|
| const FileDescriptor* file,
|
| GeneratorContext *context) {
|
| - vector<const FileDescriptor*> all_files;
|
| + std::vector<const FileDescriptor*> all_files;
|
| context->ListParsedFiles(&all_files);
|
| return GetOutputFileContent(
|
| generator_name, parameter, file->name(),
|
|
|