initial commit

This commit is contained in:
2025-09-01 22:12:29 +02:00
parent b1873f9c1d
commit 02a54f61c0
5598 changed files with 903558 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
// 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.
syntax = "proto3";
package google.protobuf;
option go_package = "google.golang.org/protobuf/types/known/anypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// `Any` contains an arbitrary serialized protocol buffer message along with a
// URL that describes the type of the serialized message.
//
// Protobuf library provides support to pack/unpack Any values in the form
// of utility functions or additional generated methods of the Any type.
//
// Example 1: Pack and unpack a message in C++.
//
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }
//
// Example 2: Pack and unpack a message in Java.
//
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
// // or ...
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
// foo = any.unpack(Foo.getDefaultInstance());
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := anypb.New(foo)
// if err != nil {
// ...
// }
// ...
// foo := &pb.Foo{}
// if err := any.UnmarshalTo(foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/'
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
// JSON
// ====
// The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example:
//
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }
//
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }
//
// If the embedded message type is well-known and has a custom JSON
// representation, that representation will be embedded adding a field
// `value` which holds the custom JSON in addition to the `@type`
// field. Example (for message [google.protobuf.Duration][]):
//
// {
// "@type": "type.googleapis.com/google.protobuf.Duration",
// "value": "1.212s"
// }
//
message Any {
// A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. This string must contain at least
// one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
//
// In practice, teams usually precompile into the binary all types that they
// expect it to use in the context of Any. However, for URLs which use the
// scheme `http`, `https`, or no scheme, one can optionally set up a type
// server that maps type URLs to message definitions as follows:
//
// * If no scheme is provided, `https` is assumed.
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the
// URL, or have them precompiled into a binary to avoid any
// lookup. Therefore, binary compatibility needs to be preserved
// on changes to types. (Use versioned type names to manage
// breaking changes.)
//
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com. As of May 2023, there are no widely used type server
// implementations and no plans to implement one.
//
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
//
string type_url = 1;
// Must be a valid serialized protocol buffer of the above specified type.
bytes value = 2;
}

View File

@@ -0,0 +1,207 @@
// 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.
syntax = "proto3";
package google.protobuf;
import "google/protobuf/source_context.proto";
import "google/protobuf/type.proto";
option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/apipb";
// Api is a light-weight descriptor for an API Interface.
//
// Interfaces are also described as "protocol buffer services" in some contexts,
// such as by the "service" keyword in a .proto file, but they are different
// from API Services, which represent a concrete implementation of an interface
// as opposed to simply a description of methods and bindings. They are also
// sometimes simply referred to as "APIs" in other contexts, such as the name of
// this message itself. See https://cloud.google.com/apis/design/glossary for
// detailed terminology.
message Api {
// The fully qualified name of this interface, including package name
// followed by the interface's simple name.
string name = 1;
// The methods of this interface, in unspecified order.
repeated Method methods = 2;
// Any metadata attached to the interface.
repeated Option options = 3;
// A version string for this interface. If specified, must have the form
// `major-version.minor-version`, as in `1.10`. If the minor version is
// omitted, it defaults to zero. If the entire version field is empty, the
// major version is derived from the package name, as outlined below. If the
// field is not empty, the version in the package name will be verified to be
// consistent with what is provided here.
//
// The versioning schema uses [semantic
// versioning](http://semver.org) where the major version number
// indicates a breaking change and the minor version an additive,
// non-breaking change. Both version numbers are signals to users
// what to expect from different versions, and should be carefully
// chosen based on the product plan.
//
// The major version is also reflected in the package name of the
// interface, which must end in `v<major-version>`, as in
// `google.feature.v1`. For major versions 0 and 1, the suffix can
// be omitted. Zero major versions must only be used for
// experimental, non-GA interfaces.
//
string version = 4;
// Source context for the protocol buffer service represented by this
// message.
SourceContext source_context = 5;
// Included interfaces. See [Mixin][].
repeated Mixin mixins = 6;
// The source syntax of the service.
Syntax syntax = 7;
}
// Method represents a method of an API interface.
message Method {
// The simple name of this method.
string name = 1;
// A URL of the input message type.
string request_type_url = 2;
// If true, the request is streamed.
bool request_streaming = 3;
// The URL of the output message type.
string response_type_url = 4;
// If true, the response is streamed.
bool response_streaming = 5;
// Any metadata attached to the method.
repeated Option options = 6;
// The source syntax of this method.
Syntax syntax = 7;
}
// Declares an API Interface to be included in this interface. The including
// interface must redeclare all the methods from the included interface, but
// documentation and options are inherited as follows:
//
// - If after comment and whitespace stripping, the documentation
// string of the redeclared method is empty, it will be inherited
// from the original method.
//
// - Each annotation belonging to the service config (http,
// visibility) which is not set in the redeclared method will be
// inherited.
//
// - If an http annotation is inherited, the path pattern will be
// modified as follows. Any version prefix will be replaced by the
// version of the including interface plus the [root][] path if
// specified.
//
// Example of a simple mixin:
//
// package google.acl.v1;
// service AccessControl {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v1/{resource=**}:getAcl";
// }
// }
//
// package google.storage.v2;
// service Storage {
// rpc GetAcl(GetAclRequest) returns (Acl);
//
// // Get a data record.
// rpc GetData(GetDataRequest) returns (Data) {
// option (google.api.http).get = "/v2/{resource=**}";
// }
// }
//
// Example of a mixin configuration:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
//
// The mixin construct implies that all methods in `AccessControl` are
// also declared with same name and request/response types in
// `Storage`. A documentation generator or annotation processor will
// see the effective `Storage.GetAcl` method after inherting
// documentation and annotations as follows:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/{resource=**}:getAcl";
// }
// ...
// }
//
// Note how the version in the path pattern changed from `v1` to `v2`.
//
// If the `root` field in the mixin is specified, it should be a
// relative path under which inherited HTTP paths are placed. Example:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
// root: acls
//
// This implies the following inherited HTTP annotation:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
// }
// ...
// }
message Mixin {
// The fully qualified name of the interface which is included.
string name = 1;
// If non-empty specifies a path under which inherited HTTP paths
// are rooted.
string root = 2;
}

View File

@@ -0,0 +1,76 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2007 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)
//
// This is proto2's version of MessageSet. See go/messageset to learn what
// MessageSets are and how they are used.
//
// In proto2, we implement MessageSet in terms of extensions, except with a
// special wire format for backwards-compatibility. To define a message that
// goes in a MessageSet in proto2, you must declare within that message's
// scope an extension of MessageSet named "message_set_extension" and with
// the field number matching the type ID. So, for example, this proto1 code:
// message Foo {
// enum TypeId { MESSAGE_TYPE_ID = 1234; }
// }
// becomes this proto2 code:
// message Foo {
// extend google.protobuf.bridge.MessageSet {
// optional Foo message_set_extension = 1234;
// }
// }
//
// Now you can use the usual proto2 extensions accessors to access this
// message. For example, the proto1 code:
// MessageSet mset;
// Foo* foo = mset.get_mutable<Foo>();
// becomes this proto2 code:
// google::protobuf::bridge::MessageSet mset;
// Foo* foo = mset.MutableExtension(Foo::message_set_extension);
//
// Of course, new code that doesn't have backwards-compatibility requirements
// should just use extensions themselves and not worry about MessageSet.
syntax = "proto2";
package google.protobuf.bridge;
option java_outer_classname = "MessageSetProtos";
option java_multiple_files = true;
option cc_enable_arenas = true;
option objc_class_prefix = "GPB";
// This is proto2's version of MessageSet.
message MessageSet {
option message_set_wire_format = true;
extensions 4 to max [verification = UNVERIFIED];
}

View File

