aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/mock_code_generator.cc
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-23 07:03:06 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-23 07:03:06 +0000
commit5f12164f54a12500d2d8276937b7ed4fec408b99 (patch)
tree5cce5fcecb4a3104ca33fd67e1d37f788b719576 /src/google/protobuf/compiler/mock_code_generator.cc
parent46ed74e8d456d7d2a983c6c86e2c347d8a5b4843 (diff)
Refactor the way output is handled in CommandLineInterface -- now it will be stored in-memory until all code generators have completed, then dumped to disk all at once. While this means that protoc uses more memory, the code is much simpler, and handles insertions much faster. Also, this made it easier to implement a useful feature: insertions will be indented to match the insertion point line. Therefore, when inserting into Python code, you don't have to figure out how much to indent your inserted code. The refactoring should also make it easier to implement output-to-jar at some point.
Diffstat (limited to 'src/google/protobuf/compiler/mock_code_generator.cc')
-rw-r--r--src/google/protobuf/compiler/mock_code_generator.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc
index cd951ad5..83d5a4e4 100644
--- a/src/google/protobuf/compiler/mock_code_generator.cc
+++ b/src/google/protobuf/compiler/mock_code_generator.cc
@@ -50,7 +50,7 @@ static const char* kSecondInsertionPointName = "second_mock_insertion_point";
static const char* kFirstInsertionPoint =
"# @@protoc_insertion_point(first_mock_insertion_point) is here\n";
static const char* kSecondInsertionPoint =
- "# @@protoc_insertion_point(second_mock_insertion_point) is here\n";
+ " # @@protoc_insertion_point(second_mock_insertion_point) is here\n";
MockCodeGenerator::MockCodeGenerator(const string& name)
: name_(name) {}
@@ -94,8 +94,10 @@ void MockCodeGenerator::ExpectGenerated(
EXPECT_EQ(GetOutputFileContent(insertion_list[i], "first_insert",
file, first_message_name),
lines[1 + i]);
- EXPECT_EQ(GetOutputFileContent(insertion_list[i], "second_insert",
- file, first_message_name),
+ // Second insertion point is indented, so the inserted text should
+ // automatically be indented too.
+ EXPECT_EQ(" " + GetOutputFileContent(insertion_list[i], "second_insert",
+ file, first_message_name),
lines[2 + insertion_list.size() + i]);
}
}