• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: kenton@google.com (Kenton Varda)
32//  Based on original Protocol Buffers design by
33//  Sanjay Ghemawat, Jeff Dean, and others.
34//
35// This file tests that various identifiers work as field and type names even
36// though the same identifiers are used internally by the C++ code generator.
37
38syntax = "proto2";
39
40// Some generic_services option(s) added automatically.
41// See:  http://go/proto2-generic-services-default
42option cc_generic_services = true;     // auto-added
43
44// We don't put this in a package within proto2 because we need to make sure
45// that the generated code doesn't depend on being in the proto2 namespace.
46package protobuf_unittest;
47
48// Test that fields can have names like "input" and "i" which are also used
49// internally by the code generator for local variables.
50message TestConflictingSymbolNames {
51  message BuildDescriptors {}
52  message TypeTraits {}
53
54  optional int32 input = 1;
55  optional int32 output = 2;
56  optional string length = 3;
57  repeated int32 i = 4;
58  repeated string new_element = 5 [ctype=STRING_PIECE];
59  optional int32 total_size = 6;
60  optional int32 tag = 7;
61
62  enum TestEnum { FOO = 0; }
63  message Data1 { repeated int32 data = 1; }
64  message Data2 { repeated TestEnum data = 1; }
65  message Data3 { repeated string data = 1; }
66  message Data4 { repeated Data4 data = 1; }
67  message Data5 { repeated string data = 1 [ctype=STRING_PIECE]; }
68  message Data6 { repeated string data = 1 [ctype=CORD]; }
69
70  optional int32 source = 8;
71  optional int32 value = 9;
72  optional int32 file = 10;
73  optional int32 from = 11;
74  optional int32 handle_uninterpreted = 12;
75  repeated int32 index = 13;
76  optional int32 controller = 14;
77  optional int32 already_here = 15;
78
79  optional uint32 uint32 = 16;
80  optional uint64 uint64 = 17;
81  optional string string = 18;
82  optional int32 memset = 19;
83  optional int32 int32 = 20;
84  optional int64 int64 = 21;
85
86  optional uint32 cached_size = 22;
87  optional uint32 extensions = 23;
88  optional uint32 bit = 24;
89  optional uint32 bits = 25;
90  optional uint32 offsets = 26;
91  optional uint32 reflection = 27;
92
93  message Cord {}
94  optional string some_cord = 28 [ctype=CORD];
95
96  message StringPiece {}
97  optional string some_string_piece = 29 [ctype=STRING_PIECE];
98
99  // Some keywords.
100  optional uint32 int = 30;
101  optional uint32 friend = 31;
102  optional uint32 class = 37;
103  optional uint32 typedecl = 39;
104  optional uint32 auto = 40;
105
106  // The generator used to #define a macro called "DO" inside the .cc file.
107  message DO {}
108  optional DO do = 32;
109
110  // Some template parameter names for extensions.
111  optional int32 field_type = 33;
112  optional bool is_packed = 34;
113
114  // test conflicting release_$name$. "length" and "do" field in this message
115  // must remain string or message fields to make the test valid.
116  optional string release_length = 35;
117  // A more extreme case, the field name "do" here is a keyword, which will be
118  // escaped to "do_" already. Test there is no conflict even with escaped field
119  // names.
120  optional DO release_do = 36;
121
122  // For clashing local variables in Serialize and ByteSize calculation.
123  optional string target = 38;
124
125  extensions 1000 to max;  // NO_PROTO3
126}
127
128message TestConflictingSymbolNamesExtension {                    // NO_PROTO3
129  extend TestConflictingSymbolNames {                            // NO_PROTO3
130    repeated int32 repeated_int32_ext = 20423638 [packed=true];  // NO_PROTO3
131  }                                                              // NO_PROTO3
132}                                                                // NO_PROTO3
133
134message TestConflictingEnumNames {  // NO_PROTO3
135  enum NestedConflictingEnum {      // NO_PROTO3
136    and = 1;                        // NO_PROTO3
137    class = 2;                      // NO_PROTO3
138    int = 3;                        // NO_PROTO3
139    typedef = 4;                    // NO_PROTO3
140    XOR = 5;                        // NO_PROTO3
141  }                                 // NO_PROTO3
142
143  optional NestedConflictingEnum conflicting_enum = 1;  // NO_PROTO3
144}  // NO_PROTO3
145
146enum ConflictingEnum {  // NO_PROTO3
147  NOT_EQ = 1;           // NO_PROTO3
148  volatile = 2;         // NO_PROTO3
149  return = 3;           // NO_PROTO3
150}  // NO_PROTO3
151
152message DummyMessage {}
153
154service TestConflictingMethodNames {
155  rpc Closure(DummyMessage) returns (DummyMessage);
156}
157