diff options
author | gmaxey <gmaxey@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-07-13 20:22:40 +0000 |
---|---|---|
committer | gmaxey <gmaxey@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-07-13 20:22:40 +0000 |
commit | b7d28d21040797dcb22c115453b7e3f671ff5958 (patch) | |
tree | c643069ae6bd3983025933a8fcd2838301042e5b | |
parent | 44e12245280534390773b7db71d5301ba1963ac8 (diff) | |
download | ATCD-b7d28d21040797dcb22c115453b7e3f671ff5958.tar.gz |
ChangeLogTag: Wed Jul 13 13:17:56 2005 Gary Maxey <gary.maxey@hp.com>
-rw-r--r-- | TAO/ChangeLog | 15 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/Test_impl.cpp | 516 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/Test_impl.h | 154 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/client.cpp | 1420 | ||||
-rwxr-xr-x | TAO/tests/OBV/ValueBox/run_test.pl | 49 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/server.cpp | 105 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/valuebox.idl | 99 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/valuebox.mpc | 33 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/vb_basic.idl | 77 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/vb_struct.idl | 68 | ||||
-rw-r--r-- | TAO/tests/OBV/ValueBox/vb_union.idl | 22 |
11 files changed, 2558 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 1831bea99e9..fd12b0ab349 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,18 @@ +Wed Jul 13 13:17:56 2005 Gary Maxey <gary.maxey@hp.com> + + * tests/OBV/ValueBox/client.cpp: + * tests/OBV/ValueBox/run_test.pl: + * tests/OBV/ValueBox/server.cpp: + * tests/OBV/ValueBox/Test_impl.cpp: + * tests/OBV/ValueBox/Test_impl.h: + * tests/OBV/ValueBox/valuebox.idl: + * tests/OBV/ValueBox/valuebox.mpc: + * tests/OBV/ValueBox/vb_basic.idl: + * tests/OBV/ValueBox/vb_struct.idl: + * tests/OBV/ValueBox/vb_union.idl: + + New test for valuebox feature + Wed Jul 13 15:14:46 2005 Justin Michel <michel_j@ociweb.com> * NEWS: diff --git a/TAO/tests/OBV/ValueBox/Test_impl.cpp b/TAO/tests/OBV/ValueBox/Test_impl.cpp new file mode 100644 index 00000000000..78f1ee5d371 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/Test_impl.cpp @@ -0,0 +1,516 @@ +// $Id$ + +#include "Test_impl.h" + +ACE_RCSID(Forward, + Test_impl, + "$Id$") + +Test_impl::Test_impl (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +//*************************************************************************** +// Rotate characters in string, last character becomes the first and +// all others are shifted to the right. +//*************************************************************************** +void rotate_string(char *s) +{ + unsigned char c; + size_t l; + + l = strlen(s); + if (l>1) + { + c = s[l-1]; + memmove(&s[1], &s[0], l-1); + s[0] = c; + } +} + + +VBlong * +Test_impl::basic_op1 (VBlong * p1, VBlong *& p2, VBlong_out p3) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_RETURN (p3, + VBlong (p2->_value()*5), + 0); + + p2->_value (p2->_value() * 3); + + VBlong *retval = 0; + ACE_NEW_RETURN (retval, + VBlong (p1->_value()*3), + 0); + + return retval; +} + +vb_basic::M_VBlong * +Test_impl::basic_op2 (vb_basic::M_VBlong * p1, + vb_basic::M_VBlong *& p2, + vb_basic::M_VBlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_RETURN (p3, + vb_basic::M_VBlong (p2->_value()*5), + 0); + + p2->_value (p2->_value() * 3); + + vb_basic::M_VBlong *retval = 0; + ACE_NEW_RETURN (retval, + vb_basic::M_VBlong (p1->_value()*3), + 0); + + return retval; +} + +::CORBA::Long +Test_impl::basic_op3 (::CORBA::Long p1, ::CORBA::Long& p2, + ::CORBA::Long_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + p3 = p2 * 5; + + p2 = p2 * 3; + + return p1 * 3; +} + + +VBstring * +Test_impl::string_op1 (::VBstring * p1, + ::VBstring *& p2, + ::VBstring_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + rotate_string (p2->_boxed_inout ()); + + ACE_NEW_RETURN (p3, + VBstring (p2->_value ()), + 0); + + rotate_string (p1->_boxed_inout ()); + + VBstring *retval = 0; + ACE_NEW_RETURN (retval, + VBstring (p1->_value ()), + 0); + + return retval; +} + +char * +Test_impl::string_op2 (const char * p1, + char *& p2, + CORBA::String_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + rotate_string (p2); + + p3 = CORBA::string_alloc (strlen(p2)); + strcpy (p3, p2); + + rotate_string ((char *) p1); + + char *return_string; + return_string = CORBA::string_alloc (strlen(p1)); + strcpy (return_string, p1); + + return return_string; +} + +::VBseqlong * +Test_impl::seq_op1 (::VBseqlong * p1, + ::VBseqlong *& p2, + ::VBseqlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_RETURN (p3, + VBseqlong(*p2), + 0); + for (CORBA::ULong i=0; i<p3->_value().length(); i++) + { + (*p3)[i] *= 5; + } + + for (CORBA::ULong i=0; i<p2->_value().length(); i++) + { + (*p2)[i] *= 3; + } + + VBseqlong *retval = 0; + ACE_NEW_RETURN (retval, + VBseqlong(*p1), + 0); + + return retval; +} + +void +Test_impl::seq_op2 (const ::TDseqlong & p1, + ::TDseqlong & p2, + ::TDseqlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW (p3, + TDseqlong(p1)); + for (CORBA::ULong i=0; i<p3->length(); i++) + { + (*p3)[i] *= 5; + } + + for (CORBA::ULong i=0; i<p2.length(); i++) + { + p2[i] *= 3; + } +} + +::VBfixed_struct1 * +Test_impl::struct_op1 (::VBfixed_struct1 * p1, + ::VBfixed_struct1 *& p2, + ::VBfixed_struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_RETURN (p3, + VBfixed_struct1 (p2->_value()), + 0); + // transform p3 values + p3->l (p3->l() * 5); + p3->abstruct().s1 = (p3->abstruct()).s1 * 5; + p3->abstruct().s2 = (p3->abstruct()).s2 * 5; + + // transform p2 values + p2->l (p2->l() * 3); + p2->abstruct().s1 = (p2->abstruct()).s1 * 3; + p2->abstruct().s2 = (p2->abstruct()).s2 * 3; + + VBfixed_struct1 *retval = 0; + ACE_NEW_RETURN (retval, + VBfixed_struct1 (p1->_value()), + 0); + + return retval; +} + +void +Test_impl::struct_op2 (const ::Fixed_Struct1 & p1, + ::Fixed_Struct1 & p2, + ::Fixed_Struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + p3 = p1; + + p2.l *= 3; + p2.abstruct.s1 *= 3; + p2.abstruct.s2 *= 3; +} + +::VBvariable_struct1 * +Test_impl::struct_op3 (::VBvariable_struct1 * p1, + ::VBvariable_struct1 *& p2, + ::VBvariable_struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // transform p2 values + p2->l (p2->l() * 3); + rotate_string ((CORBA::Char *)p2->str()); + + ACE_NEW_RETURN (p3, + VBvariable_struct1 (p2->_value()), + 0); + + VBvariable_struct1 *retval = 0; + ACE_NEW_RETURN (retval, + VBvariable_struct1 (p1->_value()), + 0); + + return retval; +} + + +void +Test_impl::struct_op4 (const ::Variable_Struct1 & p1, + ::Variable_Struct1 & p2, + ::Variable_Struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW (p3, + Variable_Struct1()); + p3->l = p1.l; + p3->str = p1.str; + + p2.l *= 3; + rotate_string ((CORBA::Char *)p2.str.in()); +} + + +::VBlongarray * +Test_impl::array_op1 (::VBlongarray * p1, + ::VBlongarray *& p2, + ::VBlongarray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + long array_len = sizeof(LongArray) / sizeof(long); + + for (long i=0; i<array_len; i++) + { + (*p2)[i] *= 3; + } + + ACE_NEW_RETURN (p3, + VBlongarray(*p2), + 0); + + VBlongarray *retval = 0; + ACE_NEW_RETURN (retval, + VBlongarray(*p1), + 0); + + return retval; +} + +void +Test_impl::array_op2 (const ::LongArray p1, + ::LongArray p2, + ::LongArray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + long array_len = sizeof(LongArray) / sizeof(long); + + for (long i=0; i<array_len; i++) + { + p2[i] *= 3; + } + + for (long i=0; i<array_len; i++) + { + p3[i] = p1[i]; + } +} + + +::VBstringarray * +Test_impl::array_op3 (::VBstringarray * p1, + ::VBstringarray *& p2, + ::VBstringarray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + long array_len = sizeof( ::StringArray ) / sizeof( StringArray_slice ); + + char * p; + for (long i=0; i<array_len; i++) + { + p = (CORBA::Char *)((*p2)[i]).in(); + rotate_string (p); + } + + ACE_NEW_RETURN (p3, + VBstringarray(*p2), + 0); + + VBstringarray *retval = 0; + ACE_NEW_RETURN (retval, + VBstringarray(*p1), + 0); + + return retval; +} + +void +Test_impl::array_op4 (const ::StringArray p1, + ::StringArray p2, + ::StringArray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + long array_len = sizeof( ::StringArray ) / sizeof( StringArray_slice ); + + char * p; + for (long i=0; i<array_len; i++) + { + p = (CORBA::Char *)(p2[i]).in(); + rotate_string (p); + } + + StringArray_slice *sa = StringArray_alloc (); + + for (long i=0; i<array_len; i++) + { + sa[i] = p1[i]; + } + + p3 = sa; + +} + + +::VBfixed_union1 * +Test_impl::union_op1 (::VBfixed_union1 * p1, + ::VBfixed_union1 *& p2, + ::VBfixed_union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Long longValue; + CORBA::Short shortValue; + ACE_NEW_RETURN (p3, + VBfixed_union1 (), + 0); + VBfixed_union1 *rv = 0; + ACE_NEW_RETURN (rv, + VBfixed_union1 (), + 0); + + // Set output and return values + switch (p1->_d ()) + { + case 1: // Long + longValue = p1->m1 () * 3; + p3->m1 (longValue); + rv->m1 (longValue); + break; + case 2: // Short + shortValue = p1->m2 () * 3; + p3->m2 (shortValue); + rv->m2 (shortValue); + break; + } + + // Set new "inout" parameter value + switch (p2->_d()) + { + case 1: // Long + p2->m1 (p2->m1 () * 3); + break; + case 2: // Short + p2->m2 (p2->m2 () * 3); + break; + } + + return rv; +} + +void +Test_impl::union_op2 (const ::Fixed_Union1 & p1, + ::Fixed_Union1 & p2, + ::Fixed_Union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + p3 = p1; + + // Set new "inout" parameter value + switch (p2._d()) + { + case 1: // Long + p2.m1 (p2.m1 () * 3); + break; + case 2: // Short + p2.m2 (p2.m2 () * 3); + break; + } +} + +::VBvariable_union1 * +Test_impl::union_op3 (::VBvariable_union1 * p1, + ::VBvariable_union1 *& p2, + ::VBvariable_union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Long longValue; + CORBA::String_var stringValue; + ACE_NEW_RETURN (p3, + VBvariable_union1 (), + 0); + VBvariable_union1 *rv = 0; + ACE_NEW_RETURN (rv, + VBvariable_union1 (), + 0); + + + // Set output and return values + switch (p1->_d ()) + { + case 1: // Long + longValue = p1->m1 (); + p3->m1 (longValue); + rv->m1 (longValue); + break; + case 2: // String + stringValue = p1->m2 (); + p3->m2 (stringValue); + rv->m2 (stringValue); + break; + } + + // Set new "inout" parameter value + switch (p2->_d()) + { + case 1: // Long + p2->m1 (p2->m1 () * 3); + break; + case 2: // String + stringValue = p2->m2 (); + rotate_string (stringValue); + p2->m2 (stringValue); + break; + } + + return rv; +} + +void +Test_impl::union_op4 (const ::Variable_Union1 & p1, + ::Variable_Union1 & p2, + ::Variable_Union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::String_var stringValue; + + // Return value of "in" parameter to "out" parameter + ACE_NEW (p3, + Variable_Union1()); + + switch (p1._d ()) + { + case 1: // Long + p3->m1 (p1.m1 ()); + break; + case 2: // String + p3->m2 (p1.m2 ()); + break; + } + + // Set new "inout" parameter value + switch (p2._d()) + { + case 1: // Long + p2.m1 (p2.m1 () * 3); + break; + case 2: // String + stringValue = p2.m2 (); + rotate_string (stringValue); + p2.m2 (stringValue); + break; + } +} + diff --git a/TAO/tests/OBV/ValueBox/Test_impl.h b/TAO/tests/OBV/ValueBox/Test_impl.h new file mode 100644 index 00000000000..186f6b9daab --- /dev/null +++ b/TAO/tests/OBV/ValueBox/Test_impl.h @@ -0,0 +1,154 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/OBV/ValueBox +// +// = FILENAME +// Test_impl.h +// +// = AUTHOR +// Gary Maxey +// +// ============================================================================ + + +#ifndef TAO_TEST_IMPL_H +#define TAO_TEST_IMPL_H + +#include "valueboxS.h" + + +class Test_impl : public POA_Test +{ +public: + Test_impl (CORBA::ORB_ptr orb); + // ctor + + virtual VBlong * basic_op1 ( + VBlong * p1, + VBlong *& p2, + VBlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual vb_basic::M_VBlong * basic_op2(vb_basic::M_VBlong * p1, + vb_basic::M_VBlong *& p2, + vb_basic::M_VBlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CORBA::Long basic_op3 ( + ::CORBA::Long p1, + ::CORBA::Long& p2, + ::CORBA::Long_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual VBstring * string_op1 (::VBstring * p1, + ::VBstring *& p2, + ::VBstring_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual char * string_op2 (const char * p1, + char *& p2, + CORBA::String_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBseqlong * seq_op1 (::VBseqlong * p1, + ::VBseqlong *& p2, + ::VBseqlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void seq_op2 (const ::TDseqlong & p1, + ::TDseqlong & p2, + ::TDseqlong_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBfixed_struct1 * struct_op1 ( + ::VBfixed_struct1 * p1, + ::VBfixed_struct1 *& p2, + ::VBfixed_struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void struct_op2 (const ::Fixed_Struct1 & p1, + ::Fixed_Struct1 & p2, + ::Fixed_Struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBvariable_struct1 * struct_op3 (::VBvariable_struct1 * p1, + ::VBvariable_struct1 *& p2, + ::VBvariable_struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + + virtual void struct_op4 (const ::Variable_Struct1 & p1, + ::Variable_Struct1 & p2, + ::Variable_Struct1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBlongarray * array_op1 (::VBlongarray * p1, + ::VBlongarray *& p2, + ::VBlongarray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + + virtual void array_op2 (const ::LongArray p1, + ::LongArray p2, + ::LongArray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBstringarray * array_op3 (::VBstringarray * p1, + ::VBstringarray *& p2, + ::VBstringarray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void array_op4 (const ::StringArray p1, + ::StringArray p2, + ::StringArray_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBfixed_union1 * union_op1 (::VBfixed_union1 * p1, + ::VBfixed_union1 *& p2, + ::VBfixed_union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void union_op2 (const ::Fixed_Union1 & p1, + ::Fixed_Union1 & p2, + ::Fixed_Union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::VBvariable_union1 * union_op3 (::VBvariable_union1 * p1, + ::VBvariable_union1 *& p2, + ::VBvariable_union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void union_op4 (const ::Variable_Union1 & p1, + ::Variable_Union1 & p2, + ::Variable_Union1_out p3 + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + +private: + CORBA::ORB_var orb_; + // The ORB +}; + +#endif /* TAO_TEST_IMPL_H */ diff --git a/TAO/tests/OBV/ValueBox/client.cpp b/TAO/tests/OBV/ValueBox/client.cpp new file mode 100644 index 00000000000..03662c0780c --- /dev/null +++ b/TAO/tests/OBV/ValueBox/client.cpp @@ -0,0 +1,1420 @@ +// $Id$ + +#include "valueboxC.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(ValueBox, + client, + "$Id$") + + +const char *ior = "file://test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + + +#define VERIFY(Condition) \ +{ \ + if ((Condition)==0) \ + { \ + fail++; \ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %d\n", \ + (int)(__LINE__))); \ + } \ +} + +// +// Templated function for testing various aspects of valuetypes. +// valuebox is a type created by the user, with UT as the underlying type. +// It is assumed that, on entry, valuebox->_value() != val1, and that +// val1 and val2 are distinct. +// +template <class BoxT, class UT> +int box_test1 (BoxT *valuebox, UT val1, UT val2) +{ + int fail = 0; + BoxT *valuebox_clone = 0; + + // should be a deep copy of val1... + VERIFY ( &valuebox_clone->_boxed_inout () != &valuebox->_boxed_inout () ); + + // but values should be equal + VERIFY ( valuebox_clone->_value () == valuebox->_value () ); + + // Check that modifier is working. + valuebox_clone->_value ( val2 ); + VERIFY ( valuebox_clone->_value () != valuebox->_value () ); + + // use operator= + *valuebox = val2; + VERIFY ( valuebox_clone->_value () == valuebox->_value () ); + + // Check that _value and _boxed_in are the same. + VERIFY ( valuebox_clone->_value () == valuebox_clone->_boxed_in () ); + VERIFY ( valuebox->_value () == valuebox->_boxed_in () ); + + // Used _boxed_inout to change the value + VERIFY ( valuebox->_value () != val1 ); + valuebox->_boxed_inout () = val1; + VERIFY ( valuebox->_value () == val1 ); + + // Use _boxed_out to access the value + VERIFY ( valuebox_clone->_value () != val1 ); + valuebox_clone->_boxed_out () = val1; + VERIFY ( valuebox_clone->_value () == val1 ); + + // Test _copy_value + CORBA::ValueBase *copy = valuebox->_copy_value (); + VERIFY ( copy != 0 ); + // check add_ref, remove_ref + copy->_add_ref (); + copy->_remove_ref (); + + // try downcast...then we can check that copy was correct. + BoxT *down = BoxT::_downcast (copy); + VERIFY ( down->_value () == val1 ); + down->_value ( val2 ); + VERIFY ( down->_value () != valuebox->_value () ); + VERIFY ( down->_value () == val2 ); + CORBA::remove_ref (copy); + + // cleanup. Use purify on the PC to check for leaks. + CORBA::remove_ref (valuebox_clone); + + return fail; +} + +template <class BoxT, class UT> +int simple_box_test () +{ + int fail = 0; + BoxT *p = 0; + ACE_NEW_RETURN (p, + BoxT (101), + 1); + fail += box_test1<BoxT, UT> (p, 101, 202); + + CORBA::remove_ref (p); + + return fail; + +} + +// +// Test boxed values that use an underlying UT& +// +template <class BoxT, class UT> +int box_test_ref (BoxT *valuebox, UT &val1, UT &val2) +{ + int fail = 0; + BoxT *p = 0; + ACE_NEW_RETURN (p, + BoxT (val1), + 1); + + // should be a deep copy of val1... + VERIFY ( &p->_boxed_inout () != &valuebox->_boxed_inout () ); + + p->_value ( val2 ); // deep copy + VERIFY ( &p->_boxed_inout () != &valuebox->_boxed_inout () ); + + *valuebox = val2; // deep copy, too. + VERIFY ( &p->_boxed_inout () != &valuebox->_boxed_inout () ); + + CORBA::remove_ref (p); + + return fail; +} + +int test_basic (void) +{ + int fail = 0; + + // Basic types + fail += simple_box_test<VBshort, CORBA::Short> (); + fail += simple_box_test<VBlong, CORBA::Long> (); + fail += simple_box_test<VBlonglong, CORBA::LongLong> (); + fail += simple_box_test<VBushort, CORBA::UShort> (); + fail += simple_box_test<VBulong, CORBA::ULong> (); + fail += simple_box_test<VBulonglong, CORBA::ULongLong> (); + fail += simple_box_test<VBwchar, CORBA::WChar> (); + fail += simple_box_test<VBoctet, CORBA::Octet> (); + fail += simple_box_test<VBfloat, CORBA::Float> (); + fail += simple_box_test<VBdouble, CORBA::Double> (); + + VBchar *pchar = 0; + ACE_NEW_RETURN (pchar, + VBchar ('A'), + 1); + fail += box_test1<VBchar, CORBA::Char> (pchar, 'A', 'Z'); + CORBA::remove_ref (pchar); + + VBboolean *pbool = 0; + ACE_NEW_RETURN (pbool, + VBboolean (true), + 1); + fail += box_test1<VBboolean, CORBA::Boolean> (pbool, true, false); + CORBA::remove_ref (pbool); + + // Typedef of basic types + fail += simple_box_test<VBTDshort, CORBA::Short> (); + fail += simple_box_test<VBTDlong, CORBA::Long> (); + fail += simple_box_test<VBTDlonglong, CORBA::LongLong> (); + fail += simple_box_test<VBTDushort, CORBA::UShort> (); + fail += simple_box_test<VBTDulong, CORBA::ULong> (); + fail += simple_box_test<VBTDulonglong, CORBA::ULongLong> (); + fail += simple_box_test<VBTDwchar, CORBA::WChar> (); + fail += simple_box_test<VBTDoctet, CORBA::Octet> (); + fail += simple_box_test<VBTDfloat, CORBA::Float> (); + fail += simple_box_test<VBTDdouble, CORBA::Double> (); + + VBTDchar *pchar2 = 0; + ACE_NEW_RETURN (pchar2, + VBTDchar ('A'), + 1); + fail += box_test1<VBTDchar, CORBA::Char> (pchar2, 'A', 'Z'); + CORBA::remove_ref (pchar2); + + VBTDboolean *pbool2 = 0; + ACE_NEW_RETURN (pbool2, + VBTDboolean (true), + 1); + fail += box_test1<VBTDboolean, CORBA::Boolean> (pbool2, true, false); + CORBA::remove_ref (pbool2); + + // Enumerated type + VBenum *penum = 0; + ACE_NEW_RETURN (penum, + VBenum (yellow), + 1); + fail += box_test1<VBenum, Color> (penum, yellow, red); + CORBA::remove_ref (penum); + + // Typedef of enumerated type + VBTDenum *penum2 = 0; + ACE_NEW_RETURN (penum2, + VBTDenum (yellow), + 1); + fail += box_test1<VBTDenum, Color> (penum2, yellow, red); + CORBA::remove_ref (penum2); + + // Any + CORBA::Any *a1 = 0; + ACE_NEW_RETURN (a1, + CORBA::Any (), + 1); + CORBA::Any_var any1 (a1); + + CORBA::Any *a2 = 0; + ACE_NEW_RETURN (a2, + CORBA::Any (), + 1); + CORBA::Any_var any2 (a2); + + VBany *pany = 0; + ACE_NEW_RETURN (pany, + VBany (any1.in ()), + 1); + fail += box_test_ref<VBany, CORBA::Any> (pany, any1.inout (), + any2.inout ()); + CORBA::remove_ref (pany); + + // Typedef of Any + VBTDany *pany2 = 0; + ACE_NEW_RETURN (pany2, + VBTDany (any1.in ()), + 1); + fail += box_test_ref<VBTDany, CORBA::Any> (pany2, any1.inout (), + any2.inout ()); + CORBA::remove_ref (pany); + + return fail; +} + +int test_basic_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + + //============================================================ + // Test method invocation with boxed value + //============================================================ + + VBlong *p1 = 0; + ACE_NEW_RETURN (p1, + VBlong(25), + 1); + VBlong *p2 = 0; + ACE_NEW_RETURN (p2, + VBlong(53), + 1); + VBlong *p3; + + VERIFY (p1->_value () == 25); + VERIFY (p2->_value () == 53); + + VBlong_var result = + test_object->basic_op1(p1, p2, p3); + + VERIFY (p2->_value () == (53*3)); + VERIFY (p3->_value () == (53*5)); + VERIFY (result->_value () == (p1->_value () *3)); + + //============================================================ + // Test method invocation with boxed value from nested module + //============================================================ + + vb_basic::M_VBlong *mp1 = 0; + ACE_NEW_RETURN (mp1, + vb_basic::M_VBlong(25), + 1); + + vb_basic::M_VBlong *mp2 = 0; + ACE_NEW_RETURN (mp2, + vb_basic::M_VBlong(53), + 1); + + vb_basic::M_VBlong *mp3; + + VERIFY (mp1->_value () == 25); + VERIFY (mp2->_value () == 53); + + vb_basic::M_VBlong_var mresult = + test_object->basic_op2(mp1, mp2, mp3); + + VERIFY (mp2->_value () == (53*3)); + VERIFY (mp3->_value () == (53*5)); + VERIFY (mresult->_value () == (mp1->_value () *3)); + + //============================================================ + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + p1->_value(67); + p2->_value(93); + + long lresult = + test_object->basic_op3(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY (p2->_value () == (93*3)); + VERIFY (p3->_value () == (93*5)); + VERIFY (lresult == (p1->_value()*3)); + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_basic_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_basic_invocations: caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + + +int test_boxed_string() +{ + int fail = 0; + const char *string1 = "First-string"; + const char *string2 = "Second-string"; + + // Establish that we have data setup correctly... + VERIFY (strcmp (string1, string2) < 0); + VERIFY (strcmp (string2, string1) > 0); + VERIFY (strcmp (string1, string1) == 0); + + // Make some objects, using our data + VBstring_var vbstring1; + ACE_NEW_RETURN (vbstring1, + VBstring(string1), + 1); + VBstring *vbstring2 = 0; + ACE_NEW_RETURN (vbstring2, + VBstring(string1), // tests const char * ctor. + 1); + + VERIFY (strcmp (vbstring1->_value(), string1) == 0); + VERIFY (strcmp (vbstring2->_value(), string1) == 0); + + // Test assignment operators + char *carray1 = 0; + ACE_NEW_RETURN (carray1, + char[15], + 1); + memcpy(carray1, string2, strlen(string2)); + *vbstring2 = carray1; // char * (adopted by box) + VERIFY ((*vbstring2)[0] == 'S'); + *vbstring2 = string1; + VERIFY ((*vbstring2)[0] == 'F'); + CORBA::String_var svar(string2); + *vbstring2 = svar; + VERIFY ((*vbstring2)[0] == 'S'); + + // Test _value modifiers--like assignment drill above. + char *carray2 = 0; + ACE_NEW_RETURN (carray2, + char[15], + 1); + memcpy(carray2, string1, strlen(string1)); + vbstring2->_value(carray2); // char * (adopted by box) + VERIFY ((*vbstring2)[0] == 'F'); + vbstring2->_value(string2); // const char * + VERIFY ((*vbstring2)[0] == 'S'); + (*vbstring2)[0] = 'Y'; + VERIFY ((*vbstring2)[0] != 'S'); + vbstring2->_value(svar); + VERIFY ((*vbstring2)[0] == 'S'); + // test value accessor + VERIFY ( (vbstring2->_value())[0] == 'S' ); + + // + // Test ctors. + // const boxed string + VBstring *vbstring3 = 0; + ACE_NEW_RETURN (vbstring3, + VBstring(*vbstring2), + 1); + VERIFY ((*vbstring3)[0] == 'S'); + (*vbstring3)[0] = 'W'; + VERIFY ((*vbstring3)[0] == 'W' && (*vbstring2)[0] == 'S'); + vbstring3->_remove_ref(); + + // + // char * + char *carray3 = 0; + ACE_NEW_RETURN (carray3, + char[15], + 1); + memcpy(carray3, string1, strlen(string1)); + VBstring *vbstring4 = 0; + ACE_NEW_RETURN (vbstring4, + VBstring(carray3), + 1); + VERIFY ((*vbstring4)[0] == 'F'); + vbstring4->_remove_ref(); + + // + // test CORBA::String_var ctor + VBstring *vbstring5 = 0; + ACE_NEW_RETURN (vbstring5, + VBstring(svar), + 1); + VERIFY ((*vbstring5)[0] == 'S'); + (*vbstring5)[0] = 'W'; + VERIFY ((*vbstring5)[0] == 'W' && (svar.in())[0] == 'S'); + vbstring5->_remove_ref(); + + // release, as usual + vbstring2->_remove_ref(); + return fail; +} + + +int test_boxed_string_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + + //============================================================ + // Test method invocation with boxed value + //============================================================ + + VBstring *p1 = 0; + ACE_NEW_RETURN (p1, + VBstring("string1"), + 1); + VBstring *p2 = 0; + ACE_NEW_RETURN (p2, + VBstring("string2"), + 1); + VBstring *p3; + + VERIFY (strcmp(p1->_value (), "string1") == 0); + VERIFY (strcmp(p2->_value (), "string2") == 0); + + VBstring_var result = test_object->string_op1(p1, p2, p3); + + VERIFY (strcmp(p2->_value (), "2string") == 0); + VERIFY (strcmp(p3->_value (), "2string") == 0); + VERIFY (strcmp(result->_value (), "1string") == 0); + + //============================================================ + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + p2->_value("second string2"); + + char * sresult = + test_object->string_op2(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY (strcmp(p2->_value (), "2second string") == 0); + VERIFY (strcmp(p3->_value (), "2second string") == 0); + VERIFY (strcmp(sresult, "1string") == 0); + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_boxed_string_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_boxed_string_invocations: " + "caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + +// +// Test boxed sequence types. +// +int test_boxed_sequence (void) +{ + int fail = 0; + VBseqlong *vbseqlong1 = 0; + ACE_NEW_RETURN (vbseqlong1, + VBseqlong (), + 1); + + VBseqlong *temp; + ACE_NEW_RETURN (temp, + VBseqlong (), + 1); + + VBseqlong_var vbseqlong2 (temp); + VERIFY (vbseqlong1->length() == 0); + VERIFY (vbseqlong2->length() == 0); + CORBA::Long *longarray = 0; + ACE_NEW_RETURN (longarray, + CORBA::Long[3], + 1); + longarray[0] = 101; + longarray[1] = 202; + longarray[2] = 303; + + // Create a sequence + TDseqlong *temp2; + ACE_NEW_RETURN (temp2, + TDseqlong(10, 3, longarray, 1), + 1); + TDseqlong_var seqlong1 (temp2); + VERIFY (seqlong1[0] == 101 && seqlong1[2] == 303); + + VBseqlong *vbseqlong3 = 0; + ACE_NEW_RETURN (vbseqlong3, + VBseqlong(seqlong1.in()), + 1); + + // Test sequence ctor. + VBseqlong *vbseqlong4 = 0; + ACE_NEW_RETURN (vbseqlong4, + VBseqlong(10, 3, longarray, 0), + 1); + + // Test assignment and subscript operators + vbseqlong2 = vbseqlong3; + VERIFY (vbseqlong2->length() == 3); + VBseqlong &vbseqlong5 = *vbseqlong2.inout(); + VERIFY (vbseqlong5[2] == 303); + vbseqlong5[2] = 444; + VERIFY (vbseqlong5[2] == 444); + VERIFY (seqlong1[0] == 101 && seqlong1[2] == 303); + VERIFY ((*vbseqlong4)[0] == 101 && (*vbseqlong4)[2] == 303); + seqlong1[0] = 111; + VERIFY ((*vbseqlong4)[0] == 111); + VERIFY (vbseqlong4->maximum() == 10); + *vbseqlong4 = vbseqlong1->_value(); + VERIFY (vbseqlong4->length() == 0); + + // Test copy_value + VBseqlong *vbseqlong6 = VBseqlong::_downcast( vbseqlong4->_copy_value() ); + VERIFY (vbseqlong6->length() == 0); + + // release + vbseqlong1->_remove_ref(); + vbseqlong3->_remove_ref(); + vbseqlong4->_remove_ref(); + vbseqlong6->_remove_ref(); + + return fail; +} + + + +int test_boxed_sequence_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + + //============================================================ + // Test method invocation with boxed value + //============================================================ + + VBseqlong *p1 = 0; + ACE_NEW_RETURN (p1, + VBseqlong(4), + 1); + VBseqlong *p2 = 0; + ACE_NEW_RETURN (p2, + VBseqlong(3), + 1); + VBseqlong *p3; + p1->length(4); + p2->length(3); + + (*p1)[0] = 10; + (*p1)[1] = 9; + (*p1)[2] = 8; + (*p1)[3] = 7; + + (*p2)[0] = 100; + (*p2)[1] = 99; + (*p2)[2] = 98; + + VERIFY ((*p1)[0] == 10); + VERIFY ((*p1)[1] == 9); + VERIFY ((*p1)[2] == 8); + VERIFY ((*p1)[3] == 7); + + VBseqlong_var result = test_object->seq_op1(p1, p2, p3); + + VERIFY ((*p2)[0] == 100*3); + VERIFY ((*p2)[1] == 99*3); + VERIFY ((*p2)[2] == 98*3); + VERIFY ((*p3)[0] == 100*5); + VERIFY ((*p3)[1] == 99*5); + VERIFY ((*p3)[2] == 98*5); + VERIFY ((*result)[0] == 10); + VERIFY ((*result)[1] == 9); + VERIFY ((*result)[2] == 8); + VERIFY ((*result)[3] == 7); + + //============================================================ + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + test_object->seq_op2(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY ((*p2)[0] == 100*3*3); + VERIFY ((*p2)[1] == 99*3*3); + VERIFY ((*p2)[2] == 98*3*3); + VERIFY ((*p3)[0] == (*p1)[0]*5); + VERIFY ((*p3)[1] == (*p1)[1]*5); + VERIFY ((*p3)[2] == (*p1)[2]*5); + VERIFY ((*p3)[3] == (*p1)[3]*5); + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_boxed_sequence_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_boxed_sequence_invocations: " + "caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + + +// +// Test a boxed struct type. This is not templated since the struct +// members are accessed by name, so this is specific to a certain IDL. +// +int test_boxed_struct (void) +{ + int fail = 0; + + Fixed_Struct1 *fixed_struct_a = 0; + ACE_NEW_RETURN (fixed_struct_a, + Fixed_Struct1 (), + 1); + fixed_struct_a->l = 3233; + fixed_struct_a->abstruct.s1 = 73; + fixed_struct_a->abstruct.s2 = 37; + + // Test the VBfixed_struct1 constructor + VBfixed_struct1 *valuebox1 = 0; + ACE_NEW_RETURN (valuebox1, + VBfixed_struct1 (*fixed_struct_a), + 1); + + // Test boxed copy ctor. + VBfixed_struct1_var valuebox2; + ACE_NEW_RETURN (valuebox2, + VBfixed_struct1 (*valuebox1), + 1); + + VERIFY (valuebox1->l () == valuebox2->l ()); + VERIFY ((valuebox1->abstruct ()).s1 == (valuebox2->abstruct ()).s1 ); + VERIFY ((valuebox1->abstruct ()).s2 == (valuebox2->abstruct ()).s2 ); + + // Change an element + valuebox1->l (505); + VERIFY (valuebox1->l () != valuebox2->l ()); + + // Change some more, to test other types. + (valuebox2->abstruct ()).s1 = 667; + VERIFY ((valuebox1->abstruct ()).s1 != (valuebox2->abstruct ()).s1 ); + (valuebox2->abstruct ()).s2 = 1667; + VERIFY ((valuebox1->abstruct ()).s2 != (valuebox2->abstruct ()).s2 ); + + Fixed_Struct1 *fixed_struct_b = 0; + ACE_NEW_RETURN (fixed_struct_b, + Fixed_Struct1 (), + 1); + fixed_struct_b->l = 7372; + fixed_struct_b->abstruct.s1 = 11; + fixed_struct_b->abstruct.s2 = 51; + + // Make another VBfixed_struct1 + VBfixed_struct1 *valuebox3 = 0; + ACE_NEW_RETURN (valuebox3, + VBfixed_struct1 (), + 1); + + // Test assignment operator + *valuebox3 = *fixed_struct_b; + + VERIFY (valuebox3->l () == fixed_struct_b->l); + VERIFY ((valuebox3->abstruct ()).s1 == fixed_struct_b->abstruct.s1); + VERIFY ((valuebox3->abstruct ()).s2 == fixed_struct_b->abstruct.s2); + + // Test _value modifier method + valuebox2->_value (*fixed_struct_b); + VERIFY (valuebox2->l () == fixed_struct_b->l); + VERIFY ((valuebox2->abstruct ()).s1 == fixed_struct_b->abstruct.s1); + VERIFY ((valuebox2->abstruct ()).s2 == fixed_struct_b->abstruct.s2); + + // Test _copy_value and _downcast + VBfixed_struct1_var valuebox4 = + VBfixed_struct1::_downcast (valuebox3->_copy_value ()); + VERIFY (valuebox4->l () == fixed_struct_b->l); + VERIFY ((valuebox4->abstruct ()).s1 == fixed_struct_b->abstruct.s1); + VERIFY ((valuebox4->abstruct ()).s2 == fixed_struct_b->abstruct.s2); + + // + // valuebox1 and valuebox3 must be explicitly removed. + CORBA::remove_ref (valuebox1); + CORBA::remove_ref (valuebox3); + + // + // as well as the structs we new'ed. + delete fixed_struct_a; + delete fixed_struct_b; + + // + // Other types are _var so their dtors will clean up remaining + // allocations. + + return fail; +} + + + +int test_boxed_struct_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + + //============================================================ + // Fixed struct + // Test method invocation with boxed value + //============================================================ + Fixed_Struct1 fs1; + fs1.l = 29; + fs1.abstruct.s1 = 117; + fs1.abstruct.s2 = 21; + + VBfixed_struct1 *p1 = 0; + ACE_NEW_RETURN (p1, + VBfixed_struct1(fs1), + 1); + + Fixed_Struct1 fs2; + fs2.l = 92; + fs2.abstruct.s1 = 171; + fs2.abstruct.s2 = 12; + + VBfixed_struct1 *p2 = 0; + ACE_NEW_RETURN (p2, + VBfixed_struct1(fs2), + 1); + + VBfixed_struct1 *p3; + + VERIFY (p1->l() == 29); + VERIFY ((p1->abstruct()).s1 == 117); + VERIFY ((p1->abstruct()).s2 == 21); + + VBfixed_struct1_var result = test_object->struct_op1(p1, p2, p3); + + VERIFY (p2->l() == 92*3); + VERIFY ((p2->abstruct()).s1 == 171*3); + VERIFY ((p2->abstruct()).s2 == 12*3); + + VERIFY (p3->l() == 92*5); + VERIFY ((p3->abstruct()).s1 == 171*5); + VERIFY ((p3->abstruct()).s2 == 12*5); + + VERIFY (result->l() == fs1.l); + VERIFY ((result->abstruct()).s1 == fs1.abstruct.s1); + VERIFY ((result->abstruct()).s2 == fs1.abstruct.s2); + + //============================================================ + // Fixed struct + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + test_object->struct_op2(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY (p2->l() == 92*3*3); + VERIFY ((p2->abstruct()).s1 == 171*3*3); + VERIFY ((p2->abstruct()).s2 == 12*3*3); + + VERIFY (p3->l() == fs1.l); + VERIFY ((p3->abstruct()).s1 == fs1.abstruct.s1); + VERIFY ((p3->abstruct()).s2 == fs1.abstruct.s2); + + //============================================================ + // Variable struct + // Test method invocation with boxed value + //============================================================ + + Variable_Struct1 vs1; + vs1.l = 29; + vs1.str = "variable1"; + + VBvariable_struct1 *p4 = 0; + ACE_NEW_RETURN (p4, + VBvariable_struct1 (vs1), + 1); + + Variable_Struct1 vs2; + vs2.l = 37; + vs2.str = "variable2"; + + VBvariable_struct1 *p5 = 0; + ACE_NEW_RETURN (p5, + VBvariable_struct1 (vs2), + 1); + + VBvariable_struct1 *p6; + + + VERIFY (p4->l() == 29); + VERIFY (strcmp(p4->str(), "variable1") == 0); + + VBvariable_struct1_var result2 = test_object->struct_op3(p4, p5, p6); + + VERIFY (p5->l() == vs2.l*3); + VERIFY (strcmp(p5->str(), "2variable") == 0); + + VERIFY (p6->l() == vs2.l*3); + VERIFY (strcmp(p6->str(), "2variable") == 0); + + VERIFY (result2->l() == vs1.l); + VERIFY (strcmp(result2->str(), vs1.str) == 0); + + + //============================================================ + // Variable struct + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + test_object->struct_op4(p4->_boxed_in(), p5->_boxed_inout(), + p6->_boxed_out()); + + VERIFY (p5->l() == vs2.l*3*3); + VERIFY (strcmp(p5->str(), "e2variabl") == 0); + + VERIFY (p6->l() == vs1.l); + VERIFY (strcmp(p6->str(), vs1.str) == 0); + + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_boxed_struct_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_boxed_struct_invocations: " + "caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + +// +// Test boxed array types. +// +int test_boxed_array() +{ + int fail = 0; + LongArray la; + la[0] = 101; + la[1] = 202; + la[2] = 303; + + // three ctors + VBlongarray *valuebox1 = 0; + ACE_NEW_RETURN (valuebox1, + VBlongarray, + 1); + VBlongarray *valuebox2 = 0; + ACE_NEW_RETURN (valuebox2, + VBlongarray(la), + 1); + VBlongarray *valuebox3 = 0; + ACE_NEW_RETURN (valuebox3, + VBlongarray(*valuebox2), + 1); + + VERIFY ((*valuebox2)[0] == 101 + && valuebox2->_value()[1] == 202 + && valuebox2->_value()[2] == 303); + + VERIFY ((*valuebox3)[0] == 101 + && (*valuebox3)[1] == 202 + && (*valuebox3)[2] == 303); + + (*valuebox3)[0] = 111; + valuebox3->_value()[1] = 222; + + VERIFY ((*valuebox2)[0] == 101 + && (*valuebox2)[1] == 202 + && (*valuebox2)[2] == 303); + + VERIFY ((*valuebox3)[0] == 111 + && (*valuebox3)[1] == 222 + && (*valuebox3)[2] == 303); + + *valuebox1 = la; + + VERIFY ((*valuebox1)[0] == 101 + && valuebox1->_value()[1] == 202 + && valuebox1->_value()[2] == 303); + + valuebox2->_value(la); + + VERIFY ((*valuebox2)[0] == 101 + && valuebox2->_value()[1] == 202 + && valuebox2->_value()[2] == 303); + + LongArray_var lv_la(LongArray_dup(la)); + *valuebox2 = lv_la.in(); + + *valuebox2 = valuebox3->_value(); + valuebox3->_value()[1] = 777; + VERIFY ((*valuebox2)[0] == 111 + && valuebox2->_value()[1] == 222 + && valuebox2->_value()[2] == 303); + + // release + valuebox1->_remove_ref(); + valuebox2->_remove_ref(); + valuebox3->_remove_ref(); + + return fail; +} + + + +int test_boxed_array_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + //============================================================ + // Array (fixed) + // Test method invocation with boxed value + //============================================================ + + LongArray la; + la[0] = 101; + la[1] = 202; + la[2] = 303; + + VBlongarray *p1 = 0; + ACE_NEW_RETURN (p1, + VBlongarray (la), + 1); + + LongArray la2; + la2[0] = 3101; + la2[1] = 3202; + la2[2] = 3303; + + VBlongarray *p2 = 0; + ACE_NEW_RETURN (p2, + VBlongarray (la2), + 1); + + VERIFY ((*p1)[0] == 101 + && (*p1)[1] == 202 + && (*p1)[2] == 303); + + VBlongarray *p3; + + VBlongarray_var result = test_object->array_op1 (p1, p2, p3); + + VERIFY ((*p2)[0] == (3101*3) + && (*p2)[1] == (3202*3) + && (*p3)[2] == (3303*3)); + + VERIFY ((*p3)[0] == (3101*3) + && (*p3)[1] == (3202*3) + && (*p3)[2] == (3303*3)); + + VERIFY ((*result)[0] == 101 + && (*result)[1] == 202 + && (*result)[2] == 303); + + //============================================================ + // Array (fixed) + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + test_object->array_op2(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY ((*p2)[0] == (3101*3*3) + && (*p2)[1] == (3202*3*3) + && (*p2)[2] == (3303*3*3)); + + VERIFY ((*p3)[0] == (*p1)[0] + && (*p3)[1] == (*p1)[1] + && (*p3)[2] == (*p1)[2]); + + //============================================================ + // Array (variable) + // Test method invocation with boxed value + //============================================================ + + StringArray sa; + sa[0] = "in string1"; + sa[1] = "in string2"; + + VBstringarray *p4 = 0; + ACE_NEW_RETURN (p4, + VBstringarray (sa), + 1); + + StringArray sa2; + sa2[0] = "inout string1"; + sa2[1] = "inout string2"; + + VBstringarray *p5 = 0; + ACE_NEW_RETURN (p5, + VBstringarray (sa2), + 1); + + VERIFY (strcmp((*p4)[0], sa[0]) == 0); + VERIFY (strcmp((*p4)[1], sa[1]) == 0); + + VBstringarray *p6; + + VBstringarray_var result2 = test_object->array_op3 (p4, p5, p6); + + VERIFY (strcmp((*p5)[0], "1inout string") == 0); + VERIFY (strcmp((*p5)[1], "2inout string") == 0); + VERIFY (strcmp((*p6)[0], "1inout string") == 0); + VERIFY (strcmp((*p6)[1], "2inout string") == 0); + VERIFY (strcmp((*result2)[0], sa[0]) == 0); + VERIFY (strcmp((*result2)[1], sa[1]) == 0); + + //============================================================ + // Array (variable) + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + +// Disable the following for now. Need to troubleshoot it. +#if 0 +// Following gets compilation error on parameter 3 +// test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(), +// p6->_boxed_out()); + +// Trying the following variation to troubleshoot. No compilation error +// but p6 is unchanged after return from method. + StringArray sa_experimental; + StringArray_slice *slice = p6->_boxed_out(); + StringArray_out an_out (slice); + + test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(), + an_out); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) after array_op4\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[0]=%s\n", (const char *)((*p5)[0]))); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[1]=%s\n", (const char *)((*p5)[1]))); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[0]=%s\n", (const char *)((*p6)[0]))); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[1]=%s\n", (const char *)((*p6)[1]))); + VERIFY (strcmp((*p5)[0], "g1inout strin") == 0); + VERIFY (strcmp((*p5)[1], "g2inout strin") == 0); + VERIFY (strcmp((*p6)[0], sa[0]) == 0); + VERIFY (strcmp((*p6)[1], sa[1]) == 0); +#endif + + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_boxed_array_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_boxed_array_invocations: " + "caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + + +// +// Test a boxed union type. +// +int test_boxed_union() +{ + int fail = 0; + + VBfixed_union1 *ptemp; + ACE_NEW_RETURN (ptemp, + VBfixed_union1 (), + 1); + VBfixed_union1_var valuebox1(ptemp); + + + Fixed_Union1 *ptemp2; + ACE_NEW_RETURN (ptemp2, + Fixed_Union1 (), + 1); + Fixed_Union1_var fixed_union1(ptemp2); + + // Test modifiers, accessors, discriminant access + valuebox1->m1 (37); + VERIFY (valuebox1->m1 () == 37); + VERIFY (valuebox1->_d () == 1 || valuebox1->_d () == 2); + + // Explicitly set discriminant, make sure thats the only thing + // that changes. + valuebox1->_d (2); + VERIFY (valuebox1->_d () == 2); + VERIFY (valuebox1->m1 () == 37); + valuebox1->_d (1); + VERIFY (valuebox1->_d () == 1); + VERIFY (valuebox1->m1 () == 37); + + // Use _value() to access + valuebox1->_value ()._d (2); + VERIFY (valuebox1->_d () == 2); + + // Use _value as modifier. + valuebox1->_value (fixed_union1.in()); + VERIFY (valuebox1->_d () != 1 && valuebox1->_d () != 2); + + // + VBfixed_union1_var valuebox2; + ACE_NEW_RETURN (valuebox2, + VBfixed_union1 (), + 1); + valuebox2->m2(333); + VERIFY (valuebox2->_d () == 2); + + // Test copy ctor + VBfixed_union1_var valuebox3; + ACE_NEW_RETURN (valuebox3, + VBfixed_union1 (*valuebox2), + 1); + VERIFY (valuebox3->_d () == 2); + VERIFY (valuebox3->m2 () == 333); + + // Test assignment op + valuebox3->m2 (456); + *valuebox3 = valuebox2->_value (); + VERIFY (valuebox3->_d () == 2); + VERIFY (valuebox3->m2 () == 333); + + // Test constructor taking union argument + fixed_union1->m2 (137); + VBfixed_union1_var valuebox4; + ACE_NEW_RETURN (valuebox4, + VBfixed_union1 (fixed_union1), + 1); + VERIFY (valuebox4->m2 () == 137); + VERIFY (valuebox4->_d () == 1 || valuebox4->_d () == 2); + + return fail; +} + + + + +int test_boxed_union_invocations (Test * test_object) +{ + int fail = 0; + + ACE_TRY_NEW_ENV + { + //============================================================ + // Union (fixed) + // Test method invocation with boxed value + //============================================================ + + Fixed_Union1 *ptemp = 0; + ACE_NEW_RETURN (ptemp, + Fixed_Union1 (), + 1); + Fixed_Union1_var fixed_union1(ptemp); + + fixed_union1->m1 (321); + VBfixed_union1 *p1 = 0; + ACE_NEW_RETURN (p1, + VBfixed_union1 (fixed_union1), + 1); + + Fixed_Union1 *ptemp2 = 0; + ACE_NEW_RETURN (ptemp2, + Fixed_Union1 (), + 1); + Fixed_Union1_var fixed_union2(ptemp2); + fixed_union2->m2 (789); + VBfixed_union1 *p2 = 0; + ACE_NEW_RETURN (p2, + VBfixed_union1 (fixed_union2), + 1); + + VERIFY (p1->_d () == 1); + VERIFY (p1->m1 () == 321); + VERIFY (p2->_d () == 2); + VERIFY (p2->m2 () == 789); + + VBfixed_union1 * p3; + + VBfixed_union1_var result = test_object->union_op1 (p1, p2, p3); + + VERIFY (p2->_d () == 2); + VERIFY (p2->m2 () == 789*3); + VERIFY (p3->_d () == 1); + VERIFY (p3->m1 () == 321*3); + VERIFY (result->_d () == 1); + VERIFY (result->m1 () == 321*3); + + //============================================================ + // Union (fixed) + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + test_object->union_op2(p1->_boxed_in(), p2->_boxed_inout(), + p3->_boxed_out()); + + VERIFY (p2->_d () == 2); + VERIFY (p2->m2 () == 789*3*3); + + VERIFY (p3->_d () == 1); + VERIFY (p3->m1 () == 321); + + //============================================================ + // Union (variable) + // Test method invocation with boxed value + //============================================================ + + Variable_Union1_var variable_union1; + ACE_NEW_RETURN (variable_union1, + Variable_Union1 (), + 1); + variable_union1->m1 (321); + VBvariable_union1 *p4 = 0; + ACE_NEW_RETURN (p4, + VBvariable_union1 (variable_union1), + 1); + + Variable_Union1_var variable_union2; + ACE_NEW_RETURN (variable_union2, + Variable_Union1 (), + 1); + variable_union2->m2 ("abracadabra"); + VBvariable_union1 *p5 = 0; + ACE_NEW_RETURN (p5, + VBvariable_union1 (variable_union2), + 1); + + VERIFY (p4->_d () == 1); + VERIFY (p4->m1 () == 321); + VERIFY (p5->_d () == 2); + VERIFY (strcmp(p5->m2 (), "abracadabra") == 0); + + VBvariable_union1 * p6; + + VBvariable_union1_var result2 = test_object->union_op3 (p4, p5, p6); + + VERIFY (p5->_d () == 2); + VERIFY (strcmp(p5->m2 (), "aabracadabr") == 0); + VERIFY (p6->_d () == 1); + VERIFY (p6->m1 () == 321); + VERIFY (result2->_d () == 1); + VERIFY (result2->m1 () == 321); + + //============================================================ + // Union (variable) + // Test _boxed_in(), _boxed_inout(), and _boxed_out()) + //============================================================ + + p4->m1 (1722); + + test_object->union_op4(p4->_boxed_in(), p5->_boxed_inout(), + p6->_boxed_out()); + + VERIFY (p5->_d () == 2); + VERIFY (strcmp(p5->m2 (), "raabracadab") == 0); + + VERIFY (p6->_d () == 1); + VERIFY (p6->m1 () == 1722); + + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "test_boxed_union_invocations"); + fail = 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) test_boxed_union_invocations: " + "caught a C++ exception \n")); + fail = 1; + } + ACE_ENDTRY; + + return fail; +} + +int +main (int argc, char *argv[]) +{ + Test_var test_object; + CORBA::ORB_var orb; + ACE_TRY_NEW_ENV + { + orb = CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + // Obtain reference to the object. + CORBA::Object_var tmp = + orb->string_to_object(ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_object = Test::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (test_object.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test reference <%s>\n", + ior), + 1); + } + } + ACE_CATCH (CORBA::Exception, ex) + { + ACE_PRINT_EXCEPTION (ex, "Initialization failure"); + return 1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Initialization failure: caught a C++ exception \n")); + return 1; + } + ACE_ENDTRY; + + int fail = 0; + + fail = test_basic (); + + fail += test_basic_invocations (test_object); + + fail += test_boxed_string (); + + fail += test_boxed_string_invocations (test_object); + + fail += test_boxed_sequence (); + + fail += test_boxed_sequence_invocations (test_object); + + fail += test_boxed_struct (); + + fail += test_boxed_struct_invocations (test_object); + + fail += test_boxed_array (); + + fail += test_boxed_array_invocations (test_object); + + fail += test_boxed_union(); + + fail += test_boxed_union_invocations (test_object); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - test finished\n")); + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + + return (fail) ? 1 : 0; +} diff --git a/TAO/tests/OBV/ValueBox/run_test.pl b/TAO/tests/OBV/ValueBox/run_test.pl new file mode 100755 index 00000000000..de69f709455 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/run_test.pl @@ -0,0 +1,49 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../../bin'; +use PerlACE::Run_Test; + +$status = 0; + +$iorfile = PerlACE::LocalFile ("server.ior"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", "-o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", "-o $iorfile"); +} +$CL = new PerlACE::Process ("client", " -k file://$iorfile"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/tests/OBV/ValueBox/server.cpp b/TAO/tests/OBV/ValueBox/server.cpp new file mode 100644 index 00000000000..c63b7646f31 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/server.cpp @@ -0,0 +1,105 @@ +// $Id$ + +#include "Test_impl.h" + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID(ValueBox, + server, + "$Id$") + +const char *ior_output_file = "test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.optarg; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + + if (parse_args (argc, argv) != 0) + return 1; + + Test_impl *test_impl; + ACE_NEW_RETURN (test_impl, + Test_impl (orb.in ()), + 1); + + PortableServer::ServantBase_var owner_transfer(test_impl); + + Test_var test = test_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + + CORBA::String_var ior = + orb->object_to_string (test.in () ACE_ENV_ARG_PARAMETER); + + // If the ior_output_file exists, output the ior to it + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + } + catch (CORBA::Exception & ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; + +} diff --git a/TAO/tests/OBV/ValueBox/valuebox.idl b/TAO/tests/OBV/ValueBox/valuebox.idl new file mode 100644 index 00000000000..e37c5ae1aa9 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/valuebox.idl @@ -0,0 +1,99 @@ +// $Id$ + +#include "vb_basic.idl" +#include "vb_struct.idl" +#include "vb_union.idl" + +// +// Boxed Strings +// +valuetype VBstring string; +valuetype VBwstring wstring; + +// +// Boxed Sequences +// +typedef sequence<long> TDseqlong; +valuetype VBseqlong TDseqlong; + +// +// Boxed array ("fixed") +// +typedef long LongArray[3]; +valuetype VBlongarray LongArray; + +// +// Boxed array ("variable") +// +typedef string StringArray[2]; +valuetype VBstringarray StringArray; + +interface Test +{ + // Boxed basic types + VBlong basic_op1(in VBlong p1, inout VBlong p2, out VBlong p3); + + vb_basic::M_VBlong basic_op2(in vb_basic::M_VBlong p1, + inout vb_basic::M_VBlong p2, + out vb_basic::M_VBlong p3); + + long basic_op3 (in long p1, inout long p2, out long p3); + + // Boxed string + VBstring string_op1(in VBstring p1, inout VBstring p2, out VBstring p3); + + string string_op2(in string p1, inout string p2, out string p3); + + // Boxed sequence + VBseqlong seq_op1(in VBseqlong p1, inout VBseqlong p2, + out VBseqlong p3); + + void seq_op2(in TDseqlong p1, inout TDseqlong p2, out TDseqlong p3); + + // Boxed struct + VBfixed_struct1 struct_op1(in VBfixed_struct1 p1, + inout VBfixed_struct1 p2, + out VBfixed_struct1 p3); + + void struct_op2(in Fixed_Struct1 p1, + inout Fixed_Struct1 p2, + out Fixed_Struct1 p3); + + VBvariable_struct1 struct_op3(in VBvariable_struct1 p1, + inout VBvariable_struct1 p2, + out VBvariable_struct1 p3); + + void struct_op4(in Variable_Struct1 p1, + inout Variable_Struct1 p2, + out Variable_Struct1 p3); + + // Boxed array (fixed) + VBlongarray array_op1 (in VBlongarray p1, inout VBlongarray p2, + out VBlongarray p3); + + void array_op2 (in LongArray p1, inout LongArray p2, out LongArray p3); + + // Boxed array (variable) + VBstringarray array_op3 (in VBstringarray p1, inout VBstringarray p2, + out VBstringarray p3); + + void array_op4 (in StringArray p1, inout StringArray p2, + out StringArray p3); + + // Boxed union + VBfixed_union1 union_op1(in VBfixed_union1 p1, + inout VBfixed_union1 p2, + out VBfixed_union1 p3); + + void union_op2(in Fixed_Union1 p1, + inout Fixed_Union1 p2, + out Fixed_Union1 p3); + + VBvariable_union1 union_op3(in VBvariable_union1 p1, + inout VBvariable_union1 p2, + out VBvariable_union1 p3); + + void union_op4(in Variable_Union1 p1, + inout Variable_Union1 p2, + out Variable_Union1 p3); +}; diff --git a/TAO/tests/OBV/ValueBox/valuebox.mpc b/TAO/tests/OBV/ValueBox/valuebox.mpc new file mode 100644 index 00000000000..9d07560ab99 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/valuebox.mpc @@ -0,0 +1,33 @@ +// -*- MPC -*- +// $Id$ + +project(*Server): taoexe, portableserver, valuetype { + IDL_Files { + vb_basic.idl + vb_struct.idl + vb_union.idl + valuebox.idl + } + Source_Files { + vb_basicC.cpp + vb_basicS.cpp + vb_structC.cpp + vb_structS.cpp + vb_unionC.cpp + vb_unionS.cpp + valueboxC.cpp + valueboxS.cpp + Test_impl.cpp + server.cpp + } +} + +project(*Client): taoexe, valuetype { + Source_Files { + vb_basicC.cpp + vb_structC.cpp + vb_unionC.cpp + valueboxC.cpp + client.cpp + } +} diff --git a/TAO/tests/OBV/ValueBox/vb_basic.idl b/TAO/tests/OBV/ValueBox/vb_basic.idl new file mode 100644 index 00000000000..3c4c5f09c54 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/vb_basic.idl @@ -0,0 +1,77 @@ +// $Id$ + +//========================================================================= +// Valuebox of basic types +//========================================================================= + +// Valuebox of all basic types defined at outermost scope: + +enum Color { red, orange, yellow, green, blue, indigo, violet }; + +valuetype VBshort short; +valuetype VBlong long; +valuetype VBlonglong long long; +valuetype VBushort unsigned short; +valuetype VBulong unsigned long; +valuetype VBulonglong unsigned long long; +valuetype VBchar char; +valuetype VBwchar wchar; +valuetype VBboolean boolean; +valuetype VBoctet octet; +valuetype VBfloat float; +valuetype VBdouble double; +valuetype VBlongdouble long double; +valuetype VBenum Color; + +// Typedefs of basic types +typedef short TDshort; +typedef long TDlong; +typedef long long TDlonglong; +typedef unsigned short TDushort; +typedef unsigned long TDulong; +typedef unsigned long long TDulonglong; +typedef char TDchar; +typedef wchar TDwchar; +typedef boolean TDboolean; +typedef octet TDoctet; +typedef float TDfloat; +typedef double TDdouble; +typedef long double TDlongdouble; +typedef Color TDenum; + +// Value box of typedef of basic types +valuetype VBTDshort TDshort; +valuetype VBTDlong TDlong; +valuetype VBTDlonglong TDlonglong; +valuetype VBTDushort TDushort; +valuetype VBTDulong TDulong; +valuetype VBTDulonglong TDulonglong; +valuetype VBTDchar TDchar; +valuetype VBTDwchar TDwchar; +valuetype VBTDboolean TDboolean; +valuetype VBTDoctet TDoctet; +valuetype VBTDfloat TDfloat; +valuetype VBTDdouble TDdouble; +valuetype VBTDlongdouble TDlongdouble; +valuetype VBTDenum TDenum; +// $Id$ + +// Any and typedef of any +valuetype VBany any; +typedef any TDany; +valuetype VBTDany TDany; + +module vb_basic +{ + // Valuebox defined within a module scope + valuetype M_VBlong long; + + interface Test + { + M_VBlong basic_op1(in M_VBlong p1, inout M_VBlong p2, + out M_VBlong p3); + }; +}; + +// Valuebox of an interface +valuetype VBinterface vb_basic::Test; diff --git a/TAO/tests/OBV/ValueBox/vb_struct.idl b/TAO/tests/OBV/ValueBox/vb_struct.idl new file mode 100644 index 00000000000..318653e5009 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/vb_struct.idl @@ -0,0 +1,68 @@ +// $Id$ + +//========================================================================= +// Valuebox of structs +//========================================================================= + +// "Fixed" struct +struct Fixed_Struct1 +{ long l; + struct Bstruct {short s1; short s2; } abstruct; +}; + +// "Variable" struct +struct Variable_Struct1 +{ long l; + string str; +}; + +typedef Variable_Struct1 TDvariable_struct1; + +interface InterfaceFwd; + +interface Interface1 +{ + long getval(in short s); +}; + +enum Pet { dog, cat, fish, rhinoceros }; +typedef short short_array[15]; + +union Union1 switch(long) +{ + case 1: long m1; + case 2: Pet m2; +}; + +typedef sequence<long> LongSeq; + +// Use all possible types inside a struct +struct Variable_Struct2 +{ + long len; // predefined type + any whatever; // predefined type + Pet apet; // enum + octet octet_array[10]; // array + short_array td_array; // typedefed array + Interface1 intf1; // interface + InterfaceFwd intf2; // interface fwd + string str; // string + wstring wstr; // string + LongSeq ls; // typedef sequence + sequence <Pet> sqq; // sequence + struct NestedStruct1 { short s; string str2; } ns1; // structure + Variable_Struct1 NestedStruct2; + TDvariable_struct1 NestedStruct3; + Union1 un; // union +}; + +valuetype VBfixed_struct1 Fixed_Struct1; + +valuetype VBvariable_struct1 Variable_Struct1; + +valuetype VBvariable_struct2 Variable_Struct2; + +interface InterfaceFwd +{ + long getval(in short s); +}; diff --git a/TAO/tests/OBV/ValueBox/vb_union.idl b/TAO/tests/OBV/ValueBox/vb_union.idl new file mode 100644 index 00000000000..0a05be46651 --- /dev/null +++ b/TAO/tests/OBV/ValueBox/vb_union.idl @@ -0,0 +1,22 @@ +// $Id$ + +//========================================================================= +// Valuebox of unions +//========================================================================= + +union Fixed_Union1 switch(long) +{ + case 1: long m1; + case 2: short m2; +}; + +union Variable_Union1 switch(long) +{ + case 1: long m1; + case 2: string m2; +}; + + +valuetype VBfixed_union1 Fixed_Union1; + +valuetype VBvariable_union1 Variable_Union1; |