1/* 2 * Copyright (c) 2009-2021, Google LLC 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of Google LLC nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28syntax = "proto2"; 29 30package pkg; 31 32import public "upb/util/def_to_proto_public_import_test.proto"; 33 34import "upb/util/def_to_proto_regular_import_test.proto"; 35 36option optimize_for = CODE_SIZE; 37option go_package = "foo_go_package"; 38option java_package = "bar_java_package"; 39option java_outer_classname = "baz_java_outer_classname"; 40option csharp_namespace = "quux_csharp_namespace"; 41option objc_class_prefix = "the_objc_prefix"; 42option cc_enable_arenas = true; 43 44message Message { 45 optional int32 a = 1 [default = 3]; 46 oneof foo { 47 string oneof_string = 2 [default = "abc\n"]; 48 string oneof_bool = 3 [default = "true"]; 49 bytes oneof_bytes = 4 [default = "abc\xef\xfe"]; 50 } 51 optional pkg.RegularImportMessage regular_import_message = 6; 52 optional pkg.PublicImportMessage public_import_message = 7; 53 optional pkg.Proto3Enum proto3_enum = 8; 54 extensions 1000 to max; 55 extend Message { 56 optional int32 ext = 1000; 57 } 58 59 message NestedMessage {} 60 message NestedEnum {} 61 62 // TODO: support reserved ranges in defs. 63 // (At the moment they are ignored and will not round-trip through defs). 64 // reserved 4, 6 to 8; 65} 66 67enum Enum { 68 ZERO = 0; 69 ONE = 1; 70 NEGATIVE_ONE = -1; 71} 72 73enum EnumUpper32Value { 74 UPPER32_VALUE = 40; 75} 76 77enum HasDuplicateValues { 78 option allow_alias = true; 79 80 A = 0; 81 B = 1; 82 C = 120; 83 D = 130; 84 85 G = 120; 86 F = 1; 87 E = 0; 88 H = 121; 89 I = 121; 90 J = 121; 91 K = 121; 92} 93 94service Service { 95 rpc Bar(Message) returns (Message); 96} 97 98extend Message { 99 optional int32 ext = 1001; 100} 101 102enum Has31 { 103 VALUE_31 = 31; 104} 105 106message PretendMessageSet { 107 option message_set_wire_format = true; 108 109 // Since this is message_set_wire_format, "max" here means INT32_MAX. 110 // (For normal messages "max" would mean 2**29 - 1). 111 extensions 4 to 529999999; 112 extensions 530000000 to max 113 [declaration = { 114 number: 2147483646 115 full_name: ".pkg.MessageSetItem.message_set_extension" 116 type: ".pkg.MessageSetItem" 117 }]; 118} 119 120message MessageSetItem { 121 extend PretendMessageSet { 122 // Since max is exclusive, this is INT32_MAX-1, not INT32_MAX. 123 optional MessageSetItem message_set_extension = 2147483646; 124 } 125} 126 127message UnusualDefaults { 128 optional bytes foo = 1 [default = "\\X"]; 129 optional string bar = 2 [default = "\\X"]; 130} 131