summaryrefslogtreecommitdiff
path: root/TAO/tests/IDLv4/explicit_ints/test.idl
blob: 426a962d857344454f3a61d89fb78b93f355f5e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include __TAO_IDL_FEATURES
#ifdef TAO_IDL_HAS_EXPLICIT_INTS
#  if !TAO_IDL_HAS_EXPLICIT_INTS
#    error "Expecting macro to be true"
#  endif
#else
#  error "Expecting macro to be defined"
#endif

#include "tao/Int8Seq.pidl"
#include "tao/UInt8Seq.pidl"
#include "tao/OctetSeq.pidl"
#include "tao/CharSeq.pidl"

const uint8 u8_min = 0;
const uint8 u8_max = 255;
const int8 i8_min = -128;
const int8 i8_max = 127;
const uint16 u16_max = 65535;
const int16 i16_min = -32768;
const int16 i16_max = 32767;
const uint32 u32_max = 4294967295;
const int32 i32_min = -2147483648;
const int32 i32_max = 2147483647;
const uint64 u64_max = 18446744073709551615;
const int64 i64_min = -9223372036854775808;
const int64 i64_max = 9223372036854775807;

const uint8 u8_min_overflow = u8_min - 1; // == u8_max
const int8 i8_min_overflow = i8_min - 1; // == i8_max
const uint8 u8_max_overflow = u8_max + 1; // == 0
const int8 i8_max_overflow = i8_max + 1; // == i8_min

const uint8 u8_max_negate = ~u8_max; // == 0
const int8 i8_max_negate = ~i8_max; // == i8_min

const uint8 u8_e1 = 2;
const uint8 u8_e2 = u8_e1 + 2;
const uint8 u8_e3 = u8_e2 * 3;
const uint8 u8_e4 = u8_e3 / 4;
const uint8 u8_e5 = u8_e4 | 5;
const uint8 u8_e6 = u8_e5 ^ 6;
const uint8 u8_e7 = u8_e6 & 7;
const uint8 u8_e8 = u8_e7 << 4;
const uint8 u8_e9 = u8_e8 >> 1;

const int8 i8_e1 = -2;
const int8 i8_e2 = i8_e1 - -6;
const int8 i8_e3 = i8_e2 * 3;
const int8 i8_e4 = i8_e3 / 4;
const int8 i8_e5 = i8_e4 | 5;
const int8 i8_e6 = i8_e5 ^ 6;
const int8 i8_e7 = i8_e6 & 7;
const int8 i8_e8 = i8_e7 << 4;
const int8 i8_e9 = i8_e8 >> 1;

typedef uint8 U8arr[3];
typedef int8 I8arr[3];
typedef octet Oarr[3];
typedef char Carr[3];
typedef sequence<uint8> U8seq;
typedef sequence<int8> I8seq;
typedef sequence<octet> Oseq;
typedef sequence<char> Cseq;

struct StructWithInts {
  uint8 u8;
  int8 i8;
  uint16 u16;
  int16 i16;
  uint32 u32;
  int32 i32;
  uint64 u64;
  int64 i64;

  // Make sure there's no conflict between uint8, int8, octet, and char.
  uint8 u8_arr[3];
  int8 i8_arr[3];
  sequence<uint8> u8_seq;
  sequence<int8> i8_seq;
  sequence<octet> o_seq;
  sequence<char> c_seq;

  U8arr td_u8_arr;
  I8arr td_i8_arr;
  U8seq td_u8_seq;
  I8seq td_i8_seq;
  Oseq td_o_seq;
  Cseq td_c_seq;
};

union UnionOverU8 switch (uint8) {
case 0:
  uint8 u8;
case 1:
  int8 i8;
case 2:
  uint8 u8arr[3];
case 3:
  int8 i8arr[3];
case 4:
  sequence<uint8> u8seq;
case 5:
  sequence<int8> i8seq;
};

union UnionOverI8 switch (int8) {
case 0:
  uint8 u8;
case 1:
  int8 i8;
case 2:
  uint8 u8arr[3];
case 3:
  int8 i8arr[3];
case 4:
  sequence<uint8> u8seq;
case 5:
  sequence<int8> i8seq;
};