@@ -0,0 +1,180 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Author: kenton@google.com (Kenton Varda)
//
// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
// just a program that reads a CodeGeneratorRequest from stdin and writes a
// CodeGeneratorResponse to stdout.
//
// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
// of dealing with the raw protocol defined here.
//
// A plugin executable needs only to be placed somewhere in the path. The
// plugin should be named "protoc-gen-$NAME", and will then be used when the
// flag "--${NAME}_out" is passed to protoc.
syntax = "proto2";
package google.protobuf.compiler;
option java_package = "com.google.protobuf.compiler";
option java_outer_classname = "PluginProtos";
option csharp_namespace = "Google.Protobuf.Compiler";
option go_package = "google.golang.org/protobuf/types/pluginpb";
import "google/protobuf/descriptor.proto";
// The version number of protocol compiler.
message Version {
optional int32 major = 1;
optional int32 minor = 2;
optional int32 patch = 3;
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
// be empty for mainline stable releases.
optional string suffix = 4;
}
// An encoded CodeGeneratorRequest is written to the plugin's stdin.
message CodeGeneratorRequest {
// The .proto files that were explicitly listed on the command-line. The
// code generator should generate code only for these files. Each file's
// descriptor will be included in proto_file, below.
repeated string file_to_generate = 1;
// The generator parameter passed on the command-line.
optional string parameter = 2;
// FileDescriptorProtos for all files in files_to_generate and everything
// they import. The files will appear in topological order, so each file
// appears before any file that imports it.
//
// Note: the files listed in files_to_generate will include runtime-retention
// options only, but all other files will include source-retention options.
// The source_file_descriptors field below is available in case you need
// source-retention options for files_to_generate.
//
// protoc guarantees that all proto_files will be written after
// the fields above, even though this is not technically guaranteed by the
// protobuf wire format. This theoretically could allow a plugin to stream
// in the FileDescriptorProtos and handle them one by one rather than read
// the entire set into memory at once. However, as of this writing, this
// is not similarly optimized on protoc's end -- it will store all fields in
// memory at once before sending them to the plugin.
//
// Type names of fields and extensions in the FileDescriptorProto are always
// fully qualified.
repeated FileDescriptorProto proto_file = 15;
// File descriptors with all options, including source-retention options.
// These descriptors are only provided for the files listed in
// files_to_generate.
repeated FileDescriptorProto source_file_descriptors = 17;
// The version number of protocol compiler.
optional Version compiler_version = 3;
}
// The plugin writes an encoded CodeGeneratorResponse to stdout.
message CodeGeneratorResponse {
// Error message. If non-empty, code generation failed. The plugin process
// should exit with status code zero even if it reports an error in this way.
//
// This should be used to indicate errors in .proto files which prevent the
// code generator from generating correct code. Errors which indicate a
// problem in protoc itself -- such as the input CodeGeneratorRequest being
// unparseable -- should be reported by writing a message to stderr and
// exiting with a non-zero status code.
optional string error = 1;
// A bitmask of supported features that the code generator supports.
// This is a bitwise "or" of values from the Feature enum.
optional uint64 supported_features = 2;
// Sync with code_generator.h.
enum Feature {
FEATURE_NONE = 0;
FEATURE_PROTO3_OPTIONAL = 1;
FEATURE_SUPPORTS_EDITIONS = 2;
}
// The minimum edition this plugin supports. This will be treated as an
// Edition enum, but we want to allow unknown values. It should be specified
// according the edition enum value, *not* the edition number. Only takes
// effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
optional int32 minimum_edition = 3;
// The maximum edition this plugin supports. This will be treated as an
// Edition enum, but we want to allow unknown values. It should be specified
// according the edition enum value, *not* the edition number. Only takes
// effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
optional int32 maximum_edition = 4;
// Represents a single generated file.
message File {
// The file name, relative to the output directory. The name must not
// contain "." or ".." components and must be relative, not be absolute (so,
// the file cannot lie outside the output directory). "/" must be used as
// the path separator, not "\".
//
// If the name is omitted, the content will be appended to the previous
// file. This allows the generator to break large files into small chunks,
// and allows the generated text to be streamed back to protoc so that large
// files need not reside completely in memory at one time. Note that as of
// this writing protoc does not optimize for this -- it will read the entire
// CodeGeneratorResponse before writing files to disk.
optional string name = 1;
// If non-empty, indicates that the named file should already exist, and the
// content here is to be inserted into that file at a defined insertion
// point. This feature allows a code generator to extend the output
// produced by another code generator. The original generator may provide
// insertion points by placing special annotations in the file that look
// like:
// @@protoc_insertion_point(NAME)
// The annotation can have arbitrary text before and after it on the line,
// which allows it to be placed in a comment. NAME should be replaced with
// an identifier naming the point -- this is what other generators will use
// as the insertion_point. Code inserted at this point will be placed
// immediately above the line containing the insertion point (thus multiple
// insertions to the same point will come out in the order they were added).
// The double-@ is intended to make it unlikely that the generated code
// could contain things that look like insertion points by accident.
//
// For example, the C++ code generator places the following line in the
// .pb.h files that it generates:
// // @@protoc_insertion_point(namespace_scope)
// This line appears within the scope of the file's package namespace, but
// outside of any particular class. Another plugin can then specify the
// insertion_point "namespace_scope" to generate additional classes or
// other declarations that should be placed in this scope.
//
// Note that if the line containing the insertion point begins with
// whitespace, the same whitespace will be added to every line of the
// inserted text. This is useful for languages like Python, where
// indentation matters. In these languages, the insertion point comment
// should be indented the same amount as any inserted code will need to be
// in order to work correctly in that context.
//
// The code generator that generates the initial file and the one which
// inserts into it must both run as part of a single invocation of protoc.
// Code generators are executed in the order in which they appear on the
// command line.
//
// If |insertion_point| is present, |name| must also be present.
optional string insertion_point = 2;
// The file contents.
optional string content = 15;
// Information describing the file content being inserted. If an insertion
// point is used, this information will be appropriately offset and inserted
// into the code generation metadata for the generated files.
optional GeneratedCodeInfo generated_code_info = 16;
}
repeated File file = 15;
}

View File

@@ -0,0 +1,77 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package A.B.C;
import "ruby_generated_code_proto2_import.proto";
message TestMessage {
int32 optional_int32 = 1;
int64 optional_int64 = 2;
uint32 optional_uint32 = 3;
uint64 optional_uint64 = 4;
bool optional_bool = 5;
double optional_double = 6;
float optional_float = 7;
string optional_string = 8;
bytes optional_bytes = 9;
TestEnum optional_enum = 10;
TestMessage optional_msg = 11;
TestImportedMessage optional_proto2_submessage = 12;
repeated int32 repeated_int32 = 21;
repeated int64 repeated_int64 = 22;
repeated uint32 repeated_uint32 = 23;
repeated uint64 repeated_uint64 = 24;
repeated bool repeated_bool = 25;
repeated double repeated_double = 26;
repeated float repeated_float = 27;
repeated string repeated_string = 28;
repeated bytes repeated_bytes = 29;
repeated TestEnum repeated_enum = 30;
repeated TestMessage repeated_msg = 31;
oneof my_oneof {
int32 oneof_int32 = 41;
int64 oneof_int64 = 42;
uint32 oneof_uint32 = 43;
uint64 oneof_uint64 = 44;
bool oneof_bool = 45;
double oneof_double = 46;
float oneof_float = 47;
string oneof_string = 48;
bytes oneof_bytes = 49;
TestEnum oneof_enum = 50;
TestMessage oneof_msg = 51;
}
map<int32, string> map_int32_string = 61;
map<int64, string> map_int64_string = 62;
map<uint32, string> map_uint32_string = 63;
map<uint64, string> map_uint64_string = 64;
map<bool, string> map_bool_string = 65;
map<string, string> map_string_string = 66;
map<string, TestMessage> map_string_msg = 67;
map<string, TestEnum> map_string_enum = 68;
map<string, int32> map_string_int32 = 69;
map<string, bool> map_string_bool = 70;
message NestedMessage {
int32 foo = 1;
}
NestedMessage nested_message = 80;
}
enum TestEnum {
Default = 0;
A = 1;
B = 2;
C = 3;
}

View File

@@ -0,0 +1,78 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package A.B.C;
import "ruby_generated_code_proto2_import.proto";
message TestMessage {
optional int32 optional_int32 = 1 [default = 1];
optional int64 optional_int64 = 2 [default = 2];
optional uint32 optional_uint32 = 3 [default = 3];
optional uint64 optional_uint64 = 4 [default = 4];
optional bool optional_bool = 5 [default = true];
optional double optional_double = 6 [default = 6.0];
optional float optional_float = 7 [default = 7.0];
optional string optional_string = 8 [default = "default str"];
optional bytes optional_bytes = 9 [default = "\0\1\2\100fubar"];
optional TestEnum optional_enum = 10 [default = A];
optional TestMessage optional_msg = 11;
optional TestImportedMessage optional_proto2_submessage = 12;
repeated int32 repeated_int32 = 21;
repeated int64 repeated_int64 = 22;
repeated uint32 repeated_uint32 = 23;
repeated uint64 repeated_uint64 = 24;
repeated bool repeated_bool = 25;
repeated double repeated_double = 26;
repeated float repeated_float = 27;
repeated string repeated_string = 28;
repeated bytes repeated_bytes = 29;
repeated TestEnum repeated_enum = 30;
repeated TestMessage repeated_msg = 31;
required int32 required_int32 = 41;
required int64 required_int64 = 42;
required uint32 required_uint32 = 43;
required uint64 required_uint64 = 44;
required bool required_bool = 45;
required double required_double = 46;
required float required_float = 47;
required string required_string = 48;
required bytes required_bytes = 49;
required TestEnum required_enum = 50;
required TestMessage required_msg = 51;
oneof my_oneof {
int32 oneof_int32 = 61;
int64 oneof_int64 = 62;
uint32 oneof_uint32 = 63;
uint64 oneof_uint64 = 64;
bool oneof_bool = 65;
double oneof_double = 66;
float oneof_float = 67;
string oneof_string = 68;
bytes oneof_bytes = 69;
TestEnum oneof_enum = 70;
TestMessage oneof_msg = 71;
}
message NestedMessage {
optional int32 foo = 1;
}
optional NestedMessage nested_message = 80;
}
enum TestEnum {
Default = 0;
A = 1;
B = 2;
C = 3;
}

View File

@@ -0,0 +1,12 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package A.B.C;
message TestImportedMessage {}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package one.two.a_three;
option ruby_package = "A::B::C";
message Four {
string a_string = 1;
}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package one.two.a_three.and;
option ruby_package = "AA.BB.CC";
message Four {
string another_string = 1;
}

View File

@@ -0,0 +1,14 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package one.two.a_three;
message Four {
string a_string = 1;
}

View File

