From 083ecb6f22f8096a0f71fdb716409229455bddfc Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 5 Mar 2007 13:41:44 +0000 Subject: Mon Mar 5 13:41:32 UTC 2007 Johnny Willemsen --- TAO/tests/Any/Recursive/Test.idl | 21 ++++++++++ TAO/tests/Any/Recursive/client.cpp | 35 ++++++++++------- TAO/tests/IDL_Test/union.idl | 80 +++++++++++++++++++++----------------- TAO/tests/IDL_Test/valuetype.idl | 9 +++++ 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/TAO/tests/Any/Recursive/Test.idl b/TAO/tests/Any/Recursive/Test.idl index 8c104735d17..9ac5431543b 100644 --- a/TAO/tests/Any/Recursive/Test.idl +++ b/TAO/tests/Any/Recursive/Test.idl @@ -50,6 +50,27 @@ module Test long i; }; + union RecursiveUnion2; + typedef sequence RecursiveUnionSeq2; + + union RecursiveUnion2 switch (short) + { + case 0: + struct Innerstruct3a + { + RecursiveUnionSeq2 recursive_unions; + } insb; + case 1: + short a; + case 2: + struct Innerstruct3b + { + RecursiveUnionSeq2 recursive_unions_second; + } insa; + default: + long i; + }; + union RecursiveUnionNoDefault; typedef sequence RecursiveUnionSeqNoDefault; diff --git a/TAO/tests/Any/Recursive/client.cpp b/TAO/tests/Any/Recursive/client.cpp index 5a16241ac3a..e98636c0bfb 100644 --- a/TAO/tests/Any/Recursive/client.cpp +++ b/TAO/tests/Any/Recursive/client.cpp @@ -193,10 +193,10 @@ recursive_union_test (CORBA::ORB_ptr /* orb */, ACE_DEBUG ((LM_INFO, "Executing recursive union test\n")); - Test::RecursiveUnion foo; + CORBA::Any the_any; + Test::EnumUnion foo_enum; static CORBA::Long const test_long = 238901; - CORBA::Any the_any; // First simple case, just an union with an enum as discriminator foo_enum.i (test_long); @@ -206,6 +206,7 @@ recursive_union_test (CORBA::ORB_ptr /* orb */, the_any); // Non-recursive member case. + Test::RecursiveUnion foo; foo.i (test_long); the_any <<= foo; @@ -213,6 +214,23 @@ recursive_union_test (CORBA::ORB_ptr /* orb */, ::perform_invocation (hello, the_any); + Test::RecursiveUnion2 foo2; + foo2.i (test_long); + + the_any <<= foo2; + + ::perform_invocation (hello, + the_any); + + // new variant + Test::NonRecursiveUnionWithStringStruct3 val3; + Test::Symbol3 sym; + val3.double_val (5.0); + the_any <<= val3; + + ::perform_invocation (hello, + the_any); + // Recursive member case. Test::RecursiveUnionSeq seq; seq.length (2); @@ -267,15 +285,6 @@ recursive_union_test (CORBA::ORB_ptr /* orb */, the_any <<= val2; ::perform_invocation (hello, the_any); - - // new variant - Test::NonRecursiveUnionWithStringStruct3 val3; - Test::Symbol3 sym; - val3.double_val (5.0); - the_any <<= val3; - - ::perform_invocation (hello, - the_any); } @@ -457,8 +466,8 @@ main (int argc, char *argv[]) static test_func const tests[] = { - recursive_struct_test - , recursive_union_test + recursive_union_test + , recursive_struct_test , nested_recursive_struct_test , indirectly_recursive_valuetype_test , directly_recursive_valuetype_test diff --git a/TAO/tests/IDL_Test/union.idl b/TAO/tests/IDL_Test/union.idl index 0ec2409f14e..fcf6b53c2b6 100644 --- a/TAO/tests/IDL_Test/union.idl +++ b/TAO/tests/IDL_Test/union.idl @@ -87,6 +87,16 @@ module UnionDiscTest }; }; +// AnyUnion +enum AnyUnionEnum { + ANYUNIONENUM2 +}; + +union MyAnyUnion switch (AnyUnionEnum) { + case ANYUNIONENUM2: + any my_any; +}; + // Nested unions @@ -109,7 +119,7 @@ enum disc_outer }; union inner1 switch (disc1) -{ +{ case one: short s; case two: long l; }; @@ -126,39 +136,39 @@ union outer switch (disc_outer) case out2: inner2 second; }; -module UnionTest3 +module UnionTest3 { - enum ValChoice + enum ValChoice { intVal, realVal }; - union ValType switch(ValChoice) + union ValType switch(ValChoice) { case intVal: long integerValue; case realVal: double realValue; }; - struct UpType + struct UpType { ValType high; ValType low; }; - struct DownType + struct DownType { ValType high; ValType low; }; - enum IndChoice + enum IndChoice { up_Level, down_Level }; - union IndType switch(IndChoice) + union IndType switch(IndChoice) { case up_Level: UpType up; case down_Level: DownType down; @@ -168,22 +178,22 @@ module UnionTest3 // Make sure inner union is generated in header file with // proper scoping (or lack thereof) in its name, depending // on the platform. -enum XType -{ - X_A +enum XType +{ + X_A }; -enum ZType -{ - Z_A +enum ZType +{ + Z_A }; -union X switch (XType) +union X switch (XType) { case X_A: - struct Y + struct Y { - union Z switch (ZType) + union Z switch (ZType) { case Z_A: long a; } u; @@ -228,24 +238,24 @@ struct Element } Value; }; -// A fix to the IDL compiler's typecoce generation created +// A fix to the IDL compiler's typecode generation created // a problem with unions that have more than one member, // where any member except the last is itself a scoped type. // This is the simplest example that will reproduce the problem, // if it ever reappears. -enum TestOneEnum -{ - TALL, +enum TestOneEnum +{ + TALL, SCHORT }; -enum TestTwoEnum -{ - LIGHT, +enum TestTwoEnum +{ + LIGHT, DARK }; -union TestUnion switch (short) +union TestUnion switch (short) { case 1: TestOneEnum oneEnum; case 2: TestTwoEnum twoEnum; @@ -263,23 +273,23 @@ union decl_heavy_union switch (short) ONE, TWO } m_which; - case 2: - enum en + case 2: + enum en { - a, - b, + a, + b, c } m_en_arr[10]; - case 3: - struct st + case 3: + struct st { - long a; + long a; char b; } m_st_arr[10]; - case 4: - union un switch (long) + case 4: + union un switch (long) { - case 1: long a; + case 1: long a; case 2: char b; } m_un_arr[10]; }; diff --git a/TAO/tests/IDL_Test/valuetype.idl b/TAO/tests/IDL_Test/valuetype.idl index a31a8eb7938..7a53a52193c 100644 --- a/TAO/tests/IDL_Test/valuetype.idl +++ b/TAO/tests/IDL_Test/valuetype.idl @@ -33,6 +33,15 @@ valuetype MyValueType factory make_one (); }; +enum ValueSort2 { + SYMBOL_TYPE2 +}; + +union MyValueTypeUnion switch (ValueSort2) { + case SYMBOL_TYPE2: + MyValueType symbol_val; +}; + // The original bug was caused by the default factory visitor // constructing a temporary arg of this field type. When the // arg was then destroyed, it called its base destroyer -- cgit v1.2.1