| Index: third_party/protobuf/src/google/protobuf/descriptor.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/descriptor.cc b/third_party/protobuf/src/google/protobuf/descriptor.cc
|
| index 7dfdb3773a5de5aac97db57735b291ec54b6a10d..56e11fa967ad04018a48cddf28c4ccede664fea0 100644
|
| --- a/third_party/protobuf/src/google/protobuf/descriptor.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/descriptor.cc
|
| @@ -69,7 +69,6 @@
|
| #undef PACKAGE // autoheader #defines this. :(
|
|
|
| namespace google {
|
| -
|
| namespace protobuf {
|
|
|
| const FieldDescriptor::CppType
|
| @@ -165,15 +164,6 @@ const int FieldDescriptor::kLastReservedNumber;
|
|
|
| namespace {
|
|
|
| -// Note: I distrust ctype.h due to locales.
|
| -char ToUpper(char ch) {
|
| - return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
|
| -}
|
| -
|
| -char ToLower(char ch) {
|
| - return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
|
| -}
|
| -
|
| string ToCamelCase(const string& input, bool lower_first) {
|
| bool capitalize_next = !lower_first;
|
| string result;
|
| @@ -183,7 +173,12 @@ string ToCamelCase(const string& input, bool lower_first) {
|
| if (input[i] == '_') {
|
| capitalize_next = true;
|
| } else if (capitalize_next) {
|
| - result.push_back(ToUpper(input[i]));
|
| + // Note: I distrust ctype.h due to locales.
|
| + if ('a' <= input[i] && input[i] <= 'z') {
|
| + result.push_back(input[i] - 'a' + 'A');
|
| + } else {
|
| + result.push_back(input[i]);
|
| + }
|
| capitalize_next = false;
|
| } else {
|
| result.push_back(input[i]);
|
| @@ -191,116 +186,13 @@ string ToCamelCase(const string& input, bool lower_first) {
|
| }
|
|
|
| // Lower-case the first letter.
|
| - if (lower_first && !result.empty()) {
|
| - result[0] = ToLower(result[0]);
|
| - }
|
| -
|
| - return result;
|
| -}
|
| -
|
| -string ToJsonName(const string& input) {
|
| - bool capitalize_next = false;
|
| - string result;
|
| - result.reserve(input.size());
|
| -
|
| - for (int i = 0; i < input.size(); i++) {
|
| - if (input[i] == '_') {
|
| - capitalize_next = true;
|
| - } else if (capitalize_next) {
|
| - result.push_back(ToUpper(input[i]));
|
| - capitalize_next = false;
|
| - } else {
|
| - result.push_back(input[i]);
|
| - }
|
| + if (lower_first && !result.empty() && 'A' <= result[0] && result[0] <= 'Z') {
|
| + result[0] = result[0] - 'A' + 'a';
|
| }
|
|
|
| return result;
|
| }
|
|
|
| -string EnumValueToPascalCase(const string& input) {
|
| - bool next_upper = true;
|
| - string result;
|
| - result.reserve(input.size());
|
| -
|
| - for (int i = 0; i < input.size(); i++) {
|
| - if (input[i] == '_') {
|
| - next_upper = true;
|
| - } else {
|
| - if (next_upper) {
|
| - result.push_back(ToUpper(input[i]));
|
| - } else {
|
| - result.push_back(ToLower(input[i]));
|
| - }
|
| - next_upper = false;
|
| - }
|
| - }
|
| -
|
| - return result;
|
| -}
|
| -
|
| -// Class to remove an enum prefix from enum values.
|
| -class PrefixRemover {
|
| - public:
|
| - PrefixRemover(StringPiece prefix) {
|
| - // Strip underscores and lower-case the prefix.
|
| - for (int i = 0; i < prefix.size(); i++) {
|
| - if (prefix[i] != '_') {
|
| - prefix_ += ascii_tolower(prefix[i]);
|
| - }
|
| - }
|
| - }
|
| -
|
| - // Tries to remove the enum prefix from this enum value.
|
| - // If this is not possible, returns the input verbatim.
|
| - string MaybeRemove(StringPiece str) {
|
| - // We can't just lowercase and strip str and look for a prefix.
|
| - // We need to properly recognize the difference between:
|
| - //
|
| - // enum Foo {
|
| - // FOO_BAR_BAZ = 0;
|
| - // FOO_BARBAZ = 1;
|
| - // }
|
| - //
|
| - // This is acceptable (though perhaps not advisable) because even when
|
| - // we PascalCase, these two will still be distinct (BarBaz vs. Barbaz).
|
| - size_t i, j;
|
| -
|
| - // Skip past prefix_ in str if we can.
|
| - for (i = 0, j = 0; i < str.size() && j < prefix_.size(); i++) {
|
| - if (str[i] == '_') {
|
| - continue;
|
| - }
|
| -
|
| - if (ascii_tolower(str[i]) != prefix_[j++]) {
|
| - return str.as_string();
|
| - }
|
| - }
|
| -
|
| - // If we didn't make it through the prefix, we've failed to strip the
|
| - // prefix.
|
| - if (j < prefix_.size()) {
|
| - return str.as_string();
|
| - }
|
| -
|
| - // Skip underscores between prefix and further characters.
|
| - while (i < str.size() && str[i] == '_') {
|
| - i++;
|
| - }
|
| -
|
| - // Enum label can't be the empty string.
|
| - if (i == str.size()) {
|
| - return str.as_string();
|
| - }
|
| -
|
| - // We successfully stripped the prefix.
|
| - str.remove_prefix(i);
|
| - return str.as_string();
|
| - }
|
| -
|
| - private:
|
| - string prefix_;
|
| -};
|
| -
|
| // A DescriptorPool contains a bunch of hash_maps to implement the
|
| // various Find*By*() methods. Since hashtable lookups are O(1), it's
|
| // most efficient to construct a fixed set of large hash_maps used by
|
| @@ -315,7 +207,7 @@ class PrefixRemover {
|
| // be a lot cleaner but we'd just have to convert it back to const char*
|
| // for the open source release.
|
|
|
| -typedef std::pair<const void*, const char*> PointerStringPair;
|
| +typedef pair<const void*, const char*> PointerStringPair;
|
|
|
| struct PointerStringPairEqual {
|
| inline bool operator()(const PointerStringPair& a,
|
| @@ -343,8 +235,8 @@ struct PointerIntegerPairHash {
|
| }
|
| };
|
|
|
| -typedef std::pair<const Descriptor*, int> DescriptorIntPair;
|
| -typedef std::pair<const EnumDescriptor*, int> EnumIntPair;
|
| +typedef pair<const Descriptor*, int> DescriptorIntPair;
|
| +typedef pair<const EnumDescriptor*, int> EnumIntPair;
|
|
|
| struct PointerStringPairHash {
|
| size_t operator()(const PointerStringPair& p) const {
|
| @@ -452,11 +344,11 @@ typedef hash_map<EnumIntPair, const EnumValueDescriptor*,
|
| // through all the extensions that extend a given Descriptor, and an
|
| // ordered data structure that implements lower_bound is convenient
|
| // for that.
|
| -typedef std::map<DescriptorIntPair, const FieldDescriptor*>
|
| +typedef map<DescriptorIntPair, const FieldDescriptor*>
|
| ExtensionsGroupedByDescriptorMap;
|
| typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap;
|
|
|
| -std::set<string>* allowed_proto3_extendees_ = NULL;
|
| +set<string>* allowed_proto3_extendees_ = NULL;
|
| GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_);
|
|
|
| void DeleteAllowedProto3Extendee() {
|
| @@ -464,7 +356,7 @@ void DeleteAllowedProto3Extendee() {
|
| }
|
|
|
| void InitAllowedProto3Extendee() {
|
| - allowed_proto3_extendees_ = new std::set<string>;
|
| + allowed_proto3_extendees_ = new set<string>;
|
| const char* kOptionNames[] = {
|
| "FileOptions", "MessageOptions", "FieldOptions", "EnumOptions",
|
| "EnumValueOptions", "ServiceOptions", "MethodOptions"};
|
| @@ -542,7 +434,7 @@ class DescriptorPool::Tables {
|
| // The stack of files which are currently being built. Used to detect
|
| // cyclic dependencies when loading files from a DescriptorDatabase. Not
|
| // used when fallback_database_ == NULL.
|
| - std::vector<string> pending_files_;
|
| + vector<string> pending_files_;
|
|
|
| // A set of files which we have tried to load from the fallback database
|
| // and encountered errors. We will not attempt to load them again during
|
| @@ -580,7 +472,7 @@ class DescriptorPool::Tables {
|
| inline const FieldDescriptor* FindExtension(const Descriptor* extendee,
|
| int number);
|
| inline void FindAllExtensions(const Descriptor* extendee,
|
| - std::vector<const FieldDescriptor*>* out) const;
|
| + vector<const FieldDescriptor*>* out) const;
|
|
|
| // -----------------------------------------------------------------
|
| // Adding items.
|
| @@ -620,11 +512,10 @@ class DescriptorPool::Tables {
|
| FileDescriptorTables* AllocateFileTables();
|
|
|
| private:
|
| - std::vector<string*> strings_; // All strings in the pool.
|
| - std::vector<Message*> messages_; // All messages in the pool.
|
| - std::vector<FileDescriptorTables*>
|
| - file_tables_; // All file tables in the pool.
|
| - std::vector<void*> allocations_; // All other memory allocated in the pool.
|
| + vector<string*> strings_; // All strings in the pool.
|
| + vector<Message*> messages_; // All messages in the pool.
|
| + vector<FileDescriptorTables*> file_tables_; // All file tables in the pool.
|
| + vector<void*> allocations_; // All other memory allocated in the pool.
|
|
|
| SymbolsByNameMap symbols_by_name_;
|
| FilesByNameMap files_by_name_;
|
| @@ -651,10 +542,10 @@ class DescriptorPool::Tables {
|
| int pending_files_before_checkpoint;
|
| int pending_extensions_before_checkpoint;
|
| };
|
| - std::vector<CheckPoint> checkpoints_;
|
| - std::vector<const char* > symbols_after_checkpoint_;
|
| - std::vector<const char* > files_after_checkpoint_;
|
| - std::vector<DescriptorIntPair> extensions_after_checkpoint_;
|
| + vector<CheckPoint> checkpoints_;
|
| + vector<const char* > symbols_after_checkpoint_;
|
| + vector<const char* > files_after_checkpoint_;
|
| + vector<DescriptorIntPair> extensions_after_checkpoint_;
|
|
|
| // Allocate some bytes which will be reclaimed when the pool is
|
| // destroyed.
|
| @@ -721,14 +612,14 @@ class FileDescriptorTables {
|
| // Populates p->first->locations_by_path_ from p->second.
|
| // Unusual signature dictated by GoogleOnceDynamic.
|
| static void BuildLocationsByPath(
|
| - std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
|
| + pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
|
|
|
| // Returns the location denoted by the specified path through info,
|
| // or NULL if not found.
|
| // The value of info must be that of the corresponding FileDescriptor.
|
| // (Conceptually a pure function, but stateful as an optimisation.)
|
| const SourceCodeInfo_Location* GetSourceLocation(
|
| - const std::vector<int>& path, const SourceCodeInfo* info) const;
|
| + const vector<int>& path, const SourceCodeInfo* info) const;
|
|
|
| private:
|
| SymbolsByParentMap symbols_by_parent_;
|
| @@ -1009,8 +900,7 @@ inline const FieldDescriptor* DescriptorPool::Tables::FindExtension(
|
| }
|
|
|
| inline void DescriptorPool::Tables::FindAllExtensions(
|
| - const Descriptor* extendee,
|
| - std::vector<const FieldDescriptor*>* out) const {
|
| + const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {
|
| ExtensionsGroupedByDescriptorMap::const_iterator it =
|
| extensions_.lower_bound(std::make_pair(extendee, 0));
|
| for (; it != extensions_.end() && it->first.first == extendee; ++it) {
|
| @@ -1130,7 +1020,7 @@ void* DescriptorPool::Tables::AllocateBytes(int size) {
|
| }
|
|
|
| void FileDescriptorTables::BuildLocationsByPath(
|
| - std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {
|
| + pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {
|
| for (int i = 0, len = p->second->location_size(); i < len; ++i) {
|
| const SourceCodeInfo_Location* loc = &p->second->location().Get(i);
|
| p->first->locations_by_path_[Join(loc->path(), ",")] = loc;
|
| @@ -1138,8 +1028,8 @@ void FileDescriptorTables::BuildLocationsByPath(
|
| }
|
|
|
| const SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation(
|
| - const std::vector<int>& path, const SourceCodeInfo* info) const {
|
| - std::pair<const FileDescriptorTables*, const SourceCodeInfo*> p(
|
| + const vector<int>& path, const SourceCodeInfo* info) const {
|
| + pair<const FileDescriptorTables*, const SourceCodeInfo*> p(
|
| std::make_pair(this, info));
|
| locations_by_path_once_.Init(&FileDescriptorTables::BuildLocationsByPath, &p);
|
| return FindPtrOrNull(locations_by_path_, Join(path, ","));
|
| @@ -1241,7 +1131,6 @@ const DescriptorPool* DescriptorPool::generated_pool() {
|
| }
|
|
|
|
|
| -
|
| DescriptorPool* DescriptorPool::internal_generated_pool() {
|
| InitGeneratedPoolOnce();
|
| return generated_pool_;
|
| @@ -1400,8 +1289,7 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber(
|
| }
|
|
|
| void DescriptorPool::FindAllExtensions(
|
| - const Descriptor* extendee,
|
| - std::vector<const FieldDescriptor*>* out) const {
|
| + const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {
|
| MutexLockMaybe lock(mutex_);
|
| tables_->known_bad_symbols_.clear();
|
| tables_->known_bad_files_.clear();
|
| @@ -1410,7 +1298,7 @@ void DescriptorPool::FindAllExtensions(
|
| // (but do this only once per descriptor).
|
| if (fallback_database_ != NULL &&
|
| tables_->extensions_loaded_from_db_.count(extendee) == 0) {
|
| - std::vector<int> numbers;
|
| + vector<int> numbers;
|
| if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(),
|
| &numbers)) {
|
| for (int i = 0; i < numbers.size(); ++i) {
|
| @@ -2008,9 +1896,6 @@ void FieldDescriptor::CopyJsonNameTo(FieldDescriptorProto* proto) const {
|
|
|
| void OneofDescriptor::CopyTo(OneofDescriptorProto* proto) const {
|
| proto->set_name(name());
|
| - if (&options() != &OneofOptions::default_instance()) {
|
| - proto->mutable_options()->CopyFrom(options());
|
| - }
|
| }
|
|
|
| void EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const {
|
| @@ -2075,11 +1960,13 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const {
|
|
|
| namespace {
|
|
|
| -bool RetrieveOptionsAssumingRightPool(int depth, const Message& options,
|
| - std::vector<string>* option_entries) {
|
| +// Used by each of the option formatters.
|
| +bool RetrieveOptions(int depth,
|
| + const Message &options,
|
| + vector<string> *option_entries) {
|
| option_entries->clear();
|
| const Reflection* reflection = options.GetReflection();
|
| - std::vector<const FieldDescriptor*> fields;
|
| + vector<const FieldDescriptor*> fields;
|
| reflection->ListFields(options, &fields);
|
| for (int i = 0; i < fields.size(); i++) {
|
| int count = 1;
|
| @@ -2116,56 +2003,21 @@ bool RetrieveOptionsAssumingRightPool(int depth, const Message& options,
|
| return !option_entries->empty();
|
| }
|
|
|
| -// Used by each of the option formatters.
|
| -bool RetrieveOptions(int depth, const Message& options,
|
| - const DescriptorPool* pool,
|
| - std::vector<string>* option_entries) {
|
| - // When printing custom options for a descriptor, we must use an options
|
| - // message built on top of the same DescriptorPool where the descriptor
|
| - // is coming from. This is to ensure we are interpreting custom options
|
| - // against the right pool.
|
| - if (options.GetDescriptor()->file()->pool() == pool) {
|
| - return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
|
| - } else {
|
| - const Descriptor* option_descriptor =
|
| - pool->FindMessageTypeByName(options.GetDescriptor()->full_name());
|
| - if (option_descriptor == NULL) {
|
| - // google/protobuf/descriptor.proto is not in the pool. This means no
|
| - // custom options are used so we are safe to proceed with the compiled
|
| - // options message type.
|
| - return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
|
| - }
|
| - DynamicMessageFactory factory;
|
| - google::protobuf::scoped_ptr<Message> dynamic_options(
|
| - factory.GetPrototype(option_descriptor)->New());
|
| - if (dynamic_options->ParseFromString(options.SerializeAsString())) {
|
| - return RetrieveOptionsAssumingRightPool(depth, *dynamic_options,
|
| - option_entries);
|
| - } else {
|
| - GOOGLE_LOG(ERROR) << "Found invalid proto option data for: "
|
| - << options.GetDescriptor()->full_name();
|
| - return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
|
| - }
|
| - }
|
| -}
|
| -
|
| // Formats options that all appear together in brackets. Does not include
|
| // brackets.
|
| -bool FormatBracketedOptions(int depth, const Message& options,
|
| - const DescriptorPool* pool, string* output) {
|
| - std::vector<string> all_options;
|
| - if (RetrieveOptions(depth, options, pool, &all_options)) {
|
| +bool FormatBracketedOptions(int depth, const Message &options, string *output) {
|
| + vector<string> all_options;
|
| + if (RetrieveOptions(depth, options, &all_options)) {
|
| output->append(Join(all_options, ", "));
|
| }
|
| return !all_options.empty();
|
| }
|
|
|
| // Formats options one per line
|
| -bool FormatLineOptions(int depth, const Message& options,
|
| - const DescriptorPool* pool, string* output) {
|
| +bool FormatLineOptions(int depth, const Message &options, string *output) {
|
| string prefix(depth * 2, ' ');
|
| - std::vector<string> all_options;
|
| - if (RetrieveOptions(depth, options, pool, &all_options)) {
|
| + vector<string> all_options;
|
| + if (RetrieveOptions(depth, options, &all_options)) {
|
| for (int i = 0; i < all_options.size(); i++) {
|
| strings::SubstituteAndAppend(output, "$0option $1;\n",
|
| prefix, all_options[i]);
|
| @@ -2187,7 +2039,7 @@ class SourceLocationCommentPrinter {
|
| desc->GetSourceLocation(&source_loc_);
|
| }
|
| SourceLocationCommentPrinter(const FileDescriptor* file,
|
| - const std::vector<int>& path,
|
| + const vector<int>& path,
|
| const string& prefix,
|
| const DebugStringOptions& options)
|
| : options_(options), prefix_(prefix) {
|
| @@ -2220,7 +2072,7 @@ class SourceLocationCommentPrinter {
|
| string FormatComment(const string& comment_text) {
|
| string stripped_comment = comment_text;
|
| StripWhitespace(&stripped_comment);
|
| - std::vector<string> lines = Split(stripped_comment, "\n");
|
| + vector<string> lines = Split(stripped_comment, "\n");
|
| string output;
|
| for (int i = 0; i < lines.size(); ++i) {
|
| const string& line = lines[i];
|
| @@ -2248,7 +2100,7 @@ string FileDescriptor::DebugStringWithOptions(
|
| const DebugStringOptions& debug_string_options) const {
|
| string contents;
|
| {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| path.push_back(FileDescriptorProto::kSyntaxFieldNumber);
|
| SourceLocationCommentPrinter syntax_comment(
|
| this, path, "", debug_string_options);
|
| @@ -2262,8 +2114,8 @@ string FileDescriptor::DebugStringWithOptions(
|
| comment_printer(this, "", debug_string_options);
|
| comment_printer.AddPreComment(&contents);
|
|
|
| - std::set<int> public_dependencies;
|
| - std::set<int> weak_dependencies;
|
| + set<int> public_dependencies;
|
| + set<int> weak_dependencies;
|
| public_dependencies.insert(public_dependencies_,
|
| public_dependencies_ + public_dependency_count_);
|
| weak_dependencies.insert(weak_dependencies_,
|
| @@ -2283,7 +2135,7 @@ string FileDescriptor::DebugStringWithOptions(
|
| }
|
|
|
| if (!package().empty()) {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| path.push_back(FileDescriptorProto::kPackageFieldNumber);
|
| SourceLocationCommentPrinter package_comment(
|
| this, path, "", debug_string_options);
|
| @@ -2292,7 +2144,7 @@ string FileDescriptor::DebugStringWithOptions(
|
| package_comment.AddPostComment(&contents);
|
| }
|
|
|
| - if (FormatLineOptions(0, options(), pool(), &contents)) {
|
| + if (FormatLineOptions(0, options(), &contents)) {
|
| contents.append("\n"); // add some space if we had options
|
| }
|
|
|
| @@ -2303,7 +2155,7 @@ string FileDescriptor::DebugStringWithOptions(
|
|
|
| // Find all the 'group' type extensions; we will not output their nested
|
| // definitions (those will be done with their group field descriptor).
|
| - std::set<const Descriptor*> groups;
|
| + set<const Descriptor*> groups;
|
| for (int i = 0; i < extension_count(); i++) {
|
| if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) {
|
| groups.insert(extension(i)->message_type());
|
| @@ -2373,12 +2225,12 @@ void Descriptor::DebugString(int depth, string *contents,
|
| }
|
| contents->append(" {\n");
|
|
|
| - FormatLineOptions(depth, options(), file()->pool(), contents);
|
| + FormatLineOptions(depth, options(), contents);
|
|
|
| // Find all the 'group' types for fields and extensions; we will not output
|
| // their nested definitions (those will be done with their group field
|
| // descriptor).
|
| - std::set<const Descriptor*> groups;
|
| + set<const Descriptor*> groups;
|
| for (int i = 0; i < field_count(); i++) {
|
| if (field(i)->type() == FieldDescriptor::TYPE_GROUP) {
|
| groups.insert(field(i)->message_type());
|
| @@ -2511,18 +2363,8 @@ void FieldDescriptor::DebugString(int depth,
|
| field_type = FieldTypeNameDebugString();
|
| }
|
|
|
| - bool print_label = true;
|
| - // Determine whether to omit label:
|
| - // 1. For an optional field, omit label if it's in oneof or in proto3.
|
| - // 2. For a repeated field, omit label if it's a map.
|
| - if (is_optional() && (print_label_flag == OMIT_LABEL ||
|
| - file()->syntax() == FileDescriptor::SYNTAX_PROTO3)) {
|
| - print_label = false;
|
| - } else if (is_map()) {
|
| - print_label = false;
|
| - }
|
| string label;
|
| - if (print_label) {
|
| + if (print_label_flag == PRINT_LABEL && !is_map()) {
|
| label = kLabelToName[this->label()];
|
| label.push_back(' ');
|
| }
|
| @@ -2545,21 +2387,9 @@ void FieldDescriptor::DebugString(int depth,
|
| strings::SubstituteAndAppend(contents, " [default = $0",
|
| DefaultValueAsString(true));
|
| }
|
| - if (has_json_name_) {
|
| - if (!bracketed) {
|
| - bracketed = true;
|
| - contents->append("[");
|
| - } else {
|
| - contents->append(", ");
|
| - }
|
| - contents->append("json_name = \"");
|
| - contents->append(CEscape(json_name()));
|
| - contents->append("\"");
|
| - }
|
|
|
| string formatted_options;
|
| - if (FormatBracketedOptions(depth, options(), file()->pool(),
|
| - &formatted_options)) {
|
| + if (FormatBracketedOptions(depth, options(), &formatted_options)) {
|
| contents->append(bracketed ? ", " : " [");
|
| bracketed = true;
|
| contents->append(formatted_options);
|
| @@ -2603,15 +2433,11 @@ void OneofDescriptor::DebugString(int depth, string* contents,
|
| SourceLocationCommentPrinter
|
| comment_printer(this, prefix, debug_string_options);
|
| comment_printer.AddPreComment(contents);
|
| - strings::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name());
|
| -
|
| - FormatLineOptions(depth, options(), containing_type()->file()->pool(),
|
| - contents);
|
| -
|
| + strings::SubstituteAndAppend(
|
| + contents, "$0 oneof $1 {", prefix, name());
|
| if (debug_string_options.elide_oneof_body) {
|
| contents->append(" ... }\n");
|
| } else {
|
| - contents->append("\n");
|
| for (int i = 0; i < field_count(); i++) {
|
| field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents,
|
| debug_string_options);
|
| @@ -2646,7 +2472,7 @@ void EnumDescriptor::DebugString(int depth, string *contents,
|
| strings::SubstituteAndAppend(contents, "$0enum $1 {\n",
|
| prefix, name());
|
|
|
| - FormatLineOptions(depth, options(), file()->pool(), contents);
|
| + FormatLineOptions(depth, options(), contents);
|
|
|
| for (int i = 0; i < value_count(); i++) {
|
| value(i)->DebugString(depth, contents, debug_string_options);
|
| @@ -2681,8 +2507,7 @@ void EnumValueDescriptor::DebugString(int depth, string *contents,
|
| prefix, name(), number());
|
|
|
| string formatted_options;
|
| - if (FormatBracketedOptions(depth, options(), type()->file()->pool(),
|
| - &formatted_options)) {
|
| + if (FormatBracketedOptions(depth, options(), &formatted_options)) {
|
| strings::SubstituteAndAppend(contents, " [$0]", formatted_options);
|
| }
|
| contents->append(";\n");
|
| @@ -2711,7 +2536,7 @@ void ServiceDescriptor::DebugString(string *contents,
|
|
|
| strings::SubstituteAndAppend(contents, "service $0 {\n", name());
|
|
|
| - FormatLineOptions(1, options(), file()->pool(), contents);
|
| + FormatLineOptions(1, options(), contents);
|
|
|
| for (int i = 0; i < method_count(); i++) {
|
| method(i)->DebugString(1, contents, debug_string_options);
|
| @@ -2752,8 +2577,7 @@ void MethodDescriptor::DebugString(int depth, string *contents,
|
| server_streaming() ? "stream " : "");
|
|
|
| string formatted_options;
|
| - if (FormatLineOptions(depth, options(), service()->file()->pool(),
|
| - &formatted_options)) {
|
| + if (FormatLineOptions(depth, options(), &formatted_options)) {
|
| strings::SubstituteAndAppend(contents, " {\n$0$1}\n",
|
| formatted_options, prefix);
|
| } else {
|
| @@ -2766,7 +2590,7 @@ void MethodDescriptor::DebugString(int depth, string *contents,
|
|
|
| // Location methods ===============================================
|
|
|
| -bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
|
| +bool FileDescriptor::GetSourceLocation(const vector<int>& path,
|
| SourceLocation* out_location) const {
|
| GOOGLE_CHECK_NOTNULL(out_location);
|
| if (source_code_info_) {
|
| @@ -2792,7 +2616,7 @@ bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
|
| }
|
|
|
| bool FileDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path; // empty path for root FileDescriptor
|
| + vector<int> path; // empty path for root FileDescriptor
|
| return GetSourceLocation(path, out_location);
|
| }
|
|
|
| @@ -2806,49 +2630,49 @@ bool FieldDescriptor::is_packed() const {
|
| }
|
|
|
| bool Descriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool OneofDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return containing_type()->file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return service()->file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| bool EnumValueDescriptor::GetSourceLocation(
|
| SourceLocation* out_location) const {
|
| - std::vector<int> path;
|
| + vector<int> path;
|
| GetLocationPath(&path);
|
| return type()->file()->GetSourceLocation(path, out_location);
|
| }
|
|
|
| -void Descriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void Descriptor::GetLocationPath(vector<int>* output) const {
|
| if (containing_type()) {
|
| containing_type()->GetLocationPath(output);
|
| output->push_back(DescriptorProto::kNestedTypeFieldNumber);
|
| @@ -2859,7 +2683,7 @@ void Descriptor::GetLocationPath(std::vector<int>* output) const {
|
| }
|
| }
|
|
|
| -void FieldDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void FieldDescriptor::GetLocationPath(vector<int>* output) const {
|
| if (is_extension()) {
|
| if (extension_scope() == NULL) {
|
| output->push_back(FileDescriptorProto::kExtensionFieldNumber);
|
| @@ -2876,13 +2700,13 @@ void FieldDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| }
|
| }
|
|
|
| -void OneofDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void OneofDescriptor::GetLocationPath(vector<int>* output) const {
|
| containing_type()->GetLocationPath(output);
|
| output->push_back(DescriptorProto::kOneofDeclFieldNumber);
|
| output->push_back(index());
|
| }
|
|
|
| -void EnumDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void EnumDescriptor::GetLocationPath(vector<int>* output) const {
|
| if (containing_type()) {
|
| containing_type()->GetLocationPath(output);
|
| output->push_back(DescriptorProto::kEnumTypeFieldNumber);
|
| @@ -2893,18 +2717,18 @@ void EnumDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| }
|
| }
|
|
|
| -void EnumValueDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void EnumValueDescriptor::GetLocationPath(vector<int>* output) const {
|
| type()->GetLocationPath(output);
|
| output->push_back(EnumDescriptorProto::kValueFieldNumber);
|
| output->push_back(index());
|
| }
|
|
|
| -void ServiceDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void ServiceDescriptor::GetLocationPath(vector<int>* output) const {
|
| output->push_back(FileDescriptorProto::kServiceFieldNumber);
|
| output->push_back(index());
|
| }
|
|
|
| -void MethodDescriptor::GetLocationPath(std::vector<int>* output) const {
|
| +void MethodDescriptor::GetLocationPath(vector<int>* output) const {
|
| service()->GetLocationPath(output);
|
| output->push_back(ServiceDescriptorProto::kMethodFieldNumber);
|
| output->push_back(index());
|
| @@ -2959,17 +2783,17 @@ class DescriptorBuilder {
|
| // As we build descriptors we store copies of the options messages in
|
| // them. We put pointers to those copies in this vector, as we build, so we
|
| // can later (after cross-linking) interpret those options.
|
| - std::vector<OptionsToInterpret> options_to_interpret_;
|
| + vector<OptionsToInterpret> options_to_interpret_;
|
|
|
| bool had_errors_;
|
| string filename_;
|
| FileDescriptor* file_;
|
| FileDescriptorTables* file_tables_;
|
| - std::set<const FileDescriptor*> dependencies_;
|
| + set<const FileDescriptor*> dependencies_;
|
|
|
| // unused_dependency_ is used to record the unused imported files.
|
| // Note: public import is not considered.
|
| - std::set<const FileDescriptor*> unused_dependency_;
|
| + set<const FileDescriptor*> unused_dependency_;
|
|
|
| // If LookupSymbol() finds a symbol that is in a file which is not a declared
|
| // dependency of this file, it will fail, but will set
|
| @@ -3150,8 +2974,6 @@ class DescriptorBuilder {
|
| void BuildOneof(const OneofDescriptorProto& proto,
|
| Descriptor* parent,
|
| OneofDescriptor* result);
|
| - void CheckEnumValueUniqueness(const EnumDescriptorProto& proto,
|
| - const EnumDescriptor* result);
|
| void BuildEnum(const EnumDescriptorProto& proto,
|
| const Descriptor* parent,
|
| EnumDescriptor* result);
|
| @@ -3222,10 +3044,8 @@ class DescriptorBuilder {
|
| // in unknown_fields to check if field innermost_field is set on the
|
| // innermost message. Returns false and sets an error if so.
|
| bool ExamineIfOptionIsSet(
|
| - std::vector<const FieldDescriptor*>::const_iterator
|
| - intermediate_fields_iter,
|
| - std::vector<const FieldDescriptor*>::const_iterator
|
| - intermediate_fields_end,
|
| + vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,
|
| + vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
|
| const FieldDescriptor* innermost_field, const string& debug_msg_name,
|
| const UnknownFieldSet& unknown_fields);
|
|
|
| @@ -3551,8 +3371,7 @@ Symbol DescriptorBuilder::FindSymbol(const string& name) {
|
| // dependency also defines the same package. We can't really rule out this
|
| // symbol unless none of the dependencies define it.
|
| if (IsInPackage(file_, name)) return result;
|
| - for (std::set<const FileDescriptor*>::const_iterator it =
|
| - dependencies_.begin();
|
| + for (set<const FileDescriptor*>::const_iterator it = dependencies_.begin();
|
| it != dependencies_.end(); ++it) {
|
| // Note: A dependency may be NULL if it was not found or had errors.
|
| if (*it != NULL && IsInPackage(*it, name)) return result;
|
| @@ -3771,13 +3590,9 @@ bool DescriptorBuilder::AddSymbol(
|
|
|
| if (tables_->AddSymbol(full_name, symbol)) {
|
| if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) {
|
| - // This is only possible if there was already an error adding something of
|
| - // the same name.
|
| - if (!had_errors_) {
|
| - GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in "
|
| - "symbols_by_name_, but was defined in "
|
| - "symbols_by_parent_; this shouldn't be possible.";
|
| - }
|
| + GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in "
|
| + "symbols_by_name_, but was defined in symbols_by_parent_; "
|
| + "this shouldn't be possible.";
|
| return false;
|
| }
|
| return true;
|
| @@ -4095,12 +3910,12 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
|
| }
|
|
|
| // Make sure all dependencies are loaded.
|
| - std::set<string> seen_dependencies;
|
| + set<string> seen_dependencies;
|
| result->dependency_count_ = proto.dependency_size();
|
| result->dependencies_ =
|
| tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size());
|
| unused_dependency_.clear();
|
| - std::set<int> weak_deps;
|
| + set<int> weak_deps;
|
| for (int i = 0; i < proto.weak_dependency_size(); ++i) {
|
| weak_deps.insert(proto.weak_dependency(i));
|
| }
|
| @@ -4199,7 +4014,7 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
|
| // extension options known, so all interpretations should now succeed.
|
| if (!had_errors_) {
|
| OptionInterpreter option_interpreter(this);
|
| - for (std::vector<OptionsToInterpret>::iterator iter =
|
| + for (vector<OptionsToInterpret>::iterator iter =
|
| options_to_interpret_.begin();
|
| iter != options_to_interpret_.end(); ++iter) {
|
| option_interpreter.InterpretOptions(&(*iter));
|
| @@ -4347,7 +4162,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
|
| for (int j = 0; j < result->reserved_range_count(); j++) {
|
| const Descriptor::ReservedRange* range2 = result->reserved_range(j);
|
| if (range1->end > range2->start && range2->end > range1->start) {
|
| - AddError(result->full_name(), proto.extension_range(i),
|
| + AddError(result->full_name(), proto.extension_range(j),
|
| DescriptorPool::ErrorCollector::NUMBER,
|
| strings::Substitute("Extension range $0 to $1 overlaps with "
|
| "reserved range $2 to $3.",
|
| @@ -4358,7 +4173,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
|
| for (int j = i + 1; j < result->extension_range_count(); j++) {
|
| const Descriptor::ExtensionRange* range2 = result->extension_range(j);
|
| if (range1->end > range2->start && range2->end > range1->start) {
|
| - AddError(result->full_name(), proto.extension_range(i),
|
| + AddError(result->full_name(), proto.extension_range(j),
|
| DescriptorPool::ErrorCollector::NUMBER,
|
| strings::Substitute("Extension range $0 to $1 overlaps with "
|
| "already-defined range $2 to $3.",
|
| @@ -4411,7 +4226,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
|
| result->json_name_ = tables_->AllocateString(proto.json_name());
|
| } else {
|
| result->has_json_name_ = false;
|
| - result->json_name_ = tables_->AllocateString(ToJsonName(proto.name()));
|
| + result->json_name_ = result->camelcase_name_;
|
| }
|
|
|
| // Some compilers do not allow static_cast directly between two enum types,
|
| @@ -4469,14 +4284,11 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
|
| break;
|
| case FieldDescriptor::CPPTYPE_FLOAT:
|
| if (proto.default_value() == "inf") {
|
| - result->default_value_float_ =
|
| - std::numeric_limits<float>::infinity();
|
| + result->default_value_float_ = numeric_limits<float>::infinity();
|
| } else if (proto.default_value() == "-inf") {
|
| - result->default_value_float_ =
|
| - -std::numeric_limits<float>::infinity();
|
| + result->default_value_float_ = -numeric_limits<float>::infinity();
|
| } else if (proto.default_value() == "nan") {
|
| - result->default_value_float_ =
|
| - std::numeric_limits<float>::quiet_NaN();
|
| + result->default_value_float_ = numeric_limits<float>::quiet_NaN();
|
| } else {
|
| result->default_value_float_ = io::SafeDoubleToFloat(
|
| io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos));
|
| @@ -4484,14 +4296,11 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
|
| break;
|
| case FieldDescriptor::CPPTYPE_DOUBLE:
|
| if (proto.default_value() == "inf") {
|
| - result->default_value_double_ =
|
| - std::numeric_limits<double>::infinity();
|
| + result->default_value_double_ = numeric_limits<double>::infinity();
|
| } else if (proto.default_value() == "-inf") {
|
| - result->default_value_double_ =
|
| - -std::numeric_limits<double>::infinity();
|
| + result->default_value_double_ = -numeric_limits<double>::infinity();
|
| } else if (proto.default_value() == "nan") {
|
| - result->default_value_double_ =
|
| - std::numeric_limits<double>::quiet_NaN();
|
| + result->default_value_double_ = numeric_limits<double>::quiet_NaN();
|
| } else {
|
| result->default_value_double_ =
|
| io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos);
|
| @@ -4714,82 +4523,10 @@ void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto,
|
| result->field_count_ = 0;
|
| result->fields_ = NULL;
|
|
|
| - // Copy options.
|
| - if (!proto.has_options()) {
|
| - result->options_ = NULL; // Will set to default_instance later.
|
| - } else {
|
| - AllocateOptions(proto.options(), result);
|
| - }
|
| -
|
| AddSymbol(result->full_name(), parent, result->name(),
|
| proto, Symbol(result));
|
| }
|
|
|
| -void DescriptorBuilder::CheckEnumValueUniqueness(
|
| - const EnumDescriptorProto& proto, const EnumDescriptor* result) {
|
| -
|
| - // Check that enum labels are still unique when we remove the enum prefix from
|
| - // values that have it.
|
| - //
|
| - // This will fail for something like:
|
| - //
|
| - // enum MyEnum {
|
| - // MY_ENUM_FOO = 0;
|
| - // FOO = 1;
|
| - // }
|
| - //
|
| - // By enforcing this reasonable constraint, we allow code generators to strip
|
| - // the prefix and/or PascalCase it without creating conflicts. This can lead
|
| - // to much nicer language-specific enums like:
|
| - //
|
| - // enum NameType {
|
| - // FirstName = 1,
|
| - // LastName = 2,
|
| - // }
|
| - //
|
| - // Instead of:
|
| - //
|
| - // enum NameType {
|
| - // NAME_TYPE_FIRST_NAME = 1,
|
| - // NAME_TYPE_LAST_NAME = 2,
|
| - // }
|
| - PrefixRemover remover(result->name());
|
| - std::map<string, const google::protobuf::EnumValueDescriptor*> values;
|
| - for (int i = 0; i < result->value_count(); i++) {
|
| - const google::protobuf::EnumValueDescriptor* value = result->value(i);
|
| - string stripped =
|
| - EnumValueToPascalCase(remover.MaybeRemove(value->name()));
|
| - std::pair<std::map<string, const google::protobuf::EnumValueDescriptor*>::iterator,
|
| - bool>
|
| - insert_result = values.insert(std::make_pair(stripped, value));
|
| - bool inserted = insert_result.second;
|
| -
|
| - // We don't throw the error if the two conflicting symbols are identical, or
|
| - // if they map to the same number. In the former case, the normal symbol
|
| - // duplication error will fire so we don't need to (and its error message
|
| - // will make more sense). We allow the latter case so users can create
|
| - // aliases which add or remove the prefix (code generators that do prefix
|
| - // stripping should de-dup the labels in this case).
|
| - if (!inserted && insert_result.first->second->name() != value->name() &&
|
| - insert_result.first->second->number() != value->number()) {
|
| - string error_message =
|
| - "When enum name is stripped and label is PascalCased (" + stripped +
|
| - "), this value label conflicts with " + values[stripped]->name() +
|
| - ". This will make the proto fail to compile for some languages, such "
|
| - "as C#.";
|
| - // There are proto2 enums out there with conflicting names, so to preserve
|
| - // compatibility we issue only a warning for proto2.
|
| - if (result->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) {
|
| - AddWarning(value->full_name(), proto.value(i),
|
| - DescriptorPool::ErrorCollector::NAME, error_message);
|
| - } else {
|
| - AddError(value->full_name(), proto.value(i),
|
| - DescriptorPool::ErrorCollector::NAME, error_message);
|
| - }
|
| - }
|
| - }
|
| -}
|
| -
|
| void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
|
| const Descriptor* parent,
|
| EnumDescriptor* result) {
|
| @@ -4818,8 +4555,6 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
|
|
|
| BUILD_ARRAY(proto, result, value, BuildEnumValue, result);
|
|
|
| - CheckEnumValueUniqueness(proto, result);
|
| -
|
| // Copy options.
|
| if (!proto.has_options()) {
|
| result->options_ = NULL; // Will set to default_instance later.
|
| @@ -5048,10 +4783,6 @@ void DescriptorBuilder::CrossLinkMessage(
|
| oneof_decl->fields_ =
|
| tables_->AllocateArray<const FieldDescriptor*>(oneof_decl->field_count_);
|
| oneof_decl->field_count_ = 0;
|
| -
|
| - if (oneof_decl->options_ == NULL) {
|
| - oneof_decl->options_ = &OneofOptions::default_instance();
|
| - }
|
| }
|
|
|
| // Then fill them in.
|
| @@ -5235,16 +4966,13 @@ void DescriptorBuilder::CrossLinkField(
|
| const FieldDescriptor* conflicting_field =
|
| file_tables_->FindFieldByNumber(field->containing_type(),
|
| field->number());
|
| - string containing_type_name = field->containing_type() == NULL
|
| - ? "unknown"
|
| - : field->containing_type()->full_name();
|
| if (field->is_extension()) {
|
| AddError(field->full_name(), proto,
|
| DescriptorPool::ErrorCollector::NUMBER,
|
| strings::Substitute("Extension number $0 has already been used "
|
| "in \"$1\" by extension \"$2\".",
|
| field->number(),
|
| - containing_type_name,
|
| + field->containing_type()->full_name(),
|
| conflicting_field->full_name()));
|
| } else {
|
| AddError(field->full_name(), proto,
|
| @@ -5252,7 +4980,7 @@ void DescriptorBuilder::CrossLinkField(
|
| strings::Substitute("Field number $0 has already been used in "
|
| "\"$1\" by field \"$2\".",
|
| field->number(),
|
| - containing_type_name,
|
| + field->containing_type()->full_name(),
|
| conflicting_field->name()));
|
| }
|
| } else {
|
| @@ -5446,14 +5174,14 @@ void DescriptorBuilder::ValidateProto3Message(
|
| // In proto3, we reject field names if they conflict in camelCase.
|
| // Note that we currently enforce a stricter rule: Field names must be
|
| // unique after being converted to lowercase with underscores removed.
|
| - std::map<string, const FieldDescriptor*> name_to_field;
|
| + map<string, const FieldDescriptor*> name_to_field;
|
| for (int i = 0; i < message->field_count(); ++i) {
|
| string lowercase_name = ToLowercaseWithoutUnderscores(
|
| message->field(i)->name());
|
| if (name_to_field.find(lowercase_name) != name_to_field.end()) {
|
| AddError(message->full_name(), proto,
|
| DescriptorPool::ErrorCollector::OTHER,
|
| - "The JSON camel-case name of field \"" +
|
| + "The JSON camcel-case name of field \"" +
|
| message->field(i)->name() + "\" conflicts with field \"" +
|
| name_to_field[lowercase_name]->name() + "\". This is not " +
|
| "allowed in proto3.");
|
| @@ -5597,7 +5325,7 @@ void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm,
|
| const EnumDescriptorProto& proto) {
|
| VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue);
|
| if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) {
|
| - std::map<int, string> used_values;
|
| + map<int, string> used_values;
|
| for (int i = 0; i < enm->value_count(); ++i) {
|
| const EnumValueDescriptor* enum_value = enm->value(i);
|
| if (used_values.find(enum_value->number()) != used_values.end()) {
|
| @@ -5724,10 +5452,10 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field,
|
|
|
| void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
|
| const DescriptorProto& proto) {
|
| - std::map<string, const Descriptor*> seen_types;
|
| + map<string, const Descriptor*> seen_types;
|
| for (int i = 0; i < message->nested_type_count(); ++i) {
|
| const Descriptor* nested = message->nested_type(i);
|
| - std::pair<std::map<string, const Descriptor*>::iterator, bool> result =
|
| + pair<map<string, const Descriptor*>::iterator, bool> result =
|
| seen_types.insert(std::make_pair(nested->name(), nested));
|
| if (!result.second) {
|
| if (result.first->second->options().map_entry() ||
|
| @@ -5744,7 +5472,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
|
| // Check for conflicted field names.
|
| for (int i = 0; i < message->field_count(); ++i) {
|
| const FieldDescriptor* field = message->field(i);
|
| - std::map<string, const Descriptor*>::iterator iter =
|
| + map<string, const Descriptor*>::iterator iter =
|
| seen_types.find(field->name());
|
| if (iter != seen_types.end() && iter->second->options().map_entry()) {
|
| AddError(message->full_name(), proto,
|
| @@ -5756,7 +5484,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
|
| // Check for conflicted enum names.
|
| for (int i = 0; i < message->enum_type_count(); ++i) {
|
| const EnumDescriptor* enum_desc = message->enum_type(i);
|
| - std::map<string, const Descriptor*>::iterator iter =
|
| + map<string, const Descriptor*>::iterator iter =
|
| seen_types.find(enum_desc->name());
|
| if (iter != seen_types.end() && iter->second->options().map_entry()) {
|
| AddError(message->full_name(), proto,
|
| @@ -5768,7 +5496,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
|
| // Check for conflicted oneof names.
|
| for (int i = 0; i < message->oneof_decl_count(); ++i) {
|
| const OneofDescriptor* oneof_desc = message->oneof_decl(i);
|
| - std::map<string, const Descriptor*>::iterator iter =
|
| + map<string, const Descriptor*>::iterator iter =
|
| seen_types.find(oneof_desc->name());
|
| if (iter != seen_types.end() && iter->second->options().map_entry()) {
|
| AddError(message->full_name(), proto,
|
| @@ -5903,7 +5631,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
|
| // name in |debug_msg_name|, for use in error messages.
|
| const Descriptor* descriptor = options_descriptor;
|
| const FieldDescriptor* field = NULL;
|
| - std::vector<const FieldDescriptor*> intermediate_fields;
|
| + vector<const FieldDescriptor*> intermediate_fields;
|
| string debug_msg_name = "";
|
|
|
| for (int i = 0; i < uninterpreted_option_->name_size(); ++i) {
|
| @@ -6011,7 +5739,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
|
|
|
| // Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all
|
| // the intermediate messages.
|
| - for (std::vector<const FieldDescriptor*>::reverse_iterator iter =
|
| + for (vector<const FieldDescriptor*>::reverse_iterator iter =
|
| intermediate_fields.rbegin();
|
| iter != intermediate_fields.rend(); ++iter) {
|
| google::protobuf::scoped_ptr<UnknownFieldSet> parent_unknown_fields(
|
| @@ -6061,9 +5789,8 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting(
|
| }
|
|
|
| bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
|
| - std::vector<const FieldDescriptor*>::const_iterator
|
| - intermediate_fields_iter,
|
| - std::vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
|
| + vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,
|
| + vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
|
| const FieldDescriptor* innermost_field, const string& debug_msg_name,
|
| const UnknownFieldSet& unknown_fields) {
|
| // We do linear searches of the UnknownFieldSet and its sub-groups. This
|
| @@ -6523,7 +6250,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
|
| annotation_extensions.insert("google.protobuf.ServiceOptions");
|
| annotation_extensions.insert("google.protobuf.MethodOptions");
|
| annotation_extensions.insert("google.protobuf.StreamOptions");
|
| - for (std::set<const FileDescriptor*>::const_iterator
|
| + for (set<const FileDescriptor*>::const_iterator
|
| it = unused_dependency_.begin();
|
| it != unused_dependency_.end(); ++it) {
|
| // Do not log warnings for proto files which extend annotations.
|
|
|