• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc.  All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9//     * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11//     * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15//     * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31syntax = "proto3";
32
33package protobuf_unittest;
34
35import "google/protobuf/descriptor.proto";
36
37option java_multiple_files = true;
38option java_package = "com.google.protobuf.testing.proto";
39
40message TestProto3Optional {
41  message NestedMessage {
42    // The field name "b" fails to compile in proto1 because it conflicts with
43    // a local variable named "b" in one of the generated methods.  Doh.
44    // This file needs to compile in proto1 to test backwards-compatibility.
45    optional int32 bb = 1;
46  }
47
48  enum NestedEnum {
49    UNSPECIFIED = 0;
50    FOO = 1;
51    BAR = 2;
52    BAZ = 3;
53    NEG = -1;  // Intentionally negative.
54  }
55
56  // Singular
57  optional int32 optional_int32 = 1;
58  optional int64 optional_int64 = 2;
59  optional uint32 optional_uint32 = 3;
60  optional uint64 optional_uint64 = 4;
61  optional sint32 optional_sint32 = 5;
62  optional sint64 optional_sint64 = 6;
63  optional fixed32 optional_fixed32 = 7;
64  optional fixed64 optional_fixed64 = 8;
65  optional sfixed32 optional_sfixed32 = 9;
66  optional sfixed64 optional_sfixed64 = 10;
67  optional float optional_float = 11;
68  optional double optional_double = 12;
69  optional bool optional_bool = 13;
70  optional string optional_string = 14;
71  optional bytes optional_bytes = 15;
72  optional string optional_cord = 16 [ctype = CORD];
73
74  optional NestedMessage optional_nested_message = 18;
75  optional NestedMessage lazy_nested_message = 19 [lazy = true];
76  optional NestedEnum optional_nested_enum = 21;
77
78  // Add some non-optional fields to verify we can mix them.
79  int32 singular_int32 = 22;
80  int64 singular_int64 = 23;
81}
82
83message TestProto3OptionalMessage {
84  message NestedMessage {
85    string s = 1;
86  }
87
88  NestedMessage nested_message = 1;
89  optional NestedMessage optional_nested_message = 2;
90}
91
92message Proto3OptionalExtensions {
93  option (protobuf_unittest.Proto3OptionalExtensions.ext_no_optional) = 8;
94  option (protobuf_unittest.Proto3OptionalExtensions.ext_with_optional) = 16;
95
96  extend google.protobuf.MessageOptions {
97    int32 ext_no_optional = 355886728;
98    optional int32 ext_with_optional = 355886729;
99  }
100}
101