The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

891 lines
38 KiB

Squashed 'third_party/upb/' changes from 382d5afc60..60607da72e 60607da72e Merge pull request #356 from haberman/codegen-uniquefiles 7a54a5f3d6 Split the code generators for .upb and .upbdefs. b10b02f66f Merge pull request #353 from haberman/small-fixes cd7c2d2701 Merge pull request #352 from haberman/large-field-number 10b355a6e0 A couple minor fixes. These are exercised by Ruby. 6c30b5fe73 Fixed upb encoder for field numbers > 2**28. 31b3528424 Merge pull request #350 from haberman/encode-depthlimit e9551022c1 Added depth limit checking to upb_encode(). f389384c5a Merge pull request #349 from lidizheng/json-public f72c26cbc4 Make :json publically visible 5797d95172 Merge pull request #348 from haberman/json-emit-defaults 7a17493269 Removed print debugging. 695b7f4617 Added code to test UPB_JSONENC_EMITDEFAULTS. 6b357607bd Fixed bugs in JSON encoding with UPB_JSONENC_EMITDEFAULTS. 1b08391979 Merge pull request #347 from haberman/filedef-symtab ee49a8d7df Added an accessor to get the symtab from a filedef. a81b47025a Merge pull request #345 from haberman/encode-skipunknown 6535cbe380 Merge pull request #346 from timgates42/bugfix_typo_position 7225108720 docs: fix simple typo, posisiton -> position 871ff96252 Test SKIPUNKNOWN on regular fields. 0569c22a1e Removed debug print. 76764643ac Added option to binary encoder to skip unknown fields. 794ce6d061 Merge pull request #344 from haberman/deterministic-serialize a04627abc8 Added map sorting to binary and text encoders. 3e071ea91a Merge pull request #343 from haberman/msvc e70e488e09 MSVC apparently doesn't support the standard C/C++ defines. 963e501aa6 Merge pull request #342 from haberman/fuzz 8d670d8aea Renamed decode_varint32() to decode_tag(). 9abf8e043f Clamp 32-bit varints to 5 bytes to fix a fuzz failure. 50a543de7f Merge pull request #341 from haberman/code-size 9c87f1168f Added size benchmark for CODE_SIZE. 6f82028236 Merge pull request #340 from haberman/darwin-setjmp 358fa14d0e Fixed headers and updated benchmark script. bc200451ce Use a macro instead of an inline function for setjmp/longjmp. ca279f8afa Merge branch 'master' into darwin-setjmp fbc0639b07 Use _setjmp on mac to avoid saving/restoring the signal mask. 10f0a38450 Merge pull request #337 from haberman/size-benchmarks 4be07a2dce Increase build timeout until we can parallelize the build. 378a27b640 Force "size" to run locally. da48e01f05 More google3 fixes. d2446fd2db Moved cc_api_version attribute to proto_library(). 4a84390c89 Added cc_proto_library() tweaks for google3. 4dd4212a34 Merge branch 'master' into size-benchmarks ffecfef161 Merge branch 'master' into size-benchmarks 86f671d5fd Fix for Darwin (output is different, but it won't error out). 165e01ec6f Fix for old Python versions. 40fdff5e43 Merge pull request #339 from haberman/benchmark-alias 5f8bb5de1d Updated generated code. 65d166a6ba Added API for copy vs. alias and added benchmarks to test both. 27b9c999a7 Merge pull request #338 from haberman/arena-initial 9df96874e9 Start arena block doubling at initial block size. 881ddac7fe Also use .format() for gen_synthetic_protos.py. 8b7dabe1a2 Use format() instead of string interpolation, for old Python versions. 8e08282c3b Removed unused small.proto. 0f79d47215 Added missing lite binaries to size_data.txt. 555fbbc0bc Size benchmarks are working pretty well. 85cbc41a89 Merge branch 'master' into size-benchmarks e5bdfba92c Removed accidentally-added .orig file. 07851fac58 Merge pull request #336 from haberman/fuzz 982b634bc5 Fixed a few minor bugs found by fuzzing. c9d2e58480 Merge pull request #310 from haberman/fast-table a01f3e23a4 Fixes for google3 build, and exclude even more tests from macOS to avoid timeout. a83d55ee4b Exclude Clang tests from MacOS to avoid Kokoro timeouts. 73fcfe9ed0 Tried to slim down the tests a bit more. baab25b7aa Removed excess/redundant tests from Kokoro script. 1eb7bd39e7 Some formatting fixes. 9d87055ce4 Updated Kokoro build script. 4bd34da105 WIP. a7993615bf Merge branch 'master' into fast-table 3a3efe69a2 Added incompatible_use_toolchain_transition = True per https://github.com/bazelbuild/bazel/issues/11584 7b4e376f79 Switch unordered_set -> absl::flat_hash_set. fe62fc83e1 Removed obsolete includes in benchmark. 5ed089dc42 Merge pull request #335 from haberman/wyhash-rule e9b79542ad Added a BUILD file for wyhash. 7b8ae7ec4e Merge branch 'master' into size-benchmarks a5b5445da6 Merge pull request #334 from haberman/rm-port-c 6c16cba83f Removed obsolete port.c file. 484d8f746a Updated comment in wyhash.h to correct spelling mistake. 6a9d0f45b8 Merge pull request #333 from haberman/32bitfixes 5b1f0d86a1 For Kokoro, only build/test -m32 on Linux. 0497f8deed Fixed a critical bug on 32-bit builds, and added much more Kokoro testing. 7543f851f1 Merge pull request #332 from haberman/php-amalgamation 64abb5eb11 Amalgamation no longer bundles wyhash, but #includes it. a2a40792b5 Merge pull request #331 from haberman/json-oneof-fix dd0994d377 Bugfix for JSON decoding: only check real oneofs for duplicates. 496f638025 Merge pull request #330 from haberman/symtab-longjmp c9f9668234 symtab: use longjmp() for errors and avoid intermediate table. 4d9a8cd67b Merge branch 'master' into symtab-longjmp 6322d1d72d Merge pull request #329 from haberman/benchmark-ads-descriptor 5ec1d39224 Avoid building .pb.cc for ads protos, as C++ takes forever to compile. 43c207ea7e Added CMake dummy rule. c3b5637646 Added benchmark for loading ads descriptor. acd72c6d3f WIP. 6ae3b66cd2 Merge pull request #328 from haberman/optdefload 8113ebd6c7 Added explanatory comment about integer constants. f2d826b9f3 Got rid of floating-point division in table init. 723cd8ffc1 Added wyhash code and LICENSE, and removed temporary benchmark. 15e20636c3 Merge branch 'master' into optdefload 154f2c25f4 Added UTF-8 validation for proto3 string fields. e8f9eac68c Added #defines UPB_ENABLE_FASTTABLE and UPB_TRY_ENABLE_FASTTABLE. 994cf07cf3 Merge pull request #327 from benjaminp/modern-linking b5bd5807a7 Migrate to modern Starlark linking api. dc64613607 Merge branch 'fastest-table' into fast-table e86541ac1d Fixed the build after the merge. 1cd0cb17d3 Merge branch 'master' into fastest-table 901744a97e Merge pull request #326 from haberman/c99 a0d16e7073 Added a few missing copts, and made some functions proper prototypes. 558315a1c3 Added COPTS to :port. 7e5bd65098 Plumbed copts (including the crucial -std=c99) to upb_proto_library() aspect. 8f3ee80d46 Drop C89/C90 support and MSVC prior to Visual Studio 2015. a274ad786a Plumbed copts (including the crucial -std=c99) to upb_proto_library() aspect. 2c8bb6dd9d Specify C99 explicitly until/unless we stop using bool. efd576b698 Added -std=gnu99 for fastdecode and ran Buildifier. b928696942 A few more fixes, and test fastdecode under Kokoro. 55f3569cd2 A few minor fixes and more assertions. 8b38e8f214 Merge branch 'fastest-table' into fast-table 46eb82467a Added comment to decode_fast.h. bd9f8f580d Fixed a few bugs with the fast decoder. 3eba47914b Allocate hasbits and table slots in "hotness" order. 021db6fcd5 Allow larger tags into the table if they are unique mod 31. 86d9908c55 Fastdecode support for packed fields. e3e797b680 Added fasttable support for oneofs. 7ffa9c181a Fixed some small bugs and performance problems in string copying. e2c709e047 Repeated string and primitive support. e9103eda9e Merge branch 'master' into fastest-table 0756999ab6 Merge pull request #325 from haberman/inlined-arena 25db40bc30 Fixed upb::InlinedArena, which was compeltely broken. d81ba58215 Optimized short string copying. f3a2a79349 More optimization, back up to 2.56GB/s. 199c914295 Simplify push/pop when msg fits in the current buffer. d5f5db2729 Put string-copying field parser into a separate function. 883f20d4dc Merge branch 'master' into fastest-table 1bd62e8218 Merge pull request #324 from haberman/simplemomi f4adbe0698 Optimized varint decoding from Gerben. 48689df72e Eliminated bounds checks inside parsing a field. a345af9883 Added a codegen parameter for whether fasttables are generated or not. 8a3470c543 WIP. 8e8dbb5258 Merge branch 'fastest-table' into fast-table 7d17a0e8c5 Merge branch 'master' into fastest-table a7e2e8338d Fixed benchmark script. 72de7b7002 Merge branch 'fastest-table' into fast-table cb234e652c Merge branch 'master' into fastest-table b86cf2d789 Merge pull request #323 from haberman/build-files 4ea81ab107 Fixed pedantic warning. 6399b31f4b Removed ULL constants in json_decode.c. c8ae197e64 Removed "U" suffixes, they are not necessary. bc1e0b314f Fixed some strict C89 errors. 2c1664906a Removed license comments and upb_amalgamation for google3. b7dc77415a Added licenses() to all BUILD files. de22764b33 Updated Kokoro to test ... instead of :all. e3f41de6c7 Split monolithic BUILD file into many build files. fbe2bcafbc Merge pull request #4 from gerben-s/gerbens-fast-table 9e68ec033f Add repeated varints and fixed parsers d0e4b688c6 Shorten name of kAliasString, so benchmark results don't wrap. c0c9b5a168 Regenerated generated code. eb8e6de8b7 Regenerated source files. 7f0d535826 Merge branch 'fastest-table' into fast-table bf8e08074c Added a few more comments. 6e3c22e6ee Merge branch 'fastest-table' into fast-table 3238821315 Gave fast table entry a nicer name. 2a574d3d01 Added a bunch of comments for readability. 0deca8b8fb Merge branch 'master' into fast-table bfadc99709 Merge branch 'master' into fastest-table 84e0f6127d Merge branch 'master' into fastest-table 61c51a607b Merge branch 'master' into fast-table 4f066765a9 Merge pull request #320 from haberman/string-view-benchmark bf393bf086 Cleaned up benchmark names. 9eb8414b31 Added descriptor_sv.proto. ee7da95367 Bzl formatting fix per buildifier. de1b6b0718 Refactored proto2 benchmarks and added StringView benchmark. c2901eeee1 Added missing #includes (caught by Blaze). 52721eadc7 Order LargeInitialBlock after non-initial-block test. 44a7130845 Used the correct copy of the protos in the benchmark. 3a242e7a48 Merge branch 'master' into fast-table d01b712dbb Merge branch 'master' into fastest-table d225dfc2ed Buildifier formatting fixes. b0994a6501 Added missing dep from benchmark. de80054018 Make required fields optional for benchmarking. 745661bf1f Merge branch 'master' into fastest-table 11585095b7 Merge pull request #319 from haberman/copy-descriptor fd5a35d49d Minor comment changes. bdd1a516e8 Fixed other tests. 27262adf93 Snapshot descriptor.proto into our own copy for benchmarking purposes. d6b40fd5e2 Added missing dependency on reflection. b9f1b67d07 Use quoted include. 1c8c16b9b1 Use quoted include. 4f901b6430 Passes all tests. de84e20788 Merge branch 'master' into optdefload d5c64476fd Merge pull request #318 from haberman/descriptor-load-benchmark 42d2f6cef9 Add MB/s measures in the benchmarks. 1ce98b86ec Added LoadDescriptor benchmark for proto2. 4890735ce2 Added benchmark for descriptor loading. 6f59f1256e Optimizations to descriptor loading. 6874d61704 Merge pull request #317 from haberman/gencode-compat c81113e60f Added fallback code for when no enum matches. c10b24ffb2 Simplified switch(). ded2e657a7 Added compatibility with old generated code. 5b0c5c7d4a Dispatch inline. 75edd3e59c Changed to use table pairs, seems to ever-so-slightly regress. 69d99a247e Merge pull request #3 from haberman/shifted-table bca7edac8c Cleaned up table compression a bit. b95f217996 A little speed boost, now hitting 2.51GB/s. 8ed6b2fe85 Stored mask in the table pointer. a6dc88556d Tables are compressed, but perf goes down to 2.44GB/s. 91eb09b1bc Add a few comments. 7a1835d7c3 Merge branch 'master' into fast-table 8bd5c0088e Merge pull request #316 from haberman/submsg-array a4966fd230 Added a few extra sanity checks. 99acbe0da8 Fixed bug where submsg array could have excess elements. 2a0425ecf5 Merge pull request #315 from haberman/conformance-fixes 7ccf5650c7 If we encounter "null" for a non-NullValue enum, throw an error. 0a3a94a12f Updated to a new version of protobuf and fixed a few conformance tests. ddd5f28c4f Merge branch 'is_bazel' 10fa3a0c77 Merge pull request #314 from haberman/addunknown 504e105420 undef UPB_ASAN. ab96d1ec41 Removed extraneous C++-style comment. d5096f9ee8 Fixed bug in addunknown and added ASAN poisoning. 6fe84526be Mark _is_bazel to be replace in google3. f01efe8b64 Removed another C99-ism. 1749082bbb Removed C99-ism. 147e363f56 Merge branch 'master' into fast-table f2ddc15d76 Bugfix: initialize fastlimit and fastend. 65e49b694b Merge branch 'gerben-fast-table' into fast-table 1abf7d418d Added generated files. 3f719fa6b2 Bugfix: offsetting hasbits with 16 introduced a bug in calculating hasmasks. Removing extra <<16 shift in hasmask calculating and masking out the first 16 bits. This makes messages without hasbits work as well. aec762e405 Merge branch 'master' into fast-table 4f77aaafd8 Merge pull request #2 from gerben-s/fast-table 4053805759 Bugfixes d1cd80385b Merge pull request #313 from haberman/inline-arena ad21083623 Merge pull request #313 from haberman/inline-arena 2339fc779c Updated obsolete comment. b393849bbd Updated obsolete comment. ebe53f8590 Fixed compile error. b37f82b58b Fixed compile error. 71749b7caf Implemented inline array allocation, and moved type->lg2 map to reflection. 9557b97acc Implemented inline array allocation, and moved type->lg2 map to reflection. b58d2a0ee6 Shrink overhead of message representation. 0bf063a2ca Shrink overhead of message representation. d87ceeacab Shave off one more store. ddc52ab9d6 Shave off one more store. c25d895adf Shrunk the arena state that needs to be synced. 7f67f68c1c Shrunk the arena state that needs to be synced. ff40dd6ea9 Added new internal header. 85a43e5461 Added new internal header. 36662b3735 Refactor some code. I extracted some common code from all message field parsers, to a tail recursive function. Removed the varint jmp table for a simple varint parse loop, that removes the stack frames. Also careful with not losing information in repeated message tag check. When written mindful the checks and loads that happen can be reused for tag dispatch if not the expected tag. cbcd635917 Fixed memory leak. bcbcdadbd2 Fixed memory leak. e5264bd794 Merge pull request #312 from haberman/defiter 52957fa984 Merge pull request #312 from haberman/defiter 746f64692c Moved arena inline for decoder. 7363b91ac3 Moved arena inline for decoder. b8ef1dcc57 Removed C++-style comments. 575acd85bd Re-added const for all of the pointer wrapper types. 5aa5b77b41 Added simple offset-based accessors for defs, and deprecated old iterators. 33384301e2 Merge pull request #311 from haberman/proto2-benchmark2 578e7c1f4c Merge pull request #311 from haberman/proto2-benchmark2 bc301e7da4 Use merge/partial variants to give proto2 benchmark the fairest hearing. 30f01afa83 Added LargeInitialBlock test for proto2. 5d23fd99af Used shorter protobuf:: namespace alias. 9938cf8f27 Put submsg_index directly in table data. Drop oneof support for now to focus. d87179501d Another build fix. 89bd8b87e1 Fixed a few more C89 compat issues. 64d293894a Fixed bug introduced by last optimization. ff957b996c Fixed C89 compat issues. 537b6f42c2 A few updates to the benchamrk and minor implementation changes. 0dcc5641eb Replicated dispatch and implemeted array resizing logic. Up to 2.67GB/s. 526e430794 I think this may have reached the optimization limit. 4c65b25daf Handle long varints, now 2GB/s! e39ec95ca2 Hoisted updates to limits and depth out of the loop. 52a0ed3891 Fixed a bug with tag number 15. 388b6f64eb A small optimization: don't increment array length every iteration. 9e5c5ce089 Optimized memset() with cutoff and fixed group & unknown message bugs. 8dd7b5a2ca A bunch more optimization. e46e94ec7f Added benchmarks for proto2. 405e7934b1 Handle 2-byte submessage lengths. 88b1ec7784 Table-driven supports repeated sub-messages. f173642db4 Handle non-repeated submessages. e219a2d91d Merge branch 'decode-arena' into fast-table 7ec2c52346 Donate/steal from arena to accelerate decoding. d43ccfa079 Revert test changes. fac992db83 Cleanup for showing. 3937874a85 We have a properly structured algorithm, but perf regresses by 20%. 438ecaeb5a Give all field parsers a generic table entry. 383ae5293e WIP. 26abaa2345 WIP. 34b98bc030 Avoid passing too many params to fallback. 763a3f6293 WIP. 02ff6fb996 Merge pull request #309 from haberman/decoder-forceinline a202ce9629 Add UPB_FORCEINLINE for varint32 decoding. d0f2c4c8a2 Merge pull request #308 from haberman/encoder 5741eb9ad7 Expanded benchmarking script and added one size opt to the encoder. 0135399e60 Fixed bug introduced in refactoring. df3438222b Notated impossible branch as unreachable. 9b31e8fe12 Merged common encode tag paths. 5d7dc718cc Minor formatting fix. 80441e4eb4 Optimized binary encoder. ada28896b9 Changed encoder to use longjmp() for error recovery. 6e140c267c Added benchmark for encoding. 7338facddb Merge pull request #307 from veblush/port-backport 4d2251c3e4 Add UPB_NORETURN for MSC git-subtree-dir: third_party/upb git-subtree-split: 60607da72e89ba0c84c84054d2e562d8b6b61177
4 years ago
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// The messages in this file describe the definitions found in .proto files.
// A valid .proto file can be translated directly to a FileDescriptorProto
// without any other information (e.g. without reading its imports).
syntax = "proto2";
package upb_benchmark.sv;
option go_package = "google.golang.org/protobuf/types/descriptorpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection";
option objc_class_prefix = "GPB";
option cc_enable_arenas = true;
// The protocol compiler can output a FileDescriptorSet containing the .proto
// files it parses.
message FileDescriptorSet {
repeated FileDescriptorProto file = 1;
}
// Describes a complete .proto file.
message FileDescriptorProto {
optional string name = 1
[ctype = STRING_PIECE]; // file name, relative to root of source tree
optional string package = 2
[ctype = STRING_PIECE]; // e.g. "foo", "foo.bar", etc.
// Names of files imported by this file.
repeated string dependency = 3 [ctype = STRING_PIECE];
// Indexes of the public imported files in the dependency list above.
repeated int32 public_dependency = 10;
// Indexes of the weak imported files in the dependency list.
// For Google-internal migration only. Do not use.
repeated int32 weak_dependency = 11;
// All top-level definitions in this file.
repeated DescriptorProto message_type = 4;
repeated EnumDescriptorProto enum_type = 5;
repeated ServiceDescriptorProto service = 6;
repeated FieldDescriptorProto extension = 7;
optional FileOptions options = 8;
// This field contains optional information about the original source code.
// You may safely remove this entire field without harming runtime
// functionality of the descriptors -- the information is needed only by
// development tools.
optional SourceCodeInfo source_code_info = 9;
// The syntax of the proto file.
// The supported values are "proto2" and "proto3".
optional string syntax = 12 [ctype = STRING_PIECE];
}
// Describes a message type.
message DescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
repeated FieldDescriptorProto field = 2;
repeated FieldDescriptorProto extension = 6;
repeated DescriptorProto nested_type = 3;
repeated EnumDescriptorProto enum_type = 4;
message ExtensionRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Exclusive.
optional ExtensionRangeOptions options = 3;
}
repeated ExtensionRange extension_range = 5;
repeated OneofDescriptorProto oneof_decl = 8;
optional MessageOptions options = 7;
// Range of reserved tag numbers. Reserved tag numbers may not be used by
// fields or extension ranges in the same message. Reserved ranges may
// not overlap.
message ReservedRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Exclusive.
}
repeated ReservedRange reserved_range = 9;
// Reserved field names, which may not be used by fields in the same message.
// A given name may only be reserved once.
repeated string reserved_name = 10 [ctype = STRING_PIECE];
}
message ExtensionRangeOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// Describes a field within a message.
message FieldDescriptorProto {
enum Type {
// 0 is reserved for errors.
// Order is weird for historical reasons.
TYPE_DOUBLE = 1;
TYPE_FLOAT = 2;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
// negative values are likely.
TYPE_INT64 = 3;
TYPE_UINT64 = 4;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
// negative values are likely.
TYPE_INT32 = 5;
TYPE_FIXED64 = 6;
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
// Tag-delimited aggregate.
// Group type is deprecated and not supported in proto3. However, Proto3
// implementations should still be able to parse the group wire format and
// treat group fields as unknown fields.
TYPE_GROUP = 10;
TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2.
TYPE_BYTES = 12;
TYPE_UINT32 = 13;
TYPE_ENUM = 14;
TYPE_SFIXED32 = 15;
TYPE_SFIXED64 = 16;
TYPE_SINT32 = 17; // Uses ZigZag encoding.
TYPE_SINT64 = 18; // Uses ZigZag encoding.
}
enum Label {
// 0 is reserved for errors
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
}
optional string name = 1 [ctype = STRING_PIECE];
optional int32 number = 3;
optional Label label = 4;
// If type_name is set, this need not be set. If both this and type_name
// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
optional Type type = 5;
// For message and enum types, this is the name of the type. If the name
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
// rules are used to find the type (i.e. first the nested types within this
// message are searched, then within the parent, on up to the root
// namespace).
optional string type_name = 6 [ctype = STRING_PIECE];
// For extensions, this is the name of the type being extended. It is
// resolved in the same manner as type_name.
optional string extendee = 2 [ctype = STRING_PIECE];
// For numeric types, contains the original text representation of the value.
// For booleans, "true" or "false".
// For strings, contains the default text contents (not escaped in any way).
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
// TODO(kenton): Base-64 encode?
optional string default_value = 7 [ctype = STRING_PIECE];
// If set, gives the index of a oneof in the containing type's oneof_decl
// list. This field is a member of that oneof.
optional int32 oneof_index = 9;
// JSON name of this field. The value is set by protocol compiler. If the
// user has set a "json_name" option on this field, that option's value
// will be used. Otherwise, it's deduced from the field's name by converting
// it to camelCase.
optional string json_name = 10 [ctype = STRING_PIECE];
optional FieldOptions options = 8;
// If true, this is a proto3 "optional". When a proto3 field is optional, it
// tracks presence regardless of field type.
//
// When proto3_optional is true, this field must be belong to a oneof to
// signal to old proto3 clients that presence is tracked for this field. This
// oneof is known as a "synthetic" oneof, and this field must be its sole
// member (each proto3 optional field gets its own synthetic oneof). Synthetic
// oneofs exist in the descriptor only, and do not generate any API. Synthetic
// oneofs must be ordered after all "real" oneofs.
//
// For message fields, proto3_optional doesn't create any semantic change,
// since non-repeated message fields always track presence. However it still
// indicates the semantic detail of whether the user wrote "optional" or not.
// This can be useful for round-tripping the .proto file. For consistency we
// give message fields a synthetic oneof also, even though it is not required
// to track presence. This is especially important because the parser can't
// tell if a field is a message or an enum, so it must always create a
// synthetic oneof.
//
// Proto2 optional fields do not set this flag, because they already indicate
// optional with `LABEL_OPTIONAL`.
optional bool proto3_optional = 17;
}
// Describes a oneof.
message OneofDescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
optional OneofOptions options = 2;
}
// Describes an enum type.
message EnumDescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
repeated EnumValueDescriptorProto value = 2;
optional EnumOptions options = 3;
// Range of reserved numeric values. Reserved values may not be used by
// entries in the same enum. Reserved ranges may not overlap.
//
// Note that this is distinct from DescriptorProto.ReservedRange in that it
// is inclusive such that it can appropriately represent the entire int32
// domain.
message EnumReservedRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Inclusive.
}
// Range of reserved numeric values. Reserved numeric values may not be used
// by enum values in the same enum declaration. Reserved ranges may not
// overlap.
repeated EnumReservedRange reserved_range = 4;
// Reserved enum value names, which may not be reused. A given name may only
// be reserved once.
repeated string reserved_name = 5 [ctype = STRING_PIECE];
}
// Describes a value within an enum.
message EnumValueDescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
optional int32 number = 2;
optional EnumValueOptions options = 3;
}
// Describes a service.
message ServiceDescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
repeated MethodDescriptorProto method = 2;
optional ServiceOptions options = 3;
}
// Describes a method of a service.
message MethodDescriptorProto {
optional string name = 1 [ctype = STRING_PIECE];
// Input and output type names. These are resolved in the same way as
// FieldDescriptorProto.type_name, but must refer to a message type.
optional string input_type = 2 [ctype = STRING_PIECE];
optional string output_type = 3 [ctype = STRING_PIECE];
optional MethodOptions options = 4;
// Identifies if client streams multiple client messages
optional bool client_streaming = 5 [default = false];
// Identifies if server streams multiple server messages
optional bool server_streaming = 6 [default = false];
}
// ===================================================================
// Options
// Each of the definitions above may have "options" attached. These are
// just annotations which may cause code to be generated slightly differently
// or may contain hints for code that manipulates protocol messages.
//
// Clients may define custom options as extensions of the *Options messages.
// These extensions may not yet be known at parsing time, so the parser cannot
// store the values in them. Instead it stores them in a field in the *Options
// message called uninterpreted_option. This field must have the same name
// across all *Options messages. We then use this field to populate the
// extensions when we build a descriptor, at which point all protos have been
// parsed and so all extensions are known.
//
// Extension numbers for custom options may be chosen as follows:
// * For options which will only be used within a single application or
// organization, or for experimental options, use field numbers 50000
// through 99999. It is up to you to ensure that you do not use the
// same number for multiple options.
// * For options which will be published and used publicly by multiple
// independent entities, e-mail protobuf-global-extension-registry@google.com
// to reserve extension numbers. Simply provide your project name (e.g.
// Objective-C plugin) and your project website (if available) -- there's no
// need to explain how you intend to use them. Usually you only need one
// extension number. You can declare multiple options with only one extension
// number by putting them in a sub-message. See the Custom Options section of
// the docs for examples:
// https://developers.google.com/protocol-buffers/docs/proto#options
// If this turns out to be popular, a web service will be set up
// to automatically assign option numbers.
message FileOptions {
// Sets the Java package where classes generated from this .proto will be
// placed. By default, the proto package is used, but this is often
// inappropriate because proto packages do not normally start with backwards
// domain names.
optional string java_package = 1 [ctype = STRING_PIECE];
// If set, all the classes from the .proto file are wrapped in a single
// outer class with the given name. This applies to both Proto1
// (equivalent to the old "--one_java_file" option) and Proto2 (where
// a .proto always translates to a single class, but you may want to
// explicitly choose the class name).
optional string java_outer_classname = 8 [ctype = STRING_PIECE];
// If set true, then the Java code generator will generate a separate .java
// file for each top-level message, enum, and service defined in the .proto
// file. Thus, these types will *not* be nested inside the outer class
// named by java_outer_classname. However, the outer class will still be
// generated to contain the file's getDescriptor() method as well as any
// top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default = false];
// This option does nothing.
optional bool java_generate_equals_and_hash = 20 [deprecated = true];
// If set true, then the Java2 code generator will generate code that
// throws an exception whenever an attempt is made to assign a non-UTF-8
// byte sequence to a string field.
// Message reflection will do the same.
// However, an extension field still accepts non-UTF-8 byte sequences.
// This option has no effect on when used with the lite runtime.
optional bool java_string_check_utf8 = 27 [default = false];
// Generated classes can be optimized for speed or code size.
enum OptimizeMode {
SPEED = 1; // Generate complete code for parsing, serialization,
// etc.
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
}
optional OptimizeMode optimize_for = 9 [default = SPEED];
// Sets the Go package where structs generated from this .proto will be
// placed. If omitted, the Go package will be derived from the following:
// - The basename of the package import path, if provided.
// - Otherwise, the package statement in the .proto file, if present.
// - Otherwise, the basename of the .proto file, without extension.
optional string go_package = 11 [ctype = STRING_PIECE];
// Should generic services be generated in each language? "Generic" services
// are not specific to any particular RPC system. They are generated by the
// main code generators in each language (without additional plugins).
// Generic services were the only kind of service generation supported by
// early versions of google.protobuf.
//
// Generic services are now considered deprecated in favor of using plugins
// that generate code specific to your particular RPC system. Therefore,
// these default to false. Old code which depends on generic services should
// explicitly set them to true.
optional bool cc_generic_services = 16 [default = false];
optional bool java_generic_services = 17 [default = false];
optional bool py_generic_services = 18 [default = false];
optional bool php_generic_services = 42 [default = false];
// Is this file deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for everything in the file, or it will be completely ignored; in the very
// least, this is a formalization for deprecating files.
optional bool deprecated = 23 [default = false];
// Enables the use of arenas for the proto messages in this file. This applies
// only to generated classes for C++.
optional bool cc_enable_arenas = 31 [default = true];
// Sets the objective c class prefix which is prepended to all objective c
// generated classes from this .proto. There is no default.
optional string objc_class_prefix = 36 [ctype = STRING_PIECE];
// Namespace for generated classes; defaults to the package.
optional string csharp_namespace = 37 [ctype = STRING_PIECE];
// By default Swift generators will take the proto package and CamelCase it
// replacing '.' with underscore and use that to prefix the types/symbols
// defined. When this options is provided, they will use this value instead
// to prefix the types/symbols defined.
optional string swift_prefix = 39 [ctype = STRING_PIECE];
// Sets the php class prefix which is prepended to all php generated classes
// from this .proto. Default is empty.
optional string php_class_prefix = 40 [ctype = STRING_PIECE];
// Use this option to change the namespace of php generated classes. Default
// is empty. When this option is empty, the package name will be used for
// determining the namespace.
optional string php_namespace = 41 [ctype = STRING_PIECE];
// Use this option to change the namespace of php generated metadata classes.
// Default is empty. When this option is empty, the proto file name will be
// used for determining the namespace.
optional string php_metadata_namespace = 44 [ctype = STRING_PIECE];
// Use this option to change the package of ruby generated classes. Default
// is empty. When this option is not set, the package name will be used for
// determining the ruby package.
optional string ruby_package = 45 [ctype = STRING_PIECE];
// The parser stores options it doesn't recognize here.
// See the documentation for the "Options" section above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message.
// See the documentation for the "Options" section above.
extensions 1000 to max;
reserved 38;
}
message MessageOptions {
// Set true to use the old proto1 MessageSet wire format for extensions.
// This is provided for backwards-compatibility with the MessageSet wire
// format. You should not use this for any other reason: It's less
// efficient, has fewer features, and is more complicated.
//
// The message must be defined exactly as follows:
// message Foo {
// option message_set_wire_format = true;
// extensions 4 to max;
// }
// Note that the message cannot have any defined fields; MessageSets only
// have extensions.
//
// All extensions of your type must be singular messages; e.g. they cannot
// be int32s, enums, or repeated messages.
//
// Because this is an option, the above two restrictions are not enforced by
// the protocol compiler.
optional bool message_set_wire_format = 1 [default = false];
// Disables the generation of the standard "descriptor()" accessor, which can
// conflict with a field of the same name. This is meant to make migration
// from proto1 easier; new code should avoid fields named "descriptor".
optional bool no_standard_descriptor_accessor = 2 [default = false];
// Is this message deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the message, or it will be completely ignored; in the very least,
// this is a formalization for deprecating messages.
optional bool deprecated = 3 [default = false];
// Whether the message is an automatically generated map entry type for the
// maps field.
//
// For maps fields:
// map<KeyType, ValueType> map_field = 1;
// The parsed descriptor looks like:
// message MapFieldEntry {
// option map_entry = true;
// optional KeyType key = 1;
// optional ValueType value = 2;
// }
// repeated MapFieldEntry map_field = 1;
//
// Implementations may choose not to generate the map_entry=true message, but
// use a native map in the target language to hold the keys and values.
// The reflection APIs in such implementations still need to work as
// if the field is a repeated message field.
//
// NOTE: Do not set the option in .proto files. Always use the maps syntax
// instead. The option should only be implicitly set by the proto compiler
// parser.
optional bool map_entry = 7;
reserved 8; // javalite_serializable
reserved 9; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message FieldOptions {
// The ctype option instructs the C++ code generator to use a different
// representation of the field than it normally would. See the specific
// options below. This option is not yet implemented in the open source
// release -- sorry, we'll try to include it in a future version!
optional CType ctype = 1 [default = STRING];
enum CType {
// Default mode.
STRING = 0;
CORD = 1;
STRING_PIECE = 2;
}
// The packed option can be enabled for repeated primitive fields to enable
// a more efficient representation on the wire. Rather than repeatedly
// writing the tag and type for each element, the entire array is encoded as
// a single length-delimited blob. In proto3, only explicit setting it to
// false will avoid using packed encoding.
optional bool packed = 2;
// The jstype option determines the JavaScript type used for values of the
// field. The option is permitted only for 64 bit integral and fixed types
// (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
// is represented as JavaScript string, which avoids loss of precision that
// can happen when a large value is converted to a floating point JavaScript.
// Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
// use the JavaScript "number" type. The behavior of the default option
// JS_NORMAL is implementation dependent.
//
// This option is an enum to permit additional types to be added, e.g.
// goog.math.Integer.
optional JSType jstype = 6 [default = JS_NORMAL];
enum JSType {
// Use the default type.
JS_NORMAL = 0;
// Use JavaScript strings.
JS_STRING = 1;
// Use JavaScript numbers.
JS_NUMBER = 2;
}
// Should this field be parsed lazily? Lazy applies only to message-type
// fields. It means that when the outer message is initially parsed, the
// inner message's contents will not be parsed but instead stored in encoded
// form. The inner message will actually be parsed when it is first accessed.
//
// This is only a hint. Implementations are free to choose whether to use
// eager or lazy parsing regardless of the value of this option. However,
// setting this option true suggests that the protocol author believes that
// using lazy parsing on this field is worth the additional bookkeeping
// overhead typically needed to implement it.
//
// This option does not affect the public interface of any generated code;
// all method signatures remain the same. Furthermore, thread-safety of the
// interface is not affected by this option; const methods remain safe to
// call from multiple threads concurrently, while non-const methods continue
// to require exclusive access.
//
//
// Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outer message
// may return true even if the inner message has missing required fields.
// This is necessary because otherwise the inner message would have to be
// parsed in order to perform the check, defeating the purpose of lazy
// parsing. An implementation which chooses not to check required fields
// must be consistent about it. That is, for any particular sub-message, the
// implementation must either *always* check its required fields, or *never*
// check its required fields, regardless of whether or not the message has
// been parsed.
optional bool lazy = 5 [default = false];
// Is this field deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for accessors, or it will be completely ignored; in the very least, this
// is a formalization for deprecating fields.
optional bool deprecated = 3 [default = false];
// For Google-internal migration only. Do not use.
optional bool weak = 10 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
reserved 4; // removed jtype
}
message OneofOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumOptions {
// Set this option to true to allow mapping different tag names to the same
// value.
optional bool allow_alias = 2;
// Is this enum deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum, or it will be completely ignored; in the very least, this
// is a formalization for deprecating enums.
optional bool deprecated = 3 [default = false];
reserved 5; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumValueOptions {
// Is this enum value deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum value, or it will be completely ignored; in the very least,
// this is a formalization for deprecating enum values.
optional bool deprecated = 1 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message ServiceOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this service deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the service, or it will be completely ignored; in the very least,
// this is a formalization for deprecating services.
optional bool deprecated = 33 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message MethodOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this method deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the method, or it will be completely ignored; in the very least,
// this is a formalization for deprecating methods.
optional bool deprecated = 33 [default = false];
// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
// or neither? HTTP based RPC implementation may choose GET verb for safe
// methods, and PUT verb for idempotent methods instead of the default POST.
enum IdempotencyLevel {
IDEMPOTENCY_UNKNOWN = 0;
NO_SIDE_EFFECTS = 1; // implies idempotent
IDEMPOTENT = 2; // idempotent, but may have side effects
}
optional IdempotencyLevel idempotency_level = 34
[default = IDEMPOTENCY_UNKNOWN];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// A message representing a option the parser does not recognize. This only
// appears in options protos created by the compiler::Parser class.
// DescriptorPool resolves these when building Descriptor objects. Therefore,
// options protos in descriptor objects (e.g. returned by Descriptor::options(),
// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
// in them.
message UninterpretedOption {
// The name of the uninterpreted option. Each string represents a segment in
// a dot-separated name. is_extension is true iff a segment represents an
// extension (denoted with parentheses in options specs in .proto files).
// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
// "foo.(bar.baz).qux".
message NamePart {
optional string name_part = 1 [ctype = STRING_PIECE];
optional bool is_extension = 2;
}
repeated NamePart name = 2;
// The value of the uninterpreted option, in whatever type the tokenizer
// identified it as during parsing. Exactly one of these should be set.
optional string identifier_value = 3 [ctype = STRING_PIECE];
optional uint64 positive_int_value = 4;
optional int64 negative_int_value = 5;
optional double double_value = 6;
optional bytes string_value = 7;
optional string aggregate_value = 8 [ctype = STRING_PIECE];
}
// ===================================================================
// Optional source code info
// Encapsulates information about the original source file from which a
// FileDescriptorProto was generated.
message SourceCodeInfo {
// A Location identifies a piece of source code in a .proto file which
// corresponds to a particular definition. This information is intended
// to be useful to IDEs, code indexers, documentation generators, and similar
// tools.
//
// For example, say we have a file like:
// message Foo {
// optional string foo = 1 [ctype = STRING_PIECE];
// }
// Let's look at just the field definition:
// optional string foo = 1 [ctype = STRING_PIECE];
// ^ ^^ ^^ ^ ^^^
// a bc de f ghi
// We have the following locations:
// span path represents
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
//
// Notes:
// - A location may refer to a repeated field itself (i.e. not to any
// particular index within it). This is used whenever a set of elements are
// logically enclosed in a single code segment. For example, an entire
// extend block (possibly containing multiple extension definitions) will
// have an outer location whose path refers to the "extensions" repeated
// field without an index.
// - Multiple locations may have the same path. This happens when a single
// logical declaration is spread out across multiple places. The most
// obvious example is the "extend" block again -- there may be multiple
// extend blocks in the same scope, each of which will have the same path.
// - A location's span is not always a subset of its parent's span. For
// example, the "extendee" of an extension declaration appears at the
// beginning of the "extend" block and is shared by all extensions within
// the block.
// - Just because a location's span is a subset of some other location's span
// does not mean that it is a descendant. For example, a "group" defines
// both a type and a field in a single declaration. Thus, the locations
// corresponding to the type and field and their components will overlap.
// - Code which tries to interpret locations should probably be designed to
// ignore those that it doesn't understand, as more types of locations could
// be recorded in the future.
repeated Location location = 1;
message Location {
// Identifies which part of the FileDescriptorProto was defined at this
// location.
//
// Each element is a field number or an index. They form a path from
// the root FileDescriptorProto to the place where the definition. For
// example, this path:
// [ 4, 3, 2, 7, 1 ]
// refers to:
// file.message_type(3) // 4, 3
// .field(7) // 2, 7
// .name() // 1
// This is because FileDescriptorProto.message_type has field number 4:
// repeated DescriptorProto message_type = 4;
// and DescriptorProto.field has field number 2:
// repeated FieldDescriptorProto field = 2;
// and FieldDescriptorProto.name has field number 1:
// optional string name = 1 [ctype = STRING_PIECE];
//
// Thus, the above path gives the location of a field name. If we removed
// the last element:
// [ 4, 3, 2, 7 ]
// this path refers to the whole field declaration (from the beginning
// of the label to the terminating semicolon).
repeated int32 path = 1 [packed = true];
// Always has exactly three or four elements: start line, start column,
// end line (optional, otherwise assumed same as start line), end column.
// These are packed into a single field for efficiency. Note that line
// and column numbers are zero-based -- typically you will want to add
// 1 to each before displaying to a user.
repeated int32 span = 2 [packed = true];
// If this SourceCodeInfo represents a complete declaration, these are any
// comments appearing before and after the declaration which appear to be
// attached to the declaration.
//
// A series of line comments appearing on consecutive lines, with no other
// tokens appearing on those lines, will be treated as a single comment.
//
// leading_detached_comments will keep paragraphs of comments that appear
// before (but not connected to) the current element. Each paragraph,
// separated by empty lines, will be one comment element in the repeated
// field.
//
// Only the comment content is provided; comment markers (e.g. //) are
// stripped out. For block comments, leading whitespace and an asterisk
// will be stripped from the beginning of each line other than the first.
// Newlines are included in the output.
//
// Examples:
//
// optional int32 foo = 1; // Comment attached to foo.
// // Comment attached to bar.
// optional int32 bar = 2;
//
// optional string baz = 3 [ctype = STRING_PIECE];
// // Comment attached to baz.
// // Another line attached to baz.
//
// // Comment attached to qux.
// //
// // Another line attached to qux.
// optional double qux = 4;
//
// // Detached comment for corge. This is not leading or trailing comments
// // to qux or corge because there are blank lines separating it from
// // both.
//
// // Detached comment for corge paragraph 2.
//
// optional string corge = 5 [ctype = STRING_PIECE];
// /* Block comment attached
// * to corge. Leading asterisks
// * will be removed. */
// /* Block comment attached to
// * grault. */
// optional int32 grault = 6;
//
// // ignored detached comments.
optional string leading_comments = 3 [ctype = STRING_PIECE];
optional string trailing_comments = 4 [ctype = STRING_PIECE];
repeated string leading_detached_comments = 6 [ctype = STRING_PIECE];
}
}
// Describes the relationship between generated code and its original source
// file. A GeneratedCodeInfo message is associated with only one generated
// source file, but may contain references to different source .proto files.
message GeneratedCodeInfo {
// An Annotation connects some span of text in generated code to an element
// of its generating .proto file.
repeated Annotation annotation = 1;
message Annotation {
// Identifies the element in the original source .proto file. This field
// is formatted the same as SourceCodeInfo.Location.path.
repeated int32 path = 1 [packed = true];
// Identifies the filesystem path to the original source .proto.
optional string source_file = 2 [ctype = STRING_PIECE];
// Identifies the starting offset in bytes in the generated code
// that relates to the identified object.
optional int32 begin = 3;
// Identifies the ending offset in bytes in the generated code that
// relates to the identified offset. The end offset should be one past
// the last relevant byte (so the length of the text = end - begin).
optional int32 end = 4;
}
}