• 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: jonp@google.com (Jon Perlow)
32
33// This file tests that various identifiers work as field and type names even
34// though the same identifiers are used internally by the java code generator.
35
36syntax = "proto2";
37
38// Some generic_services option(s) added automatically.
39// See:  http://go/proto2-generic-services-default
40option java_generic_services = true;   // auto-added
41
42package io_protocol_tests;
43
44option java_package = "com.google.protobuf";
45option java_outer_classname = "TestBadIdentifiersProto";
46option java_generate_equals_and_hash = true;
47
48message TestMessage {
49  optional string cached_size = 1;
50  optional string serialized_size = 2;
51  optional string class = 3;
52}
53
54message Descriptor {
55  option no_standard_descriptor_accessor = true;
56  optional string descriptor = 1;
57  message NestedDescriptor {
58    option no_standard_descriptor_accessor = true;
59    optional string descriptor = 1;
60  }
61  optional NestedDescriptor nested_descriptor = 2;
62  enum NestedEnum {
63    UNKNOWN = 0;
64    FOO = 1;
65  }
66}
67
68message Parser {
69  enum ParserEnum {
70    UNKNOWN = 0;
71    PARSER = 1;
72  }
73  optional ParserEnum parser = 1;
74}
75
76message Deprecated {
77  enum TestEnum {
78    UNKNOWN = 0;
79    FOO = 1;
80
81    // Test if @Deprecated annotation conflicts with Deprecated message name.
82    BAR = 2 [ deprecated = true ];
83  }
84
85  optional int32 field1 = 1 [deprecated=true];
86  optional TestEnum field2 = 2 [deprecated=true];
87  optional TestMessage field3 = 3 [deprecated=true];
88}
89
90message Override {
91  optional int32 override = 1;
92}
93
94message Object {
95  optional int32 object = 1;
96  optional string string_object = 2;
97}
98
99message String {
100  optional string string = 1;
101}
102
103message Integer {
104  optional int32 integer = 1;
105}
106
107message Long {
108  optional int32 long = 1;
109}
110
111message Float {
112  optional float float = 1;
113}
114
115message Double {
116  optional double double = 1;
117}
118
119service TestConflictingMethodNames {
120  rpc Override(TestMessage) returns (TestMessage);
121}
122
123message TestConflictingFieldNames {
124  enum TestEnum {
125    UNKNOWN = 0;
126    FOO = 1;
127  }
128  message TestMessage {
129  }
130  repeated int32 int32_field = 1;
131  repeated TestEnum enum_field = 2;
132  repeated string string_field = 3;
133  repeated bytes bytes_field = 4;
134  repeated TestMessage message_field = 5;
135
136  optional int32 int32_field_count = 11;
137  optional TestEnum enum_field_count = 12;
138  optional string string_field_count = 13;
139  optional bytes bytes_field_count = 14;
140  optional TestMessage message_field_count = 15;
141
142  repeated int32 Int32Field = 21;  // NO_PROTO3
143  repeated TestEnum EnumField = 22;  // NO_PROTO3
144  repeated string StringField = 23;  // NO_PROTO3
145  repeated bytes BytesField = 24;  // NO_PROTO3
146  repeated TestMessage MessageField = 25;  // NO_PROTO3
147
148  // This field conflicts with "int32_field" as they both generate
149  // the method getInt32FieldList().
150  required int32 int32_field_list = 31;  // NO_PROTO3
151
152  extensions 1000 to max;  // NO_PROTO3
153
154  repeated int64 int64_field = 41;
155  extend TestConflictingFieldNames {  // NO_PROTO3
156    // We don't generate accessors for extensions so the following extension
157    // fields don't conflict with the repeated field "int64_field".
158    optional int64 int64_field_count = 1001;  // NO_PROTO3
159    optional int64 int64_field_list = 1002;  // NO_PROTO3
160  }  // NO_PROTO3
161}
162
163message TestMapField {
164  message MapField {}
165  message Pair {}
166  message Message {}
167
168  map<int32, int32> map_field = 1;
169}
170