Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/code_generator.h

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/compiler/code_generator.h
diff --git a/third_party/protobuf/src/google/protobuf/compiler/code_generator.h b/third_party/protobuf/src/google/protobuf/compiler/code_generator.h
index b917d3733436f60ce3e92ba48f2c31fe190f70c5..b989f151328fc7c8e08c5c3fbe2225fd11fb3f7d 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/code_generator.h
+++ b/third_party/protobuf/src/google/protobuf/compiler/code_generator.h
@@ -50,7 +50,6 @@ namespace io { class ZeroCopyOutputStream; }
class FileDescriptor;
namespace compiler {
-class Version;
// Defined in this file.
class CodeGenerator;
@@ -67,11 +66,11 @@ class LIBPROTOC_EXPORT CodeGenerator {
// Generates code for the given proto file, generating one or more files in
// the given output directory.
//
- // A parameter to be passed to the generator can be specified on the command
- // line. This is intended to be used to pass generator specific parameters.
- // It is empty if no parameter was given. ParseGeneratorParameter (below),
- // can be used to accept multiple parameters within the single parameter
- // command line flag.
+ // A parameter to be passed to the generator can be specified on the
+ // command line. This is intended to be used by Java and similar languages
+ // to specify which specific class from the proto file is to be generated,
+ // though it could have other uses as well. It is empty if no parameter was
+ // given.
//
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
@@ -80,27 +79,36 @@ class LIBPROTOC_EXPORT CodeGenerator {
GeneratorContext* generator_context,
string* error) const = 0;
- // Generates code for all given proto files.
+ // Generates code for all given proto files, generating one or more files in
+ // the given output directory.
+ //
+ // This method should be called instead of |Generate()| when
+ // |HasGenerateAll()| returns |true|. It is used to emulate legacy semantics
+ // when more than one `.proto` file is specified on one compiler invocation.
//
- // WARNING: The canonical code generator design produces one or two output
- // files per input .proto file, and we do not wish to encourage alternate
- // designs.
+ // WARNING: Please do not use unless legacy semantics force the code generator
+ // to produce a single output file for all input files, or otherwise require
+ // an examination of all input files first. The canonical code generator
+ // design produces one output file per input .proto file, and we do not wish
+ // to encourage alternate designs.
//
// A parameter is given as passed on the command line, as in |Generate()|
// above.
//
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
- virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
+ virtual bool GenerateAll(const vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* generator_context,
- string* error) const;
+ string* error) const {
+ *error = "Unimplemented GenerateAll() method.";
+ return false;
+ }
- // This is no longer used, but this class is part of the opensource protobuf
- // library, so it has to remain to keep vtables the same for the current
- // version of the library. When protobufs does a api breaking change, the
- // method can be removed.
- virtual bool HasGenerateAll() const { return true; }
+ // Returns true if the code generator expects to receive all FileDescriptors
+ // at once (via |GenerateAll()|), rather than one at a time (via
+ // |Generate()|). This is required to implement legacy semantics.
+ virtual bool HasGenerateAll() const { return false; }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);
@@ -142,11 +150,7 @@ class LIBPROTOC_EXPORT GeneratorContext {
// Returns a vector of FileDescriptors for all the files being compiled
// in this run. Useful for languages, such as Go, that treat files
// differently when compiled as a set rather than individually.
- virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output);
-
- // Retrieves the version number of the protocol compiler associated with
- // this GeneratorContext.
- virtual void GetCompilerVersion(Version* version) const;
+ virtual void ListParsedFiles(vector<const FileDescriptor*>* output);
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
@@ -163,7 +167,7 @@ typedef GeneratorContext OutputDirectory;
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
extern void ParseGeneratorParameter(const string&,
- std::vector<std::pair<string, string> >*);
+ vector<pair<string, string> >*);
} // namespace compiler
} // namespace protobuf

Powered by Google App Engine
This is Rietveld 408576698