diff options
author | nechda <nechda@yandex-team.com> | 2024-08-29 23:50:27 +0300 |
---|---|---|
committer | nechda <nechda@yandex-team.com> | 2024-08-30 00:05:25 +0300 |
commit | e10d6638f07a82edae3ea8197b9f5c0affcc07ea (patch) | |
tree | 571c38cec05813766a1ad290c9d51ce7ace52919 /contrib/libs/protoc/src/google/protobuf/compiler/parser.h | |
parent | e79b38f2bbbf78d295d1901d2a79f898022d5224 (diff) | |
download | ydb-e10d6638f07a82edae3ea8197b9f5c0affcc07ea.tar.gz |
Update cpp-protobuf to 22.5
Привет!\
Этот PR переключат cpp & python библиотеки protobuf на версию 22.5
Если у вас возникли проблемы после влития этого PR:
1. Если начали падать канон тесты, то проведите их переканонизацию
2. Прочитайте <https://wiki.yandex-team.ru/users/nechda/obnovlenie-cpp-protobuf-22.5/> страничку с основными изменениями
3. Если страничка в вики не помогла, то пишите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/DEVTOOLSSUPPORT)
7fecade616c20a841b9e9af7b7998bdfc8d2807d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/parser.h')
-rw-r--r-- | contrib/libs/protoc/src/google/protobuf/compiler/parser.h | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h index c92b5f28f4c..72db054327d 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h @@ -38,17 +38,18 @@ #define GOOGLE_PROTOBUF_COMPILER_PARSER_H__ #include <cstdint> -#include <map> #include <string> #include <utility> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/io/tokenizer.h> -#include <google/protobuf/repeated_field.h> +#include "y_absl/container/flat_hash_map.h" +#include "y_absl/strings/string_view.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/tokenizer.h" +#include "google/protobuf/repeated_field.h" // Must be included last. -#include <google/protobuf/port_def.inc> +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -71,6 +72,8 @@ class SourceLocationTable; class PROTOBUF_EXPORT Parser { public: Parser(); + Parser(const Parser&) = delete; + Parser& operator=(const Parser&) = delete; ~Parser(); // Parse the entire input and construct a FileDescriptorProto representing @@ -98,7 +101,7 @@ class PROTOBUF_EXPORT Parser { // Returns the identifier used in the "syntax = " declaration, if one was // seen during the last call to Parse(), or the empty string otherwise. - const TProtoStringType& GetSyntaxIdentifier() { return syntax_identifier_; } + y_absl::string_view GetSyntaxIdentifier() { return syntax_identifier_; } // If set true, input files will be required to begin with a syntax // identifier. Otherwise, files may omit this. If a syntax identifier @@ -151,38 +154,41 @@ class PROTOBUF_EXPORT Parser { inline bool AtEnd(); // True if the next token matches the given text. - inline bool LookingAt(const char* text); + inline bool LookingAt(y_absl::string_view text); // True if the next token is of the given type. inline bool LookingAtType(io::Tokenizer::TokenType token_type); // If the next token exactly matches the text given, consume it and return // true. Otherwise, return false without logging an error. - bool TryConsume(const char* text); + bool TryConsume(y_absl::string_view text); // These attempt to read some kind of token from the input. If successful, // they return true. Otherwise they return false and add the given error // to the error list. // Consume a token with the exact text given. - bool Consume(const char* text, const char* error); + bool Consume(y_absl::string_view text, y_absl::string_view error); // Same as above, but automatically generates the error "Expected \"text\".", // where "text" is the expected token text. - bool Consume(const char* text); + bool Consume(y_absl::string_view text); // Consume a token of type IDENTIFIER and store its text in "output". - bool ConsumeIdentifier(TProtoStringType* output, const char* error); + bool ConsumeIdentifier(TProtoStringType* output, y_absl::string_view error); // Consume an integer and store its value in "output". - bool ConsumeInteger(int* output, const char* error); + bool ConsumeInteger(int* output, y_absl::string_view error); // Consume a signed integer and store its value in "output". - bool ConsumeSignedInteger(int* output, const char* error); + bool ConsumeSignedInteger(int* output, y_absl::string_view error); // Consume a 64-bit integer and store its value in "output". If the value // is greater than max_value, an error will be reported. bool ConsumeInteger64(arc_ui64 max_value, arc_ui64* output, - const char* error); + y_absl::string_view error); + // Try to consume a 64-bit integer and store its value in "output". No + // error is reported on failure, allowing caller to consume token another way. + bool TryConsumeInteger64(arc_ui64 max_value, arc_ui64* output); // Consume a number and store its value in "output". This will accept // tokens of either INTEGER or FLOAT type. - bool ConsumeNumber(double* output, const char* error); + bool ConsumeNumber(double* output, y_absl::string_view error); // Consume a string literal and store its (unescaped) value in "output". - bool ConsumeString(TProtoStringType* output, const char* error); + bool ConsumeString(TProtoStringType* output, y_absl::string_view error); // Consume a token representing the end of the statement. Comments between // this token and the next will be harvested for documentation. The given @@ -193,27 +199,30 @@ class PROTOBUF_EXPORT Parser { // have been passed around by const reference, for no particularly good // reason. We should probably go through and change them all to mutable // pointer to make this more intuitive. - bool TryConsumeEndOfDeclaration(const char* text, + bool TryConsumeEndOfDeclaration(y_absl::string_view text, const LocationRecorder* location); - bool TryConsumeEndOfDeclarationFinishScope(const char* text, + bool TryConsumeEndOfDeclarationFinishScope(y_absl::string_view text, const LocationRecorder* location); - bool ConsumeEndOfDeclaration(const char* text, + bool ConsumeEndOfDeclaration(y_absl::string_view text, const LocationRecorder* location); // ----------------------------------------------------------------- // Error logging helpers - // Invokes error_collector_->AddError(), if error_collector_ is not NULL. - void AddError(int line, int column, const TProtoStringType& error); + // Invokes error_collector_->RecordError(), if error_collector_ is not NULL. + void RecordError(int line, int column, y_absl::string_view error); - // Invokes error_collector_->AddError() with the line and column number + // Invokes error_collector_->RecordError() with the line and column number // of the current token. - void AddError(const TProtoStringType& error); + void RecordError(y_absl::string_view error); - // Invokes error_collector_->AddWarning() with the line and column number + // Invokes error_collector_->RecordWarning(), if error_collector_ is not NULL. + void RecordWarning(int line, int column, y_absl::string_view warning); + + // Invokes error_collector_->RecordWarning() with the line and column number // of the current token. - void AddWarning(const TProtoStringType& warning); + void RecordWarning(y_absl::string_view warning); // Records a location in the SourceCodeInfo.location table (see // descriptor.proto). We use RAII to ensure that the start and end locations @@ -304,7 +313,7 @@ class PROTOBUF_EXPORT Parser { // were no errors; only that there were no *syntax* errors. For instance, // if a service method is defined using proper syntax but uses a primitive // type as its input or output, ParseMethodField() still returns true - // and only reports the error by calling AddError(). In practice, this + // and only reports the error by calling RecordError(). In practice, this // makes logic much simpler for the caller. // Parse a top-level message, enum, service, etc. @@ -392,6 +401,7 @@ class PROTOBUF_EXPORT Parser { const LocationRecorder& message_location); bool ParseReservedNames(DescriptorProto* message, const LocationRecorder& parent_location); + bool ParseReservedName(TProtoStringType* name, y_absl::string_view error_message); bool ParseReservedNumbers(DescriptorProto* message, const LocationRecorder& parent_location); bool ParseReserved(EnumDescriptorProto* message, @@ -545,8 +555,6 @@ class PROTOBUF_EXPORT Parser { // the next element (See SourceCodeInfo.Location in descriptor.proto), when // ConsumeEndOfDeclaration() is called. std::vector<TProtoStringType> upcoming_detached_comments_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); }; // A table mapping (descriptor, ErrorLocation) pairs -- as reported by @@ -570,7 +578,7 @@ class PROTOBUF_EXPORT SourceLocationTable { bool Find(const Message* descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int* line, int* column) const; - bool FindImport(const Message* descriptor, const TProtoStringType& name, int* line, + bool FindImport(const Message* descriptor, y_absl::string_view name, int* line, int* column) const; // Adds a location to the table. @@ -584,12 +592,12 @@ class PROTOBUF_EXPORT SourceLocationTable { void Clear(); private: - typedef std::map< + using LocationMap = y_absl::flat_hash_map< std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, - std::pair<int, int> > - LocationMap; + std::pair<int, int>>; LocationMap location_map_; - std::map<std::pair<const Message*, TProtoStringType>, std::pair<int, int> > + y_absl::flat_hash_map<std::pair<const Message*, TProtoStringType>, + std::pair<int, int>> import_location_map_; }; @@ -597,6 +605,6 @@ class PROTOBUF_EXPORT SourceLocationTable { } // namespace protobuf } // namespace google -#include <google/protobuf/port_undef.inc> +#include "google/protobuf/port_undef.inc" #endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__ |