1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc.  All rights reserved.
3// http://code.google.com/p/protobuf/
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
38
39// Some generic_services option(s) added automatically.
40// See:  http://go/proto2-generic-services-default
41option cc_generic_services = true;     // auto-added
42
43// We don't put this in a package within proto2 because we need to make sure
44// that the generated code doesn't depend on being in the proto2 namespace.
45package protobuf_unittest;
46
47// Test that fields can have names like "input" and "i" which are also used
48// internally by the code generator for local variables.
49message TestConflictingSymbolNames {
50  message BuildDescriptors {}
51  message TypeTraits {}
52
53  optional int32 input = 1;
54  optional int32 output = 2;
55  optional string length = 3;
56  repeated int32 i = 4;
57  repeated string new_element = 5 [ctype=STRING_PIECE];
58  optional int32 total_size = 6;
59  optional int32 tag = 7;
60
61  enum TestEnum { FOO = 1; }
62  message Data1 { repeated int32 data = 1; }
63  message Data2 { repeated TestEnum data = 1; }
64  message Data3 { repeated string data = 1; }
65  message Data4 { repeated Data4 data = 1; }
66  message Data5 { repeated string data = 1 [ctype=STRING_PIECE]; }
67  message Data6 { repeated string data = 1 [ctype=CORD]; }
68
69  optional int32 source = 8;
70  optional int32 value = 9;
71  optional int32 file = 10;
72  optional int32 from = 11;
73  optional int32 handle_uninterpreted = 12;
74  repeated int32 index = 13;
75  optional int32 controller = 14;
76  optional int32 already_here = 15;
77
78  optional uint32 uint32 = 16;
79  optional uint64 uint64 = 17;
80  optional string string = 18;
81  optional int32 memset = 19;
82  optional int32 int32 = 20;
83  optional int64 int64 = 21;
84
85  optional uint32 cached_size = 22;
86  optional uint32 extensions = 23;
87  optional uint32 bit = 24;
88  optional uint32 bits = 25;
89  optional uint32 offsets = 26;
90  optional uint32 reflection = 27;
91
92  message Cord {}
93  optional string some_cord = 28 [ctype=CORD];
94
95  message StringPiece {}
96  optional string some_string_piece = 29 [ctype=STRING_PIECE];
97
98  // Some keywords.
99  optional uint32 int = 30;
100  optional uint32 friend = 31;
101
102  // The generator used to #define a macro called "DO" inside the .cc file.
103  message DO {}
104  optional DO do = 32;
105
106  // Some template parameter names for extensions.
107  optional int32 field_type = 33;
108  optional bool is_packed = 34;
109
110  extensions 1000 to max;
111}
112
113message TestConflictingSymbolNamesExtension {
114  extend TestConflictingSymbolNames {
115    repeated int32 repeated_int32_ext = 20423638 [packed=true];
116  }
117}
118
119message DummyMessage {}
120
121service TestConflictingMethodNames {
122  rpc Closure(DummyMessage) returns (DummyMessage);
123}
124