@@ -0,0 +1,45 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package pb;
import "google/protobuf/descriptor.proto";
extend google.protobuf.FeatureSet {
optional CppFeatures cpp = 1000;
}
message CppFeatures {
// Whether or not to treat an enum field as closed. This option is only
// applicable to enum fields, and will be removed in the future. It is
// consistent with the legacy behavior of using proto3 enum types for proto2
// fields.
optional bool legacy_closed_enum = 1 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
];
enum StringType {
STRING_TYPE_UNKNOWN = 0;
VIEW = 1;
CORD = 2;
STRING = 3;
}
optional StringType string_type = 2 [
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
edition_defaults = { edition: EDITION_PROTO2, value: "STRING" },
edition_defaults = { edition: EDITION_2024, value: "VIEW" }
];
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
// 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.
syntax = "proto3";
package google.protobuf;
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/durationpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "DurationProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// A Duration represents a signed, fixed-length span of time represented
// as a count of seconds and fractions of seconds at nanosecond
// resolution. It is independent of any calendar and concepts like "day"
// or "month". It is related to Timestamp in that the difference between
// two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years.
//
// # Examples
//
// Example 1: Compute Duration from two Timestamps in pseudo code.
//
// Timestamp start = ...;
// Timestamp end = ...;
// Duration duration = ...;
//
// duration.seconds = end.seconds - start.seconds;
// duration.nanos = end.nanos - start.nanos;
//
// if (duration.seconds < 0 && duration.nanos > 0) {
// duration.seconds += 1;
// duration.nanos -= 1000000000;
// } else if (duration.seconds > 0 && duration.nanos < 0) {
// duration.seconds -= 1;
// duration.nanos += 1000000000;
// }
//
// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
//
// Timestamp start = ...;
// Duration duration = ...;
// Timestamp end = ...;
//
// end.seconds = start.seconds + duration.seconds;
// end.nanos = start.nanos + duration.nanos;
//
// if (end.nanos < 0) {
// end.seconds -= 1;
// end.nanos += 1000000000;
// } else if (end.nanos >= 1000000000) {
// end.seconds += 1;
// end.nanos -= 1000000000;
// }
//
// Example 3: Compute Duration from datetime.timedelta in Python.
//
// td = datetime.timedelta(days=3, minutes=10)
// duration = Duration()
// duration.FromTimedelta(td)
//
// # JSON Mapping
//
// In JSON format, the Duration type is encoded as a string rather than an
// object, where the string ends in the suffix "s" (indicating seconds) and
// is preceded by the number of seconds, with nanoseconds expressed as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
message Duration {
// Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
int64 seconds = 1;
// Signed fractions of a second at nanosecond resolution of the span
// of time. Durations less than one second are represented with a 0
// `seconds` field and a positive or negative `nanos` field. For durations
// of one second or more, a non-zero value for the `nanos` field must be
// of the same sign as the `seconds` field. Must be from -999,999,999
// to +999,999,999 inclusive.
int32 nanos = 2;
}

View File

@@ -0,0 +1,26 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
enum Proto2Enum {
BAR = 1;
BAZ = 2;
}
message Proto2EnumMessage {
optional Proto2Enum enum_field = 1;
optional Proto2Enum enum_field_default = 2 [default = BAZ];
enum Proto2NestedEnum {
FOO = 1;
BAT = 2;
}
optional Proto2NestedEnum nested_enum_field = 3;
optional Proto2NestedEnum nested_enum_field_default = 4 [default = BAT];
}

View File

@@ -0,0 +1,18 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
// LINT: ALLOW_GROUPS
message Proto2Group {
optional group Groupfield = 2 {
optional int32 int32_field = 1;
}
}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
import "google/protobuf/editions/codegen_tests/proto2_optional.proto";
message Proto2ImportMessage {
optional Proto2Optional sub_message_field = 1;
}

View File

@@ -0,0 +1,33 @@
// This is a detached leading comment
//
// With a forced unwrapped line.
// File detached leading comment
// Syntax leading comment
syntax = "proto2"; // Syntax trailing comment
// Package leading comment
package protobuf_editions_test.proto2; // Package trailing comment
// Leading message comment
message Foo { // Message trailing comment
// Message inner comment
// Field leading comment
optional int32 field1 = 1; // Field trailing comment
optional /* card */ int32 /* type */ field2 /* name */ = 2 /* tag */;
// Message inner trailing comment
} // Message trailing comment
// Leading message comment
enum Bar { // Enum trailing comment
// Enum inner comment
// Enum value leading comment
BAR_UNKNOWN = 0; // Enum value trailing comment
// Enum inner trailing comment
} // Enum trailing comment

View File

@@ -0,0 +1,33 @@
syntax = "proto2";
package protobuf_editions_test.proto2;
/**
Multiline message comment - no asterisk
*/
message Message1 {
/**
Multiline field comment - no asterisk
*/
optional string field = 1;
}
/*
* Multiline message comment - single asterisk
*/
message Message2 {
/*
* Multiline message comment - single asterisk
*/
optional string field = 1;
}
/**
* Exactly one trait must be set. Extension # is vendor_id + 1.
*/
message Message3 {
/**
* Exactly one trait must be set. Extension # is vendor_id + 1.
*/
optional string field = 1;
}

View File

@@ -0,0 +1,65 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Optional {
optional int32 int32_field = 17;
optional float float_field = 18;
optional double double_field = 19;
optional int64 int64_field = 20;
optional uint32 uint32_field = 21;
optional uint64 uint64_field = 22;
optional sint32 sint32_field = 23;
optional sint64 sint64_field = 24;
optional fixed32 fixed32_field = 25;
optional fixed64 fixed64_field = 26;
optional sfixed32 sfixed32_field = 27;
optional sfixed64 sfixed64_field = 28;
optional bool bool_field = 29;
optional string string_field = 30;
optional bytes bytes_field = 31;
message SubMessage {
optional int32 int32_field = 17;
optional float float_field = 18;
optional double double_field = 19;
optional int64 int64_field = 20;
optional uint32 uint32_field = 21;
optional uint64 uint64_field = 22;
optional sint32 sint32_field = 23;
optional sint64 sint64_field = 24;
optional fixed32 fixed32_field = 25;
optional fixed64 fixed64_field = 26;
optional sfixed32 sfixed32_field = 27;
optional sfixed64 sfixed64_field = 28;
optional bool bool_field = 29;
optional string string_field = 30;
optional bytes bytes_field = 31;
}
oneof oneof_field {
int32 int32_oneof_field = 152;
float float_oneof_field = 153;
double double_oneof_field = 154;
int64 int64_oneof_field = 155;
uint32 uint32_oneof_field = 156;
uint64 uint64_oneof_field = 157;
sint32 sint32_oneof_field = 158;
sint64 sint64_oneof_field = 159;
fixed32 fixed32_oneof_field = 160;
fixed64 fixed64_oneof_field = 161;
sfixed32 sfixed32_oneof_field = 162;
sfixed64 sfixed64_oneof_field = 163;
bool bool_oneof_field = 164;
string string_oneof_field = 165;
bytes bytes_oneof_field = 166;
}
optional SubMessage sub_message = 2;
}

View File

@@ -0,0 +1,14 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Packed {
repeated int32 int32_field = 1 [packed = true];
}

View File

@@ -0,0 +1,18 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
import "google/protobuf/editions/codegen_tests/proto3_enum.proto";
message Proto2ImportedEnumMessage {
optional protobuf_editions_test.proto3.Proto3Enum enum_field = 1;
optional protobuf_editions_test.proto3.Proto3Enum enum_field_default = 2
[default = BAZ];
}

View File

@@ -0,0 +1,47 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Required {
required int32 int32_field = 17;
required float float_field = 18;
required double double_field = 19;
required int64 int64_field = 20;
required uint32 uint32_field = 21;
required uint64 uint64_field = 22;
required sint32 sint32_field = 23;
required sint64 sint64_field = 24;
required fixed32 fixed32_field = 25;
required fixed64 fixed64_field = 26;
required sfixed32 sfixed32_field = 27;
required sfixed64 sfixed64_field = 28;
required bool bool_field = 29;
required string string_field = 30;
required bytes bytes_field = 31;
message SubMessage {
required int32 int32_field = 17;
required float float_field = 18;
required double double_field = 19;
required int64 int64_field = 20;
required uint32 uint32_field = 21;
required uint64 uint64_field = 22;
required sint32 sint32_field = 23;
required sint64 sint64_field = 24;
required fixed32 fixed32_field = 25;
required fixed64 fixed64_field = 26;
required sfixed32 sfixed32_field = 27;
required sfixed64 sfixed64_field = 28;
required bool bool_field = 29;
required string string_field = 30;
required bytes bytes_field = 31;
}
required SubMessage sub_message = 2;
}

View File

@@ -0,0 +1,19 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Unpacked {
repeated int32 int32_field = 1;
repeated string string_field = 2;
message SubMessage {
optional int32 int32_field = 1;
}
repeated SubMessage sub_message_field = 3;
}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Utf8Disabled {
optional string string_field = 1;
map<string, string> map_field = 2;
}

View File

@@ -0,0 +1,17 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
option optimize_for = LITE_RUNTIME;
message Proto2Utf8Lite {
optional string string_field = 1;
map<string, string> map_field = 2;
}

View File

@@ -0,0 +1,14 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.proto2;
message Proto2Utf8Verify {
optional string string_field = 1;
}

View File

@@ -0,0 +1,26 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
enum Proto3Enum {
UNKNOWN = 0;
BAR = 1;
BAZ = 2;
}
message Proto3EnumMessage {
Proto3Enum enum_field = 1;
enum Proto3NestedEnum {
UNKNOWN = 0;
FOO = 1;
BAT = 2;
}
optional Proto3NestedEnum nested_enum_field = 3;
}

View File

@@ -0,0 +1,65 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
message Proto3Implicit {
int32 int32_field = 17;
float float_field = 18;
double double_field = 19;
int64 int64_field = 20;
uint32 uint32_field = 21;
uint64 uint64_field = 22;
sint32 sint32_field = 23;
sint64 sint64_field = 24;
fixed32 fixed32_field = 25;
fixed64 fixed64_field = 26;
sfixed32 sfixed32_field = 27;
sfixed64 sfixed64_field = 28;
bool bool_field = 29;
string string_field = 30;
bytes bytes_field = 31;
message SubMessage {
int32 int32_field = 17;
float float_field = 18;
double double_field = 19;
int64 int64_field = 20;
uint32 uint32_field = 21;
uint64 uint64_field = 22;
sint32 sint32_field = 23;
sint64 sint64_field = 24;
fixed32 fixed32_field = 25;
fixed64 fixed64_field = 26;
sfixed32 sfixed32_field = 27;
sfixed64 sfixed64_field = 28;
bool bool_field = 29;
string string_field = 30;
bytes bytes = 31;
}
oneof oneof_field {
int32 int32_oneof_field = 152;
float float_oneof_field = 153;
double double_oneof_field = 154;
int64 int64_oneof_field = 155;
uint32 uint32_oneof_field = 156;
uint64 uint64_oneof_field = 157;
sint32 sint32_oneof_field = 158;
sint64 sint64_oneof_field = 159;
fixed32 fixed32_oneof_field = 160;
fixed64 fixed64_oneof_field = 161;
sfixed32 sfixed32_oneof_field = 162;
sfixed64 sfixed64_oneof_field = 163;
bool bool_oneof_field = 164;
string string_oneof_field = 165;
bytes bytes_oneof_field = 166;
}
SubMessage sub_message = 2;
}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
import "google/protobuf/editions/codegen_tests/proto3_implicit.proto";
message Proto3ImportMessage {
Proto3Implicit sub_message_field = 1;
}

