/*
 * 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 pkg;

import public "upb/util/def_to_proto_public_import_test.proto";

import "upb/util/def_to_proto_regular_import_test.proto";

option optimize_for = CODE_SIZE;
option go_package = "foo_go_package";
option java_package = "bar_java_package";
option java_outer_classname = "baz_java_outer_classname";
option csharp_namespace = "quux_csharp_namespace";
option objc_class_prefix = "the_objc_prefix";
option cc_enable_arenas = true;

message Message {
  optional int32 a = 1 [default = 3];
  oneof foo {
    string oneof_string = 2 [default = "abc\n"];
    string oneof_bool = 3 [default = "true"];
    bytes oneof_bytes = 4 [default = "abc\xef\xfe"];
  }
  optional pkg.RegularImportMessage regular_import_message = 6;
  optional pkg.PublicImportMessage public_import_message = 7;
  optional pkg.Proto3Enum proto3_enum = 8;
  extensions 1000 to max;
  extend Message {
    optional int32 ext = 1000;
  }

  message NestedMessage {}
  message NestedEnum {}

  // TODO: support reserved ranges in defs.
  // (At the moment they are ignored and will not round-trip through defs).
  // reserved 4, 6 to 8;
}

enum Enum {
  ZERO = 0;
  ONE = 1;
  NEGATIVE_ONE = -1;
}

enum EnumUpper32Value {
  UPPER32_VALUE = 40;
}

enum HasDuplicateValues {
  option allow_alias = true;

  A = 0;
  B = 1;
  C = 120;
  D = 130;

  G = 120;
  F = 1;
  E = 0;
  H = 121;
  I = 121;
  J = 121;
  K = 121;
}

service Service {
  rpc Bar(Message) returns (Message);
}

extend Message {
  optional int32 ext = 1001;
}

enum Has31 {
  VALUE_31 = 31;
}

message PretendMessageSet {
  option message_set_wire_format = true;

  // Since this is message_set_wire_format, "max" here means INT32_MAX.
  // (For normal messages "max" would mean 2**29 - 1).
  extensions 4 to 529999999;
  extensions 530000000 to max
  [declaration = {
    number: 2147483646
    full_name: ".pkg.MessageSetItem.message_set_extension"
    type: ".pkg.MessageSetItem"
  }];
}

message MessageSetItem {
  extend PretendMessageSet {
    // Since max is exclusive, this is INT32_MAX-1, not INT32_MAX.
    optional MessageSetItem message_set_extension = 2147483646;
  }
}

message UnusualDefaults {
  optional bytes foo = 1 [default = "\\X"];
  optional string bar = 2 [default = "\\X"];
}
