| Index: third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc
|
| similarity index 56%
|
| copy from third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| copy to third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc
|
| index 455c239a936bd9cec724ab65e85092b743fa1070..566819898b1e31dc032804a4dc2b8c0eee86680c 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,53 +28,54 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Author: kenton@google.com (Kenton Varda)
|
| -// Based on original Protocol Buffers design by
|
| -// Sanjay Ghemawat, Jeff Dean, and others.
|
| +#include <sstream>
|
|
|
| #include <google/protobuf/compiler/code_generator.h>
|
| -
|
| -#include <google/protobuf/stubs/common.h>
|
| +#include <google/protobuf/compiler/plugin.h>
|
| +#include <google/protobuf/descriptor.h>
|
| +#include <google/protobuf/descriptor.pb.h>
|
| +#include <google/protobuf/io/printer.h>
|
| +#include <google/protobuf/io/zero_copy_stream.h>
|
| #include <google/protobuf/stubs/strutil.h>
|
|
|
| +#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
|
| +#include <google/protobuf/compiler/csharp/csharp_enum.h>
|
| +#include <google/protobuf/compiler/csharp/csharp_helpers.h>
|
| +
|
| +using google::protobuf::internal::scoped_ptr;
|
| +
|
| namespace google {
|
| namespace protobuf {
|
| namespace compiler {
|
| +namespace csharp {
|
|
|
| -CodeGenerator::~CodeGenerator() {}
|
| -GeneratorContext::~GeneratorContext() {}
|
| -
|
| -io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
|
| - const string& filename, const string& insertion_point) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
|
| - return NULL; // make compiler happy
|
| +EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor) :
|
| + SourceGeneratorBase(descriptor->file()),
|
| + descriptor_(descriptor) {
|
| }
|
|
|
| -void GeneratorContext::ListParsedFiles(
|
| - vector<const FileDescriptor*>* output) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
|
| +EnumGenerator::~EnumGenerator() {
|
| }
|
|
|
| -// Parses a set of comma-delimited name/value pairs.
|
| -void ParseGeneratorParameter(const string& text,
|
| - vector<pair<string, string> >* output) {
|
| - vector<string> parts;
|
| - SplitStringUsing(text, ",", &parts);
|
| -
|
| - for (int i = 0; i < parts.size(); i++) {
|
| - string::size_type equals_pos = parts[i].find_first_of('=');
|
| - pair<string, string> value;
|
| - if (equals_pos == string::npos) {
|
| - value.first = parts[i];
|
| - value.second = "";
|
| - } else {
|
| - value.first = parts[i].substr(0, equals_pos);
|
| - value.second = parts[i].substr(equals_pos + 1);
|
| - }
|
| - output->push_back(value);
|
| +void EnumGenerator::Generate(io::Printer* printer) {
|
| + WriteEnumDocComment(printer, descriptor_);
|
| + WriteGeneratedCodeAttributes(printer);
|
| + printer->Print("$access_level$ enum $name$ {\n",
|
| + "access_level", class_access_level(),
|
| + "name", descriptor_->name());
|
| + printer->Indent();
|
| + for (int i = 0; i < descriptor_->value_count(); i++) {
|
| + WriteEnumValueDocComment(printer, descriptor_->value(i));
|
| + printer->Print("$name$ = $number$,\n",
|
| + "name", descriptor_->value(i)->name(),
|
| + "number", SimpleItoa(descriptor_->value(i)->number()));
|
| }
|
| + printer->Outdent();
|
| + printer->Print("}\n");
|
| + printer->Print("\n");
|
| }
|
|
|
| +} // namespace csharp
|
| } // namespace compiler
|
| } // namespace protobuf
|
| } // namespace google
|
|
|