View File

@@ -0,0 +1,47 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
message Proto3Optional {
optional int32 int32_field = 17;
optional float float_field = 18;
optional double double_field = 19;
optional int64 int64_field = 20;
optional uint32 uint32_field = 21;
optional uint64 uint64_field = 22;
optional sint32 sint32_field = 23;
optional sint64 sint64_field = 24;
optional fixed32 fixed32_field = 25;
optional fixed64 fixed64_field = 26;
optional sfixed32 sfixed32_field = 27;
optional sfixed64 sfixed64_field = 28;
optional bool bool_field = 29;
optional string string_field = 30;
optional bytes bytes_field = 31;
message SubMessage {
optional int32 int32_field = 17;
optional float float_field = 18;
optional double double_field = 19;
optional int64 int64_field = 20;
optional uint32 uint32_field = 21;
optional uint64 uint64_field = 22;
optional sint32 sint32_field = 23;
optional sint64 sint64_field = 24;
optional fixed32 fixed32_field = 25;
optional fixed64 fixed64_field = 26;
optional sfixed32 sfixed32_field = 27;
optional sfixed64 sfixed64_field = 28;
optional bool bool_field = 29;
optional string string_field = 30;
optional bytes bytes_field = 31;
}
optional SubMessage optional_message = 2;
}

View File

@@ -0,0 +1,20 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
message Proto3Packed {
repeated int32 int32_field = 1;
repeated string string_field = 2;
message SubMessage {
int32 int32_field = 1;
}
repeated SubMessage sub_message_field = 3;
repeated int32 explicitly_packed = 4 [packed = true];
}

View File

@@ -0,0 +1,19 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
message Proto3Unpacked {
repeated int32 int32_field = 1 [packed = false];
repeated string string_field = 2 [packed = false];
message SubMessage {
int32 int32_field = 1;
}
repeated SubMessage sub_message_field = 3 [packed = false];
}

View File

@@ -0,0 +1,15 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.proto3;
message Proto3Utf8Strict {
string string_field = 1;
map<string, string> map_field = 10;
}

View File

@@ -0,0 +1,129 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
edition = "2023";
// This file contains various edge cases we've collected from migrating real
// protos in order to lock down the transformations.
// LINT: ALLOW_GROUPS
package protobuf_editions_test;
import "net/proto/proto1_features.proto";
import "third_party/java_src/protobuf/current/java/com/google/protobuf/java_features.proto";
import "google/protobuf/cpp_features.proto";
import "google/protobuf/editions/proto/editions_transform_proto3.proto";
option features.repeated_field_encoding = EXPANDED;
option features.utf8_validation = NONE;
option java_multiple_files = true;
message EmptyMessage {
}
message EmptyMessage2 {
}
service EmptyService {
}
service BasicService {
rpc BasicMethod(EmptyMessage) returns (EmptyMessage) {}
}
// clang-format off
message UnformattedMessage {
int32 a = 1;
message Foo {
int32 a = 1;
}
Foo foo = 2 [
features.message_encoding = DELIMITED
];
string string_piece_with_zero = 3 [
ctype = STRING_PIECE,
default = "ab\000c"
];
float long_float_name_wrapped = 4;
}
// clang-format on
message ParentMessage {
message ExtendedMessage {
extensions 536860000 to 536869999 [
declaration = {
number: 536860000
full_name: ".protobuf_editions_test.extension"
type: ".protobuf_editions_test.EmptyMessage"
}
];
}
}
extend ParentMessage.ExtendedMessage {
EmptyMessage extension = 536860000;
}
message TestMessage {
string string_field = 1;
map<string, string> string_map_field = 7;
repeated int32 int_field = 8;
repeated int32 int_field_packed = 9 [
features.repeated_field_encoding = PACKED,
features.(pb.proto1).legacy_packed = true
];
repeated int32 int_field_unpacked = 10;
repeated int32 options_strip_beginning = 4 [
/* inline comment */
debug_redact = true,
deprecated = false
];
repeated int32 options_strip_middle = 5 [
debug_redact = true,
deprecated = false
];
repeated int32 options_strip_end = 6 [
debug_redact = true,
deprecated = false
];
message OptionalGroup {
int32 a = 17;
}
OptionalGroup optionalgroup = 16 [
features.message_encoding = DELIMITED
];
}
enum TestEnum {
option features.enum_type = CLOSED;
FOO = 1; // Non-zero default
BAR = 2;
BAZ = 3;
NEG = -1; // Intentionally negative.
}
message TestOpenEnumMessage {
TestEnumProto3 open_enum_field = 1 [
features.(pb.cpp).legacy_closed_enum = true,
features.(pb.java).legacy_closed_enum = true
];
TestEnum closed_enum_field = 2;
}

View File

@@ -0,0 +1,19 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
edition = "2023";
package protobuf_editions_test;
option features.utf8_validation = NONE;
option optimize_for = LITE_RUNTIME;
message TestMessageLite {
string string_field = 1;
map<string, string> string_map_field = 4;
int32 int_field = 5;
}

View File

@@ -0,0 +1,18 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
edition = "2023";
package protobuf_editions_test;
option features.utf8_validation = NONE;
message TestMessageUtf8Disabled {
string string_field = 1;
map<string, string> string_map_field = 4;
int32 int_field = 5;
}

View File

@@ -0,0 +1,32 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
edition = "2023";
package protobuf_editions_test;
import "net/proto/proto1_features.proto";
option features.field_presence = IMPLICIT;
enum TestEnumProto3 {
TEST_ENUM_PROTO3_UNKNOWN = 0;
TEST_ENUM_PROTO3_VALUE = 1;
}
message TestMessageProto3 {
string string_field = 1;
map<string, string> string_map_field = 4;
repeated int32 int_field = 7;
repeated int32 int_field_packed = 8 [
features.(pb.proto1).legacy_packed = true
];
repeated int32 int_field_unpacked = 9 [
features.repeated_field_encoding = EXPANDED
];
}

View File

@@ -0,0 +1,18 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
edition = "2023";
package protobuf_editions_test;
option features.field_presence = IMPLICIT;
message TestMessageProto3 {
string string_field = 1;
map<string, string> string_map_field = 4;
repeated int32 int_field = 7;
}

View File

@@ -0,0 +1,14 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.golden;
message SimpleProto2 {
optional int32 int32_field = 1;
}

View File

@@ -0,0 +1,16 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test.golden;
import "google/protobuf/editions/golden/simple_proto2.proto";
message AnotherMessage {
optional SimpleProto2 field = 1;
}

View File

@@ -0,0 +1,14 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test.golden;
message SimpleProto3 {
optional int32 int32_field = 1;
}

View File

@@ -0,0 +1,91 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
import "google/protobuf/editions/proto/editions_transform_proto3.proto";
// This file contains various edge cases we've collected from migrating real
// protos in order to lock down the transformations.
// LINT: ALLOW_GROUPS
package protobuf_editions_test;
option java_multiple_files = true;
option cc_enable_arenas = true;
message EmptyMessage {}
message EmptyMessage2 {}
service EmptyService {}
service BasicService {
rpc BasicMethod(EmptyMessage) returns (EmptyMessage) {}
}
// clang-format off
message UnformattedMessage{
optional int32 a=1 ;
optional group Foo = 2 { optional int32 a = 1; }
optional string string_piece_with_zero = 3 [ctype=STRING_PIECE,
default="ab\000c"];
optional float
long_float_name_wrapped = 4;
}
// clang-format on
message ParentMessage {
message ExtendedMessage {
extensions 536860000 to 536869999 [declaration = {
number: 536860000
full_name: ".protobuf_editions_test.extension"
type: ".protobuf_editions_test.EmptyMessage"
}];
}
}
extend ParentMessage.ExtendedMessage {
optional EmptyMessage extension = 536860000;
}
message TestMessage {
optional string string_field = 1;
map<string, string> string_map_field = 7;
repeated int32 int_field = 8;
repeated int32 int_field_packed = 9 [packed = true];
repeated int32 int_field_unpacked = 10 [packed = false];
repeated int32 options_strip_beginning = 4 [
packed = false,
/* inline comment*/ debug_redact = true,
deprecated = false
];
repeated int32 options_strip_middle = 5
[debug_redact = true, packed = false, deprecated = false];
repeated int32 options_strip_end = 6
[debug_redact = true, deprecated = false, packed = false];
optional group OptionalGroup = 16 {
optional int32 a = 17;
}
}
enum TestEnum {
FOO = 1; // Non-zero default
BAR = 2;
BAZ = 3;
NEG = -1; // Intentionally negative.
}
message TestOpenEnumMessage {
optional TestEnumProto3 open_enum_field = 1;
optional TestEnum closed_enum_field = 2;
}

View File

@@ -0,0 +1,20 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test;
option optimize_for = LITE_RUNTIME;
message TestMessageLite {
optional string string_field = 1;
map<string, string> string_map_field = 4;
optional int32 int_field = 5;
}

View File

@@ -0,0 +1,19 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto2";
package protobuf_editions_test;
message TestMessageUtf8Disabled {
optional string string_field = 1;
map<string, string> string_map_field = 4;
optional int32 int_field = 5;
}

View File

