/*
 * Copyright (c) 2009-2021, Google LLC
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Google LLC nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

syntax = "proto2";

package upb_test;

import "src/google/protobuf/test_messages_proto3.proto";

message TestExtensions {
  extensions 1000 to max;
  extend TestExtensions {
    optional int32 optional_int32_ext = 1000;
  }
  message Nested {
    extend TestExtensions {
      repeated int32 repeated_int32_ext = 1001;
    }
  }
}

extend TestExtensions {
  optional protobuf_test_messages.proto3.TestAllTypesProto3 optional_msg_ext =
      1002;
}

message TestMessageSet {
  option message_set_wire_format = true;

  extensions 4 to max;
}

message MessageSetMember {
  optional int32 optional_int32 = 1;
  extend TestMessageSet {
    optional MessageSetMember message_set_extension = 4;
  }
}

message Proto2EnumMessage {
  enum Proto2TestEnum {
    ZERO = 0;
    NEGATIVE = -1;
    SMALL = 15;
    LARGE = 12345;
  }

  optional Proto2TestEnum optional_enum = 1;
  repeated Proto2TestEnum repeated_enum = 2;
  repeated Proto2TestEnum packed_enum = 3 [packed = true];
}

// The same fields as Proto2EnumMessage, but with int32 fields so we can fake
// wire format.
message Proto2FakeEnumMessage {
  optional int32 optional_enum = 1;
  repeated int32 repeated_enum = 2;
  repeated int32 packed_enum = 3 [packed = true];
}

message EmptyMessage {}

message TestRequiredFields {
  required int32 required_int32 = 1;
  optional int32 optional_int32 = 2;
  required int64 required_int64 = 3;
  optional TestRequiredFields optional_message = 4;
  required EmptyMessage required_message = 5;
}

message SubMessageHasRequired {
  optional TestRequiredFields optional_message = 1;
}

message TestMaxRequiredFields {
  required int32 required_int32_1 = 1;
  required int32 required_int32_2 = 2;
  required int32 required_int32_3 = 3;
  required int32 required_int32_4 = 4;
  required int32 required_int32_5 = 5;
  required int32 required_int32_6 = 6;
  required int32 required_int32_7 = 7;
  required int32 required_int32_8 = 8;
  required int32 required_int32_9 = 9;
  required int32 required_int32_10 = 10;
  required int32 required_int32_11 = 11;
  required int32 required_int32_12 = 12;
  required int32 required_int32_13 = 13;
  required int32 required_int32_14 = 14;
  required int32 required_int32_15 = 15;
  required int32 required_int32_16 = 16;
  required int32 required_int32_17 = 17;
  required int32 required_int32_18 = 18;
  required int32 required_int32_19 = 19;
  required int32 required_int32_20 = 20;
  required int32 required_int32_21 = 21;
  required int32 required_int32_22 = 22;
  required int32 required_int32_23 = 23;
  required int32 required_int32_24 = 24;
  required int32 required_int32_25 = 25;
  required int32 required_int32_26 = 26;
  required int32 required_int32_27 = 27;
  required int32 required_int32_28 = 28;
  required int32 required_int32_29 = 29;
  required int32 required_int32_30 = 30;
  required int32 required_int32_31 = 31;
  required int32 required_int32_32 = 32;
  required int32 required_int32_33 = 33;
  required int32 required_int32_34 = 34;
  required int32 required_int32_35 = 35;
  required int32 required_int32_36 = 36;
  required int32 required_int32_37 = 37;
  required int32 required_int32_38 = 38;
  required int32 required_int32_39 = 39;
  required int32 required_int32_40 = 40;
  required int32 required_int32_41 = 41;
  required int32 required_int32_42 = 42;
  required int32 required_int32_43 = 43;
  required int32 required_int32_44 = 44;
  required int32 required_int32_45 = 45;
  required int32 required_int32_46 = 46;
  required int32 required_int32_47 = 47;
  required int32 required_int32_48 = 48;
  required int32 required_int32_49 = 49;
  required int32 required_int32_50 = 50;
  required int32 required_int32_51 = 51;
  required int32 required_int32_52 = 52;
  required int32 required_int32_53 = 53;
  required int32 required_int32_54 = 54;
  required int32 required_int32_55 = 55;
  required int32 required_int32_56 = 56;
  required int32 required_int32_57 = 57;
  required int32 required_int32_58 = 58;
  required int32 required_int32_59 = 59;
  required int32 required_int32_60 = 60;
  required int32 required_int32_61 = 61;
  required int32 required_int32_62 = 62;
}

message TestMapField {
  enum EnumMap {
    ZERO = 0;
    ONE = 1;
    TWO = 2;
  }
  map<int32, EnumMap> map_field = 1;
}

message TestMapFieldExtra {
  enum EnumMap {
    ZERO = 0;
    ONE = 1;
    TWO = 2;
    THREE = 3;
  }
  map<int32, EnumMap> map_field = 1;
}
