aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-07 02:08:03 +0000
committerkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-07 02:08:03 +0000
commit535301894efb5ae340d835a4b1de465f3beeb487 (patch)
treec816894658e7260d2f2433e96ed116d5460e7af2
parent2429e3a0deb0b26b8723c717555c09d14842373f (diff)
downloadprotobuf-535301894efb5ae340d835a4b1de465f3beeb487.tar.gz
protobuf-535301894efb5ae340d835a4b1de465f3beeb487.tar.bz2
protobuf-535301894efb5ae340d835a4b1de465f3beeb487.zip
Address comments from various code reviews.
-rw-r--r--java/src/main/java/com/google/protobuf/TextFormat.java8
-rwxr-xr-xpython/google/protobuf/text_format.py12
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc11
3 files changed, 26 insertions, 5 deletions
diff --git a/java/src/main/java/com/google/protobuf/TextFormat.java b/java/src/main/java/com/google/protobuf/TextFormat.java
index ed26722d..cb23f0c3 100644
--- a/java/src/main/java/com/google/protobuf/TextFormat.java
+++ b/java/src/main/java/com/google/protobuf/TextFormat.java
@@ -704,7 +704,13 @@ public final class TextFormat {
return ByteString.copyFrom(list);
}
- public void consumeByteString(List<ByteString> list) throws ParseException {
+ /**
+ * Like {@link #consumeByteString()} but adds each token of the string to
+ * the given list. String literals (whether bytes or text) may come in
+ * multiple adjacent tokens which are automatically concatenated, like in
+ * C or Python.
+ */
+ private void consumeByteString(List<ByteString> list) throws ParseException {
final char quote = currentToken.length() > 0 ? currentToken.charAt(0)
: '\0';
if (quote != '\"' && quote != '\'') {
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py
index 428e8c55..cc6ac902 100755
--- a/python/google/protobuf/text_format.py
+++ b/python/google/protobuf/text_format.py
@@ -536,12 +536,18 @@ class _Tokenizer(object):
Raises:
ParseError: If a byte array value couldn't be consumed.
"""
- list = [self.ConsumeSingleByteString()]
+ list = [self._ConsumeSingleByteString()]
while len(self.token) > 0 and self.token[0] in ('\'', '"'):
- list.append(self.ConsumeSingleByteString())
+ list.append(self._ConsumeSingleByteString())
return "".join(list)
- def ConsumeSingleByteString(self):
+ def _ConsumeSingleByteString(self):
+ """Consume one token of a string literal.
+
+ String literals (whether bytes or text) can come in multiple adjacent
+ tokens which are automatically concatenated, like in C or Python. This
+ method only consumes one token.
+ """
text = self.token
if len(text) < 1 or text[0] not in ('\'', '"'):
raise self._ParseError('Exptected string.')
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 1bc4ce89..525dfc03 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -219,14 +219,23 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
// -------------------------------------------------------------------
-// An OutputDirectory implementation that writes to disk.
+// An OutputDirectory implementation that buffers files in memory, then dumps
+// them all to disk on demand.
class CommandLineInterface::MemoryOutputDirectory : public OutputDirectory {
public:
MemoryOutputDirectory();
~MemoryOutputDirectory();
+ // Write all files in the directory to disk at the given output location,
+ // which must end in a '/'.
bool WriteAllToDisk(const string& prefix);
+
+ // Write the contents of this directory to a ZIP-format archive with the
+ // given name.
bool WriteAllToZip(const string& filename);
+
+ // Add a boilerplate META-INF/MANIFEST.MF file as required by the Java JAR
+ // format, unless one has already been written.
void AddJarManifest();
// implements OutputDirectory --------------------------------------