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 40package io_protocol_tests; 41 42option java_generic_services = true; // auto-added 43option java_package = "com.google.protobuf"; 44option java_outer_classname = "TestBadIdentifiersProto"; 45 46message TestMessage { 47 optional string cached_size = 1; 48 optional string serialized_size = 2; 49 optional string class = 3; 50} 51 52message Descriptor { 53 option no_standard_descriptor_accessor = true; 54 55 optional string descriptor = 1; 56 message NestedDescriptor { 57 option no_standard_descriptor_accessor = true; 58 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 repeated int32 int32_field = 1; 130 repeated TestEnum enum_field = 2; 131 repeated string string_field = 3; 132 repeated bytes bytes_field = 4; 133 repeated TestMessage message_field = 5; 134 135 optional int32 int32_field_count = 11; 136 optional TestEnum enum_field_count = 12; 137 optional string string_field_count = 13; 138 optional bytes bytes_field_count = 14; 139 optional TestMessage message_field_count = 15; 140 141 repeated int32 Int32Field = 21; // NO_PROTO3 142 repeated TestEnum EnumField = 22; // NO_PROTO3 143 repeated string StringField = 23; // NO_PROTO3 144 repeated bytes BytesField = 24; // NO_PROTO3 145 repeated TestMessage MessageField = 25; // NO_PROTO3 146 147 // This field conflicts with "int32_field" as they both generate 148 // the method getInt32FieldList(). 149 required int32 int32_field_list = 31; // NO_PROTO3 150 151 // These field pairs have the same Java converted name 152 optional string field_name = 32; // NO_PROTO3 153 optional string field__name = 33; // NO_PROTO3 154 optional int32 _2conflict = 34; // NO_PROTO3 155 optional int32 __2conflict = 35; 156 157 extensions 1000 to max; // NO_PROTO3 158 159 repeated int64 int64_field = 41; 160 extend TestConflictingFieldNames { // NO_PROTO3 161 // We don't generate accessors for extensions so the following extension 162 // fields don't conflict with the repeated field "int64_field". 163 optional int64 int64_field_count = 1001; // NO_PROTO3 164 optional int64 int64_field_list = 1002; // NO_PROTO3 165 } // NO_PROTO3 166} 167 168message TestMapField { 169 message MapField {} 170 message Pair {} 171 message Message {} 172 173 map<int32, int32> map_field = 1; 174} 175 176message TestLeadingNumberFields { 177 optional int32 _30day_impressions = 1; 178 repeated string _60day_impressions = 2; 179 180 optional string __2_underscores = 3; 181 repeated string __2repeated_underscores = 4; 182 183 optional int32 _32 = 32; 184 repeated int64 _64 = 64; 185} 186