Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
4.3 KiB
195 lines
4.3 KiB
// Protocol Buffers - Google's data interchange format |
|
// Copyright 2023 Google LLC. All rights reserved. |
|
// |
|
// Use of this source code is governed by a BSD-style |
|
// license that can be found in the LICENSE file or at |
|
// https://developers.google.com/open-source/licenses/bsd |
|
|
|
edition = "2023"; |
|
|
|
package hpb_unittest; |
|
|
|
import "google/protobuf/compiler/hpb/tests/child_model.proto"; |
|
|
|
option features.enum_type = CLOSED; |
|
option features.repeated_field_encoding = EXPANDED; |
|
option features.utf8_validation = NONE; |
|
|
|
message TestModelContainer { |
|
repeated TestModel models = 1; |
|
ChildModel3 proto_3_child = 2; |
|
|
|
extensions 10000 to max |
|
[verification = UNVERIFIED]; |
|
} |
|
|
|
message TestModel { |
|
int32 value = 1; |
|
repeated int32 value_array = 2; // _UPB_MODE_ARRAY |
|
repeated int32 value_packed_array = 3 |
|
[features.repeated_field_encoding = |
|
PACKED]; // _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED |
|
|
|
repeated int32 value_deprec = 4 [deprecated = true]; |
|
|
|
string str1 = 115; |
|
bool b1 = 9; |
|
bool b2 = 10; |
|
string str2 = 50; |
|
string str3 = 11; |
|
float optional_float = 14; |
|
double optional_double = 15; |
|
int64 optional_int64 = 16; |
|
uint32 optional_uint32 = 17; |
|
uint64 optional_uint64 = 18; |
|
sint32 optional_sint32 = 19; |
|
sint64 optional_sint64 = 20; |
|
fixed32 optional_fixed32 = 21; |
|
fixed64 optional_fixed64 = 22; |
|
sfixed32 optional_sfixed32 = 23; |
|
sfixed64 optional_sfixed64 = 24; |
|
repeated int64 repeated_int64 = 25; |
|
repeated uint64 repeated_uint64 = 26; |
|
repeated fixed64 repeated_fixed64 = 27; |
|
repeated sfixed64 repeated_sfixed64 = 28; |
|
repeated bool repeated_bool = 29; |
|
repeated string repeated_string = 35; |
|
bytes optional_bytes = 36; |
|
|
|
message NestedChild { |
|
string nested_child_name = 211; |
|
} |
|
|
|
NestedChild nested_child_1 = 212; |
|
ChildModel1 child_model_1 = 222; |
|
repeated ChildModel1 child_models = 223; |
|
ChildModel1 bar = 224; |
|
|
|
oneof child_oneof1 { |
|
string oneof_member1 = 98; |
|
bool oneof_member2 = 99; |
|
} |
|
|
|
int32 int_value_with_default = 31 [default = 65]; // Not supported yet |
|
|
|
string string_value_with_default = 32 |
|
[default = "hello"]; // Not supported yet |
|
|
|
float float_value_with_default = 33 [default = inf]; |
|
|
|
float double_value_with_default = 34 [default = -inf]; |
|
|
|
map<int32, ChildModel1> child_map = 225; |
|
TestModel recursive_child = 226; |
|
map<string, ChildModel1> child_str_map = 227; |
|
map<string, int32> str_to_int_map = 228; |
|
map<string, string> str_to_str_map = 229; |
|
|
|
extend TestAnnotation { |
|
OtherExtension in_message_ext = 15000; |
|
} |
|
|
|
enum Category { |
|
IMAGES = 5; |
|
NEWS = 6; |
|
VIDEO = 7; |
|
RADIO = 8 [deprecated = true]; |
|
} |
|
|
|
Category category = 37; |
|
|
|
// keyword collisions (double, template, ...) |
|
oneof type { |
|
string string = 230; |
|
int64 int64 = 231; |
|
double double = 232; |
|
} |
|
|
|
string template = 233; |
|
string msg = 234; |
|
string arena = 235; |
|
|
|
// Tests publicly imported enum. |
|
TestEnum imported_enum = 238; |
|
|
|
string phase = 239; |
|
bool clear_phase = 240; |
|
string doc_id = 241; |
|
bool set_doc_id = 242; |
|
|
|
extensions 10000 to max |
|
[verification = UNVERIFIED]; |
|
} |
|
|
|
// Old version with fewer fields to test backward/forward compatibility. |
|
message TestModelContainerV1 { |
|
repeated TestModelV1 models = 1; |
|
} |
|
|
|
message TestModelV1 { |
|
int32 value = 1; |
|
repeated int32 value2 = 2; |
|
repeated int32 value3 = 3 [features.repeated_field_encoding = PACKED]; |
|
|
|
repeated int32 value4 = 4 [deprecated = true]; |
|
|
|
bool b1 = 9; |
|
bool b2 = 10; |
|
string str2 = 50; |
|
} |
|
|
|
enum PrimaryColors { |
|
RED = 1; |
|
GREEN = 2; |
|
BLUE = 3; |
|
} |
|
|
|
// TestModel extension. |
|
message ThemeExtension { |
|
extend TestModel { |
|
ThemeExtension theme_extension = 12003; |
|
} |
|
|
|
string ext_name = 1; |
|
bool ext_bool = 2; |
|
} |
|
|
|
extend TestModel { |
|
ThemeExtension theme = 12001; |
|
} |
|
|
|
message ContainerExtension { |
|
extend TestModelContainer { |
|
ContainerExtension container_extension = 12004; |
|
} |
|
|
|
string ext_container_name = 1; |
|
} |
|
|
|
extend TestModelContainer { |
|
ContainerExtension container_ext = 12005; |
|
} |
|
|
|
message OtherExtension { |
|
string ext2_name = 1; |
|
} |
|
|
|
extend TestModel { |
|
OtherExtension other_ext = 12002; |
|
} |
|
|
|
message TestAnnotation { |
|
extensions 10000 to max |
|
[verification = UNVERIFIED]; |
|
} |
|
|
|
message TestMessageHasEnum { |
|
EnumDeclaredAfterMessage enum_declared_after_message = 1; |
|
} |
|
|
|
enum EnumDeclaredAfterMessage { |
|
ZERO = 0; |
|
ONE = 1; |
|
TWO = 2; |
|
THREE = 3; |
|
}
|
|
|