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/java/helpers.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/java/helpers.h')
-rw-r--r-- | contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h | 91 |
1 files changed, 37 insertions, 54 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h index 7f4c4aad14..e4fac63426 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h @@ -38,10 +38,15 @@ #include <cstdint> #include <string> -#include <google/protobuf/io/printer.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/compiler/java/context.h> -#include <google/protobuf/descriptor.pb.h> +#include "y_absl/strings/string_view.h" +#include "google/protobuf/compiler/java/names.h" +#include "google/protobuf/compiler/java/options.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/printer.h" + +// Must be last. +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -53,7 +58,7 @@ namespace java { extern const char kThickSeparator[]; extern const char kThinSeparator[]; -bool IsForbiddenKotlin(const TProtoStringType& field_name); +bool IsForbiddenKotlin(y_absl::string_view field_name); // If annotation_file is non-empty, prints a javax.annotation.Generated // annotation to the given Printer. annotation_file will be referenced in the @@ -64,38 +69,20 @@ bool IsForbiddenKotlin(const TProtoStringType& field_name); // annotation_file should be generated from the filename of the source file // being annotated (which in turn must be a Java identifier plus ".java"). void PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$', - const TProtoStringType& annotation_file = ""); + y_absl::string_view annotation_file = "", + Options options = {}); // If a GeneratedMessageLite contains non-lite enums, then its verifier // must be instantiated inline, rather than retrieved from the enum class. -void PrintEnumVerifierLogic(io::Printer* printer, - const FieldDescriptor* descriptor, - const std::map<TProtoStringType, TProtoStringType>& variables, - const char* var_name, - const char* terminating_string, bool enforce_lite); - -// Converts a name to camel-case. If cap_first_letter is true, capitalize the -// first letter. -TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first); - -char ToUpperCh(char ch); -char ToLowerCh(char ch); +void PrintEnumVerifierLogic( + io::Printer* printer, const FieldDescriptor* descriptor, + const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& variables, + y_absl::string_view var_name, y_absl::string_view terminating_string, + bool enforce_lite); // Converts a name to camel-case. If cap_first_letter is true, capitalize the // first letter. -TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name, - bool cap_first_letter); -// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes -// "fooBarBaz" or "FooBarBaz", respectively. -TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field); -TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field); - -// Similar, but for method names. (Typically, this merely has the effect -// of lower-casing the first letter of the name.) -TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method); - -// Same as UnderscoresToCamelCase, but checks for reserved keywords -TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field); +TProtoStringType ToCamelCase(y_absl::string_view input, bool lower_first); // Similar to UnderscoresToCamelCase, but guarantees that the result is a // complete Java identifier by adding a _ if needed. @@ -113,11 +100,15 @@ TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor); TProtoStringType FileClassName(const FileDescriptor* file, bool immutable = true); // Returns the file's Java package name. -TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable); +TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable, + Options options = {}); // Returns output directory for the given package name. TProtoStringType JavaPackageToDir(TProtoStringType package_name); +// Returns the name with Kotlin keywords enclosed in backticks +TProtoStringType EscapeKotlinKeywords(TProtoStringType name); + // Comma-separate list of option-specified interfaces implemented by the // Message, to follow the "implements" declaration of the Message definition. TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor); @@ -194,20 +185,8 @@ inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) { // (e.g.) be "OrBuilder" for some generated interfaces. template <typename Descriptor> TProtoStringType AnnotationFileName(const Descriptor* descriptor, - const TProtoStringType& suffix) { - return descriptor->name() + suffix + ".java.pb.meta"; -} - -template <typename Descriptor> -void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer, - Descriptor* descriptor, bool immutable, - const TProtoStringType& suffix = "") { - if (IsOwnFile(descriptor, immutable)) { - PrintGeneratedAnnotation(printer, '$', - context->options().annotate_code - ? AnnotationFileName(descriptor, suffix) - : ""); - } + y_absl::string_view suffix) { + return y_absl::StrCat(descriptor->name(), suffix, ".java.pb.meta"); } // Get the unqualified name that should be used for a field's field @@ -233,28 +212,30 @@ enum JavaType { JavaType GetJavaType(const FieldDescriptor* field); -const char* PrimitiveTypeName(JavaType type); +y_absl::string_view PrimitiveTypeName(JavaType type); // Get the fully-qualified class name for a boxed primitive type, e.g. // "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message // types. -const char* BoxedPrimitiveTypeName(JavaType type); +y_absl::string_view BoxedPrimitiveTypeName(JavaType type); // Kotlin source does not distinguish between primitives and non-primitives, // but does use Kotlin-specific qualified types for them. -const char* KotlinTypeName(JavaType type); +y_absl::string_view KotlinTypeName(JavaType type); // Get the name of the java enum constant representing this type. E.g., // "INT32" for FieldDescriptor::TYPE_INT32. The enum constant's full // name is "com.google.protobuf.WireFormat.FieldType.INT32". -const char* FieldTypeName(const FieldDescriptor::Type field_type); +y_absl::string_view FieldTypeName(const FieldDescriptor::Type field_type); class ClassNameResolver; TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable, - ClassNameResolver* name_resolver); + ClassNameResolver* name_resolver, + Options options = {}); inline TProtoStringType ImmutableDefaultValue(const FieldDescriptor* field, - ClassNameResolver* name_resolver) { - return DefaultValue(field, true, name_resolver); + ClassNameResolver* name_resolver, + Options options = {}) { + return DefaultValue(field, true, name_resolver, options); } bool IsDefaultValueJavaDefault(const FieldDescriptor* field); bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field); @@ -333,7 +314,8 @@ bool IsReferenceType(JavaType type); // Returns the capitalized name for calling relative functions in // CodedInputStream -const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable); +y_absl::string_view GetCapitalizedType(const FieldDescriptor* field, + bool immutable, Options options); // For encodings with fixed sizes, returns that size in bytes. Otherwise // returns -1. @@ -471,4 +453,5 @@ std::pair<int, int> GetTableDrivenNumberOfEntriesAndLookUpStartFieldNumber( } // namespace protobuf } // namespace google +#include "google/protobuf/port_undef.inc" #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__ |