@@ -0,0 +1,25 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test;
enum TestEnumProto3 {
TEST_ENUM_PROTO3_UNKNOWN = 0;
TEST_ENUM_PROTO3_VALUE = 1;
}
message TestMessageProto3 {
string string_field = 1;
map<string, string> string_map_field = 4;
repeated int32 int_field = 7;
repeated int32 int_field_packed = 8 [packed = true];
repeated int32 int_field_unpacked = 9 [packed = false];
}

View File

@@ -0,0 +1,19 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package protobuf_editions_test;
message TestMessageProto3 {
string string_field = 1;
map<string, string> string_map_field = 4;
repeated int32 int_field = 7;
}

View File

@@ -0,0 +1,51 @@
// 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.
syntax = "proto3";
package google.protobuf;
option go_package = "google.golang.org/protobuf/types/known/emptypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
// A generic empty message that you can re-use to avoid defining duplicated
// empty messages in your APIs. A typical example is to use it as the request
// or the response type of an API method. For instance:
//
// service Foo {
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
// }
//
message Empty {}

View File

@@ -0,0 +1,245 @@
// 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.
syntax = "proto3";
package google.protobuf;
option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb";
option cc_enable_arenas = true;
// `FieldMask` represents a set of symbolic field paths, for example:
//
// paths: "f.a"
// paths: "f.b.d"
//
// Here `f` represents a field in some root message, `a` and `b`
// fields in the message found in `f`, and `d` a field found in the
// message in `f.b`.
//
// Field masks are used to specify a subset of fields that should be
// returned by a get operation or modified by an update operation.
// Field masks also have a custom JSON encoding (see below).
//
// # Field Masks in Projections
//
// When used in the context of a projection, a response message or
// sub-message is filtered by the API to only contain those fields as
// specified in the mask. For example, if the mask in the previous
// example is applied to a response message as follows:
//
// f {
// a : 22
// b {
// d : 1
// x : 2
// }
// y : 13
// }
// z: 8
//
// The result will not contain specific values for fields x,y and z
// (their value will be set to the default, and omitted in proto text
// output):
//
//
// f {
// a : 22
// b {
// d : 1
// }
// }
//
// A repeated field is not allowed except at the last position of a
// paths string.
//
// If a FieldMask object is not present in a get operation, the
// operation applies to all fields (as if a FieldMask of all fields
// had been specified).
//
// Note that a field mask does not necessarily apply to the
// top-level response message. In case of a REST get operation, the
// field mask applies directly to the response, but in case of a REST
// list operation, the mask instead applies to each individual message
// in the returned resource list. In case of a REST custom method,
// other definitions may be used. Where the mask applies will be
// clearly documented together with its declaration in the API. In
// any case, the effect on the returned resource/resources is required
// behavior for APIs.
//
// # Field Masks in Update Operations
//
// A field mask in update operations specifies which fields of the
// targeted resource are going to be updated. The API is required
// to only change the values of the fields as specified in the mask
// and leave the others untouched. If a resource is passed in to
// describe the updated values, the API ignores the values of all
// fields not covered by the mask.
//
// If a repeated field is specified for an update operation, new values will
// be appended to the existing repeated field in the target resource. Note that
// a repeated field is only allowed in the last position of a `paths` string.
//
// If a sub-message is specified in the last position of the field mask for an
// update operation, then new value will be merged into the existing sub-message
// in the target resource.
//
// For example, given the target message:
//
// f {
// b {
// d: 1
// x: 2
// }
// c: [1]
// }
//
// And an update message:
//
// f {
// b {
// d: 10
// }
// c: [2]
// }
//
// then if the field mask is:
//
// paths: ["f.b", "f.c"]
//
// then the result will be:
//
// f {
// b {
// d: 10
// x: 2
// }
// c: [1, 2]
// }
//
// An implementation may provide options to override this default behavior for
// repeated and message fields.
//
// In order to reset a field's value to the default, the field must
// be in the mask and set to the default value in the provided resource.
// Hence, in order to reset all fields of a resource, provide a default
// instance of the resource and set all fields in the mask, or do
// not provide a mask as described below.
//
// If a field mask is not present on update, the operation applies to
// all fields (as if a field mask of all fields has been specified).
// Note that in the presence of schema evolution, this may mean that
// fields the client does not know and has therefore not filled into
// the request will be reset to their default. If this is unwanted
// behavior, a specific service may require a client to always specify
// a field mask, producing an error if not.
//
// As with get operations, the location of the resource which
// describes the updated values in the request message depends on the
// operation kind. In any case, the effect of the field mask is
// required to be honored by the API.
//
// ## Considerations for HTTP REST
//
// The HTTP kind of an update operation which uses a field mask must
// be set to PATCH instead of PUT in order to satisfy HTTP semantics
// (PUT must only be used for full updates).
//
// # JSON Encoding of Field Masks
//
// In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions.
//
// As an example, consider the following message declarations:
//
// message Profile {
// User user = 1;
// Photo photo = 2;
// }
// message User {
// string display_name = 1;
// string address = 2;
// }
//
// In proto a field mask for `Profile` may look as such:
//
// mask {
// paths: "user.display_name"
// paths: "photo"
// }
//
// In JSON, the same mask is represented as below:
//
// {
// mask: "user.displayName,photo"
// }
//
// # Field Masks and Oneof Fields
//
// Field masks treat fields in oneofs just as regular fields. Consider the
// following message:
//
// message SampleMessage {
// oneof test_oneof {
// string name = 4;
// SubMessage sub_message = 9;
// }
// }
//
// The field mask can be:
//
// mask {
// paths: "name"
// }
//
// Or:
//
// mask {
// paths: "sub_message"
// }
//
// Note that oneof type names ("test_oneof" in this case) cannot be used in
// paths.
//
// ## Field Mask Verification
//
// The implementation of any API method which has a FieldMask type field in the
// request should verify the included field paths, and return an
// `INVALID_ARGUMENT` error if any path is unmappable.
message FieldMask {
// The set of field mask paths.
repeated string paths = 1;
}

View File

