summaryrefslogtreecommitdiff
path: root/TAO/tests/IDL_Test/union_anonymous.idl
blob: 0800949f504db238896b2019f21ad3d735b0bb27 (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
//=============================================================================
/**
 *  @file    union_anonymous.idl
 *
 *  This file contains examples of IDL code that has
 *  caused problems in the past for the TAO IDL
 *  compiler. This test is to make sure the problems
 *  stay fixed.
 *
 *
 *  @author Jeff Parsons <parsons@cs.wustl.edu> and TAO users.
 */
//=============================================================================

// Tricky case of lookup for a recursive union. When defined
// inside another datatype like this, the union is referenced
// inside itself before the closing brace is seen, but not
// declared yet.
struct Element
{
  union ValueUnion switch (short)
  {
    case 0:
      long lvalue;
    case 1:
      sequence<ValueUnion> VUValue;
  } Value;
};

// Test for various kinds of declarations inside a union,
// similar to the example in enum_in_struct.idl.
typedef long NamedLongArray[10];

union decl_heavy_union switch (short)
{
  case 1:
    enum which
    {
      ZERO,
      ONE,
      TWO
    } m_which;
  case 2:
    enum en
    {
      a,
      b,
      c
    } m_en_arr[10];
  case 3:
    struct st
    {
      long a;
      char b;
    } m_st_arr[10];
  case 4:
    union un switch (long)
    {
      case 1: long a;
      case 2: char b;
    } m_un_arr[10];
  // The following caused compile problems once
  // when generating ostream ops
  case 5:
    NamedLongArray m_named_long_array;
  case 6:
    long m_anon_long_array[10];
};