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

Side by Side Diff: third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 3 years, 12 months 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 unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, const Options* op tions) : 53 EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, const Options* op tions) :
54 SourceGeneratorBase(descriptor->file(), options), 54 SourceGeneratorBase(descriptor->file(), options),
55 descriptor_(descriptor) { 55 descriptor_(descriptor) {
56 } 56 }
57 57
58 EnumGenerator::~EnumGenerator() { 58 EnumGenerator::~EnumGenerator() {
59 } 59 }
60 60
61 void EnumGenerator::Generate(io::Printer* printer) { 61 void EnumGenerator::Generate(io::Printer* printer) {
62 WriteEnumDocComment(printer, descriptor_); 62 WriteEnumDocComment(printer, descriptor_);
63 WriteGeneratedCodeAttributes(printer);
63 printer->Print("$access_level$ enum $name$ {\n", 64 printer->Print("$access_level$ enum $name$ {\n",
64 "access_level", class_access_level(), 65 "access_level", class_access_level(),
65 "name", descriptor_->name()); 66 "name", descriptor_->name());
66 printer->Indent(); 67 printer->Indent();
67 std::set<string> used_names; 68 std::set<string> used_names;
68 for (int i = 0; i < descriptor_->value_count(); i++) { 69 for (int i = 0; i < descriptor_->value_count(); i++) {
69 WriteEnumValueDocComment(printer, descriptor_->value(i)); 70 WriteEnumValueDocComment(printer, descriptor_->value(i));
70 string original_name = descriptor_->value(i)->name(); 71 string original_name = descriptor_->value(i)->name();
71 string name = GetEnumValueName(descriptor_->name(), descriptor_->value(i)- >name()); 72 string name = options()->legacy_enum_values
73 ? descriptor_->value(i)->name()
74 : GetEnumValueName(descriptor_->name(), descriptor_->value(i)->name()) ;
72 // Make sure we don't get any duplicate names due to prefix removal. 75 // Make sure we don't get any duplicate names due to prefix removal.
73 while (!used_names.insert(name).second) { 76 while (!used_names.insert(name).second) {
74 // It's possible we'll end up giving this warning multiple times, but th at's better than not at all. 77 // It's possible we'll end up giving this warning multiple times, but th at's better than not at all.
75 GOOGLE_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name 78 GOOGLE_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name
76 << ") in " << descriptor_->name() << "; adding underscore to distingui sh"; 79 << ") in " << descriptor_->name() << "; adding underscore to distingui sh";
77 name += "_"; 80 name += "_";
78 } 81 }
79 printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$ ,\n", 82 printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$ ,\n",
80 "original_name", original_name, 83 "original_name", original_name,
81 "name", name, 84 "name", name,
82 "number", SimpleItoa(descriptor_->value(i)->number())); 85 "number", SimpleItoa(descriptor_->value(i)->number()));
83 } 86 }
84 printer->Outdent(); 87 printer->Outdent();
85 printer->Print("}\n"); 88 printer->Print("}\n");
86 printer->Print("\n"); 89 printer->Print("\n");
87 } 90 }
88 91
89 } // namespace csharp 92 } // namespace csharp
90 } // namespace compiler 93 } // namespace compiler
91 } // namespace protobuf 94 } // namespace protobuf
92 } // namespace google 95 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698