@@ -0,0 +1,427 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
//
// Sample messages to generate example code.
edition = "2023";
package protobuf_test_messages.edition;
import "google/protobuf/cpp_features.proto";
option optimize_for = SPEED;
option features.(pb.cpp).string_type = VIEW;
// This proto includes every type of field in both singular and repeated
// forms.
//
// Also, crucially, all messages and enums in this file are eventually
// submessages of this message. So for example, a fuzz test of TestAllTypes
// could trigger bugs that occur in any message type in this file. We verify
// this stays true in a unit test.
message TestAllTypesEdition {
message NestedMessage {
int32 a = 1;
TestAllTypesEdition corecursive = 2;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
NEG = -1; // Intentionally negative.
}
// Singular
int32 optional_int32 = 1;
int64 optional_int64 = 2;
uint32 optional_uint32 = 3;
uint64 optional_uint64 = 4;
sint32 optional_sint32 = 5;
sint64 optional_sint64 = 6;
fixed32 optional_fixed32 = 7;
fixed64 optional_fixed64 = 8;
sfixed32 optional_sfixed32 = 9;
sfixed64 optional_sfixed64 = 10;
float optional_float = 11;
double optional_double = 12;
bool optional_bool = 13;
string optional_string = 14;
bytes optional_bytes = 15;
NestedMessage optional_nested_message = 18;
ForeignMessageEdition optional_foreign_message = 19;
NestedEnum optional_nested_enum = 21;
ForeignEnumEdition optional_foreign_enum = 22;
string optional_string_piece = 24 [ctype = STRING_PIECE];
string optional_cord = 25 [ctype = CORD];
TestAllTypesEdition recursive_message = 27;
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
repeated uint32 repeated_uint32 = 33;
repeated uint64 repeated_uint64 = 34;
repeated sint32 repeated_sint32 = 35;
repeated sint64 repeated_sint64 = 36;
repeated fixed32 repeated_fixed32 = 37;
repeated fixed64 repeated_fixed64 = 38;
repeated sfixed32 repeated_sfixed32 = 39;
repeated sfixed64 repeated_sfixed64 = 40;
repeated float repeated_float = 41;
repeated double repeated_double = 42;
repeated bool repeated_bool = 43;
repeated string repeated_string = 44;
repeated bytes repeated_bytes = 45;
repeated NestedMessage repeated_nested_message = 48;
repeated ForeignMessageEdition repeated_foreign_message = 49;
repeated NestedEnum repeated_nested_enum = 51;
repeated ForeignEnumEdition repeated_foreign_enum = 52;
repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
repeated string repeated_cord = 55 [ctype = CORD];
// Packed
repeated int32 packed_int32 = 75 [features.repeated_field_encoding = PACKED];
repeated int64 packed_int64 = 76 [features.repeated_field_encoding = PACKED];
repeated uint32 packed_uint32 = 77
[features.repeated_field_encoding = PACKED];
repeated uint64 packed_uint64 = 78
[features.repeated_field_encoding = PACKED];
repeated sint32 packed_sint32 = 79
[features.repeated_field_encoding = PACKED];
repeated sint64 packed_sint64 = 80
[features.repeated_field_encoding = PACKED];
repeated fixed32 packed_fixed32 = 81
[features.repeated_field_encoding = PACKED];
repeated fixed64 packed_fixed64 = 82
[features.repeated_field_encoding = PACKED];
repeated sfixed32 packed_sfixed32 = 83
[features.repeated_field_encoding = PACKED];
repeated sfixed64 packed_sfixed64 = 84
[features.repeated_field_encoding = PACKED];
repeated float packed_float = 85 [features.repeated_field_encoding = PACKED];
repeated double packed_double = 86
[features.repeated_field_encoding = PACKED];
repeated bool packed_bool = 87 [features.repeated_field_encoding = PACKED];
repeated NestedEnum packed_nested_enum = 88
[features.repeated_field_encoding = PACKED];
// Unpacked
repeated int32 unpacked_int32 = 89
[features.repeated_field_encoding = EXPANDED];
repeated int64 unpacked_int64 = 90
[features.repeated_field_encoding = EXPANDED];
repeated uint32 unpacked_uint32 = 91
[features.repeated_field_encoding = EXPANDED];
repeated uint64 unpacked_uint64 = 92
[features.repeated_field_encoding = EXPANDED];
repeated sint32 unpacked_sint32 = 93
[features.repeated_field_encoding = EXPANDED];
repeated sint64 unpacked_sint64 = 94
[features.repeated_field_encoding = EXPANDED];
repeated fixed32 unpacked_fixed32 = 95
[features.repeated_field_encoding = EXPANDED];
repeated fixed64 unpacked_fixed64 = 96
[features.repeated_field_encoding = EXPANDED];
repeated sfixed32 unpacked_sfixed32 = 97
[features.repeated_field_encoding = EXPANDED];
repeated sfixed64 unpacked_sfixed64 = 98
[features.repeated_field_encoding = EXPANDED];
repeated float unpacked_float = 99
[features.repeated_field_encoding = EXPANDED];
repeated double unpacked_double = 100
[features.repeated_field_encoding = EXPANDED];
repeated bool unpacked_bool = 101
[features.repeated_field_encoding = EXPANDED];
repeated NestedEnum unpacked_nested_enum = 102
[features.repeated_field_encoding = EXPANDED];
// Map
map<int32, int32> map_int32_int32 = 56;
map<int64, int64> map_int64_int64 = 57;
map<uint32, uint32> map_uint32_uint32 = 58;
map<uint64, uint64> map_uint64_uint64 = 59;
map<sint32, sint32> map_sint32_sint32 = 60;
map<sint64, sint64> map_sint64_sint64 = 61;
map<fixed32, fixed32> map_fixed32_fixed32 = 62;
map<fixed64, fixed64> map_fixed64_fixed64 = 63;
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
map<int32, float> map_int32_float = 66;
map<int32, double> map_int32_double = 67;
map<bool, bool> map_bool_bool = 68;
map<string, string> map_string_string = 69;
map<string, bytes> map_string_bytes = 70;
map<string, NestedMessage> map_string_nested_message = 71;
map<string, ForeignMessageEdition> map_string_foreign_message = 72;
map<string, NestedEnum> map_string_nested_enum = 73;
map<string, ForeignEnumEdition> map_string_foreign_enum = 74;
oneof oneof_field {
uint32 oneof_uint32 = 111;
NestedMessage oneof_nested_message = 112;
string oneof_string = 113;
bytes oneof_bytes = 114;
bool oneof_bool = 115;
uint64 oneof_uint64 = 116;
float oneof_float = 117;
double oneof_double = 118;
NestedEnum oneof_enum = 119;
}
// extensions
extensions 120 to 200;
// groups
message Data {
int32 group_int32 = 202;
uint32 group_uint32 = 203;
}
Data data = 201 [features.message_encoding = DELIMITED];
// default values
int32 default_int32 = 241 [default = -123456789];
int64 default_int64 = 242 [default = -9123456789123456789];
uint32 default_uint32 = 243 [default = 2123456789];
uint64 default_uint64 = 244 [default = 10123456789123456789];
sint32 default_sint32 = 245 [default = -123456789];
sint64 default_sint64 = 246 [default = -9123456789123456789];
fixed32 default_fixed32 = 247 [default = 2123456789];
fixed64 default_fixed64 = 248 [default = 10123456789123456789];
sfixed32 default_sfixed32 = 249 [default = -123456789];
sfixed64 default_sfixed64 = 250 [default = -9123456789123456789];
float default_float = 251 [default = 9e9];
double default_double = 252 [default = 7e22];
bool default_bool = 253 [default = true];
string default_string = 254 [default = "Rosebud"];
bytes default_bytes = 255 [default = "joshua"];
// Test field-name-to-JSON-name convention.
// (protobuf says names can be any valid C/C++ identifier.)
int32 fieldname1 = 401;
int32 field_name2 = 402;
int32 _field_name3 = 403;
int32 field__name4_ = 404;
int32 field0name5 = 405;
int32 field_0_name6 = 406;
int32 fieldName7 = 407;
int32 FieldName8 = 408;
int32 field_Name9 = 409;
int32 Field_Name10 = 410;
int32 FIELD_NAME11 = 411;
int32 FIELD_name12 = 412;
int32 __field_name13 = 413;
int32 __Field_name14 = 414;
int32 field__name15 = 415;
int32 field__Name16 = 416;
int32 field_name17__ = 417;
int32 Field_name18__ = 418;
// Reserved for unknown fields test.
reserved 1000 to 9999;
// message_set test case.
message MessageSetCorrect {
option message_set_wire_format = true;
extensions 4 to max;
}
message MessageSetCorrectExtension1 {
extend MessageSetCorrect {
MessageSetCorrectExtension1 message_set_extension = 1547769;
}
string str = 25;
}
message MessageSetCorrectExtension2 {
extend MessageSetCorrect {
MessageSetCorrectExtension2 message_set_extension = 4135312;
}
int32 i = 9;
}
}
message ForeignMessageEdition {
int32 c = 1;
}
enum ForeignEnumEdition {
FOREIGN_FOO = 0;
FOREIGN_BAR = 1;
FOREIGN_BAZ = 2;
}
extend TestAllTypesEdition {
int32 extension_int32 = 120;
}
message UnknownToTestAllTypes {
int32 optional_int32 = 1001;
string optional_string = 1002;
ForeignMessageEdition nested_message = 1003;
message OptionalGroup {
int32 a = 1;
}
OptionalGroup optionalgroup = 1004 [features.message_encoding = DELIMITED];
bool optional_bool = 1006;
repeated int32 repeated_int32 = 1011;
}
message NullHypothesisEdition {}
message EnumOnlyEdition {
enum Bool {
kFalse = 0;
kTrue = 1;
}
}
message OneStringEdition {
string data = 1;
}
message ProtoWithKeywords {
int32 inline = 1;
string concept = 2;
repeated string requires = 3;
}
message TestAllRequiredTypesEdition {
message NestedMessage {
int32 a = 1 [features.field_presence = LEGACY_REQUIRED];
TestAllRequiredTypesEdition corecursive = 2
[features.field_presence = LEGACY_REQUIRED];
TestAllRequiredTypesEdition optional_corecursive = 3;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
NEG = -1; // Intentionally negative.
}
// Singular
int32 required_int32 = 1 [features.field_presence = LEGACY_REQUIRED];
int64 required_int64 = 2 [features.field_presence = LEGACY_REQUIRED];
uint32 required_uint32 = 3 [features.field_presence = LEGACY_REQUIRED];
uint64 required_uint64 = 4 [features.field_presence = LEGACY_REQUIRED];
sint32 required_sint32 = 5 [features.field_presence = LEGACY_REQUIRED];
sint64 required_sint64 = 6 [features.field_presence = LEGACY_REQUIRED];
fixed32 required_fixed32 = 7 [features.field_presence = LEGACY_REQUIRED];
fixed64 required_fixed64 = 8 [features.field_presence = LEGACY_REQUIRED];
sfixed32 required_sfixed32 = 9 [features.field_presence = LEGACY_REQUIRED];
sfixed64 required_sfixed64 = 10 [features.field_presence = LEGACY_REQUIRED];
float required_float = 11 [features.field_presence = LEGACY_REQUIRED];
double required_double = 12 [features.field_presence = LEGACY_REQUIRED];
bool required_bool = 13 [features.field_presence = LEGACY_REQUIRED];
string required_string = 14 [features.field_presence = LEGACY_REQUIRED];
bytes required_bytes = 15 [features.field_presence = LEGACY_REQUIRED];
NestedMessage required_nested_message = 18
[features.field_presence = LEGACY_REQUIRED];
ForeignMessageEdition required_foreign_message = 19
[features.field_presence = LEGACY_REQUIRED];
NestedEnum required_nested_enum = 21
[features.field_presence = LEGACY_REQUIRED];
ForeignEnumEdition required_foreign_enum = 22
[features.field_presence = LEGACY_REQUIRED];
string required_string_piece = 24
[ctype = STRING_PIECE, features.field_presence = LEGACY_REQUIRED];
string required_cord = 25
[ctype = CORD, features.field_presence = LEGACY_REQUIRED];
TestAllRequiredTypesEdition recursive_message = 27;
TestAllRequiredTypesEdition optional_recursive_message = 28;
// extensions
extensions 120 to 200;
// groups
message Data {
int32 group_int32 = 202 [features.field_presence = LEGACY_REQUIRED];
uint32 group_uint32 = 203 [features.field_presence = LEGACY_REQUIRED];
}
Data data = 201 [features.message_encoding = DELIMITED];
// default values
int32 default_int32 = 241
[default = -123456789, features.field_presence = LEGACY_REQUIRED];
int64 default_int64 = 242 [
default = -9123456789123456789,
features.field_presence = LEGACY_REQUIRED
];
uint32 default_uint32 = 243
[default = 2123456789, features.field_presence = LEGACY_REQUIRED];
uint64 default_uint64 = 244 [
default = 10123456789123456789,
features.field_presence = LEGACY_REQUIRED
];
sint32 default_sint32 = 245
[default = -123456789, features.field_presence = LEGACY_REQUIRED];
sint64 default_sint64 = 246 [
default = -9123456789123456789,
features.field_presence = LEGACY_REQUIRED
];
fixed32 default_fixed32 = 247
[default = 2123456789, features.field_presence = LEGACY_REQUIRED];
fixed64 default_fixed64 = 248 [
default = 10123456789123456789,
features.field_presence = LEGACY_REQUIRED
];
sfixed32 default_sfixed32 = 249
[default = -123456789, features.field_presence = LEGACY_REQUIRED];
sfixed64 default_sfixed64 = 250 [
default = -9123456789123456789,
features.field_presence = LEGACY_REQUIRED
];
float default_float = 251
[default = 9e9, features.field_presence = LEGACY_REQUIRED];
double default_double = 252
[default = 7e22, features.field_presence = LEGACY_REQUIRED];
bool default_bool = 253
[default = true, features.field_presence = LEGACY_REQUIRED];
string default_string = 254
[default = "Rosebud", features.field_presence = LEGACY_REQUIRED];
bytes default_bytes = 255
[default = "joshua", features.field_presence = LEGACY_REQUIRED];
// Reserved for unknown fields test.
reserved 1000 to 9999;
// message_set test case.
message MessageSetCorrect {
option message_set_wire_format = true;
extensions 4 to max;
}
message MessageSetCorrectExtension1 {
extend MessageSetCorrect {
MessageSetCorrectExtension1 message_set_extension = 1547769;
}
string str = 25 [features.field_presence = LEGACY_REQUIRED];
}
message MessageSetCorrectExtension2 {
extend MessageSetCorrect {
MessageSetCorrectExtension2 message_set_extension = 4135312;
}
int32 i = 9 [features.field_presence = LEGACY_REQUIRED];
}
}

