1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
|
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test Protobuf definitions with proto2 syntax.
edition = "2023";
package pbeditions;
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
option go_package = "google.golang.org/protobuf/internal/testprotos/textpbeditions";
option features.enum_type = CLOSED;
option features.utf8_validation = NONE;
// Scalars contains scalar fields.
message Scalars {
bool opt_bool = 1;
int32 opt_int32 = 2;
int64 opt_int64 = 3;
uint32 opt_uint32 = 4;
uint64 opt_uint64 = 5;
sint32 opt_sint32 = 6;
sint64 opt_sint64 = 7;
fixed32 opt_fixed32 = 8;
fixed64 opt_fixed64 = 9;
sfixed32 opt_sfixed32 = 10;
sfixed64 opt_sfixed64 = 11;
// Textproto marshal outputs fields in the same order as this proto
// definition regardless of field number. Following fields are intended to
// test that assumption.
float opt_float = 20;
double opt_double = 21;
bytes opt_bytes = 14;
string opt_string = 13;
}
// ImplicitScalars contains scalar field types with implicit field_presence
message ImplicitScalars {
bool s_bool = 1 [features.field_presence = IMPLICIT];
int32 s_int32 = 2 [features.field_presence = IMPLICIT];
int64 s_int64 = 3 [features.field_presence = IMPLICIT];
uint32 s_uint32 = 4 [features.field_presence = IMPLICIT];
uint64 s_uint64 = 5 [features.field_presence = IMPLICIT];
sint32 s_sint32 = 6 [features.field_presence = IMPLICIT];
sint64 s_sint64 = 7 [features.field_presence = IMPLICIT];
fixed32 s_fixed32 = 8 [features.field_presence = IMPLICIT];
fixed64 s_fixed64 = 9 [features.field_presence = IMPLICIT];
sfixed32 s_sfixed32 = 10 [features.field_presence = IMPLICIT];
sfixed64 s_sfixed64 = 11 [features.field_presence = IMPLICIT];
// Textproto marshal outputs fields in the same order as this proto
// definition regardless of field number. Following fields are intended to
// test that assumption.
float s_float = 20 [features.field_presence = IMPLICIT];
double s_double = 21 [features.field_presence = IMPLICIT];
bytes s_bytes = 14 [features.field_presence = IMPLICIT];
string s_string = 13 [features.field_presence = IMPLICIT];
}
enum Enum {
ONE = 1;
TWO = 2;
TEN = 10;
}
enum OpenEnum {
option features.enum_type = OPEN;
UNKNOWN = 0;
EINS = 1;
ZWEI = 2;
ZEHN = 10;
}
message UTF8Validated {
string validated_string = 1
[features.utf8_validation = VERIFY, features.field_presence = IMPLICIT];
}
message NestsUTF8Validated {
UTF8Validated validated_message = 1;
}
// Message contains enum fields.
message Enums {
Enum opt_enum = 1;
repeated Enum rpt_enum = 2;
OpenEnum implicit_enum = 5 [features.field_presence = IMPLICIT];
enum NestedEnum {
UNO = 1;
DOS = 2;
DIEZ = 10;
}
enum NestedOpenEnum {
option features.enum_type = OPEN;
UNKNOWN = 0;
EINS = 1;
ZWEI = 2;
ZEHN = 10;
}
NestedEnum opt_nested_enum = 3;
repeated NestedEnum rpt_nested_enum = 4;
NestedOpenEnum implicit_nested_enum = 6 [features.field_presence = IMPLICIT];
}
// Message contains repeated fields.
message Repeats {
repeated bool rpt_bool = 1;
repeated int32 rpt_int32 = 2;
repeated int64 rpt_int64 = 3;
repeated uint32 rpt_uint32 = 4;
repeated uint64 rpt_uint64 = 5;
repeated float rpt_float = 6;
repeated double rpt_double = 7;
repeated string rpt_string = 8;
repeated bytes rpt_bytes = 9;
}
// Message contains map fields.
message Maps {
map<int32, string> int32_to_str = 1;
map<string, Nested> str_to_nested = 4;
}
// Message type used as submessage.
message Nested {
string opt_string = 1;
Nested opt_nested = 2;
}
// Message contains message and group fields.
message Nests {
Nested opt_nested = 1;
message OptGroup {
string opt_string = 1;
Nested opt_nested = 2;
message OptNestedGroup {
fixed32 opt_fixed32 = 1;
}
OptNestedGroup optnestedgroup = 3 [features.message_encoding = DELIMITED];
OptNestedGroup nested_delimited_field = 4
[features.message_encoding = DELIMITED];
}
OptGroup optgroup = 2 [features.message_encoding = DELIMITED];
OptGroup delimited_field = 3 [features.message_encoding = DELIMITED];
repeated Nested rpt_nested = 4;
message RptGroup {
repeated string rpt_string = 1;
}
repeated RptGroup rptgroup = 5 [
features.message_encoding = DELIMITED,
features.repeated_field_encoding = EXPANDED
];
reserved reserved_field;
}
// Message contains required fields.
message Requireds {
bool req_bool = 1 [features.field_presence = LEGACY_REQUIRED];
sfixed64 req_sfixed64 = 2 [features.field_presence = LEGACY_REQUIRED];
double req_double = 3 [features.field_presence = LEGACY_REQUIRED];
string req_string = 4 [features.field_presence = LEGACY_REQUIRED];
Enum req_enum = 5 [features.field_presence = LEGACY_REQUIRED];
Nested req_nested = 6 [features.field_presence = LEGACY_REQUIRED];
}
// Message contains both required and optional fields.
message PartialRequired {
string req_string = 1 [features.field_presence = LEGACY_REQUIRED];
string opt_string = 2;
}
// Following messages are for testing required field nested in optional,
// repeated and map fields.
message NestedWithRequired {
string req_string = 1 [features.field_presence = LEGACY_REQUIRED];
}
message IndirectRequired {
NestedWithRequired opt_nested = 1;
repeated NestedWithRequired rpt_nested = 2;
map<string, NestedWithRequired> str_to_nested = 3;
oneof union {
NestedWithRequired oneof_nested = 4;
}
}
// Following messages are for testing extensions.
message Extensions {
string opt_string = 1;
extensions 20 to 100;
bool opt_bool = 101;
int32 opt_int32 = 2;
}
extend Extensions {
bool opt_ext_bool = 21;
string opt_ext_string = 22;
Enum opt_ext_enum = 23;
Nested opt_ext_nested = 24;
PartialRequired opt_ext_partial = 25;
repeated fixed32 rpt_ext_fixed32 = 31;
repeated Enum rpt_ext_enum = 32;
repeated Nested rpt_ext_nested = 33;
}
message ExtensionsContainer {
extend Extensions {
bool opt_ext_bool = 51;
string opt_ext_string = 52;
Enum opt_ext_enum = 53;
Nested opt_ext_nested = 54;
PartialRequired opt_ext_partial = 55;
repeated string rpt_ext_string = 61;
repeated Enum rpt_ext_enum = 62;
repeated Nested rpt_ext_nested = 63;
}
}
// Following messages are for testing MessageSet.
message MessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}
message MessageSetExtension {
string opt_string = 1;
extend MessageSet {
MessageSetExtension message_set_extension = 10;
MessageSetExtension not_message_set_extension = 20;
Nested ext_nested = 30;
}
}
message FakeMessageSet {
extensions 4 to max;
}
message FakeMessageSetExtension {
string opt_string = 1;
extend FakeMessageSet {
FakeMessageSetExtension message_set_extension = 10;
}
}
extend MessageSet {
FakeMessageSetExtension message_set_extension = 50;
}
// Message contains well-known type fields.
message KnownTypes {
google.protobuf.BoolValue opt_bool = 1;
google.protobuf.Int32Value opt_int32 = 2;
google.protobuf.Int64Value opt_int64 = 3;
google.protobuf.UInt32Value opt_uint32 = 4;
google.protobuf.UInt64Value opt_uint64 = 5;
google.protobuf.FloatValue opt_float = 6;
google.protobuf.DoubleValue opt_double = 7;
google.protobuf.StringValue opt_string = 8;
google.protobuf.BytesValue opt_bytes = 9;
google.protobuf.Duration opt_duration = 20;
google.protobuf.Timestamp opt_timestamp = 21;
google.protobuf.Struct opt_struct = 25;
google.protobuf.ListValue opt_list = 26;
google.protobuf.Value opt_value = 27;
google.protobuf.NullValue opt_null = 28;
google.protobuf.Empty opt_empty = 30;
google.protobuf.Any opt_any = 32;
google.protobuf.FieldMask opt_fieldmask = 40;
}
|