Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 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 | |
| 31 | // Author: mwr@google.com (Mark Rawling) |
| 32 | |
| 33 | syntax = "proto2"; |
| 34 | |
| 35 | option java_package = "com.google.apps.jspb.proto"; |
| 36 | option java_multiple_files = true; |
| 37 | |
| 38 | import "google/protobuf/descriptor.proto"; |
| 39 | |
| 40 | package jspb.test; |
| 41 | |
| 42 | message Empty { |
| 43 | } |
| 44 | |
| 45 | enum OuterEnum { |
| 46 | FOO = 1; |
| 47 | BAR = 2; |
| 48 | } |
| 49 | |
| 50 | message EnumContainer { |
| 51 | optional OuterEnum outer_enum = 1; |
| 52 | } |
| 53 | |
| 54 | message Simple1 { |
| 55 | required string a_string = 1; |
| 56 | repeated string a_repeated_string = 2; |
| 57 | optional bool a_boolean = 3; |
| 58 | } |
| 59 | |
| 60 | // A message that differs from Simple1 only by name |
| 61 | message Simple2 { |
| 62 | required string a_string = 1; |
| 63 | repeated string a_repeated_string = 2; |
| 64 | } |
| 65 | |
| 66 | message SpecialCases { |
| 67 | required string normal = 1; |
| 68 | // Examples of Js reserved names that are converted to pb_<name>. |
| 69 | required string default = 2; |
| 70 | required string function = 3; |
| 71 | required string var = 4; |
| 72 | } |
| 73 | |
| 74 | message OptionalFields { |
| 75 | message Nested { |
| 76 | optional int32 an_int = 1; |
| 77 | } |
| 78 | optional string a_string = 1; |
| 79 | required bool a_bool = 2; |
| 80 | optional Nested a_nested_message = 3; |
| 81 | repeated Nested a_repeated_message = 4; |
| 82 | repeated string a_repeated_string = 5; |
| 83 | } |
| 84 | |
| 85 | message HasExtensions { |
| 86 | optional string str1 = 1; |
| 87 | optional string str2 = 2; |
| 88 | optional string str3 = 3; |
| 89 | extensions 10 to max; |
| 90 | } |
| 91 | |
| 92 | message Complex { |
| 93 | message Nested { |
| 94 | required int32 an_int = 2; |
| 95 | } |
| 96 | required string a_string = 1; |
| 97 | required bool an_out_of_order_bool = 9; |
| 98 | optional Nested a_nested_message = 4; |
| 99 | repeated Nested a_repeated_message = 5; |
| 100 | repeated string a_repeated_string = 7; |
| 101 | } |
| 102 | |
| 103 | message IsExtension { |
| 104 | extend HasExtensions { |
| 105 | optional IsExtension ext_field = 100; |
| 106 | } |
| 107 | optional string ext1 = 1; |
| 108 | |
| 109 | // Extensions of proto2 Descriptor messages will be ignored. |
| 110 | extend google.protobuf.EnumOptions { |
| 111 | optional string simple_option = 42113038; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | message IndirectExtension { |
| 116 | extend HasExtensions { |
| 117 | optional Simple1 simple = 101; |
| 118 | optional string str = 102; |
| 119 | repeated string repeated_str = 103; |
| 120 | repeated Simple1 repeated_simple = 104; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | extend HasExtensions { |
| 125 | optional Simple1 simple1 = 105; |
| 126 | } |
| 127 | |
| 128 | message DefaultValues { |
| 129 | enum Enum { |
| 130 | E1 = 13; |
| 131 | E2 = 77; |
| 132 | } |
| 133 | optional string string_field = 1 [default="default<>\'\"abc"]; |
| 134 | optional bool bool_field = 2 [default=true]; |
| 135 | optional int64 int_field = 3 [default=11]; |
| 136 | optional Enum enum_field = 4 [default=E1]; |
| 137 | optional string empty_field = 6 [default=""]; |
| 138 | optional bytes bytes_field = 8 [default="moo"]; // Base64 encoding is "bW9v" |
| 139 | } |
| 140 | |
| 141 | message TestClone { |
| 142 | optional string str = 1; |
| 143 | optional Simple1 simple1 = 3; |
| 144 | repeated Simple1 simple2 = 5; |
| 145 | optional string unused = 7; |
| 146 | extensions 10 to max; |
| 147 | } |
| 148 | |
| 149 | message CloneExtension { |
| 150 | extend TestClone { |
| 151 | optional CloneExtension ext_field = 100; |
| 152 | } |
| 153 | optional string ext = 2; |
| 154 | } |
| 155 | |
| 156 | message TestGroup { |
| 157 | repeated group RepeatedGroup = 1 { |
| 158 | required string id = 1; |
| 159 | repeated bool some_bool = 2; |
| 160 | } |
| 161 | required group RequiredGroup = 2 { |
| 162 | required string id = 1; |
| 163 | } |
| 164 | optional group OptionalGroup = 3 { |
| 165 | required string id = 1; |
| 166 | } |
| 167 | optional string id = 4; |
| 168 | required Simple2 required_simple = 5; |
| 169 | optional Simple2 optional_simple = 6; |
| 170 | } |
| 171 | |
| 172 | message TestGroup1 { |
| 173 | optional TestGroup.RepeatedGroup group = 1; |
| 174 | } |
| 175 | |
| 176 | message TestReservedNames { |
| 177 | optional int32 extension = 1; |
| 178 | extensions 10 to max; |
| 179 | } |
| 180 | |
| 181 | message TestReservedNamesExtension { |
| 182 | extend TestReservedNames { |
| 183 | optional int32 foo = 10; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | message TestMessageWithOneof { |
| 188 | |
| 189 | oneof partial_oneof { |
| 190 | string pone = 3; |
| 191 | string pthree = 5; |
| 192 | } |
| 193 | |
| 194 | oneof recursive_oneof { |
| 195 | TestMessageWithOneof rone = 6; |
| 196 | string rtwo = 7; |
| 197 | } |
| 198 | |
| 199 | optional bool normal_field = 8; |
| 200 | repeated string repeated_field = 9; |
| 201 | |
| 202 | oneof default_oneof_a { |
| 203 | int32 aone = 10 [default = 1234]; |
| 204 | int32 atwo = 11; |
| 205 | } |
| 206 | |
| 207 | oneof default_oneof_b { |
| 208 | int32 bone = 12; |
| 209 | int32 btwo = 13 [default = 1234]; |
| 210 | } |
| 211 | } |
| 212 | |