2 //=============================================================================
6 * This file contains examples of IDL code that has
7 * caused problems in the past for the TAO IDL
8 * compiler. This test is to make sure the problems
12 * @author Jeff Parsons <parsons@cs.wustl.edu> and TAO users.
14 //=============================================================================
17 // Implicit default case
26 union Data
switch (DataType
)
28 case dtLong
: long longData
;
29 case dtShort
: short shortData
;
30 // by default, empty union
33 // Explicit default case
37 // It is important to have a module, in which
38 // the following union is declared.
48 union WhichResult
switch (Kind
)
50 case e_Result
: Result m_Result
;
51 default: long m_Unused
;
55 // Union with negative cases
56 // At the moment, the SunCC preprocessor separates the negative
57 // sign from the number. This causes problems for the scanner/lexer
59 #if
!defined
(__SUNPRO_CC
) ||
(__SUNPRO_CC
> 0x5140)
60 union foo
switch (short)
64 case -1: string foo_str_member
;
65 default: long foo_iface_member
;
66 case 0: long foo_iface_member2
;
68 #endif
// !__SUNPRO_CC || __SUNPRO_CC > 0x5120
70 // Make sure that CORBA_Any::to_* is used everywhere.
73 union BooleanUnion
switch (boolean)
75 case TRUE
: string value
;
78 union CharUnion
switch (char)
80 case 'a'
: string value
;
86 union OneBranchT
switch (boolean) { case TRUE
: octet val
; };
87 union OneBranchF
switch (boolean) { case FALSE
: octet val
; };
88 union OneBranchD
switch (boolean) { default: octet val
; };
89 union OneBranchTF
switch (boolean) { case TRUE
: case FALSE
: octet val
; };
90 union OneBranchFT
switch (boolean) { case FALSE
: case TRUE
: octet val
; };
91 union OneBranchTD
switch (boolean) { case TRUE
: default: octet val
; };
92 union OneBranchDT
switch (boolean) { default: case TRUE
: octet val
; };
93 union OneBranchFD
switch (boolean) { case FALSE
: default : octet val
; };
94 union OneBranchDF
switch (boolean) { default: case FALSE
: octet val
; };
95 union TwoBranchesTF
switch (boolean) { case TRUE
: octet val1
; case FALSE
: char val2
; };
96 union TwoBranchesFT
switch (boolean) { case FALSE
: octet val1
; case TRUE
: char val2
; };
97 union TwoBranchesTD
switch (boolean) { case TRUE
: octet val1
; default: char val2
; };
98 union TwoBranchesDT
switch (boolean) { default: octet val1
; case TRUE
: char val2
; };
99 union TwoBranchesFD
switch (boolean) { case FALSE
: octet val1
; default: char val2
; };
100 union TwoBranchesDF
switch (boolean) { default: octet val1
; case FALSE
: char val2
; };
123 union inner1
switch (disc1
)
129 union inner2
switch (disc2
)
135 union outer
switch (disc_outer
)
137 case out1
: inner1 first
;
138 case out2
: inner2 second
;
149 union ValType
switch(ValChoice
)
151 case intVal
: long integerValue
;
152 case realVal
: double realValue
;
173 union IndType
switch(IndChoice
)
175 case up_Level
: UpType up
;
176 case down_Level
: DownType down
;
180 // Make sure inner union is generated in header file with
181 // proper scoping (or lack thereof) in its name, depending
193 union X
switch (XType
)
198 union Z
switch (ZType
)
205 // Example involving union members with multiple case labels.
213 union FieldValue
switch (FieldType
)
228 // Tricky case of lookup for a recursive union. When defined
229 // inside another datatype like this, the union is referenced
230 // inside itself before the closing brace is seen, but not
234 union ValueUnion
switch (short)
239 sequence
<ValueUnion
> VUValue
;
243 // A fix to the IDL compiler's typecode generation created
244 // a problem with unions that have more than one member,
245 // where any member except the last is itself a scoped type.
246 // This is the simplest example that will reproduce the problem,
247 // if it ever reappears.
260 union TestUnion
switch (short)
262 case 1: TestOneEnum oneEnum
;
263 case 2: TestTwoEnum twoEnum
;
266 // Test for various kinds of declarations inside a union,
267 // similar to the example in enum_in_struct.idl.
269 typedef long NamedLongArray
[10];
271 union decl_heavy_union
switch (short)
294 union un
switch (long)
299 // The following caused compile problems once
300 // when generating ostream ops
302 NamedLongArray m_named_long_array
;
304 long m_anon_long_array
[10];