View File

@@ -0,0 +1,48 @@
// 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.
syntax = "proto3";
package google.protobuf;
option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb";
// `SourceContext` represents information about the source of a
// protobuf element, like the file in which it is defined.
message SourceContext {
// The path-qualified name of the .proto file that contained the associated
// protobuf element. For example: `"google/protobuf/source_context.proto"`.
string file_name = 1;
}

View File

@@ -0,0 +1,95 @@
// 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.
syntax = "proto3";
package google.protobuf;
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct`
// might be supported by a native representation. For example, in
// scripting languages like JS a struct is represented as an
// object. The details of that representation are described together
// with the proto support for the language.
//
// The JSON representation for `Struct` is JSON object.
message Struct {
// Unordered map of dynamically typed values.
map<string, Value> fields = 1;
}
// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of these
// variants. Absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value {
// The kind of value.
oneof kind {
// Represents a null value.
NullValue null_value = 1;
// Represents a double value.
double number_value = 2;
// Represents a string value.
string string_value = 3;
// Represents a boolean value.
bool bool_value = 4;
// Represents a structured value.
Struct struct_value = 5;
// Represents a repeated `Value`.
ListValue list_value = 6;
}
}
// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
enum NullValue {
// Null value.
NULL_VALUE = 0;
}
// `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
message ListValue {
// Repeated field of dynamically typed values.
repeated Value values = 1;
}

View File

@@ -0,0 +1,144 @@
// 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.
syntax = "proto3";
package google.protobuf;
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/timestamppb";
option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at
// nanosecond resolution. The count is relative to an epoch at UTC midnight on
// January 1, 1970, in the proleptic Gregorian calendar which extends the
// Gregorian calendar backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a [24-hour linear
// smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from [RFC
// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
// Example 5: Compute Timestamp from Java `Instant.now()`.
//
// Instant now = Instant.now();
//
// Timestamp timestamp =
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
// .setNanos(now.getNano()).build();
//
// Example 6: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required. A proto3 JSON serializer should always use UTC (as indicated by
// "Z") when printing the Timestamp type and a proto3 JSON parser should be
// able to accept both UTC and other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
// the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
// ) to obtain a formatter capable of generating timestamps in this format.
//
message Timestamp {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1;
// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
int32 nanos = 2;
}

View File

@@ -0,0 +1,193 @@
// 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.
syntax = "proto3";
package google.protobuf;
import "google/protobuf/any.proto";
import "google/protobuf/source_context.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf";
option java_outer_classname = "TypeProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/typepb";
// A protocol buffer message type.
message Type {
// The fully qualified message name.
string name = 1;
// The list of fields.
repeated Field fields = 2;
// The list of types appearing in `oneof` definitions in this type.
repeated string oneofs = 3;
// The protocol buffer options.
repeated Option options = 4;
// The source context.
SourceContext source_context = 5;
// The source syntax.
Syntax syntax = 6;
// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
string edition = 7;
}
// A single field of a message type.
message Field {
// Basic field types.
enum Kind {
// Field type unknown.
TYPE_UNKNOWN = 0;
// Field type double.
TYPE_DOUBLE = 1;
// Field type float.
TYPE_FLOAT = 2;
// Field type int64.
TYPE_INT64 = 3;
// Field type uint64.
TYPE_UINT64 = 4;
// Field type int32.
TYPE_INT32 = 5;
// Field type fixed64.
TYPE_FIXED64 = 6;
// Field type fixed32.
TYPE_FIXED32 = 7;
// Field type bool.
TYPE_BOOL = 8;
// Field type string.
TYPE_STRING = 9;
// Field type group. Proto2 syntax only, and deprecated.
TYPE_GROUP = 10;
// Field type message.
TYPE_MESSAGE = 11;
// Field type bytes.
TYPE_BYTES = 12;
// Field type uint32.
TYPE_UINT32 = 13;
// Field type enum.
TYPE_ENUM = 14;
// Field type sfixed32.
TYPE_SFIXED32 = 15;
// Field type sfixed64.
TYPE_SFIXED64 = 16;
// Field type sint32.
TYPE_SINT32 = 17;
// Field type sint64.
TYPE_SINT64 = 18;
}
// Whether a field is optional, required, or repeated.
enum Cardinality {
// For fields with unknown cardinality.
CARDINALITY_UNKNOWN = 0;
// For optional fields.
CARDINALITY_OPTIONAL = 1;
// For required fields. Proto2 syntax only.
CARDINALITY_REQUIRED = 2;
// For repeated fields.
CARDINALITY_REPEATED = 3;
}
// The field type.
Kind kind = 1;
// The field cardinality.
Cardinality cardinality = 2;
// The field number.
int32 number = 3;
// The field name.
string name = 4;
// The field type URL, without the scheme, for message or enumeration
// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
// The index of the field type in `Type.oneofs`, for message or enumeration
// types. The first type has index 1; zero means the type is not in the list.
int32 oneof_index = 7;
// Whether to use alternative packed wire representation.
bool packed = 8;
// The protocol buffer options.
repeated Option options = 9;
// The field JSON name.
string json_name = 10;
// The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
}
// Enum type definition.
message Enum {
// Enum type name.
string name = 1;
// Enum value definitions.
repeated EnumValue enumvalue = 2;
// Protocol buffer options.
repeated Option options = 3;
// The source context.
SourceContext source_context = 4;
// The source syntax.
Syntax syntax = 5;
// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
string edition = 6;
}
// Enum value definition.
message EnumValue {
// Enum value name.
string name = 1;
// Enum value number.
int32 number = 2;
// Protocol buffer options.
repeated Option options = 3;
}
// A protocol buffer option, which can be attached to a message, field,
// enumeration, etc.
message Option {
// The option's name. For protobuf built-in options (options defined in
// descriptor.proto), this is the short name. For example, `"map_entry"`.
// For custom options, it should be the fully-qualified name. For example,
// `"google.api.http"`.
string name = 1;
// The option's value packed in an Any message. If the value is a primitive,
// the corresponding wrapper type defined in google/protobuf/wrappers.proto
// should be used. If the value is an enum, it should be stored as an int32
// value using the google.protobuf.Int32Value type.
Any value = 2;
}
// The syntax in which a protocol buffer element is defined.
enum Syntax {
// Syntax `proto2`.
SYNTAX_PROTO2 = 0;
// Syntax `proto3`.
SYNTAX_PROTO3 = 1;
// Syntax `editions`.
SYNTAX_EDITIONS = 2;
}

View File

@@ -0,0 +1,116 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// A proto file we will use for unit testing.
syntax = "proto2";
package protobuf_unittest;
message TestFlagsAndStrings {
required int32 A = 1;
repeated group RepeatedGroup = 2 {
required string f = 3;
}
}
message TestBase64ByteArrays {
required bytes a = 1;
}
message TestJavaScriptJSON {
optional int32 a = 1;
optional float final = 2;
optional string in = 3;
optional string Var = 4;
}
message TestJavaScriptOrderJSON1 {
optional int32 d = 1;
optional int32 c = 2;
optional bool x = 3;
optional int32 b = 4;
optional int32 a = 5;
}
message TestJavaScriptOrderJSON2 {
optional int32 d = 1;
optional int32 c = 2;
optional bool x = 3;
optional int32 b = 4;
optional int32 a = 5;
repeated TestJavaScriptOrderJSON1 z = 6;
}
message TestLargeInt {
required int64 a = 1;
required uint64 b = 2;
}
message TestNumbers {
enum MyType {
OK = 0;
WARNING = 1;
ERROR = 2;
}
optional MyType a = 1;
optional int32 b = 2;
optional float c = 3;
optional bool d = 4;
optional double e = 5;
optional uint32 f = 6;
}
message TestCamelCase {
optional string normal_field = 1;
optional int32 CAPITAL_FIELD = 2;
optional int32 CamelCaseField = 3;
}
message TestBoolMap {
map<bool, int32> bool_map = 1;
}
message TestRecursion {
optional int32 value = 1;
optional TestRecursion child = 2;
}
message TestStringMap {
map<string, string> string_map = 1;
}
message TestStringSerializer {
optional string scalar_string = 1;
repeated string repeated_string = 2;
map<string, string> string_map = 3;
}
message TestMessageWithExtension {
extensions 100 to max;
}
message TestExtension {
extend TestMessageWithExtension {
optional TestExtension ext = 100;
}
optional string value = 1;
}
enum EnumValue {
PROTOCOL = 0;
BUFFER = 1;
DEFAULT = 2;
}
message TestDefaultEnumValue {
optional EnumValue enum_value = 1 [default = DEFAULT];
}

View File

