From 0517b71b259b206b4b2e036a62e6f24d6ad45084 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 10 Jan 2023 11:29:57 -0800 Subject: [PATCH] Add retention and target attributes to descriptor.proto PiperOrigin-RevId: 501049083 --- ruby/ext/google/protobuf_c/ruby-upb.c | 24 +++- ruby/ext/google/protobuf_c/ruby-upb.h | 21 +++ src/google/protobuf/descriptor.pb.cc | 177 ++++++++++++++++++-------- src/google/protobuf/descriptor.pb.h | 126 ++++++++++++++++++ src/google/protobuf/descriptor.proto | 26 ++++ 5 files changed, 321 insertions(+), 53 deletions(-) diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 4b62ad38f5e6..1fd6a89060a0 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -1231,6 +1231,24 @@ const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init = { }, }; +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init = { + 64, + 0, + { + 0x3ff, + 0x0, + }, +}; + const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init = { 64, 0, @@ -1249,12 +1267,14 @@ const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_en }, }; -static const upb_MiniTableEnum *enums_layout[7] = { +static const upb_MiniTableEnum *enums_layout[9] = { &google_protobuf_FieldDescriptorProto_Type_enum_init, &google_protobuf_FieldDescriptorProto_Label_enum_init, &google_protobuf_FileOptions_OptimizeMode_enum_init, &google_protobuf_FieldOptions_CType_enum_init, &google_protobuf_FieldOptions_JSType_enum_init, + &google_protobuf_FieldOptions_OptionRetention_enum_init, + &google_protobuf_FieldOptions_OptionTargetType_enum_init, &google_protobuf_MethodOptions_IdempotencyLevel_enum_init, &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init, }; @@ -1264,7 +1284,7 @@ const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout = { enums_layout, NULL, 27, - 7, + 9, 0, }; diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index fc0883e213ed..86a7d17045ef 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -3310,6 +3310,25 @@ typedef enum { google_protobuf_FieldOptions_JS_NUMBER = 2 } google_protobuf_FieldOptions_JSType; +typedef enum { + google_protobuf_FieldOptions_RETENTION_UNKNOWN = 0, + google_protobuf_FieldOptions_RETENTION_RUNTIME = 1, + google_protobuf_FieldOptions_RETENTION_SOURCE = 2 +} google_protobuf_FieldOptions_OptionRetention; + +typedef enum { + google_protobuf_FieldOptions_TARGET_TYPE_UNKNOWN = 0, + google_protobuf_FieldOptions_TARGET_TYPE_FILE = 1, + google_protobuf_FieldOptions_TARGET_TYPE_EXTENSION_RANGE = 2, + google_protobuf_FieldOptions_TARGET_TYPE_MESSAGE = 3, + google_protobuf_FieldOptions_TARGET_TYPE_FIELD = 4, + google_protobuf_FieldOptions_TARGET_TYPE_ONEOF = 5, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM = 6, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM_ENTRY = 7, + google_protobuf_FieldOptions_TARGET_TYPE_SERVICE = 8, + google_protobuf_FieldOptions_TARGET_TYPE_METHOD = 9 +} google_protobuf_FieldOptions_OptionTargetType; + typedef enum { google_protobuf_FileOptions_SPEED = 1, google_protobuf_FileOptions_CODE_SIZE = 2, @@ -3333,6 +3352,8 @@ extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Label_enum_i extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Type_enum_init; extern const upb_MiniTableEnum google_protobuf_FieldOptions_CType_enum_init; extern const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init; extern const upb_MiniTableEnum google_protobuf_FileOptions_OptimizeMode_enum_init; extern const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init; extern const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init; diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 35ab4b9857ae..9dc9f7359566 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -537,7 +537,7 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; PROTOBUF_NAMESPACE_CLOSE static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; -static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[7]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[9]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; const ::uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( @@ -1180,7 +1180,7 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "eld_conflicts\030\013 \001(\010B\002\030\001\022C\n\024uninterpreted" "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" "pretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020" - "\007J\004\010\010\020\tJ\004\010\t\020\n\"\333\003\n\014FieldOptions\022:\n\005ctype\030" + "\007J\004\010\010\020\tJ\004\010\t\020\n\"\301\006\n\014FieldOptions\022:\n\005ctype\030" "\001 \001(\0162#.google.protobuf.FieldOptions.CTy" "pe:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001" "(\0162$.google.protobuf.FieldOptions.JSType" @@ -1191,58 +1191,67 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr" "etedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020" "\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORM" - "AL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020" - "\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpr" - "eted_option\030\347\007 \003(\0132$.google.protobuf.Uni" - "nterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\307\001\n\013EnumOpti" - "ons\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003" - " \001(\010:\005false\0222\n&deprecated_legacy_json_fi" - "eld_conflicts\030\006 \001(\010B\002\030\001\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumVal" - "ueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024" - "uninterpreted_option\030\347\007 \003(\0132$.google.pro" - "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016" - "ServiceOptions\022\031\n\ndeprecated\030! \001(\010:\005fals" - "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" - "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" - "\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecated\030! \001(\010:" - "\005false\022_\n\021idempotency_level\030\" \001(\0162/.goog" - "le.protobuf.MethodOptions.IdempotencyLev" - "el:\023IDEMPOTENCY_UNKNOWN\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption\"P\n\020IdempotencyLevel\022\027\n\023IDEM" - "POTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016" - "\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterpre" - "tedOption\022;\n\004name\030\002 \003(\0132-.google.protobu" - "f.UninterpretedOption.NamePart\022\030\n\020identi" - "fier_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004" - " \001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014doub" - "le_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017" - "aggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tnam" - "e_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016S" - "ourceCodeInfo\022:\n\010location\030\001 \003(\0132(.google" - ".protobuf.SourceCodeInfo.Location\032\206\001\n\010Lo" - "cation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002" - "\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021trailing" - "_comments\030\004 \001(\t\022!\n\031leading_detached_comm" - "ents\030\006 \003(\t\"\234\002\n\021GeneratedCodeInfo\022A\n\nanno" - "tation\030\001 \003(\0132-.google.protobuf.Generated" - "CodeInfo.Annotation\032\303\001\n\nAnnotation\022\020\n\004pa" - "th\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005beg" - "in\030\003 \001(\005\022\013\n\003end\030\004 \001(\005\022H\n\010semantic\030\005 \001(\0162" - "6.google.protobuf.GeneratedCodeInfo.Anno" - "tation.Semantic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n" - "\003SET\020\001\022\t\n\005ALIAS\020\002B~\n\023com.google.protobuf" - "B\020DescriptorProtosH\001Z-google.golang.org/" - "protobuf/types/descriptorpb\370\001\001\242\002\003GPB\252\002\032G" - "oogle.Protobuf.Reflection" + "AL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002\"U\n\017Op" + "tionRetention\022\025\n\021RETENTION_UNKNOWN\020\000\022\025\n\021" + "RETENTION_RUNTIME\020\001\022\024\n\020RETENTION_SOURCE\020" + "\002\"\214\002\n\020OptionTargetType\022\027\n\023TARGET_TYPE_UN" + "KNOWN\020\000\022\024\n\020TARGET_TYPE_FILE\020\001\022\037\n\033TARGET_" + "TYPE_EXTENSION_RANGE\020\002\022\027\n\023TARGET_TYPE_ME" + "SSAGE\020\003\022\025\n\021TARGET_TYPE_FIELD\020\004\022\025\n\021TARGET" + "_TYPE_ONEOF\020\005\022\024\n\020TARGET_TYPE_ENUM\020\006\022\032\n\026T" + "ARGET_TYPE_ENUM_ENTRY\020\007\022\027\n\023TARGET_TYPE_S" + "ERVICE\020\010\022\026\n\022TARGET_TYPE_METHOD\020\t*\t\010\350\007\020\200\200" + "\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpret" + "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" + "erpretedOption*\t\010\350\007\020\200\200\200\200\002\"\307\001\n\013EnumOption" + "s\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001" + "(\010:\005false\0222\n&deprecated_legacy_json_fiel" + "d_conflicts\030\006 \001(\010B\002\030\001\022C\n\024uninterpreted_o" + "ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr" + "etedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValue" + "Options\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024un" + "interpreted_option\030\347\007 \003(\0132$.google.proto" + "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016Se" + "rviceOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022" + "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." + "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"" + "\255\002\n\rMethodOptions\022\031\n\ndeprecated\030! \001(\010:\005f" + "alse\022_\n\021idempotency_level\030\" \001(\0162/.google" + ".protobuf.MethodOptions.IdempotencyLevel" + ":\023IDEMPOTENCY_UNKNOWN\022C\n\024uninterpreted_o" + "ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr" + "etedOption\"P\n\020IdempotencyLevel\022\027\n\023IDEMPO" + "TENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\n" + "IDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterprete" + "dOption\022;\n\004name\030\002 \003(\0132-.google.protobuf." + "UninterpretedOption.NamePart\022\030\n\020identifi" + "er_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001" + "(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014double" + "_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017ag" + "gregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_" + "part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016Sou" + "rceCodeInfo\022:\n\010location\030\001 \003(\0132(.google.p" + "rotobuf.SourceCodeInfo.Location\032\206\001\n\010Loca" + "tion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001" + "\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021trailing_c" + "omments\030\004 \001(\t\022!\n\031leading_detached_commen" + "ts\030\006 \003(\t\"\234\002\n\021GeneratedCodeInfo\022A\n\nannota" + "tion\030\001 \003(\0132-.google.protobuf.GeneratedCo" + "deInfo.Annotation\032\303\001\n\nAnnotation\022\020\n\004path" + "\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begin" + "\030\003 \001(\005\022\013\n\003end\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626." + "google.protobuf.GeneratedCodeInfo.Annota" + "tion.Semantic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003S" + "ET\020\001\022\t\n\005ALIAS\020\002B~\n\023com.google.protobufB\020" + "DescriptorProtosH\001Z-google.golang.org/pr" + "otobuf/types/descriptorpb\370\001\001\242\002\003GPB\252\002\032Goo" + "gle.Protobuf.Reflection" }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { false, false, - 6345, + 6703, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, @@ -1435,10 +1444,76 @@ constexpr int FieldOptions::JSType_ARRAYSIZE; #endif // (__cplusplus < 201703) && // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() { +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_OptionRetention_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[5]; } +bool FieldOptions_OptionRetention_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} +#if (__cplusplus < 201703) && \ + (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) + +constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_UNKNOWN; +constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_RUNTIME; +constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_SOURCE; +constexpr FieldOptions_OptionRetention FieldOptions::OptionRetention_MIN; +constexpr FieldOptions_OptionRetention FieldOptions::OptionRetention_MAX; +constexpr int FieldOptions::OptionRetention_ARRAYSIZE; + +#endif // (__cplusplus < 201703) && + // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_OptionTargetType_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); + return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; +} +bool FieldOptions_OptionTargetType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + return true; + default: + return false; + } +} +#if (__cplusplus < 201703) && \ + (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) + +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_UNKNOWN; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_FILE; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_EXTENSION_RANGE; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_MESSAGE; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_FIELD; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ONEOF; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ENUM; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ENUM_ENTRY; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_SERVICE; +constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_METHOD; +constexpr FieldOptions_OptionTargetType FieldOptions::OptionTargetType_MIN; +constexpr FieldOptions_OptionTargetType FieldOptions::OptionTargetType_MAX; +constexpr int FieldOptions::OptionTargetType_ARRAYSIZE; + +#endif // (__cplusplus < 201703) && + // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); + return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[7]; +} bool MethodOptions_IdempotencyLevel_IsValid(int value) { switch (value) { case 0: @@ -1463,7 +1538,7 @@ constexpr int MethodOptions::IdempotencyLevel_ARRAYSIZE; // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GeneratedCodeInfo_Annotation_Semantic_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; + return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[8]; } bool GeneratedCodeInfo_Annotation_Semantic_IsValid(int value) { switch (value) { diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 5edf01cbad13..6b8d15f316ac 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -350,6 +350,71 @@ inline bool FieldOptions_JSType_Parse(absl::string_view name, FieldOptions_JSTyp return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( FieldOptions_JSType_descriptor(), name, value); } +enum FieldOptions_OptionRetention : int { + FieldOptions_OptionRetention_RETENTION_UNKNOWN = 0, + FieldOptions_OptionRetention_RETENTION_RUNTIME = 1, + FieldOptions_OptionRetention_RETENTION_SOURCE = 2, +}; + +PROTOBUF_EXPORT bool FieldOptions_OptionRetention_IsValid(int value); +constexpr FieldOptions_OptionRetention FieldOptions_OptionRetention_OptionRetention_MIN = static_cast(0); +constexpr FieldOptions_OptionRetention FieldOptions_OptionRetention_OptionRetention_MAX = static_cast(2); +constexpr int FieldOptions_OptionRetention_OptionRetention_ARRAYSIZE = 2 + 1; +PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* +FieldOptions_OptionRetention_descriptor(); +template +const std::string& FieldOptions_OptionRetention_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to OptionRetention_Name()."); + return FieldOptions_OptionRetention_Name(static_cast(value)); +} +template <> +inline const std::string& FieldOptions_OptionRetention_Name(FieldOptions_OptionRetention value) { + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool FieldOptions_OptionRetention_Parse(absl::string_view name, FieldOptions_OptionRetention* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + FieldOptions_OptionRetention_descriptor(), name, value); +} +enum FieldOptions_OptionTargetType : int { + FieldOptions_OptionTargetType_TARGET_TYPE_UNKNOWN = 0, + FieldOptions_OptionTargetType_TARGET_TYPE_FILE = 1, + FieldOptions_OptionTargetType_TARGET_TYPE_EXTENSION_RANGE = 2, + FieldOptions_OptionTargetType_TARGET_TYPE_MESSAGE = 3, + FieldOptions_OptionTargetType_TARGET_TYPE_FIELD = 4, + FieldOptions_OptionTargetType_TARGET_TYPE_ONEOF = 5, + FieldOptions_OptionTargetType_TARGET_TYPE_ENUM = 6, + FieldOptions_OptionTargetType_TARGET_TYPE_ENUM_ENTRY = 7, + FieldOptions_OptionTargetType_TARGET_TYPE_SERVICE = 8, + FieldOptions_OptionTargetType_TARGET_TYPE_METHOD = 9, +}; + +PROTOBUF_EXPORT bool FieldOptions_OptionTargetType_IsValid(int value); +constexpr FieldOptions_OptionTargetType FieldOptions_OptionTargetType_OptionTargetType_MIN = static_cast(0); +constexpr FieldOptions_OptionTargetType FieldOptions_OptionTargetType_OptionTargetType_MAX = static_cast(9); +constexpr int FieldOptions_OptionTargetType_OptionTargetType_ARRAYSIZE = 9 + 1; +PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* +FieldOptions_OptionTargetType_descriptor(); +template +const std::string& FieldOptions_OptionTargetType_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to OptionTargetType_Name()."); + return FieldOptions_OptionTargetType_Name(static_cast(value)); +} +template <> +inline const std::string& FieldOptions_OptionTargetType_Name(FieldOptions_OptionTargetType value) { + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool FieldOptions_OptionTargetType_Parse(absl::string_view name, FieldOptions_OptionTargetType* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + FieldOptions_OptionTargetType_descriptor(), name, value); +} enum MethodOptions_IdempotencyLevel : int { MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN = 0, MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1, @@ -4662,6 +4727,55 @@ class PROTOBUF_EXPORT FieldOptions final : return FieldOptions_JSType_Parse(name, value); } + using OptionRetention = FieldOptions_OptionRetention; + static constexpr OptionRetention RETENTION_UNKNOWN = FieldOptions_OptionRetention_RETENTION_UNKNOWN; + static constexpr OptionRetention RETENTION_RUNTIME = FieldOptions_OptionRetention_RETENTION_RUNTIME; + static constexpr OptionRetention RETENTION_SOURCE = FieldOptions_OptionRetention_RETENTION_SOURCE; + static inline bool OptionRetention_IsValid(int value) { + return FieldOptions_OptionRetention_IsValid(value); + } + static constexpr OptionRetention OptionRetention_MIN = FieldOptions_OptionRetention_OptionRetention_MIN; + static constexpr OptionRetention OptionRetention_MAX = FieldOptions_OptionRetention_OptionRetention_MAX; + static constexpr int OptionRetention_ARRAYSIZE = FieldOptions_OptionRetention_OptionRetention_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* OptionRetention_descriptor() { + return FieldOptions_OptionRetention_descriptor(); + } + template + static inline const std::string& OptionRetention_Name(T value) { + return FieldOptions_OptionRetention_Name(value); + } + static inline bool OptionRetention_Parse(absl::string_view name, OptionRetention* value) { + return FieldOptions_OptionRetention_Parse(name, value); + } + + using OptionTargetType = FieldOptions_OptionTargetType; + static constexpr OptionTargetType TARGET_TYPE_UNKNOWN = FieldOptions_OptionTargetType_TARGET_TYPE_UNKNOWN; + static constexpr OptionTargetType TARGET_TYPE_FILE = FieldOptions_OptionTargetType_TARGET_TYPE_FILE; + static constexpr OptionTargetType TARGET_TYPE_EXTENSION_RANGE = FieldOptions_OptionTargetType_TARGET_TYPE_EXTENSION_RANGE; + static constexpr OptionTargetType TARGET_TYPE_MESSAGE = FieldOptions_OptionTargetType_TARGET_TYPE_MESSAGE; + static constexpr OptionTargetType TARGET_TYPE_FIELD = FieldOptions_OptionTargetType_TARGET_TYPE_FIELD; + static constexpr OptionTargetType TARGET_TYPE_ONEOF = FieldOptions_OptionTargetType_TARGET_TYPE_ONEOF; + static constexpr OptionTargetType TARGET_TYPE_ENUM = FieldOptions_OptionTargetType_TARGET_TYPE_ENUM; + static constexpr OptionTargetType TARGET_TYPE_ENUM_ENTRY = FieldOptions_OptionTargetType_TARGET_TYPE_ENUM_ENTRY; + static constexpr OptionTargetType TARGET_TYPE_SERVICE = FieldOptions_OptionTargetType_TARGET_TYPE_SERVICE; + static constexpr OptionTargetType TARGET_TYPE_METHOD = FieldOptions_OptionTargetType_TARGET_TYPE_METHOD; + static inline bool OptionTargetType_IsValid(int value) { + return FieldOptions_OptionTargetType_IsValid(value); + } + static constexpr OptionTargetType OptionTargetType_MIN = FieldOptions_OptionTargetType_OptionTargetType_MIN; + static constexpr OptionTargetType OptionTargetType_MAX = FieldOptions_OptionTargetType_OptionTargetType_MAX; + static constexpr int OptionTargetType_ARRAYSIZE = FieldOptions_OptionTargetType_OptionTargetType_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* OptionTargetType_descriptor() { + return FieldOptions_OptionTargetType_descriptor(); + } + template + static inline const std::string& OptionTargetType_Name(T value) { + return FieldOptions_OptionTargetType_Name(value); + } + static inline bool OptionTargetType_Parse(absl::string_view name, OptionTargetType* value) { + return FieldOptions_OptionTargetType_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { @@ -13917,6 +14031,18 @@ inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOpt return ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_descriptor(); } template <> +struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention>() { + return ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention_descriptor(); +} +template <> +struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType>() { + return ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType_descriptor(); +} +template <> struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel> : std::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel>() { diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index da8225f4ef8c..b6108d03b8f6 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -631,6 +631,32 @@ message FieldOptions { // formats, e.g. when the field contains sensitive credentials. optional bool debug_redact = 16 [default = false]; + // If set to RETENTION_SOURCE, the option will be omitted from the binary. + // Note: as of January 2023, support for this is in progress and does not yet + // have an effect (b/264593489). + enum OptionRetention { + RETENTION_UNKNOWN = 0; + RETENTION_RUNTIME = 1; + RETENTION_SOURCE = 2; + } + + // This indicates the types of entities that the field may apply to when used + // as an option. If it is unset, then the field may be freely used as an + // option on any kind of entity. Note: as of January 2023, support for this is + // in progress and does not yet have an effect (b/264593489). + enum OptionTargetType { + TARGET_TYPE_UNKNOWN = 0; + TARGET_TYPE_FILE = 1; + TARGET_TYPE_EXTENSION_RANGE = 2; + TARGET_TYPE_MESSAGE = 3; + TARGET_TYPE_FIELD = 4; + TARGET_TYPE_ONEOF = 5; + TARGET_TYPE_ENUM = 6; + TARGET_TYPE_ENUM_ENTRY = 7; + TARGET_TYPE_SERVICE = 8; + TARGET_TYPE_METHOD = 9; + } + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999;