• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8syntax = "proto2";
9
10package pkg;
11
12import public "upb/util/def_to_proto_public_import_test.proto";
13
14import "upb/util/def_to_proto_regular_import_test.proto";
15
16option optimize_for = CODE_SIZE;
17option go_package = "foo_go_package";
18option java_package = "bar_java_package";
19option java_outer_classname = "baz_java_outer_classname";
20option csharp_namespace = "quux_csharp_namespace";
21option objc_class_prefix = "the_objc_prefix";
22option cc_enable_arenas = true;
23
24message Message {
25  optional int32 a = 1 [default = 3];
26  oneof foo {
27    string oneof_string = 2 [default = "abc\n"];
28    string oneof_bool = 3 [default = "true"];
29    bytes oneof_bytes = 4 [default = "abc\xef\xfe"];
30  }
31  optional pkg.RegularImportMessage regular_import_message = 6;
32  optional pkg.PublicImportMessage public_import_message = 7;
33  optional pkg.Proto3Enum proto3_enum = 8;
34  extensions 1000 to max;
35  extend Message {
36    optional int32 ext = 1000;
37  }
38
39  message NestedMessage {}
40  message NestedEnum {}
41
42  // TODO: support reserved ranges in defs.
43  // (At the moment they are ignored and will not round-trip through defs).
44  // reserved 4, 6 to 8;
45}
46
47enum Enum {
48  ZERO = 0;
49  ONE = 1;
50  NEGATIVE_ONE = -1;
51}
52
53enum EnumUpper32Value {
54  UPPER32_VALUE = 40;
55}
56
57enum HasDuplicateValues {
58  option allow_alias = true;
59
60  A = 0;
61  B = 1;
62  C = 120;
63  D = 130;
64
65  G = 120;
66  F = 1;
67  E = 0;
68  H = 121;
69  I = 121;
70  J = 121;
71  K = 121;
72}
73
74service Service {
75  rpc Bar(Message) returns (Message);
76}
77
78extend Message {
79  optional int32 ext = 1001;
80}
81
82enum Has31 {
83  VALUE_31 = 31;
84}
85
86message PretendMessageSet {
87  option message_set_wire_format = true;
88
89  // Since this is message_set_wire_format, "max" here means INT32_MAX.
90  // (For normal messages "max" would mean 2**29 - 1).
91  extensions 4 to 529999999;
92  extensions 530000000 to max
93  [declaration = {
94    number: 2147483646
95    full_name: ".pkg.MessageSetItem.message_set_extension"
96    type: ".pkg.MessageSetItem"
97  }];
98}
99
100message MessageSetItem {
101  extend PretendMessageSet {
102    // Since max is exclusive, this is INT32_MAX-1, not INT32_MAX.
103    optional MessageSetItem message_set_extension = 2147483646;
104  }
105}
106
107message UnusualDefaults {
108  optional bytes foo = 1 [default = "\\X"];
109  optional string bar = 2 [default = "\\X"];
110}
111