@@ -0,0 +1,301 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
syntax = "proto3";
package proto3;
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/unittest.proto";
option java_package = "com.google.protobuf.util";
option java_outer_classname = "JsonFormatProto3";
enum EnumType {
FOO = 0;
BAR = 1;
TLSv1_2 = 2;
}
message MessageType {
int32 value = 1;
}
message TestMessage {
bool bool_value = 1;
int32 int32_value = 2;
int64 int64_value = 3;
uint32 uint32_value = 4;
uint64 uint64_value = 5;
float float_value = 6;
double double_value = 7;
string string_value = 8;
bytes bytes_value = 9;
EnumType enum_value = 10;
MessageType message_value = 11;
repeated bool repeated_bool_value = 21;
repeated int32 repeated_int32_value = 22;
repeated int64 repeated_int64_value = 23;
repeated uint32 repeated_uint32_value = 24;
repeated uint64 repeated_uint64_value = 25;
repeated float repeated_float_value = 26;
repeated double repeated_double_value = 27;
repeated string repeated_string_value = 28;
repeated bytes repeated_bytes_value = 29;
repeated EnumType repeated_enum_value = 30;
repeated MessageType repeated_message_value = 31;
optional bool optional_bool_value = 41;
optional int32 optional_int32_value = 42;
optional int64 optional_int64_value = 43;
optional uint32 optional_uint32_value = 44;
optional uint64 optional_uint64_value = 45;
optional float optional_float_value = 46;
optional double optional_double_value = 47;
optional string optional_string_value = 48;
optional bytes optional_bytes_value = 49;
optional EnumType optional_enum_value = 50;
optional MessageType optional_message_value = 51;
}
message TestOneof {
// In JSON format oneof fields behave mostly the same as optional
// fields except that:
// 1. Oneof fields have field presence information and will be
// printed if it's set no matter whether it's the default value.
// 2. Multiple oneof fields in the same oneof cannot appear at the
// same time in the input.
oneof oneof_value {
int32 oneof_int32_value = 1;
string oneof_string_value = 2;
bytes oneof_bytes_value = 3;
EnumType oneof_enum_value = 4;
MessageType oneof_message_value = 5;
google.protobuf.NullValue oneof_null_value = 6;
}
}
message TestMap {
map<bool, int32> bool_map = 1;
map<int32, int32> int32_map = 2;
map<int64, int32> int64_map = 3;
map<uint32, int32> uint32_map = 4;
map<uint64, int32> uint64_map = 5;
map<string, int32> string_map = 6;
}
message TestNestedMap {
map<bool, int32> bool_map = 1;
map<int32, int32> int32_map = 2;
map<int64, int32> int64_map = 3;
map<uint32, int32> uint32_map = 4;
map<uint64, int32> uint64_map = 5;
map<string, int32> string_map = 6;
map<string, TestNestedMap> map_map = 7;
}
message TestStringMap {
map<string, string> string_map = 1;
}
message TestWrapper {
google.protobuf.BoolValue bool_value = 1;
google.protobuf.Int32Value int32_value = 2;
google.protobuf.Int64Value int64_value = 3;
google.protobuf.UInt32Value uint32_value = 4;
google.protobuf.UInt64Value uint64_value = 5;
google.protobuf.FloatValue float_value = 6;
google.protobuf.DoubleValue double_value = 7;
google.protobuf.StringValue string_value = 8;
google.protobuf.BytesValue bytes_value = 9;
repeated google.protobuf.BoolValue repeated_bool_value = 11;
repeated google.protobuf.Int32Value repeated_int32_value = 12;
repeated google.protobuf.Int64Value repeated_int64_value = 13;
repeated google.protobuf.UInt32Value repeated_uint32_value = 14;
repeated google.protobuf.UInt64Value repeated_uint64_value = 15;
repeated google.protobuf.FloatValue repeated_float_value = 16;
repeated google.protobuf.DoubleValue repeated_double_value = 17;
repeated google.protobuf.StringValue repeated_string_value = 18;
repeated google.protobuf.BytesValue repeated_bytes_value = 19;
}
message TestTimestamp {
google.protobuf.Timestamp value = 1;
repeated google.protobuf.Timestamp repeated_value = 2;
}
message TestDuration {
google.protobuf.Duration value = 1;
repeated google.protobuf.Duration repeated_value = 2;
}
message TestFieldMask {
google.protobuf.FieldMask value = 1;
}
message TestStruct {
google.protobuf.Struct value = 1;
repeated google.protobuf.Struct repeated_value = 2;
}
message TestAny {
google.protobuf.Any value = 1;
repeated google.protobuf.Any repeated_value = 2;
}
message TestValue {
google.protobuf.Value value = 1;
repeated google.protobuf.Value repeated_value = 2;
}
message TestListValue {
google.protobuf.ListValue value = 1;
repeated google.protobuf.ListValue repeated_value = 2;
}
message TestBoolValue {
bool bool_value = 1;
map<bool, int32> bool_map = 2;
}
message TestNullValue {
google.protobuf.NullValue null_value = 20;
repeated google.protobuf.NullValue repeated_null_value = 21;
}
message TestCustomJsonName {
int32 value = 1 [json_name = "@value"];
}
message TestEvilJson {
int32 regular_value = 1 [json_name = "regular_name"];
int32 script = 2 [json_name = "</script>"];
int32 quotes = 3 [json_name = "unbalanced\"quotes"];
int32 script_and_quotes = 4
[json_name = "\"<script>alert('hello!);</script>"];
}
message TestExtensions {
.protobuf_unittest.TestAllExtensions extensions = 1;
}
message TestEnumValue {
EnumType enum_value1 = 1;
EnumType enum_value2 = 2;
EnumType enum_value3 = 3;
}
message MapsTestCases {
EmptyMap empty_map = 1;
StringtoInt string_to_int = 2;
IntToString int_to_string = 3;
Mixed1 mixed1 = 4;
Mixed2 mixed2 = 5;
MapOfObjects map_of_objects = 6;
// Empty key tests
StringtoInt empty_key_string_to_int1 = 7;
StringtoInt empty_key_string_to_int2 = 8;
StringtoInt empty_key_string_to_int3 = 9;
BoolToString empty_key_bool_to_string = 10;
IntToString empty_key_int_to_string = 11;
Mixed1 empty_key_mixed = 12;
MapOfObjects empty_key_map_objects = 13;
}
message EmptyMap {
map<int32, int32> map = 1;
}
message StringtoInt {
map<string, int32> map = 1;
}
message IntToString {
map<int32, string> map = 1;
}
message BoolToString {
map<bool, string> map = 1;
}
message Mixed1 {
string msg = 1;
map<string, float> map = 2;
}
message Mixed2 {
enum E {
E0 = 0;
E1 = 1;
E2 = 2;
E3 = 3;
}
map<int32, bool> map = 1;
E ee = 2;
}
message MapOfObjects {
message M {
string inner_text = 1;
}
map<string, M> map = 1;
}
message MapIn {
string other = 1;
repeated string things = 2;
map<string, string> map_input = 3;
map<string, google.protobuf.Any> map_any = 4;
}
message MapOut {
map<string, MapM> map1 = 1;
map<string, MapOut> map2 = 2;
map<int32, string> map3 = 3;
map<bool, string> map4 = 5;
string bar = 4;
}
// A message with exactly the same wire representation as MapOut, but using
// repeated message fields instead of map fields. We use this message to test
// the wire-format compatibility of the JSON transcoder (e.g., whether it
// handles missing keys correctly).
message MapOutWireFormat {
message Map1Entry {
string key = 1;
MapM value = 2;
}
repeated Map1Entry map1 = 1;
message Map2Entry {
string key = 1;
MapOut value = 2;
}
repeated Map2Entry map2 = 2;
message Map3Entry {
int32 key = 1;
string value = 2;
}
repeated Map3Entry map3 = 3;
message Map4Entry {
bool key = 1;
string value = 2;
}
repeated Map4Entry map4 = 5;
string bar = 4;
}
message MapM {
string foo = 1;
}

View File

@@ -0,0 +1,123 @@
// 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.
//
// Wrappers for primitive (non-message) types. These types are useful
// for embedding primitives in the `google.protobuf.Any` type and for places
// where we need to distinguish between the absence of a primitive
// typed field and its default value.
//
// These wrappers have no meaningful use within repeated fields as they lack
// the ability to detect presence on individual elements.
// These wrappers have no meaningful use within a map or a oneof since
// individual entries of a map or fields of a oneof can already detect presence.
syntax = "proto3";
package google.protobuf;
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/wrapperspb";
option java_package = "com.google.protobuf";
option java_outer_classname = "WrappersProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// Wrapper message for `double`.
//
// The JSON representation for `DoubleValue` is JSON number.
message DoubleValue {
// The double value.
double value = 1;
}
// Wrapper message for `float`.
//
// The JSON representation for `FloatValue` is JSON number.
message FloatValue {
// The float value.
float value = 1;
}
// Wrapper message for `int64`.
//
// The JSON representation for `Int64Value` is JSON string.
message Int64Value {
// The int64 value.
int64 value = 1;
}
// Wrapper message for `uint64`.
//
// The JSON representation for `UInt64Value` is JSON string.
message UInt64Value {
// The uint64 value.
uint64 value = 1;
}
// Wrapper message for `int32`.
//
// The JSON representation for `Int32Value` is JSON number.
message Int32Value {
// The int32 value.
int32 value = 1;
}
// Wrapper message for `uint32`.
//
// The JSON representation for `UInt32Value` is JSON number.
message UInt32Value {
// The uint32 value.
uint32 value = 1;
}
// Wrapper message for `bool`.
//
// The JSON representation for `BoolValue` is JSON `true` and `false`.
message BoolValue {
// The bool value.
bool value = 1;
}
// Wrapper message for `string`.
//
// The JSON representation for `StringValue` is JSON string.
message StringValue {
// The string value.
string value = 1;
}
// Wrapper message for `bytes`.
//
// The JSON representation for `BytesValue` is JSON string.
message BytesValue {
// The bytes value.
bytes value = 1;
}