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 33syntax = "proto2"; 34 35option java_package = "com.google.apps.jspb.proto"; 36option java_multiple_files = true; 37 38import "google/protobuf/descriptor.proto"; 39 40package jspb.test; 41 42message Empty {} 43 44enum OuterEnum { 45 FOO = 1; 46 BAR = 2; 47} 48 49message EnumContainer { 50 optional OuterEnum outer_enum = 1; 51} 52 53message Simple1 { 54 required string a_string = 1; 55 repeated string a_repeated_string = 2; 56 optional bool a_boolean = 3; 57} 58 59// A message that differs from Simple1 only by name 60message Simple2 { 61 required string a_string = 1; 62 repeated string a_repeated_string = 2; 63} 64 65message SpecialCases { 66 required string normal = 1; 67 // Examples of Js reserved names that are converted to pb_<name>. 68 required string default = 2; 69 required string function = 3; 70 required string var = 4; 71} 72 73message OptionalFields { 74 message Nested { 75 optional int32 an_int = 1; 76 } 77 optional string a_string = 1; 78 required bool a_bool = 2; 79 optional Nested a_nested_message = 3; 80 repeated Nested a_repeated_message = 4; 81 repeated string a_repeated_string = 5; 82} 83 84message HasExtensions { 85 optional string str1 = 1; 86 optional string str2 = 2; 87 optional string str3 = 3; 88 extensions 10 to max; 89} 90 91message Complex { 92 message Nested { 93 required int32 an_int = 2; 94 } 95 required string a_string = 1; 96 optional bool an_out_of_order_bool = 9; 97 optional Nested a_nested_message = 4; 98 repeated Nested a_repeated_message = 5; 99 repeated string a_repeated_string = 7; 100 optional double a_floating_point_field = 10; 101} 102 103message OuterMessage { 104 // Make sure this doesn't conflict with the other Complex message. 105 message Complex { 106 optional int32 inner_complex_field = 1; 107 } 108} 109 110message MineField { 111 // document.cookie is a banned property in a couple of conformance check 112 // configs at Google. Verify that having a field called cookie doesn't confuse 113 // the compiler and break the build. 114 optional string cookie = 1; 115} 116 117message IsExtension { 118 extend HasExtensions { 119 optional IsExtension ext_field = 100; 120 } 121 optional string ext1 = 1; 122 123 // Extensions of proto2 Descriptor messages will be ignored. 124 extend google.protobuf.EnumOptions { 125 optional string simple_option = 42113038; 126 } 127} 128 129message IndirectExtension { 130 extend HasExtensions { 131 optional Simple1 simple = 101; 132 optional string str = 102; 133 repeated string repeated_str = 103; 134 repeated Simple1 repeated_simple = 104; 135 } 136} 137 138extend HasExtensions { 139 optional Simple1 simple1 = 105; 140} 141 142message DefaultValues { 143 enum Enum { 144 E1 = 13; 145 E2 = 77; 146 } 147 optional string string_field = 1 [default = "default<>\'\"abc"]; 148 optional bool bool_field = 2 [default = true]; 149 optional int64 int_field = 3 [default = 11]; 150 optional Enum enum_field = 4 [default = E1]; 151 optional string empty_field = 6 [default = ""]; 152 optional bytes bytes_field = 8 153 [default = "moo"]; // Base64 encoding is "bW9v" 154} 155 156message FloatingPointFields { 157 optional float optional_float_field = 1; 158 required float required_float_field = 2; 159 repeated float repeated_float_field = 3; 160 optional float default_float_field = 4 [default = 2.0]; 161 optional double optional_double_field = 5; 162 required double required_double_field = 6; 163 repeated double repeated_double_field = 7; 164 optional double default_double_field = 8 [default = 2.0]; 165} 166 167message BooleanFields { 168 optional bool optional_boolean_field = 1; 169 required bool required_boolean_field = 2; 170 repeated bool repeated_boolean_field = 3; 171 optional bool default_boolean_field = 4 [default = true]; 172} 173 174message TestClone { 175 optional string str = 1; 176 optional Simple1 simple1 = 3; 177 repeated Simple1 simple2 = 5; 178 optional bytes bytes_field = 6; 179 optional string unused = 7; 180 extensions 10 to max; 181} 182 183message TestCloneExtension { 184 extend TestClone { 185 optional TestCloneExtension low_ext = 11; 186 } 187 optional int32 f = 1; 188} 189 190message CloneExtension { 191 extend TestClone { 192 optional CloneExtension ext_field = 100; 193 } 194 optional string ext = 2; 195} 196 197message TestGroup { 198 repeated group RepeatedGroup = 1 { 199 required string id = 1; 200 repeated bool some_bool = 2; 201 } 202 required group RequiredGroup = 2 { 203 required string id = 1; 204 } 205 optional group OptionalGroup = 3 { 206 required string id = 1; 207 } 208 optional string id = 4; 209 required Simple2 required_simple = 5; 210 optional Simple2 optional_simple = 6; 211} 212 213message TestGroup1 { 214 optional TestGroup.RepeatedGroup group = 1; 215} 216 217message TestReservedNames { 218 optional int32 extension = 1; 219 extensions 10 to max; 220} 221 222message TestReservedNamesExtension { 223 extend TestReservedNames { 224 optional int32 foo = 10; 225 } 226} 227 228message TestMessageWithOneof { 229 230 oneof partial_oneof { 231 string pone = 3; 232 string pthree = 5; 233 } 234 235 oneof recursive_oneof { 236 TestMessageWithOneof rone = 6; 237 string rtwo = 7; 238 } 239 240 optional bool normal_field = 8; 241 repeated string repeated_field = 9; 242 243 oneof default_oneof_a { 244 int32 aone = 10 [default = 1234]; 245 int32 atwo = 11; 246 } 247 248 oneof default_oneof_b { 249 int32 bone = 12; 250 int32 btwo = 13 [default = 1234]; 251 } 252} 253 254message TestEndsWithBytes { 255 optional int32 value = 1; 256 optional bytes data = 2; 257} 258 259// This message is for testing extension handling doesn't affect fields before 260// pivot. Don't add new field to this message. See b/117298778 for more detail. 261message TestLastFieldBeforePivot { 262 optional int32 last_field_before_pivot = 1; 263 extensions 100 to max; 264} 265 266extend TestLastFieldBeforePivot { 267 optional int32 extend_test_last_field_before_pivot_field = 101; 268} 269 270 271message Int64Types { 272 optional int64 int64_normal = 1 [jstype = JS_NORMAL]; 273 optional sint64 int64_string = 2 [jstype = JS_STRING]; 274 optional uint64 int64_number = 3 [jstype = JS_NUMBER]; 275 276} 277 278message TestMapFieldsNoBinary { 279 map<string, string> map_string_string = 1; 280 map<string, int32> map_string_int32 = 2; 281 map<string, int64> map_string_int64 = 3; 282 map<string, bool> map_string_bool = 4; 283 map<string, double> map_string_double = 5; 284 map<string, MapValueEnumNoBinary> map_string_enum = 6; 285 map<string, MapValueMessageNoBinary> map_string_msg = 7; 286 287 map<int32, string> map_int32_string = 8; 288 map<int64, string> map_int64_string = 9; 289 map<bool, string> map_bool_string = 10; 290 291 optional TestMapFieldsNoBinary test_map_fields = 11; 292 map<string, TestMapFieldsNoBinary> map_string_testmapfields = 12; 293} 294 295enum MapValueEnumNoBinary { 296 MAP_VALUE_FOO_NOBINARY = 0; 297 MAP_VALUE_BAR_NOBINARY = 1; 298 MAP_VALUE_BAZ_NOBINARY = 2; 299} 300 301message MapValueMessageNoBinary { 302 optional int32 foo = 1; 303} 304 305message Deeply { 306 message Nested { 307 message Message { 308 optional int32 count = 1; 309 } 310 } 311} 312 313 314