/* Test handling of enums with different value ranges.
 * Depending on compiler and the packed_enum setting, the datatypes
 * for enums can be either signed or unsigned. In past this has caused
 * a bit of a problem for the encoder/decoder (issue #164).
 */

syntax = "proto2";

import 'nanopb.proto';

option (nanopb_fileopt).long_names = false;

enum UnpackedUint8 {
    option (nanopb_enumopt).packed_enum = false;
    UU8_MIN = 0;
    UU8_MAX = 255;
}

enum PackedUint8 {
    option (nanopb_enumopt).packed_enum = true;
    PU8_MIN = 0;
    PU8_MAX = 255;
}

enum UnpackedInt8 {
    option (nanopb_enumopt).packed_enum = false;
    UI8_MIN = -128;
    UI8_MAX = 127;
}

enum PackedInt8 {
    option (nanopb_enumopt).packed_enum = true;
    PI8_MIN = -128;
    PI8_MAX = 127;
}

enum UnpackedUint16 {
    option (nanopb_enumopt).packed_enum = false;
    UU16_MIN = 0;
    UU16_MAX = 65535;
}

enum PackedUint16 {
    option (nanopb_enumopt).packed_enum = true;
    PU16_MIN = 0;
    PU16_MAX = 65535;
}

enum UnpackedInt16 {
    option (nanopb_enumopt).packed_enum = false;
    UI16_MIN = -32768;
    UI16_MAX = 32767;
}

enum PackedInt16 {
    option (nanopb_enumopt).packed_enum = true;
    PI16_MIN = -32768;
    PI16_MAX = 32767;
}

/* Protobuf supports enums up to 32 bits.
 * The 32 bit case is covered by HugeEnum in the alltypes test.
 */

message PackedEnums {
    required PackedUint8  u8_min  = 1;
    required PackedUint8  u8_max  = 2;
    required PackedInt8   i8_min  = 3;
    required PackedInt8   i8_max  = 4;
    required PackedUint16 u16_min = 5;
    required PackedUint16 u16_max = 6;
    required PackedInt16  i16_min = 7;
    required PackedInt16  i16_max = 8;
}

message UnpackedEnums {
    required UnpackedUint8  u8_min  = 1;
    required UnpackedUint8  u8_max  = 2;
    required UnpackedInt8   i8_min  = 3;
    required UnpackedInt8   i8_max  = 4;
    required UnpackedUint16 u16_min = 5;
    required UnpackedUint16 u16_max = 6;
    required UnpackedInt16  i16_min = 7;
    required UnpackedInt16  i16_max = 8;
}

