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 31syntax = "proto3"; 32 33package protobuf_unittest; 34 35option java_multiple_files = true; 36option java_package = "com.google.protobuf.testing.proto"; 37 38message TestProto3Optional { 39 message NestedMessage { 40 // The field name "b" fails to compile in proto1 because it conflicts with 41 // a local variable named "b" in one of the generated methods. Doh. 42 // This file needs to compile in proto1 to test backwards-compatibility. 43 optional int32 bb = 1; 44 } 45 46 enum NestedEnum { 47 UNSPECIFIED = 0; 48 FOO = 1; 49 BAR = 2; 50 BAZ = 3; 51 NEG = -1; // Intentionally negative. 52 } 53 54 // Singular 55 optional int32 optional_int32 = 1; 56 optional int64 optional_int64 = 2; 57 optional uint32 optional_uint32 = 3; 58 optional uint64 optional_uint64 = 4; 59 optional sint32 optional_sint32 = 5; 60 optional sint64 optional_sint64 = 6; 61 optional fixed32 optional_fixed32 = 7; 62 optional fixed64 optional_fixed64 = 8; 63 optional sfixed32 optional_sfixed32 = 9; 64 optional sfixed64 optional_sfixed64 = 10; 65 optional float optional_float = 11; 66 optional double optional_double = 12; 67 optional bool optional_bool = 13; 68 optional string optional_string = 14; 69 optional bytes optional_bytes = 15; 70 optional string optional_cord = 16 [ctype = CORD]; 71 72 optional NestedMessage optional_nested_message = 18; 73 optional NestedMessage lazy_nested_message = 19 [lazy = true]; 74 optional NestedEnum optional_nested_enum = 21; 75 76 // Add some non-optional fields to verify we can mix them. 77 int32 singular_int32 = 22; 78 int64 singular_int64 = 23; 79} 80