diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-10 03:03:13 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-10 03:03:13 +0000 |
commit | 206f5f0f9ec46480b8125a117e6e19ee5c0eb9bd (patch) | |
tree | e4e306ae28107f56ba0cea218f48c9d4cbb1932c | |
parent | 01b1bdf02d4c66624500826e483a61ccf0411fe5 (diff) | |
download | ATCD-206f5f0f9ec46480b8125a117e6e19ee5c0eb9bd.tar.gz |
ChangeLogTag:Thu Mar 9 18:50:44 2000 Carlos O'Ryan <coryan@uci.edu>
47 files changed, 1410 insertions, 3671 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 375ebf1f906..32345ec4ed3 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,89 @@ +Thu Mar 9 18:50:44 2000 Carlos O'Ryan <coryan@uci.edu> + + * tao/Any.h: + * tao/Any.i: + * tao/Any.cpp: + The <<= and >>= operators must set a function to cleanup the + objects stored by the Any. The function usually just casts from + void* to the real type and invokes 'delete' or CORBA::release(). + This is far more efficient, type safe and maintainable than the + deep_free approach. + The function is provided in the _tao_replace() method. For the + time beign (until the hand-crafted code is fixed), we maintain + both versions. + + * TAO_IDL/be/be_visitor_array/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_array/array_ch.cpp: + * TAO_IDL/be/be_visitor_array/array_cs.cpp: + * TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp: + * TAO_IDL/be/be_visitor_enum/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_exception/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_exception/exception_ch.cpp: + * TAO_IDL/be/be_visitor_exception/exception_cs.cpp: + * TAO_IDL/be/be_visitor_interface/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_interface/interface_ch.cpp: + * TAO_IDL/be/be_visitor_interface/interface_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp: + * TAO_IDL/be/be_visitor_structure/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_structure/structure_ch.cpp: + * TAO_IDL/be/be_visitor_structure/structure_cs.cpp: + * TAO_IDL/be/be_visitor_union/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_union/union_ch.cpp: + * TAO_IDL/be/be_visitor_union/union_cs.cpp: + Modified to: + - Generate an _tao_any_destructor() function to destroy the + object stored into an any. For sequences, structures, unions + and interfaces the function is an static function of the + corresponding class. For arrays it is a static member of the + T_forany class. + - The generated <<= and >>= operators have been modified to pass + the _tao_any_destructor. Thus the generated code no longer + depends on deep_free! + Furthermore the implementations of the <<= operators have been + optimized. It makes no sense to pre-allocate the object, + because sometimes the >>= operator is never invoked. In other + word: eager evaluation only makes sense when the result is + used all the time, and this is not the case for the <<= + operators. + + * tao/BoundsC.cpp: + * tao/BoundsC.h: + * tao/CONV_FRAMEC.cpp: + * tao/CONV_FRAMEC.h: + * tao/CurrentC.cpp: + * tao/CurrentC.h: + * tao/DomainC.cpp: + Updated to use the new _tao_replace() methods. + + * tao/DynAny_i.cpp: + The >>=(char*&) operators have been removed from the Any class, + they were a TAO extension. + + * tests/Param_Test/Makefile: + * tests/Param_Test/anyop.cpp: + Updated dependencies. + + * tests/Param_Test/any.cpp: + * tests/Param_Test/bd_wstring.cpp: + * tests/Param_Test/objref.cpp: + * tests/Param_Test/param_test_i.cpp: + * tests/Param_Test/recursive_union.cpp: + * tests/Param_Test/typecode.cpp: + * tests/Param_Test/ub_any_seq.cpp: + * tests/Param_Test/ub_string.cpp: + * tests/Param_Test/ub_wstring.cpp: + Fix a few memory management problems and some glaring bugs. + With this round of changes all the DII and SII tests pass! + We still have to look for memory leaks. + + * TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp: + * tao/decode.cpp: + * tao/encode.cpp: + These files were not commited in the last change. + Wed Mar 8 19:18:10 2000 Carlos O'Ryan <coryan@uci.edu> * tao/Makefile: diff --git a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp index 8d6da3795ab..62fec777a98 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp @@ -62,21 +62,23 @@ be_visitor_array_any_op_cs::visit_array (be_array *node) << "TAO_OutputCDR stream;" << be_nl << "stream << _tao_elem;" << be_nl << "if (_tao_elem.nocopy ()) // no copy" << be_idt_nl - << "_tao_any._tao_replace (" << be_idt << be_idt_nl + << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl << "1," << be_nl << "(void *)_tao_elem.in ()," << be_nl + << node->name () << "_forany::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "else // copy" << be_idt_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl - << node->tc_name () << "," << be_nl - << "TAO_ENCAP_BYTE_ORDER," << be_nl - << "stream.begin ()," << be_nl - << "1," << be_nl + << node->tc_name () << "," << be_nl + << "TAO_ENCAP_BYTE_ORDER," << be_nl + << "stream.begin ()," << be_nl + << "1," << be_nl << node->name () << "_dup (_tao_elem.in ())," << be_nl + << node->name () << "_forany::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt << be_uidt << be_uidt_nl << "}" << be_nl @@ -112,9 +114,10 @@ be_visitor_array_any_op_cs::visit_array (be_array *node) << "if (stream >> _tao_elem)" << be_nl << "{" << be_idt_nl << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl - << node->tc_name () << "," << be_nl - << "1," << be_nl - << "_tao_elem.inout ()," << be_nl + << node->tc_name () << "," << be_nl + << "1," << be_nl + << "_tao_elem.inout ()," << be_nl + << node->name () << "_forany::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp index 1bce1789c7b..0e569b9bd21 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp @@ -463,7 +463,9 @@ be_visitor_array_ch::gen_forany_defn (be_array *node) << " &); // copy constructor" << be_nl; // destructor *os << "~" << foranyname << " (void); // destructor" << be_nl; - *os << be_nl; + + *os << "static void _tao_any_destructor (void*);" << be_nl; + // assignment operator from a pointer to slice *os << foranyname << " &operator= (" << namebuf << "_slice *);" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp index 441bc4c812b..14ade612858 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp @@ -97,8 +97,17 @@ int be_visitor_array_cs::visit_array (be_array *node) } } - // dup method os->indent (); + + *os << "void " << fname << "_forany" + << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << fname << "_slice *tmp = ACE_static_cast (" + << fname << "_slice*,x);" << be_nl + << fname << "_free (tmp);" << be_uidt_nl + << "}\n\n"; + + // dup method *os << fname << "_slice *" << be_nl << fname << "_dup (const " << fname << "_slice *_tao_src_array)" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp index 3688f94df0b..523c98a2ea2 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp @@ -72,15 +72,15 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) -1); } - // If we contain an anonymous sequence, + // If we contain an anonymous sequence, // generate code for the sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { // CDR operators for sequences are now declared in the .i file, // so we pass this state to the function. - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH) + if (this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -88,7 +88,7 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) "visit_array - " "gen_anonymous_base_type failed\n"), -1); - } + } } // for anonymous arrays, the type name has a _ prepended. We compute the @@ -557,7 +557,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) switch (bt->node_type ()) { - // the following have a _var type and must be + // the following have a _var type and must be // handled in a special way case AST_Decl::NT_string: case AST_Decl::NT_wstring: @@ -569,7 +569,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) { // we need to separately handle this case of pseudo // objects because they have a _var type - be_predefined_type *pt = + be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); if (!pt) { @@ -624,7 +624,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) switch (bt->node_type ()) { - // the following have a _var type and must be + // the following have a _var type and must be // handled in a special way case AST_Decl::NT_string: case AST_Decl::NT_wstring: @@ -636,7 +636,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) { // we need to separately handle this case of pseudo // objects because they have a _var type - be_predefined_type *pt = + be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); if (!pt) { diff --git a/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp index 88d51dd2715..29e55939276 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp @@ -56,28 +56,20 @@ be_visitor_enum_any_op_cs::visit_enum (be_enum *node) *os << "void operator<<= (CORBA::Any &_tao_any, " << node->name () << " _tao_elem)" << be_nl << "{" << be_idt_nl - << node->name () << " *_tao_any_val;" << be_nl - << "ACE_NEW (_tao_any_val, " << node->name () - << " (_tao_elem));" << be_nl - << "if (!_tao_any_val) return;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "TAO_OutputCDR stream;" << be_nl - << "stream << *_tao_any_val;" << be_nl + << "stream << _tao_elem;" << be_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl - << "1," << be_nl - << "_tao_any_val," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl - << "// free allocated storage" << be_nl - << "delete _tao_any_val;" << be_uidt_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp index 3ac5c434f64..5b3e5d589aa 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp @@ -56,27 +56,20 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) *os << "void operator<<= (CORBA::Any &_tao_any, const " << node->name () << " &_tao_elem) // copying" << be_nl << "{" << be_idt_nl - << node->name () << " *_tao_any_val = 0;" << be_nl - << "ACE_NEW (_tao_any_val, " << node->name () - << " (_tao_elem));" << be_nl - << "if (!_tao_any_val) return;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "TAO_OutputCDR stream;" << be_nl - << "stream << *_tao_any_val;" << be_nl + << "stream << _tao_elem;" << be_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl - << "1," << be_nl - << "_tao_any_val," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY " << be_nl - << "{" << be_idt_nl - << "delete _tao_any_val;" << be_uidt_nl + << "{" << be_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -94,6 +87,7 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) << "stream.begin ()," << be_nl << "1," << be_nl << "_tao_elem," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl @@ -139,6 +133,7 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, _tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl @@ -190,12 +185,13 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) << ");" << be_uidt_nl << "if (stream >> *(" << node->name () << " *)_tao_elem)" << be_nl << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->_tao_replace (" + << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, ACE_const_cast (" << node->name () << " *&, _tao_elem))," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp index c7d4d544277..01203dc65c4 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp @@ -90,7 +90,9 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) *os << node->local_name () << " (void); // default ctor" << be_nl; *os << node->local_name () << " (const " << node->local_name () << " &); // copy ctor" << be_nl; - *os << "~" << node->local_name () << " (void); // dtor" << be_nl; + *os << "~" << node->local_name () << " (void);" << be_nl; + + *os << "static void _tao_any_destructor (void*);" << be_nl; // assignment operator *os << node->local_name () << " &operator= (const " diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp index 33306b05046..a75aeb0bb23 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp @@ -75,6 +75,14 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) *os << "{" << be_nl; *os << "}\n\n"; + *os << "void " + << node->name () << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << node->name () << " *tmp = ACE_static_cast (" + << node->name () << "*,x);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}\n\n"; + // copy constructor os->indent (); *os << "// copy constructor" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp index 09cc032fbd7..17de951310f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp @@ -70,33 +70,25 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) *os << "void operator<<= (CORBA::Any &_tao_any, " << node->full_name () << "_ptr _tao_elem)" << be_nl << "{" << be_idt_nl - << "CORBA::Object_ptr *_tao_obj_ptr = 0;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl - << "ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr);" << be_nl - << "*_tao_obj_ptr = " << node->full_name () - << "::_duplicate (_tao_elem);" << be_nl << "TAO_OutputCDR stream;" << be_nl - << "if (stream << *_tao_obj_ptr)" << be_nl + << "if (stream << _tao_elem)" << be_nl << "{" << be_idt_nl - << "_tao_any._tao_replace (" << be_idt << be_idt_nl + << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl << "1," << be_nl - << "_tao_obj_ptr," << be_nl + << node->full_name () << "::_duplicate (_tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "delete _tao_obj_ptr;" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_obj_ptr;" << be_uidt_nl + << "{" << be_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -104,8 +96,6 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " << node->full_name () << "_ptr &_tao_elem)" << be_nl << "{" << be_idt_nl - << "CORBA::Object_ptr *tmp = 0;" << be_nl - << "ACE_NEW_RETURN (tmp, CORBA::Object_ptr, 0);" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl @@ -113,7 +103,6 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << "if (!type->equivalent (" << node->tc_name () << ", ACE_TRY_ENV)) // not equal" << be_idt_nl << "{" << be_idt_nl - << "delete tmp;" << be_nl << "return 0;" << be_uidt_nl << "}" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl @@ -127,25 +116,20 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << "_tao_elem = " << node->full_name () << "::_narrow (_tao_obj_var.in (), ACE_TRY_ENV);" << be_nl << "ACE_TRY_CHECK;" << be_nl - << "*tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object" << be_nl << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl - << "tmp," << be_nl + << "_tao_elem," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else // failure" << be_nl - << "{" << be_idt_nl - << "delete tmp;" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl - << "delete tmp;" << be_nl << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl << "return 0;" << be_uidt_nl << "}" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 910b3bfe156..a648adc1685 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -116,7 +116,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) if (inherited->is_nested ()) { // inherited node is used in the scope of "node" node - scope = + scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); } @@ -179,8 +179,9 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << be_idt_nl << "{" << be_idt_nl << "return (" << node->local_name () << "_ptr)0;" << be_uidt_nl - << "}" << be_uidt << "\n\n"; + << "}" << be_uidt << "\n" << be_nl; + *os << "static void _tao_any_destructor (void*);\n\n"; // generate code for the interface definition by traversing thru the // elements of its scope. We depend on the front-end to have made sure @@ -194,7 +195,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) "codegen for scope failed\n"), -1); } // the _is_a method - os->indent (); + os->indent (); *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl << "const CORBA::Char *type_id, " << be_nl << "CORBA::Environment &env = " << be_idt_nl @@ -241,9 +242,9 @@ be_visitor_interface_ch::visit_interface (be_interface *node) } delete visitor; visitor = 0; - + os->gen_endif (); - + // by using a visitor to declare and define the TypeCode, we have the // added advantage to conditionally not generate any code. This will be // based on the command line options. This is still TO-DO diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index bf07949afb8..1ddc3d0e2a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -62,6 +62,14 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // first generate the code for the static methods + *os << "void " + << node->name () << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << node->name () << " *tmp = ACE_static_cast (" + << node->name () << "*,x);" << be_nl + << "CORBA::release (tmp);" << be_uidt_nl + << "}\n" << be_nl; + // The _narrow method *os << node->full_name () << "_ptr " << node->full_name () << "::_narrow (" << be_idt << be_idt_nl @@ -70,14 +78,14 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << ")" << be_uidt_nl << "{" << be_idt_nl << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "return " << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ();" << be_uidt_nl << "CORBA::Boolean is_a = obj->_is_a (\"" << node->repoID () << "\", ACE_TRY_ENV);" << be_nl - << "ACE_CHECK_RETURN (" << bt->nested_type_name (this->ctx_->scope ()) + << "ACE_CHECK_RETURN (" << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ());" << be_nl << "if (is_a == 0)" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "return " << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ();" << be_uidt_nl; *os << "return " << bt->nested_type_name (this->ctx_->scope ()) @@ -99,15 +107,15 @@ be_visitor_interface_cs::visit_interface (be_interface *node) if (!idl_global->gen_locality_constraint ()) { *os << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "return " << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ();" << be_uidt_nl; *os << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << "stub->_incr_refcnt ();" << be_nl // Declare the default proxy. - << bt->nested_type_name (this->ctx_->scope ()) - << "_ptr default_proxy = " - << bt->nested_type_name (this->ctx_->scope ()) + << bt->nested_type_name (this->ctx_->scope ()) + << "_ptr default_proxy = " + << bt->nested_type_name (this->ctx_->scope ()) <<"::_nil ();" << be_nl; // If the policy didtates that the proxy be collocated, use the @@ -120,14 +128,14 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "_Stub_Factory_function_pointer (obj);" << be_uidt_nl<<"}"<<be_uidt_nl; - // The default proxy will either be returned else be transformed to + // The default proxy will either be returned else be transformed to // a smart one! *os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl - << "ACE_NEW_RETURN (default_proxy, " - << bt->nested_type_name (this->ctx_->scope ()) - << " (stub), " << bt->nested_type_name (this->ctx_->scope ()) + << "ACE_NEW_RETURN (default_proxy, " + << bt->nested_type_name (this->ctx_->scope ()) + << " (stub), " << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ());"<< be_uidt_nl - << "return TAO_" << node->flat_name () + << "return TAO_" << node->flat_name () << "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (default_proxy);" << be_uidt_nl; } @@ -141,7 +149,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << node->repoID () << "\")) == 0" << be_uidt_nl << ")" << be_uidt_nl << "ACE_THROW_RETURN (CORBA::MARSHAL (), " - << bt->nested_type_name (this->ctx_->scope ()) + << bt->nested_type_name (this->ctx_->scope ()) << "::_nil ());" << be_uidt_nl; // Locality constraint objects alway use "direct" collocated @@ -150,7 +158,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "ACE_NEW_RETURN (" << be_idt << be_idt_nl << "retval," << be_nl << node->full_coll_name (be_interface::DIRECT) << " (" - << "ACE_reinterpret_cast (POA_" + << "ACE_reinterpret_cast (POA_" << bt->nested_type_name (this->ctx_->scope ()) << "_ptr, servant), 0)," << be_nl << "0" << be_uidt_nl << ");" << be_uidt_nl @@ -162,7 +170,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // The _duplicate method *os << node->full_name () << "_ptr " << be_nl << node->full_name () << "::_duplicate (" - << bt->nested_type_name (this->ctx_->scope ()) + << bt->nested_type_name (this->ctx_->scope ()) << "_ptr obj)" << be_nl << "{" << be_idt_nl << "if (!CORBA::is_nil (obj))" << be_idt_nl @@ -215,7 +223,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // Smart Proxy classes be_visitor_context ctx (*this->ctx_); be_visitor *visitor = 0; - + ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS); visitor = tao_cg->make_visitor (&ctx); if (!visitor || (node->accept (visitor) == -1)) @@ -229,7 +237,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) } delete visitor; visitor = 0; - + // by using a visitor to declare and define the TypeCode, we have the // added advantage to conditionally not generate any code. This will be // based on the command line options. This is still TO-DO @@ -245,6 +253,6 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp index 46264e18ed4..ecd69ec6316 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp @@ -1,4 +1,4 @@ -// +q// // $Id$ // @@ -101,10 +101,10 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper *os << "get_"; } *os << node->local_name () << "("; - + if (!idl_global->exception_support ()) *os << "CORBA::Environment &ACE_TRY_ENV"; - + *os << ")" << be_uidt; // now generate the throw specs @@ -175,7 +175,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper - *os << "// we have the is_system_exception boolean" << be_nl + *os << "// we have the is_system_exception boolean" << be_nl << "// the byte_order boolean and" << be_nl << "// the marshaled_exception sequence of octet" << be_nl << " TAO_InputCDR _tao_in ((const char*) " @@ -221,7 +221,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper << "// We can not use ACE_THROW here." << be_nl << "return;" << be_uidt_nl << "}" << be_uidt << be_uidt_nl; - + if (node->exceptions()) { *os << be_idt_nl @@ -242,20 +242,18 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper << "if (ACE_OS::strcmp (type_id.in (), except_id) != 0)" << be_idt_nl << "continue;" << be_uidt_nl << be_nl - + << "// match" << be_nl - << "CORBA::Exception_ptr exception = exceptions_data[i].alloc ();" + << "CORBA::Exception_ptr exception = exceptions_data[i].alloc ();" << be_nl << be_nl << "if (exception == 0)" << be_idt_nl << "ACE_THROW (CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE," << be_nl << " CORBA::COMPLETED_YES));" << be_uidt_nl - << "_tao_in.decode (exception->_type ()," << be_nl - << " exception," << be_nl - << " 0," << be_nl - << " ACE_TRY_ENV);" << be_nl << be_nl; - + << "exception->_tao_decode (_tao_in, ACE_TRY_ENV);" + << be_nl << be_nl; + *os << "// @@ There should be a better way to raise this exception!" << be_nl << "// This code works for both native and emulated exceptions," << be_nl << "// but it is ugly." << be_nl @@ -273,8 +271,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper << " CORBA::COMPLETED_YES));" << be_uidt_nl << "}" << be_uidt << be_uidt_nl; } - - *os << "};\n\n"; + + *os << "};\n\n"; return 0; } - diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp index 507ad37a2ed..95eb19cf185 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp @@ -72,6 +72,7 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) << "stream.begin ()," << be_nl << "1," << be_nl << "_tao_any_val," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK; " << be_uidt_nl @@ -101,6 +102,7 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) << "stream.begin ()," << be_nl << "1," << be_nl << "_tao_elem," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl @@ -146,6 +148,7 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, _tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl @@ -197,12 +200,13 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) << ");" << be_uidt_nl << "if (stream >> *(" << node->name () << " *)_tao_elem)" << be_nl << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->_tao_replace (" + << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, ACE_const_cast (" << node->name () << " *&, _tao_elem))," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp index b82db5c9a4e..9db72bba017 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp @@ -74,13 +74,13 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) -1); } - // If our base type is anonymous sequence, + // If our base type is anonymous sequence, // generate code for the base type sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS) + if (this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -88,7 +88,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) "visit_sequence - " "gen_anonymous_base_type failed\n"), -1); - } + } } // generate the CDR << and >> operator defns @@ -194,7 +194,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) *os << "return 1;" << be_uidt_nl; *os << "// retrieve all the elements" << be_nl; - + if (bt->node_type () == AST_Decl::NT_sequence) { this->visit_node (node); @@ -593,7 +593,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) } *os << "_copy (_tao_sequence[i], tmp.in ());" << be_nl; - + if (bt->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -660,7 +660,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) if (pt->pt () == AST_PredefinedType::PT_pseudo) { - *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" + *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" << be_uidt_nl; } else @@ -689,7 +689,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) } *os << "_var tmp_var (" << be_idt << be_idt_nl; - + if (bt->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index 6d3a4b62438..074c73c966f 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -227,7 +227,7 @@ be_visitor_sequence_ch::instantiate_sequence (be_sequence *node) } else { - predef = + predef = be_predefined_type::narrow_from_decl ( alias->primitive_base_type () ); @@ -373,7 +373,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) << ");" << be_nl; *os << node->local_name () << " (const " << node->local_name () << " &); // copy ctor" << be_nl; - *os << "~" << node->local_name () << " (void); // dtor\n\n"; + *os << "~" << node->local_name () << " (void);" << be_nl + << "static void _tao_any_destructor (void*);\n\n"; // generate the _ptr_type and _var_type typedefs // but we must protect against certain versions of g++ @@ -461,12 +462,12 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) char namebuf [NAMEBUFSIZE]; // names be_type *bt; // base type - ACE_OS::memset (namebuf, - '\0', + ACE_OS::memset (namebuf, + '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, - "%s_var", + ACE_OS::sprintf (namebuf, + "%s_var", node->local_name ()->get_string ()); os = this->ctx_->stream (); @@ -509,7 +510,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // fixed-size base types only if (bt->size_type () == be_decl::FIXED) { - *os << namebuf << " (const " << node->local_name () + *os << namebuf << " (const " << node->local_name () << " &); // fixed-size base types only" << be_nl; } @@ -519,13 +520,12 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // assignment operator from a pointer *os << namebuf << " &operator= (" << node->local_name () << " *);" << be_nl; // assignment from _var - *os << namebuf << " &operator= (const " << namebuf << - " &);" << be_nl; + *os << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // fixed-size base types only if (bt->size_type () == be_decl::FIXED) { - *os << namebuf << " &operator= (const " << node->local_name () + *os << namebuf << " &operator= (const " << node->local_name () << " &); // fixed-size base types only" << be_nl; } @@ -543,7 +543,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) if (bt->size_type () == be_decl::VARIABLE) { - *os << "operator " << node->local_name () + *os << "operator " << node->local_name () << " *&(); // variable-size base types only" << be_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp index 7bf08e17fce..f350d2d38ef 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp @@ -306,7 +306,15 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) // destructor *os << node->name () << "::~" << node->local_name () << " (void) // dtor" << be_nl - << "{}\n\n"; + << "{}" << be_nl + + << "void " + << node->name () << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << node->name () << " *tmp = ACE_static_cast (" + << node->name () << "*,x);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}\n\n"; os->gen_endif (); node->cli_stub_gen (1); @@ -341,13 +349,13 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) case be_sequence::MNG_STRING: // sequence of strings if (!node->unbounded ()) this->gen_bounded_str_sequence (node); - // else + // else // inheriting from the right class is enough break; case be_sequence::MNG_WSTRING: // sequence of strings if (!node->unbounded ()) this->gen_bounded_wstr_sequence (node); - // else + // else // inheriting from the right class is enough break; default: // not a managed type @@ -358,9 +366,9 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) be_predefined_type *predef = 0; if (bt->base_node_type () == AST_Type::NT_pre_defined) { - be_typedef* alias = + be_typedef* alias = be_typedef::narrow_from_decl (bt); - + if (alias == 0) { predef = @@ -368,7 +376,7 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) } else { - predef = + predef = be_predefined_type::narrow_from_decl ( alias->primitive_base_type () ); @@ -395,4 +403,3 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) return 0; } - diff --git a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp index 7a14ec318b5..28414ed5186 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp @@ -56,27 +56,20 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node) *os << "void operator<<= (CORBA::Any &_tao_any, const " << node->name () << " &_tao_elem) // copying" << be_nl << "{" << be_idt_nl - << node->name () << " *_any_val = 0;" << be_nl - << "ACE_NEW (_any_val, " << node->name () - << " (_tao_elem));" << be_nl - << "if (!_any_val) return;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "TAO_OutputCDR stream;" << be_nl - << "stream << *_any_val;" << be_nl + << "stream << _tao_elem;" << be_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl - << "1," << be_nl - << "_any_val," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _any_val;" << be_uidt_nl + << "{" << be_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -94,14 +87,14 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node) << "stream.begin ()," << be_nl << "1," << be_nl << "_tao_elem," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "_tao_elem = 0;" << be_uidt_nl + << "delete _tao_elem;" << be_uidt_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -139,6 +132,7 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node) << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, _tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl @@ -190,12 +184,13 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node) << ");" << be_uidt_nl << "if (stream >> *(" << node->name () << " *)_tao_elem)" << be_nl << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->_tao_replace (" + << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, ACE_const_cast (" << node->name () << " *&, _tao_elem))," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp index fef518b3e7c..eb03d4ec2ea 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp @@ -64,7 +64,9 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) *os << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)\n"; os->indent (); *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n\n"; + << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_nl; + + *os << "static void _tao_any_destructor (void*);\n\n"; // generate code for field members if (this->visit_scope (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp index 830b5a7a0a3..daa59d3ce89 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp @@ -39,7 +39,7 @@ be_visitor_structure_cs::~be_visitor_structure_cs (void) { } -// visit the Structure_Cs node and its scope +// visit the structure node and its scope int be_visitor_structure_cs::visit_structure (be_structure *node) { if (!node->cli_stub_gen () && !node->imported ()) @@ -61,6 +61,15 @@ int be_visitor_structure_cs::visit_structure (be_structure *node) ), -1); } + TAO_OutStream *os = this->ctx_->stream (); + os->indent (); + *os << "void " + << node->name () << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << node->name () << " *tmp = ACE_static_cast (" + << node->name () << "*,x);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}\n\n"; // do any code generation required for the scope members // all we have to do is to visit the scope diff --git a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp index d2086f0b3d7..bf0bed0a9b3 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp @@ -57,9 +57,6 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) << "const " << node->name () << " &_tao_elem" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl - << node->name () << " *_any_val = 0;" << be_nl - << "ACE_NEW (_any_val, " << node->name () << " (_tao_elem));" - << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl; @@ -68,8 +65,7 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) *os << "}" << be_nl << "ACE_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _any_val;" << be_uidt_nl + << "{" << be_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -88,8 +84,7 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) *os << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "_tao_elem = 0;" << be_uidt_nl + << "delete _tao_elem;" << be_uidt_nl << "}" << be_nl << "ACE_ENDTRY;" << be_uidt_nl << "}\n" << be_nl; @@ -240,21 +235,15 @@ gen_insertion (TAO_OutStream *os, be_union *node) { *os << "TAO_OutputCDR stream;" << be_nl - << "if (stream << *_any_val)" << be_nl + << "if (stream << _tao_elem)" << be_nl << "{" << be_idt_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl << "stream.begin ()," << be_nl - << "1," << be_nl - << "_any_val," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "delete _any_val;" << be_uidt_nl << "}" << be_uidt_nl; return 0; } @@ -273,6 +262,7 @@ gen_insertion_nocopy (TAO_OutStream *os, << "stream.begin ()," << be_nl << "1," << be_nl << "_tao_elem," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_uidt_nl @@ -295,6 +285,7 @@ gen_extraction (TAO_OutStream *os, << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, _tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl @@ -313,15 +304,16 @@ be_visitor_union_any_op_compiled_cs:: gen_const_extraction (TAO_OutStream *os, be_union *node) { - *os << be_nl << "if (stream >> *(" << node->name () + *os << be_nl << "if (stream >> *(" << node->name () << " *)_tao_elem)" << be_nl << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->_tao_replace (" + << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_reinterpret_cast (void *, ACE_const_cast (" << node->name () << " *&, _tao_elem))," << be_nl + << node->name () << "::_tao_any_destructor," << be_nl << "ACE_TRY_ENV" << be_uidt_nl << ");" << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp index ecbd98a907b..8d54113865e 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp @@ -72,14 +72,15 @@ int be_visitor_union_ch::visit_union (be_union *node) << "public:" << be_idt_nl // generate default and copy constructors - << node->local_name () << " (void); // default constructor" << be_nl + << node->local_name () << " (void);" << be_nl << node->local_name () << " (const " << node->local_name () - << " &); // copy constructor" << be_nl + << " &);" << be_nl // generate destructor - << "~" << node->local_name () << " (void); // destructor" << be_nl + << "~" << node->local_name () << " (void);" << be_nl + << "static void _tao_any_destructor (void*);\n" << be_nl // generate assignment operator << node->local_name () << " &operator= (const " - << node->local_name () << " &); // copy constructor\n\n"; + << node->local_name () << " &);\n\n"; // retrieve the disriminant type bt = be_type::narrow_from_decl (node->disc_type ()); diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp index c823582f2c1..bf9ec529b9f 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp @@ -188,13 +188,21 @@ int be_visitor_union_cs::visit_union (be_union *node) os->indent (); *os << "// destructor" << be_nl - << node->name () << "::~" << node->local_name () + << node->name () << "::~" << node->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "// finalize" << be_nl << "this->_reset (this->disc_, 1);" << be_uidt_nl << "}" << be_nl << be_nl; + *os << "void " + << node->name () << "::_tao_any_destructor (void *x)" << be_nl + << "{" << be_idt_nl + << node->name () << " *tmp = ACE_static_cast (" + << node->name () << "*,x);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}\n" << be_nl; + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); // Reset this for generating the assignment operator. @@ -204,7 +212,7 @@ int be_visitor_union_cs::visit_union (be_union *node) os->indent (); *os << "// assignment operator" << be_nl; *os << node->name () << " &" << be_nl; // return type - *os << node->name () << "::operator= (const ::" + *os << node->name () << "::operator= (const ::" << node->name () << " &u)" << be_nl; *os << "{\n"; os->incr_indent (); diff --git a/TAO/tao/Any.cpp b/TAO/tao/Any.cpp index fca84306ff2..5f900811457 100644 --- a/TAO/tao/Any.cpp +++ b/TAO/tao/Any.cpp @@ -65,10 +65,11 @@ CORBA_Any::value (void) const CORBA_Any::CORBA_Any (void) : type_ (CORBA::TypeCode::_duplicate (CORBA::_tc_null)), - value_ (0), byte_order_ (TAO_ENCAP_BYTE_ORDER), cdr_ (0), - any_owns_data_ (0) + any_owns_data_ (0), + value_ (0), + destructor_ (0) { } @@ -81,10 +82,11 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr, void *, CORBA::Environment &ACE_TRY_ENV) : type_ (CORBA::TypeCode::_duplicate (CORBA::_tc_null)), - value_ (0), byte_order_ (TAO_ENCAP_BYTE_ORDER), cdr_ (0), - any_owns_data_ (0) + any_owns_data_ (0), + value_ (0), + destructor_ (0) { ACE_THROW (CORBA::NO_IMPLEMENT ()); } @@ -94,10 +96,11 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr, CORBA::Boolean, CORBA::Environment &ACE_TRY_ENV) : type_ (CORBA::TypeCode::_duplicate (CORBA::_tc_null)), - value_ (0), byte_order_ (TAO_ENCAP_BYTE_ORDER), cdr_ (0), - any_owns_data_ (0) + any_owns_data_ (0), + value_ (0), + destructor_ (0) { ACE_THROW (CORBA::NO_IMPLEMENT ()); } @@ -125,10 +128,11 @@ CORBA_Any::replace (CORBA::TypeCode_ptr, CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr tc, CORBA::Environment &) : type_ (CORBA::TypeCode::_duplicate (tc)), - value_ (0), byte_order_ (TAO_ENCAP_BYTE_ORDER), cdr_ (0), - any_owns_data_ (0) + any_owns_data_ (0), + value_ (0), + destructor_ (0) { // ACE_THROW (CORBA::NO_IMPLEMENT ()); } @@ -139,9 +143,10 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr type, int byte_order, const ACE_Message_Block* mb) : type_ (CORBA::TypeCode::_duplicate (type)), - value_ (0), byte_order_ (byte_order), - any_owns_data_ (0) + any_owns_data_ (0), + value_ (0), + destructor_ (0) { ACE_NEW (this->cdr_, ACE_Message_Block); ACE_CDR::consolidate (this->cdr_, mb); @@ -149,9 +154,10 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr type, // Copy constructor for "Any". CORBA_Any::CORBA_Any (const CORBA_Any &src) - : value_ (0), - cdr_ (0), - any_owns_data_ (0) + : cdr_ (0), + any_owns_data_ (0), + value_ (0), + destructor_ (0) { if (src.type_ != 0) this->type_ = @@ -281,8 +287,6 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, CORBA::release (this->type_); this->type_ = tmp; - this->any_owns_data_ = 0; - this->byte_order_ = byte_order; ACE_NEW (this->cdr_, ACE_Message_Block); ACE_CDR::consolidate (this->cdr_, mb); @@ -307,6 +311,7 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, this->free_value (ACE_TRY_ENV); ACE_CHECK; + this->any_owns_data_ = any_owns_data; this->value_ = value; // Duplicate tc and then release this->type_, just in case tc and @@ -315,8 +320,6 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, CORBA::release (this->type_); this->type_ = tmp; - this->any_owns_data_ = any_owns_data; - this->byte_order_ = byte_order; ACE_NEW (this->cdr_, ACE_Message_Block); ACE_CDR::consolidate (this->cdr_, mb); @@ -326,6 +329,22 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, void CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, + int byte_order, + const ACE_Message_Block *mb, + CORBA::Boolean any_owns_data, + void* value, + CORBA::Any::_tao_destructor destructor, + CORBA::Environment &ACE_TRY_ENV) +{ + this->_tao_replace (tc, byte_order, mb, + any_owns_data, value, + ACE_TRY_ENV); + ACE_CHECK; + this->destructor_ = destructor; +} + +void +CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, CORBA::Boolean any_owns_data, void* value, CORBA::Environment &ACE_TRY_ENV) @@ -333,6 +352,7 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, this->free_value (ACE_TRY_ENV); ACE_CHECK; + this->any_owns_data_ = any_owns_data; this->value_ = value; // Duplicate tc and then release this->type_, just in case tc and @@ -340,8 +360,18 @@ CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, CORBA::TypeCode_ptr tmp = CORBA::TypeCode::_duplicate (tc); CORBA::release (this->type_); this->type_ = tmp; +} - this->any_owns_data_ = any_owns_data; +void +CORBA_Any::_tao_replace (CORBA::TypeCode_ptr tc, + CORBA::Boolean any_owns_data, + void* value, + CORBA::Any::_tao_destructor destructor, + CORBA::Environment &ACE_TRY_ENV) +{ + this->_tao_replace (tc, any_owns_data, value, ACE_TRY_ENV); + ACE_CHECK; + this->destructor_ = destructor; } // Free internal data. @@ -351,12 +381,21 @@ CORBA_Any::free_value (CORBA::Environment &ACE_TRY_ENV) { if (this->any_owns_data_ && this->value_ != 0) { - // This is not exception safe. - DEEP_FREE (this->type_, this->value_, 0, ACE_TRY_ENV); - ACE_CHECK; - ::operator delete (this->value_); + if (this->destructor_ == 0) + { + // This is not exception safe. + DEEP_FREE (this->type_, this->value_, 0, ACE_TRY_ENV); + ACE_CHECK; + ::operator delete (this->value_); + } + else + { + (*this->destructor_) (this->value_); + } } + this->any_owns_data_ = 0; this->value_ = 0; + this->destructor_ = 0; } void @@ -429,13 +468,9 @@ CORBA_Any::operator<<= (CORBA::Short s) { TAO_OutputCDR stream; stream << s; - CORBA::Short *ns; - ACE_NEW (ns, CORBA::Short (s)); this->_tao_replace (CORBA::_tc_short, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - ns, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -456,13 +491,9 @@ CORBA_Any::operator<<= (CORBA::UShort s) { TAO_OutputCDR stream; stream << s; - CORBA::UShort *ns; - ACE_NEW (ns, CORBA::UShort (s)); this->_tao_replace (CORBA::_tc_ushort, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - ns, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -483,13 +514,9 @@ CORBA_Any::operator<<= (CORBA::Long l) { TAO_OutputCDR stream; stream << l; - CORBA::Long *nl; - ACE_NEW (nl, CORBA::Long (l)); this->_tao_replace (CORBA::_tc_long, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nl, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -510,13 +537,9 @@ CORBA_Any::operator<<= (CORBA::ULong l) { TAO_OutputCDR stream; stream << l; - CORBA::ULong *nl; - ACE_NEW (nl, CORBA::ULong (l)); this->_tao_replace (CORBA::_tc_ulong, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nl, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -537,13 +560,9 @@ CORBA_Any::operator<<= (CORBA::LongLong l) { TAO_OutputCDR stream; stream << l; - CORBA::LongLong *nl; - ACE_NEW (nl, CORBA::LongLong (l)); this->_tao_replace (CORBA::_tc_longlong, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nl, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -564,13 +583,9 @@ CORBA_Any::operator<<= (CORBA::ULongLong l) { TAO_OutputCDR stream; stream << l; - CORBA::ULongLong *nl; - ACE_NEW (nl, CORBA::ULongLong (l)); this->_tao_replace (CORBA::_tc_ulonglong, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nl, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -591,13 +606,9 @@ CORBA_Any::operator<<= (CORBA::Float f) { TAO_OutputCDR stream; stream << f; - CORBA::Float *nf; - ACE_NEW (nf, CORBA::Float (f)); this->_tao_replace (CORBA::_tc_float, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nf, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -618,13 +629,9 @@ CORBA_Any::operator<<= (CORBA::Double d) { TAO_OutputCDR stream; stream << d; - CORBA::Double *nd; - ACE_NEW (nd, CORBA::Double (d)); this->_tao_replace (CORBA::_tc_double, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nd, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -645,13 +652,9 @@ CORBA_Any::operator<<= (CORBA::LongDouble d) { TAO_OutputCDR stream; stream << d; - CORBA::LongDouble *nd; - ACE_NEW (nd, CORBA::LongDouble (d)); this->_tao_replace (CORBA::_tc_longdouble, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nd, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -673,13 +676,9 @@ CORBA_Any::operator<<= (const CORBA_Any& a) { TAO_OutputCDR stream; stream << a; - CORBA_Any_ptr na; - ACE_NEW (na, CORBA::Any (a)); this->_tao_replace (CORBA::_tc_any, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - na, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -694,6 +693,13 @@ CORBA_Any::operator<<= (const CORBA_Any& a) // insertion of Any - non-copying void +CORBA::Any::_tao_any_destructor (void *x) +{ + CORBA::Any *tmp = ACE_static_cast (CORBA::Any*,x); + delete tmp; +} + +void CORBA::Any::operator<<= (CORBA::Any* a) { ACE_DECLARE_NEW_CORBA_ENV; @@ -706,6 +712,7 @@ CORBA::Any::operator<<= (CORBA::Any* a) stream.begin (), 1, a, + CORBA::Any::_tao_any_destructor, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -728,13 +735,9 @@ CORBA_Any::operator<<= (from_boolean b) { TAO_OutputCDR stream; stream << b; - CORBA::Boolean *nb; - ACE_NEW (nb, CORBA::Boolean (b.val_)); this->_tao_replace (CORBA::_tc_boolean, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nb, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -755,13 +758,9 @@ CORBA_Any::operator<<= (from_octet o) { TAO_OutputCDR stream; stream << o; - CORBA::Octet *no; - ACE_NEW (no, CORBA::Octet (o.val_)); this->_tao_replace (CORBA::_tc_octet, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - no, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -782,13 +781,9 @@ CORBA_Any::operator<<= (from_char c) { TAO_OutputCDR stream; stream << c; - CORBA::Char *nc; - ACE_NEW (nc, CORBA::Char (c.val_)); this->_tao_replace (CORBA::_tc_char, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nc, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -809,13 +804,9 @@ CORBA_Any::operator<<= (from_wchar wc) { TAO_OutputCDR stream; stream << wc; - CORBA::WChar *nwc; - ACE_NEW (nwc, CORBA::WChar (wc.val_)); this->_tao_replace (CORBA::_tc_wchar, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - nwc, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -837,17 +828,9 @@ CORBA_Any::operator<<= (CORBA::TypeCode_ptr tc) { TAO_OutputCDR stream; stream << tc; - CORBA::TypeCode_ptr *_tao_tc; - - ACE_NEW (_tao_tc, - CORBA::TypeCode_ptr); - - *_tao_tc = CORBA::TypeCode::_duplicate (tc); this->_tao_replace (CORBA::_tc_TypeCode, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _tao_tc, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -903,23 +886,19 @@ CORBA::Any::operator<<= (const CORBA::Object_ptr obj) void CORBA::Any::operator<<= (CORBA::Object_ptr *objptr) { + if (objptr == 0) + return; // @@ Should we raise an exception? + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { TAO_OutputCDR stream; stream << *objptr; - CORBA::Object_ptr *_tao_object_ptr; - - ACE_NEW (_tao_object_ptr, - CORBA::Object_ptr); - - *_tao_object_ptr = *objptr; + delete objptr; this->_tao_replace (CORBA::_tc_Object, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _tao_object_ptr, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -1084,24 +1063,12 @@ CORBA_Any::operator>>= (CORBA::Short &s) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - s = *(CORBA::Short *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_short (s); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_short (s); } ACE_CATCHANY { @@ -1125,24 +1092,12 @@ CORBA_Any::operator>>= (CORBA::UShort &s) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - s = *(CORBA::UShort *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_ushort (s); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_ushort (s); } ACE_CATCHANY { @@ -1166,24 +1121,12 @@ CORBA_Any::operator>>= (CORBA::Long &l) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - l = *(CORBA::Long *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_long (l); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_long (l); } ACE_CATCHANY { @@ -1207,24 +1150,12 @@ CORBA_Any::operator>>= (CORBA::ULong &l) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - l = *(CORBA::ULong *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_ulong (l); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_ulong (l); } ACE_CATCHANY { @@ -1248,24 +1179,12 @@ CORBA_Any::operator>>= (CORBA::LongLong &l) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - l = *(CORBA::LongLong *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_longlong (l); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_longlong (l); } ACE_CATCHANY { @@ -1289,24 +1208,12 @@ CORBA_Any::operator>>= (CORBA::ULongLong &l) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - l = *(CORBA::ULongLong *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_ulonglong (l); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_ulonglong (l); } ACE_CATCHANY { @@ -1330,24 +1237,12 @@ CORBA_Any::operator>>= (CORBA::Float &f) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - f = *(CORBA::Float *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_float (f); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_float (f); } ACE_CATCHANY { @@ -1371,24 +1266,12 @@ CORBA_Any::operator>>= (CORBA::Double &d) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - d = *(CORBA::Double *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_double (d); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_double (d); } ACE_CATCHANY { @@ -1412,24 +1295,12 @@ CORBA_Any::operator>>= (CORBA::LongDouble &ld) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - ld = *(CORBA::LongDouble *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - return stream.read_longdouble (ld); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + return stream.read_longdouble (ld); } ACE_CATCHANY { @@ -1453,25 +1324,13 @@ CORBA_Any::operator>>= (CORBA::Any &a) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - a = *(CORBA::Any *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - if (stream >> a) - return 1; - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + if (stream >> a) + return 1; } ACE_CATCHANY { @@ -1490,6 +1349,7 @@ CORBA_Any::operator>>= (const CORBA::Any *&a) const ACE_TRY { + a = 0; CORBA::Boolean equivalent = this->type_->equivalent (CORBA::_tc_any, ACE_TRY_ENV); @@ -1497,6 +1357,7 @@ CORBA_Any::operator>>= (const CORBA::Any *&a) const if (!equivalent) return 0; + if (this->any_owns_data_ && this->value_) { a = (CORBA::Any *) this->value_; @@ -1504,14 +1365,23 @@ CORBA_Any::operator>>= (const CORBA::Any *&a) const } else { - ACE_NEW_RETURN (a, - CORBA::Any, - 0); + CORBA::Any_var tmp; + ACE_NEW_RETURN (tmp.out (), CORBA::Any, 0); TAO_InputCDR stream (this->cdr_, this->byte_order_); - if (stream >> *ACE_const_cast (CORBA::Any*&,a)) - return 1; - delete ACE_const_cast (CORBA::Any *&, a); + if (!(stream >> tmp.inout ())) + return 0; + + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_any, + 1, + ACE_static_cast(CORBA::Any*,tmp), + CORBA::Any::_tao_any_destructor, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_const_cast (CORBA::Any *&, a) = tmp._retn (); + return 1; } } ACE_CATCHANY @@ -1524,73 +1394,14 @@ CORBA_Any::operator>>= (const CORBA::Any *&a) const } ACE_ENDTRY; - a = 0; return 0; } -CORBA::Boolean -CORBA_Any::operator>>= (char *&s) const +static void +_tao_any_string_destructor (void *x) { - ACE_DECLARE_NEW_CORBA_ENV; - - ACE_TRY - { - CORBA::Boolean result = - this->type_->equivalent (CORBA::_tc_string, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - if (result) - { - if (this->any_owns_data_ && this->value_) - { - s = *(char **) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - if (stream.read_string (s)) - { - ACE_const_cast (CORBA_Any *, - this)->any_owns_data_ = 1; - - char **tmp; - - ACE_NEW_RETURN (tmp, - char *, - 0); - - *tmp = s; - - ACE_const_cast (CORBA_Any *, - this)->value_ = tmp; - - return 1; - } - else - { - s = 0; - return 0; - } - } - } - else - { - s = 0; - return 0; - } - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("Exception in unbounded string extraction\n"))); - } - ACE_ENDTRY; - - s = 0; - return 0; + char *tmp = ACE_static_cast (char*,x); + CORBA::string_free (tmp); } CORBA::Boolean @@ -1600,52 +1411,38 @@ CORBA_Any::operator>>= (const char *&s) const ACE_TRY { + s = 0; + CORBA::Boolean result = this->type_->equivalent (CORBA::_tc_string, ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - s = *(char **) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - if (stream.read_string ((char *&)s)) - { - ACE_const_cast (CORBA_Any *, - this)->any_owns_data_ = 1; - - char **tmp; - - ACE_NEW_RETURN (tmp, - char *, - 0); - - *tmp = (char *)s; - - ACE_const_cast (CORBA_Any *, - this)->value_ = tmp; - - return 1; - } - else - { - s = 0; - return 0; - } - } - } - else + if (!result) + return 0; + + if (this->any_owns_data_ && this->value_) { - s = 0; - return 0; + s = ACE_static_cast (char *,this->value_); + return 1; } + + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + CORBA::String_var tmp; + if (!stream.read_string (tmp.out ())) + return 0; + + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_string, + 1, + tmp.inout (), + _tao_any_string_destructor, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + s = tmp._retn (); + return 1; } ACE_CATCHANY { @@ -1654,128 +1451,55 @@ CORBA_Any::operator>>= (const char *&s) const } ACE_ENDTRY; - s = 0; return 0; } +static void +_tao_any_wstring_destructor (void *x) +{ + CORBA::WChar *tmp = ACE_static_cast (CORBA::WChar*,x); + CORBA::wstring_free (tmp); +} + CORBA::Boolean -CORBA_Any::operator>>= (CORBA::WChar *&ws) const +CORBA_Any::operator>>= (const CORBA::WChar *&s) const { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { + s = 0; + CORBA::Boolean result = this->type_->equivalent (CORBA::_tc_wstring, ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - ws = *(CORBA::WChar **) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - if (stream.read_wstring (ws)) - { - ACE_const_cast (CORBA_Any *, - this)->any_owns_data_ = 1; - - CORBA::WChar **tmp; - - ACE_NEW_RETURN (tmp, - CORBA::WChar *, - 0); - - *tmp = ws; - - ACE_const_cast (CORBA_Any *, - this)->value_ = tmp; - - return 1; - } - else - { - ws = 0; - return 0; - } - } - } - else + if (!result) + return 0; + + if (this->any_owns_data_ && this->value_) { - ws = 0; - return 0; + s = ACE_static_cast (CORBA::WChar *,this->value_); + return 1; } - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("Exception in unbounded wstring extraction\n"))); - } - ACE_ENDTRY; - - ws = 0; - return 0; -} -CORBA::Boolean -CORBA_Any::operator>>= (const CORBA::WChar *&ws) const -{ - ACE_DECLARE_NEW_CORBA_ENV; + TAO_InputCDR stream (this->cdr_, + this->byte_order_); + CORBA::WString_var tmp; + if (!stream.read_wstring (tmp.out ())) + return 0; - ACE_TRY - { - CORBA::Boolean result = - this->type_->equivalent (CORBA::_tc_wstring, - ACE_TRY_ENV); + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_wstring, + 1, + tmp.inout (), + _tao_any_wstring_destructor, + ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - ws = *(CORBA::WChar **) this->value_; - return 1; - } - else - { - TAO_InputCDR stream (this->cdr_, - this->byte_order_); - if (stream.read_wstring ((CORBA::WChar *&)ws)) - { - ACE_const_cast (CORBA_Any *, - this)->any_owns_data_ = 1; - - CORBA::WChar **tmp; - - ACE_NEW_RETURN (tmp, - CORBA::WChar *, - 0); - - *tmp = (CORBA::WChar *)ws; - - ACE_const_cast (CORBA_Any *, - this)->value_ = tmp; - - return 1; - } - else - { - ws = 0; - return 0; - } - } - } - else - { - ws = 0; - return 0; - } + s = tmp._retn (); + return 1; } ACE_CATCHANY { @@ -1784,10 +1508,16 @@ CORBA_Any::operator>>= (const CORBA::WChar *&ws) const } ACE_ENDTRY; - ws = 0; return 0; } +static void +_tao_any_tc_destructor (void *x) +{ + CORBA::TypeCode_ptr tmp = ACE_static_cast (CORBA::TypeCode_ptr,x); + CORBA::release (tmp); +} + CORBA::Boolean CORBA_Any::operator>>= (CORBA::TypeCode_ptr &tc) const { @@ -1800,25 +1530,32 @@ CORBA_Any::operator>>= (CORBA::TypeCode_ptr &tc) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - tc = *(CORBA::TypeCode_ptr *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, - this->byte_order_); - if (stream >> tc) - return 1; - } - } - else + if (!result) + return 0; + + if (this->any_owns_data_ && this->value_) { - return 0; + tc = ACE_static_cast (CORBA::TypeCode_ptr, this->value_); + return 1; } + + TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, + this->byte_order_); + CORBA::TypeCode_var tmp; + + if (!(stream >> tmp.inout ())) + return 0; + + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_TypeCode, + 1, + tmp.in (), + _tao_any_tc_destructor, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + tc = tmp._retn (); + return 1; } ACE_CATCHANY { @@ -1844,24 +1581,12 @@ CORBA_Any::operator>>= (to_boolean b) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - b.ref_ = *(CORBA::Boolean *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, - this->byte_order_); - return stream.read_boolean (b.ref_); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, + this->byte_order_); + return stream.read_boolean (b.ref_); } ACE_CATCHANY { @@ -1885,24 +1610,12 @@ CORBA_Any::operator>>= (to_octet o) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - o.ref_ = *(CORBA::Octet *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, - this->byte_order_); - return stream.read_octet (o.ref_); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, + this->byte_order_); + return stream.read_octet (o.ref_); } ACE_CATCHANY { @@ -1926,24 +1639,12 @@ CORBA_Any::operator>>= (to_char c) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - c.ref_ = *(CORBA::Char *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, - this->byte_order_); - return stream.read_char (c.ref_); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, + this->byte_order_); + return stream.read_char (c.ref_); } ACE_CATCHANY { @@ -1967,24 +1668,12 @@ CORBA_Any::operator>>= (to_wchar wc) const ACE_TRY_ENV); ACE_TRY_CHECK; - if (result) - { - if (this->any_owns_data_ && this->value_) - { - wc.ref_ = *(CORBA::WChar *) this->value_; - return 1; - } - else - { - TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, - this->byte_order_); - return stream.read_wchar (wc.ref_); - } - } - else - { - return 0; - } + if (!result) + return 0; + + TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, + this->byte_order_); + return stream.read_wchar (wc.ref_); } ACE_CATCHANY { @@ -2029,18 +1718,26 @@ CORBA_Any::operator>>= (to_string s) const if (this->any_owns_data_ && this->value_) { - s.val_ = *(char **) this->value_; + s.val_ = ACE_static_cast (char*,this->value_); return 1; } TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, this->byte_order_); - if (stream.read_string (s.val_)) - { - ACE_const_cast (CORBA_Any *,this)->any_owns_data_ = 1; - return 1; - } - // FALLTHROUGH + CORBA::String_var tmp; + if (!stream.read_string (tmp.out ())) + return 0; + + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_string, + 1, + ACE_static_cast(char*,tmp), + _tao_any_string_destructor, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + s.val_ = tmp._retn (); + return 1; } ACE_CATCHANY { @@ -2085,17 +1782,26 @@ CORBA_Any::operator>>= (to_wstring ws) const if (this->any_owns_data_ && this->value_) { - ws.val_ = *(CORBA::WChar **) this->value_; + ws.val_ = ACE_static_cast(CORBA::WChar *, this->value_); return 1; } TAO_InputCDR stream ((ACE_Message_Block *) this->cdr_, this->byte_order_); - if (stream.read_wstring (ws.val_)) - { - ACE_const_cast (CORBA_Any *,this)->any_owns_data_ = 1; - return 1; - } + CORBA::WString_var tmp; + if (!stream.read_wstring (tmp.out ())) + return 0; + + ACE_const_cast(CORBA::Any*, + this)->_tao_replace (CORBA::_tc_string, + 1, + ACE_static_cast(CORBA::WChar*,tmp), + _tao_any_wstring_destructor, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + ws.val_ = tmp._retn (); + return 1; } ACE_CATCHANY { @@ -2174,16 +1880,9 @@ CORBA_Any::operator<<= (const char* s) { TAO_OutputCDR stream; stream << s; - char **tmp; - - ACE_NEW (tmp, - char * (CORBA::string_dup (s))); - this->_tao_replace (CORBA::_tc_string, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - tmp, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -2206,16 +1905,9 @@ CORBA_Any::operator<<= (const CORBA::WChar* s) { TAO_OutputCDR stream; stream << s; - CORBA::WChar **tmp; - - ACE_NEW (tmp, - CORBA::WChar * (CORBA::wstring_dup (s))); - this->_tao_replace (CORBA::_tc_wstring, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - tmp, ACE_TRY_ENV); ACE_TRY_CHECK; } diff --git a/TAO/tao/Any.h b/TAO/tao/Any.h index a7e719ef13e..d909aa0f21f 100644 --- a/TAO/tao/Any.h +++ b/TAO/tao/Any.h @@ -187,11 +187,9 @@ public: CORBA::Boolean operator>>= (CORBA::TypeCode_ptr&) const; // extract a TypeCode - CORBA::Boolean operator>>= (char*&) const; // deperecated CORBA::Boolean operator>>= (const char*&) const; // extract an unbounded string - CORBA::Boolean operator>>= (CORBA::WChar*&) const; // deprecated CORBA::Boolean operator>>= (const CORBA::WChar*&) const; // extract an unbounded wide string @@ -332,6 +330,10 @@ public: int _tao_byte_order (void) const; // Get the byte order inside the CDR stream. + typedef void (*_tao_destructor)(void*); + // Generated data types define a 'destructor' function that + // correctly destroys an object stored in the Any. + void _tao_replace (CORBA::TypeCode_ptr, int byte_order, const ACE_Message_Block *mb, @@ -343,13 +345,25 @@ public: const ACE_Message_Block *mb, CORBA::Boolean any_owns_data, void* value, - CORBA::Environment &ACE_TRY_EN); + CORBA::Environment &ACE_TRY_ENV); + void _tao_replace (CORBA::TypeCode_ptr type, + int byte_order, + const ACE_Message_Block *mb, + CORBA::Boolean any_owns_data, + void* value, + CORBA::Any::_tao_destructor destructor, + CORBA::Environment &ACE_TRY_ENV); // Replace all the contents of the any, used in the <<= operators. void _tao_replace (CORBA::TypeCode_ptr type, CORBA::Boolean any_owns_data, void* value, CORBA::Environment &ACE_TRY_ENV); + void _tao_replace (CORBA::TypeCode_ptr type, + CORBA::Boolean any_owns_data, + void* value, + CORBA::Any::_tao_destructor destructor, + CORBA::Environment &ACE_TRY_ENV); // Replace the value of the Any, used in the >>= operators. void _tao_encode (TAO_OutputCDR &cdr, @@ -367,6 +381,9 @@ public: #endif /* __GNUC__ */ // Useful for template programming. + static void _tao_any_destructor (void*); + // Used to release Anys contained into anys. + protected: void free_value (CORBA::Environment &ACE_TRY_ENV); // Release the <value_>. @@ -375,9 +392,6 @@ private: CORBA::TypeCode_ptr type_; // Typecode for the <Any>. - void *value_; - // Value for the <Any>. - int byte_order_; ACE_Message_Block *cdr_; // encoded value. @@ -385,6 +399,13 @@ private: CORBA::Boolean any_owns_data_; // Flag that indicates the ORB is responsible for deleting the data. + void *value_; + // Value for the <Any>. + + CORBA::Any::_tao_destructor destructor_; + // If not zero this is the function used to destroy objects. + + // 94-9-14 hides unsigned char insert/extract void operator<<= (unsigned char); CORBA::Boolean operator>>= (unsigned char&) const; @@ -562,7 +583,9 @@ TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, CORBA::TypeCode_ptr&); TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, - char*&); + const char*&); +TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, + const CORBA::WChar*&); TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, CORBA::Any::to_boolean); TAO_Export CORBA::Boolean operator>>= (CORBA_Any_var, diff --git a/TAO/tao/Any.i b/TAO/tao/Any.i index 1c709977d11..408e4fd4da3 100644 --- a/TAO/tao/Any.i +++ b/TAO/tao/Any.i @@ -275,7 +275,13 @@ operator >>= (CORBA_Any_var lhs, CORBA::TypeCode_ptr &rhs) } ACE_INLINE CORBA::Boolean -operator >>= (CORBA_Any_var lhs, char* &rhs) +operator >>= (CORBA_Any_var lhs, const char *&rhs) +{ + return lhs.inout () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (CORBA_Any_var lhs, const CORBA::WChar *&rhs) { return lhs.inout () >>= rhs; } diff --git a/TAO/tao/BoundsC.cpp b/TAO/tao/BoundsC.cpp index 9fd40aa7df2..942cdf15433 100644 --- a/TAO/tao/BoundsC.cpp +++ b/TAO/tao/BoundsC.cpp @@ -24,6 +24,12 @@ CORBA_Bounds::~CORBA_Bounds (void) { } +void CORBA_Bounds::_tao_any_destructor (void *x) +{ + CORBA_Bounds *tmp = ACE_static_cast (CORBA_Bounds*,x); + delete tmp; +} + // copy constructor CORBA_Bounds::CORBA_Bounds (const CORBA::Bounds &_tao_excp) : CORBA_UserException (_tao_excp._type ()) @@ -87,25 +93,18 @@ CORBA::Exception *CORBA_Bounds::_alloc (void) void operator<<= (CORBA::Any &_tao_any, const CORBA::Bounds &_tao_elem) { - CORBA::Bounds *_tao_any_val = 0; - ACE_NEW (_tao_any_val, - CORBA::Bounds (_tao_elem)); - if (!_tao_any_val) return; ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - stream << *_tao_any_val; + stream << _tao_elem; _tao_any._tao_replace (CORBA::_tc_Bounds, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _tao_any_val, ACE_TRY_ENV); ACE_TRY_CHECK; } ACE_CATCHANY { - delete _tao_any_val; } ACE_ENDTRY; } @@ -121,6 +120,7 @@ void operator<<= (CORBA::Any &_tao_any, CORBA::Bounds *_tao_elem) // non copying stream.begin (), 1, _tao_elem, + CORBA::Bounds::_tao_any_destructor, ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -152,6 +152,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CORBA::Bounds *&_tao_ele CORBA::_tc_Bounds, 1, ACE_reinterpret_cast (void*, _tao_elem), + CORBA::Bounds::_tao_any_destructor, ACE_TRY_ENV); ACE_TRY_CHECK; return 1; diff --git a/TAO/tao/BoundsC.h b/TAO/tao/BoundsC.h index 7be65208973..24964583da5 100644 --- a/TAO/tao/BoundsC.h +++ b/TAO/tao/BoundsC.h @@ -47,7 +47,8 @@ CORBA_Bounds (void); // default ctor CORBA_Bounds (const CORBA_Bounds &); // copy ctor ~CORBA_Bounds (void); // dtor - CORBA_Bounds &operator= (const CORBA_Bounds &); + static void _tao_any_destructor (void*); + CORBA_Bounds &operator= (const CORBA_Bounds &); virtual void _raise (void); diff --git a/TAO/tao/CONV_FRAMEC.cpp b/TAO/tao/CONV_FRAMEC.cpp index 8b4978ab66a..268aa91a095 100644 --- a/TAO/tao/CONV_FRAMEC.cpp +++ b/TAO/tao/CONV_FRAMEC.cpp @@ -24,6 +24,27 @@ #include "tao/CONV_FRAMEC.i" #endif /* !defined INLINE */ +void +CONV_FRAME::CodeSetComponent::_tao_any_destructor (void* x) +{ + CONV_FRAME::CodeSetComponent *tmp = ACE_static_cast(CONV_FRAME::CodeSetComponent*,x); + delete tmp; +} + +void +CONV_FRAME::CodeSetComponentInfo::_tao_any_destructor (void* x) +{ + CONV_FRAME::CodeSetComponentInfo *tmp = ACE_static_cast(CONV_FRAME::CodeSetComponentInfo*,x); + delete tmp; +} + +void +CONV_FRAME::CodeSetContext::_tao_any_destructor (void* x) +{ + CONV_FRAME::CodeSetContext *tmp = ACE_static_cast(CONV_FRAME::CodeSetContext*,x); + delete tmp; +} + static const CORBA::Long _oc_CONV_FRAME_CodeSetId[] = { TAO_ENCAP_BYTE_ORDER, // byte order @@ -269,26 +290,20 @@ TAO_NAMESPACE_END void operator<<= (CORBA::Any &_tao_any, const CONV_FRAME::CodeSetComponent &_tao_elem) // copying { - CONV_FRAME::CodeSetComponent *_any_val = 0; - ACE_NEW (_any_val, CONV_FRAME::CodeSetComponent (_tao_elem)); - if (!_any_val) return; ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - stream << *_any_val; + stream << _tao_elem; _tao_any._tao_replace ( CONV_FRAME::_tc_CodeSetComponent, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _any_val, ACE_TRY_ENV ); ACE_TRY_CHECK; } ACE_CATCHANY { - delete _any_val; } ACE_ENDTRY; } @@ -305,6 +320,7 @@ void operator<<= (CORBA::Any &_tao_any, CONV_FRAME::CodeSetComponent *_tao_elem) stream.begin (), 1, _tao_elem, + CONV_FRAME::CodeSetComponent::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -346,6 +362,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetCompo CONV_FRAME::_tc_CodeSetComponent, 1, ACE_reinterpret_cast (void *, _tao_elem), + CONV_FRAME::CodeSetComponent::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -362,7 +379,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetCompo { delete _tao_elem; _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -396,7 +413,8 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe ((CORBA::Any *)&_tao_any)->_tao_replace ( CONV_FRAME::_tc_CodeSetComponent, 1, - ACE_reinterpret_cast (void *, ACE_const_cast (CONV_FRAME::CodeSetComponent *&, _tao_elem)), + ACE_const_cast (CONV_FRAME::CodeSetComponent *&, _tao_elem), + CONV_FRAME::CodeSetComponent::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -413,7 +431,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe { delete ACE_const_cast (CONV_FRAME::CodeSetComponent *&, _tao_elem); _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -421,26 +439,20 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe void operator<<= (CORBA::Any &_tao_any, const CONV_FRAME::CodeSetComponentInfo &_tao_elem) // copying { - CONV_FRAME::CodeSetComponentInfo *_any_val = 0; - ACE_NEW (_any_val, CONV_FRAME::CodeSetComponentInfo (_tao_elem)); - if (!_any_val) return; ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - stream << *_any_val; + stream << _tao_elem; _tao_any._tao_replace ( CONV_FRAME::_tc_CodeSetComponentInfo, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _any_val, ACE_TRY_ENV ); ACE_TRY_CHECK; } ACE_CATCHANY { - delete _any_val; } ACE_ENDTRY; } @@ -457,6 +469,7 @@ void operator<<= (CORBA::Any &_tao_any, CONV_FRAME::CodeSetComponentInfo *_tao_e stream.begin (), 1, _tao_elem, + CONV_FRAME::CodeSetComponentInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -498,6 +511,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetCompo CONV_FRAME::_tc_CodeSetComponentInfo, 1, ACE_reinterpret_cast (void *, _tao_elem), + CONV_FRAME::CodeSetComponentInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -514,7 +528,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetCompo { delete _tao_elem; _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -549,6 +563,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe CONV_FRAME::_tc_CodeSetComponentInfo, 1, ACE_reinterpret_cast (void *, ACE_const_cast (CONV_FRAME::CodeSetComponentInfo *&, _tao_elem)), + CONV_FRAME::CodeSetComponentInfo::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -565,7 +580,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe { delete ACE_const_cast (CONV_FRAME::CodeSetComponentInfo *&, _tao_elem); _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -573,26 +588,20 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe void operator<<= (CORBA::Any &_tao_any, const CONV_FRAME::CodeSetContext &_tao_elem) // copying { - CONV_FRAME::CodeSetContext *_any_val = 0; - ACE_NEW (_any_val, CONV_FRAME::CodeSetContext (_tao_elem)); - if (!_any_val) return; ACE_TRY_NEW_ENV { TAO_OutputCDR stream; - stream << *_any_val; + stream << _tao_elem; _tao_any._tao_replace ( CONV_FRAME::_tc_CodeSetContext, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _any_val, ACE_TRY_ENV ); ACE_TRY_CHECK; } ACE_CATCHANY { - delete _any_val; } ACE_ENDTRY; } @@ -609,6 +618,7 @@ void operator<<= (CORBA::Any &_tao_any, CONV_FRAME::CodeSetContext *_tao_elem) / stream.begin (), 1, _tao_elem, + CONV_FRAME::CodeSetContext::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -650,6 +660,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetConte CONV_FRAME::_tc_CodeSetContext, 1, ACE_reinterpret_cast (void *, _tao_elem), + CONV_FRAME::CodeSetContext::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -666,7 +677,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CONV_FRAME::CodeSetConte { delete _tao_elem; _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -701,6 +712,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe CONV_FRAME::_tc_CodeSetContext, 1, ACE_reinterpret_cast (void *, ACE_const_cast (CONV_FRAME::CodeSetContext *&, _tao_elem)), + CONV_FRAME::CodeSetContext::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; @@ -717,7 +729,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CONV_FRAME::CodeSe { delete ACE_const_cast (CONV_FRAME::CodeSetContext *&, _tao_elem); _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; diff --git a/TAO/tao/CONV_FRAMEC.h b/TAO/tao/CONV_FRAMEC.h index fd43b7efa2b..8a9a5cc6abc 100644 --- a/TAO/tao/CONV_FRAMEC.h +++ b/TAO/tao/CONV_FRAMEC.h @@ -46,6 +46,8 @@ TAO_NAMESPACE CONV_FRAME struct TAO_Export CodeSetComponent { + static void _tao_any_destructor (void*); + CodeSetId native_code_set; #if !defined (TAO_USE_SEQUENCE_TEMPLATES) @@ -237,6 +239,8 @@ TAO_NAMESPACE CONV_FRAME struct TAO_Export CodeSetComponentInfo { + static void _tao_any_destructor (void*); + CodeSetComponent ForCharData; CodeSetComponent ForWcharData; }; @@ -290,6 +294,8 @@ TAO_NAMESPACE CONV_FRAME struct TAO_Export CodeSetContext { + static void _tao_any_destructor (void*); + CodeSetId char_data; CodeSetId wchar_data; }; @@ -329,29 +335,29 @@ TAO_NAMESPACE CONV_FRAME } TAO_NAMESPACE_CLOSE // module CONV_FRAME -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, const CONV_FRAME::CodeSetComponent &); // copying version -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, CONV_FRAME::CodeSetComponent*); // noncopying version -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, CONV_FRAME::CodeSetComponent *&); // deprecated -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CONV_FRAME::CodeSetComponent *&); -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, const CONV_FRAME::CodeSetComponentInfo &); // copying version -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, CONV_FRAME::CodeSetComponentInfo*); // noncopying version -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, CONV_FRAME::CodeSetComponentInfo *&); // deprecated -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CONV_FRAME::CodeSetComponentInfo *&); -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, const CONV_FRAME::CodeSetContext &); // copying version -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, CONV_FRAME::CodeSetContext*); // noncopying version -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, CONV_FRAME::CodeSetContext *&); // deprecated -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CONV_FRAME::CodeSetContext *&); #ifndef __ACE_INLINE__ diff --git a/TAO/tao/CurrentC.cpp b/TAO/tao/CurrentC.cpp index 051b2da91bd..b1179f411d4 100644 --- a/TAO/tao/CurrentC.cpp +++ b/TAO/tao/CurrentC.cpp @@ -65,6 +65,13 @@ CORBA_Current_ptr CORBA_Current::_nil (void) return (CORBA_Current_ptr)NULL; } // end of _nil +void +CORBA_Current::_tao_any_destructor (void* x) +{ + CORBA_Current *tmp = ACE_static_cast (CORBA_Current*,x); + CORBA::release (tmp); +} + CORBA::Boolean CORBA_Current::_is_a (const CORBA::Char *value, CORBA::Environment &ACE_TRY_ENV) { if ( @@ -82,47 +89,34 @@ const char* CORBA_Current::_interface_repository_id (void) const void operator<<= (CORBA::Any &_tao_any, CORBA::Current_ptr _tao_elem) { - CORBA::Object_ptr *_tao_obj_ptr = 0; ACE_TRY_NEW_ENV { - ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr); - *_tao_obj_ptr = CORBA::Current::_duplicate (_tao_elem); TAO_OutputCDR stream; - if (stream << *_tao_obj_ptr) + if (stream << _tao_elem) { _tao_any._tao_replace ( - CORBA::_tc_Current, + CORBA::_tc_Current, TAO_ENCAP_BYTE_ORDER, stream.begin (), - 1, - _tao_obj_ptr, ACE_TRY_ENV ); ACE_TRY_CHECK; } - else - { - delete _tao_obj_ptr; - } } ACE_CATCHANY { - delete _tao_obj_ptr; } ACE_ENDTRY; } CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CORBA::Current_ptr &_tao_elem) { - CORBA::Object_ptr *tmp = 0; - ACE_NEW_RETURN (tmp, CORBA::Object_ptr, 0); ACE_TRY_NEW_ENV { _tao_elem = CORBA::Current::_nil (); CORBA::TypeCode_var type = _tao_any.type (); if (!type->equivalent (CORBA::_tc_Current, ACE_TRY_ENV)) // not equal { - delete tmp; return 0; } ACE_TRY_CHECK; @@ -135,24 +129,19 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CORBA::Current_ptr &_tao { _tao_elem = CORBA::Current::_narrow (_tao_obj_var.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - *tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object ((CORBA::Any *)&_tao_any)->_tao_replace ( CORBA::_tc_Current, 1, - tmp, + _tao_elem, + CORBA::Current::_tao_any_destructor, ACE_TRY_ENV ); ACE_TRY_CHECK; return 1; } - else // failure - { - delete tmp; - } } ACE_CATCHANY { - delete tmp; _tao_elem = CORBA::Current::_nil (); return 0; } @@ -160,4 +149,3 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CORBA::Current_ptr &_tao _tao_elem = CORBA::Current::_nil (); return 0; } - diff --git a/TAO/tao/CurrentC.h b/TAO/tao/CurrentC.h index 5cb043d1077..3815ff7ba2f 100644 --- a/TAO/tao/CurrentC.h +++ b/TAO/tao/CurrentC.h @@ -111,7 +111,7 @@ private: #if !defined (_CORBA_CURRENT_CH_) #define _CORBA_CURRENT_CH_ -class CORBA_Current : public virtual ACE_CORBA_1 (Object) +class CORBA_Current : public virtual CORBA_Object { public: #if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8 @@ -125,6 +125,7 @@ class CORBA_Current : public virtual ACE_CORBA_1 (Object) CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()); static CORBA_Current_ptr _nil (void); + static void _tao_any_destructor (void*); virtual CORBA::Boolean _is_a (const CORBA::Char *type_id, CORBA_Environment &ACE_TRY_ENV = @@ -147,9 +148,9 @@ class CORBA_Current : public virtual ACE_CORBA_1 (Object) #endif /* end #if !defined */ // Any operators for interface CORBA_Current -TAO_Export void operator<<= (CORBA::Any &, +TAO_Export void operator<<= (CORBA::Any &, CORBA_Current_ptr); -TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, +TAO_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA_Current *&); #if defined (__ACE_INLINE__) diff --git a/TAO/tao/DomainC.cpp b/TAO/tao/DomainC.cpp index fb4cb68d5fb..4c0d5fbe556 100644 --- a/TAO/tao/DomainC.cpp +++ b/TAO/tao/DomainC.cpp @@ -349,7 +349,7 @@ void operator<<= (CORBA::Any &_tao_any, CORBA::DomainManager_ptr _tao_elem) if (stream << *_tao_obj_ptr) { _tao_any._tao_replace ( - CORBA::_tc_DomainManager, + CORBA::_tc_DomainManager, TAO_ENCAP_BYTE_ORDER, stream.begin (), 1, @@ -442,7 +442,7 @@ void operator<<= (CORBA::Any &_tao_any, CORBA::ConstructionPolicy_ptr _tao_elem) if (stream << *_tao_obj_ptr) { _tao_any._tao_replace ( - CORBA::_tc_ConstructionPolicy, + CORBA::_tc_ConstructionPolicy, TAO_ENCAP_BYTE_ORDER, stream.begin (), 1, @@ -542,7 +542,7 @@ void operator<<= ( _tao_any_val, ACE_TRY_ENV ); - ACE_TRY_CHECK; + ACE_TRY_CHECK; } else { @@ -625,7 +625,7 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, CORBA::DomainManagerList { delete _tao_elem; _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; @@ -676,9 +676,8 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const CORBA::DomainManag { delete ACE_const_cast (CORBA::DomainManagerList *&, _tao_elem); _tao_elem = 0; - return 0; + return 0; } ACE_ENDTRY; return 0; } - diff --git a/TAO/tao/DynAny_i.cpp b/TAO/tao/DynAny_i.cpp index 5c4a8249545..5189137cd04 100644 --- a/TAO/tao/DynAny_i.cpp +++ b/TAO/tao/DynAny_i.cpp @@ -672,7 +672,7 @@ TAO_DynAny_i::get_double (CORBA::Environment &ACE_TRY_ENV) char * TAO_DynAny_i::get_string (CORBA::Environment &ACE_TRY_ENV) { - CORBA::Char *val; + const char *val; if (!(this->value_ >>= val)) { diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp deleted file mode 100644 index bd3c67e640b..00000000000 --- a/TAO/tao/decode.cpp +++ /dev/null @@ -1,1484 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO -// -// = FILENAME -// decode.cpp -// -// = DESCRIPTION -// Code for decoding different data types -// -// The original code had a single static decoder function defined on -// the CDR class that called traverse to interpret the data -// types. This version defines a virtual method "decode" on each -// class and avoids calling traverse. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "tao/Marshal.h" -#include "tao/CDR.h" -#include "tao/Environment.h" -#include "tao/GIOP.h" -#include "tao/Any.h" -#include "tao/Principal.h" -#include "tao/MProfile.h" -#include "tao/Object.h" -#include "tao/Stub.h" -#include "tao/varout.h" -#include "tao/ORB.h" -#include "tao/Union.h" -#include "tao/ORB_Core.h" -#include "tao/debug.h" - -ACE_RCSID(tao, decode, "$Id$") - -// The decoder is exactly the reverse of the encoder, except that: -// -// * Unmarshaling some data types involve allocating memory. Such -// types include sequences (the buffer), objrefs, Principals, Anys, -// TypeCodes, and strings. -// -// * The decoder is used when retrieving typecode parameters from -// encapsulations. This means it must deal with "CORBA::tk_indirect", -// the magic value (~0u) signifying typecode indirection. -// -// This second case is identified by a bit of a hack: the second -// "data" value is used to hold the parent typecode, rather than being -// ignored. This means that all other invocations of decoder () ** -// MUST ** pass zero for the second data parameter, in case they -// decode a TypeCode. If they didn't, this case might be signified -// inappropriately. -// -// XXX desirable to have a less hacky solution to that ... pull that -// code out into a separate routine called both by CDR::decoder () and -// by the code retrieving typecode parameters from encapsulations. - -typedef TAO_Object_Field_T<CORBA::Object,CORBA::Object_var> TAO_Object_Field_Class; - -CORBA::TypeCode::traverse_status -TAO_Marshal_Primitive::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - TAO_InputCDR *stream = (TAO_InputCDR *) context; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; // status of encode operation - - switch (tc->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_decoding = stream->read_short (*(CORBA::Short *) data); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_decoding = stream->read_long (*(CORBA::Long *) data); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_decoding = stream->read_longlong (*(CORBA::LongLong *) data); - break; - case CORBA::tk_boolean: - continue_decoding = stream->read_boolean (*(CORBA::Boolean *) data); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_decoding = stream->read_char (*(CORBA::Char *) data); - break; - case CORBA::tk_longdouble: - continue_decoding = stream->read_longdouble (*(CORBA::LongDouble *) data); - break; - case CORBA::tk_wchar: - continue_decoding = stream->read_wchar (*(CORBA::WChar *) data); - break; - default: - retval = CORBA::TypeCode::TRAVERSE_STOP; - // we are not a primitive type - } - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE - || continue_decoding != 1) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_Primitive::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -CORBA::TypeCode::traverse_status -TAO_Marshal_Any::decode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Any *any = (CORBA::Any *) data; - - // Typecode of the element that makes the Any. - CORBA::TypeCode_var elem_tc; - - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - // Status of encode operation. - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - - // Decode the typecode description for the element. - retval = stream->decode (CORBA::_tc_TypeCode, - &elem_tc.out (), - 0, - ACE_TRY_ENV); - ACE_CHECK_RETURN (retval); - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - return retval; - - // Let the Any maintain a pointer to the CDR stream - // @@ ASG + CORYAN - The following commented line would have been a great - // optimization. However, it turns out that although the Message_Block is - // heap-allocated, the actual buffer i.e., data block is allocated on the - // function call stack. Once we are out of these chain of functions and - // return into the stub, we have lost the activation record for the - // actual buffer. Hence it makes no sense keeping pointers to stack - // memory. - // - // See TAO_Stub.cpp::do_static_call in which a GIOP_Invocation is - // allocated on stack -#if 0 - any->byte_order_ = stream->byte_order (); - any->cdr_ = ACE_CDR::consolidate (stream->start ()); -#endif - // one solution is to heap allocate the GIOP_Invocation. However, that - // would be bad since not all requests will use Anys. - // - // One solution is to allocate a new Message_Block with its own heap - // allocated data_block. (We may optimize this using allocators for known - // sizes). We allocate a Message_Block of the size that is required by - // the data type held by the Any. To find what is the size of this data - // in the CDR, we traverse the CDR by skipping past this data type. We - // then get an offset using the "begin" and "end" shown below that tells - // us the size. The skipping is done on a temporary CDR stream and not on - // the actual incoming CDR stream. Once we have allocated a new - // Message_Block, we simply append the data into it from the original CDR - // stream. - char *begin, *end; - TAO_InputCDR temp (*stream); - - begin = stream->rd_ptr (); - retval = temp.skip (elem_tc.in (), ACE_TRY_ENV); - ACE_CHECK_RETURN (retval); - - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - return retval; - - end = temp.rd_ptr (); - - // We need to allocate more memory than in the original - // stream, first to guarantee that the buffer is aligned in - // memory and next because the realignment may introduce - // extra padding. 2*MAX_ALIGNMENT should be enough. - // @@EXC@@ This doesn't seem to be exception safe. - TAO_OutputCDR out (end - begin + 2 * ACE_CDR::MAX_ALIGNMENT); - - retval = out.append (elem_tc.in (), stream, ACE_TRY_ENV); - ACE_CHECK_RETURN (retval); - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - return retval; - - ACE_Message_Block::release (any->cdr_); - if (any->any_owns_data_ && any->value_ != 0) - DEEP_FREE (any->type_, any->value_, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - any->byte_order_ = stream->byte_order (); - ACE_NEW_RETURN (any->cdr_, ACE_Message_Block, - CORBA::TypeCode::TRAVERSE_STOP); - ACE_CDR::consolidate (any->cdr_, out.begin ()); - any->value_ = 0; - - if (any->type_) - CORBA::release (any->type_); - - any->type_ = elem_tc._retn (); - any->any_owns_data_ = 0; - - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_Any::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - retval); - } - return retval; -} - -CORBA::TypeCode::traverse_status -TAO_Marshal_TypeCode::decode (CORBA::TypeCode_ptr, - const void *data, - const void *parent_typecode, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - // Typecode to be decoded. - CORBA::TypeCode_ptr *tcp; - - // Typecode kind. - CORBA::ULong kind; - - static CORBA::TypeCode_ptr tc_consts [CORBA::TC_KIND_COUNT] = - { - CORBA::_tc_null, - CORBA::_tc_void, - CORBA::_tc_short, - CORBA::_tc_long, - CORBA::_tc_ushort, - - CORBA::_tc_ulong, - CORBA::_tc_float, - CORBA::_tc_double, - CORBA::_tc_boolean, - CORBA::_tc_char, - - CORBA::_tc_octet, - CORBA::_tc_any, - CORBA::_tc_TypeCode, - CORBA::_tc_Principal, - - 0, // CORBA::_tc_Object ... type ID is CORBA_Object - 0, // CORBA_tk_struct - 0, // CORBA_tk_union - 0, // CORBA_tk_enum - 0, // CORBA::_tc_string ... unbounded - 0, // CORBA_tk_sequence - 0, // CORBA_tk_array - 0, // CORBA_tk_alias - 0, // CORBA_tk_except - - CORBA::_tc_longlong, - CORBA::_tc_ulonglong, - CORBA::_tc_longdouble, - CORBA::_tc_wchar, - 0 // CORBA::_tc_wstring ... unbounded - }; - - // TypeCode for the parent. The most likely situation when a parent will be - // provided is when we are precomputing the private state of an IDL compiler - // generated or an ORB owned TypeCode, OR we are decoding an indirected - // TypeCode. In such circumstances, the decoded - // TypeCode will share resources with its parent and cannot be freed until - // its parent is being freed. - CORBA::TypeCode_ptr parent = (CORBA::TypeCode_ptr) parent_typecode; - - // Decode the "kind" field of the typecode from the stream - continue_decoding = stream->read_ulong (kind); - - if (continue_decoding == 1) - { - // The data has to be a TypeCode_ptr *. - tcp = (CORBA::TypeCode_ptr *) data; - - // Typecodes with empty parameter lists all have preallocated - // constants. We use those to reduce memory consumption and - // heap access ... also, to speed things up! - if (kind < CORBA::TC_KIND_COUNT - && (*tcp = tc_consts [(u_int) kind]) != 0) - // parent is ignored - *tcp = CORBA::TypeCode::_duplicate (tc_consts [(u_int) kind]); - else if (kind == ~0u || kind < CORBA::TC_KIND_COUNT) - { - // Either a non-constant typecode or an indirected typecode. - switch (kind) - { - // Need special handling for all kinds of typecodes that - // have nonempty parameter lists ... - default: - // Error: missed a case! - ACE_THROW_RETURN (CORBA::INTERNAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), CORBA::TypeCode::TRAVERSE_STOP); - - // Some have "simple" parameter lists ... some of these - // also have preallocated constants that could be used. - case CORBA::tk_string: - case CORBA::tk_wstring: - { - CORBA::ULong bound; - - continue_decoding = stream->read_ulong (bound); - if (continue_decoding) - { - if (bound == 0) - { - // unbounded string. Let us reuse the ORB owned - // _tc_string or _tc_wstring - if (kind == CORBA::tk_string) - *tcp = CORBA::TypeCode::_duplicate - (CORBA::_tc_string); - else - *tcp = CORBA::TypeCode::_duplicate - (CORBA::_tc_wstring); - } - else - { - // bounded string. Create a TypeCode. If it is does not - // have a parent, then the application must free it. - - // allocate a new TypeCode - - // This may produce a memory leak, because - // callers are sloppy about removing these - // objects. - CORBA::Long _oc_bounded_string [] = - {TAO_ENCAP_BYTE_ORDER, 0}; - // Bounded string. Save the bounds - _oc_bounded_string [1] = (CORBA::Long) bound; - ACE_NEW_THROW_EX (*tcp, - CORBA::TypeCode (ACE_static_cast(CORBA::TCKind, kind), - 8, - ACE_reinterpret_cast(char*,_oc_bounded_string), - 0, sizeof - (CORBA::String_var), 0), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - } - } - break; - - // Indirected typecodes, illegal at "top level" but we - // allow unmarshaling of them here because we use the same - // code to read "off the wire" (where they're illegal) and - // to read out of an encapsulation stream. We distinguish - // the case where this is legal as described above. - case ~0u: - { - if (parent_typecode == 0) - ACE_THROW_RETURN (CORBA::INTERNAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), CORBA::TypeCode::TRAVERSE_STOP); - - // Get the long indicating the encapsulation offset, - // then set up indirection stream that's like "stream" - // but has space enough only for the typecode and the - // length for the encapsulated parameters. - // - // The offset must be negative - CORBA::Long offset; - - continue_decoding = stream->read_long (offset); - if (continue_decoding) - { - // Since indirected typecodes cannot occur at the - // topmost level, they can occur starting only at the - // second and subsequent levels. This means that a - // normal encoding of that typecode occurred somewhere - // before in the stream. As a result the offset field - // must always be negative. See the CORBA spec for details. - continue_decoding = (offset < 0); - } - - // Slava Galperin <galperin@teknowledge.com> clarifies - // this: - // CORBA Spec says: - // - // The encoding of such an indirection is as a - // TypeCode with a TCKind value that has the special - // value 2^32 -1 (0xffffffff, all ones). Such - // typecodes have a single (simple) parameter, which - // is the long offset (in units of octets) from the - // simple parameter. (This means that an offset of - // negative four (-4) is illegal because it will be - // self-indirecting.) - // (CORBA V2.2 CDR Transfer Syntax February 1998 page 13-17) - // - // This apparently assumes offset from the <em> - // beginning </em> of the simple parameter. - // [Right, because otherwise the value -8 would be - // illegal] - // Because at this point stream is positioned after - // the parameter, we need to account for that when - // constructing indir_stream by subtracting 4 (length - // of the offset parameter itself). - - // TAO_InputCDR indir_stream (*stream, 8, offset - // - 4); - ACE_Message_Block *mb = (ACE_Message_Block *)stream->start (); - TAO_InputCDR indir_stream (mb->rd_ptr () + offset - 4, - -1 * (offset - 4)); - - - continue_decoding = (CORBA::Boolean) indir_stream.good_bit (); - - // Get "kind" and length of target typecode - // - // XXX this currently assumes the TCKind to which we - // indirect is the same byte order as the "parent" - // typecode -- not the right assumption; see how the - // TypeCode interpreter does it. - - CORBA::ULong indir_kind = 0; - CORBA::ULong indir_len = 0; - - // retrieve the typecode kind - if (continue_decoding) - continue_decoding = indir_stream.read_ulong (indir_kind); - - if (continue_decoding - && indir_kind >= CORBA::TC_KIND_COUNT) - continue_decoding = 0; - - // now retrieve the encapsulation length - if (continue_decoding) - continue_decoding = indir_stream.read_ulong (indir_len); - - // Now construct indirected typecode. This shares the - // typecode octets with the "parent" typecode, - // increasing the amount of memory sharing and - // reducing the cost of getting typecodes. - if (continue_decoding) - { - ACE_NEW_THROW_EX (*tcp, - CORBA::TypeCode ((CORBA::TCKind) indir_kind, - indir_len, - indir_stream.rd_ptr(), - 0, - 0, - parent), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - } - break; - - // The rest have "complex" parameter lists that are - // encoded as bulk octets ... - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_enum: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - { - CORBA::ULong length; - - // get the encapsulation length - continue_decoding = stream->read_ulong (length); - if (!continue_decoding) - break; - - // if length > MAXUNSIGNED, error ... - u_int len = (u_int) length; - - // create a new typecode - ACE_NEW_THROW_EX (*tcp, - CORBA::TypeCode ((CORBA::TCKind) kind, - len, - stream->rd_ptr (), - 0, - 0, - parent), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // skip length number of bytes in the stream, else we may - // leave the stream in an undefined state - (void) stream->skip_bytes (length); - } - } // end of switch - } - else // bad kind_ value to be decoded - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_TypeCode:decode: ") - ASYS_TEXT ("Bad kind_ value in CDR stream\n"))); - ACE_THROW_RETURN ( CORBA::BAD_TYPECODE (), CORBA::TypeCode::TRAVERSE_STOP); - } - } - - if (continue_decoding != 1) - { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_TypeCode::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Encode Principal. - -CORBA::TypeCode::traverse_status -TAO_Marshal_Principal::decode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - CORBA::Principal_ptr x; - - if ((*stream >> x) == 0) - { - *(CORBA_Principal_ptr*)data = CORBA::Principal::_nil (); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - - *(CORBA_Principal **)data = x; - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Decode obj ref. An IOR -CORBA::TypeCode::traverse_status -TAO_Marshal_ObjRef::decode (CORBA::TypeCode_ptr, - const void *data, // where the result will go - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - CORBA::Object_ptr object; - - if ((*stream >> object) == 0) - { - *(CORBA_Object_ptr*)data = CORBA::Object::_nil (); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), CORBA::TypeCode::TRAVERSE_STOP); - } - - *(CORBA_Object **)data = object; - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Decode structs. -CORBA::TypeCode::traverse_status -TAO_Marshal_Struct::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_InputCDR *stream = (TAO_InputCDR *) context; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - CORBA::Boolean continue_decoding = 1; - CORBA::TypeCode_var param; - CORBA::Long size, alignment, align_offset; - - void *start_addr = (void *)data; - - // Number of fields in the struct. - int member_count = tc->member_count (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - for (int i = 0; i < member_count - && retval == CORBA::TypeCode::TRAVERSE_CONTINUE - && continue_decoding == 1; - i++) - { - param = tc->member_type (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = param->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - alignment = param->alignment (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - align_offset = - (ptr_arith_t) ACE_ptr_align_binary (data, alignment) - - (ptr_arith_t) data - - ((ptr_arith_t) ACE_ptr_align_binary (start_addr, alignment) - - (ptr_arith_t) start_addr); - if (align_offset < 0) - align_offset += alignment; - - // if both the start_addr and data are not aligned as per - // the alignment, we do not add the offset - data = (const void *) ((ptr_arith_t) data + - ((align_offset == alignment) ? - 0 : align_offset)); - switch (param->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_decoding = - stream->read_short (*(CORBA::Short *) data); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_decoding = - stream->read_long (*(CORBA::Long *) data); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_decoding = - stream->read_longlong (*(CORBA::LongLong *) data); - break; - case CORBA::tk_boolean: - continue_decoding = - stream->read_boolean (*(CORBA::Boolean *) data); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_decoding = - stream->read_char (*(CORBA::Char *) data); - break; - case CORBA::tk_longdouble: - continue_decoding = - stream->read_longdouble (*(CORBA::LongDouble *) data); - break; - case CORBA::tk_wchar: - continue_decoding = - stream->read_wchar (*(CORBA::WChar *) data); - break; - case CORBA::tk_TypeCode: - case CORBA::tk_any: - case CORBA::tk_Principal: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_string: - case CORBA::tk_wstring: - retval = stream->decode (param.in (), data, 0, ACE_TRY_ENV); - break; - - case CORBA::tk_objref: - { - CORBA_Object_ptr object; - retval = stream->decode (param.in (), &object, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - ACE_const_cast (void *, data)); - field->_downcast (object, ACE_TRY_ENV); - } - } - break; - - default: - break; - } - data = (char *) data + size; - } - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_Struct::decode detected error\n"))); - - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Encode unions. -CORBA::TypeCode::traverse_status -TAO_Marshal_Union::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *data2, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - CORBA::TypeCode_var discrim_tc; - CORBA::TypeCode_var member_tc = 0; - CORBA::Any_ptr member_label; - CORBA::ULong discrim_size_with_pad; - const void *discrim_val; - CORBA::ULong member_count; - CORBA::Long default_index; - CORBA::ULong i; - CORBA::TypeCode_ptr default_tc = 0; - CORBA::Boolean discrim_matched = 0; - TAO_Base_Union *base_union = (TAO_Base_Union *)data; - void *member_val; - - discrim_tc = tc->discriminator_type (ACE_TRY_ENV); - // get the discriminator type - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // decode the discriminator value - discrim_val = base_union->_discriminant (); - stream->decode (discrim_tc.in (), discrim_val, data2, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - discrim_size_with_pad = tc->TAO_discrim_pad_size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // move the pointer to point to the actual value - data = (char *) data + discrim_size_with_pad; - data2 = (char *) data2 + discrim_size_with_pad; - - // now get ready to marshal the actual union value - default_index = tc->default_index (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - member_count = tc->member_count (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // check which label value matches with the discriminator - // value. Accordingly, marshal the corresponding - // member_type. If none match, check if default exists - // and marshal accordingly. Otherwise it is an error. - - for (i = 0; member_count-- != 0; i++) - { - member_label = tc->member_label (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // do the matching - CORBA::TypeCode_var type = member_label->type (); - switch (type->kind (ACE_TRY_ENV)) // kind() doesn't throw any exception. - { - case CORBA::tk_short: - { - CORBA::Short s; - *member_label >>= s; - if (s == *(CORBA::Short *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_ushort: - { - CORBA::UShort s; - *member_label >>= s; - if (s == *(CORBA::UShort *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_long: - { - CORBA::Long l; - *member_label >>= l; - if (l == *(CORBA::Long *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_ulong: - { - CORBA::ULong l; - *member_label >>= l; - if (l == *(CORBA::ULong *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_enum: - { - CORBA::ULong ul; - TAO_InputCDR stream ((ACE_Message_Block *) - member_label->_tao_get_cdr (), - member_label->_tao_byte_order ()); - (void)stream.decode (discrim_tc.in (), &ul, 0, ACE_TRY_ENV); - //@@EXC@@ Rethrow CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE)? - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (ul == *(CORBA::ULong *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_char: - { - CORBA::Char c; - *member_label >>= CORBA::Any::to_char (c); - if (c == *(CORBA::Char *) discrim_val) - discrim_matched = 1; - } - break; - case CORBA::tk_wchar: - CORBA::WChar wc; - *member_label >>= CORBA::Any::to_wchar (wc); - if (wc == *(CORBA::WChar *) discrim_val) - discrim_matched = 1; - break; - case CORBA::tk_boolean: - { - CORBA::Boolean b; - *member_label >>= CORBA::Any::to_boolean (b); - if (b == *(CORBA::Boolean *) discrim_val) - discrim_matched = 1; - } - break; - default: - ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), CORBA::TypeCode::TRAVERSE_STOP); - }// end of switch - - // get the member typecode - member_tc = tc->member_type (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // have we reached the default label?, if so, - // save a handle to the typecode for the default - if (default_index >= 0 && default_index-- == 0) - default_tc = member_tc.in (); - if (discrim_matched) - { - member_val = base_union->_access (1); - // marshal according to the matched typecode - if (member_tc->kind () == CORBA::tk_objref) - { - CORBA_Object_ptr object; - int retval = - stream->decode (member_tc.in (), &object, data2, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - // we know that the object pointer is stored in a - // TAO_Object_Field_T parametrized type - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - member_val); - field->_downcast (object, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - else - { - return stream->decode (member_tc.in (), member_val, - data2, ACE_TRY_ENV); - } - } - } // end of for loop - - // we are here only if there was no match - if (default_tc) - { - member_val = base_union->_access (1); - if (default_tc->kind () == CORBA::tk_objref) - { - CORBA_Object_ptr object; - int retval = - stream->decode (member_tc.in (), &object, data2, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - // we know that the object pointer is stored in a - // TAO_Object_Field_T parametrized type - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - member_val); - field->_downcast (object, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - else - { - return stream->decode (default_tc, member_val, - data2, ACE_TRY_ENV); - } - } - else - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// decode string -CORBA::TypeCode::traverse_status -TAO_Marshal_String::decode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - char ** str_ptr = (char**)data; - - // On decode, omit the check against specified string bounds, and - // cope with illegal "zero length" strings (all lengths on the wire - // must include a NUL). - // - // This is on the principle of being gracious in what we accept; we - // don't generate messages that fail to comply with protocol specs, - // but we will accept them when it's clear how to do so. - - continue_decoding = stream->read_string (*str_ptr); - if (continue_decoding != 1) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_String::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Decode sequence. - -CORBA::TypeCode::traverse_status -TAO_Marshal_Sequence::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - TAO_InputCDR *stream = (TAO_InputCDR *) context; - TAO_Base_Sequence *seq = (TAO_Base_Sequence *)data; - // Return status. - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - // Typecode of the element. - CORBA::TypeCode_var tc2; - // Size of element. - size_t size; - CORBA::ULong bounds; - char *value; - - // First unmarshal the sequence length ... we trust it to be right - // here, on the "be gracious in what you accept" principle. We - // don't generate illegal sequences (i.e. length > bounds). - - continue_decoding = stream->read_ulong (bounds); - - if (continue_decoding) - { - // No point decoding an empty sequence. - if (bounds > 0) - { - // Get element typecode. - tc2 = tc->content_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = tc2->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - -#if defined (TAO_NO_COPY_OCTET_SEQUENCES) - // The treatment of octet sequences is completely - // different. - if (tc2->kind_ == CORBA::tk_octet - && ACE_BIT_DISABLED (stream->start ()->flags (), - ACE_Message_Block::DONT_DELETE)) - { - TAO_Unbounded_Sequence<CORBA::Octet>* seq2 = - ACE_dynamic_cast(TAO_Unbounded_Sequence<CORBA::Octet>*, seq); - seq2->replace (bounds, stream->start ()); - seq2->mb ()->wr_ptr (seq2->mb ()->rd_ptr () + bounds); - stream->skip_bytes (bounds); - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } -#endif /* defined (TAO_NO_COPY_OCTET_SEQUENCES) */ - - // Allocate the buffer using the virtual - // _allocate_buffer method, hence the right - // constructors are invoked and size for the array - // is OK. The sequence will release it, since its - // release_ field is 1. - if (seq->maximum_ < bounds) - { - seq->_deallocate_buffer (); - seq->maximum_ = bounds; - seq->release_ = 1; - seq->buffer_ = 0; - seq->_allocate_buffer (bounds); - } - // In any case the sequence length is changed. - seq->length_ = bounds; - - - value = (char *) seq->buffer_; - - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - case CORBA::tk_short: - case CORBA::tk_ushort: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_short_array - ((CORBA::Short *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_long_array - ((CORBA::Long *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_longlong_array - ((CORBA::LongLong *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_boolean: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_octet_array - ((CORBA::Octet *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_char: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_char_array - ((CORBA::Char *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_octet: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_octet_array - ((CORBA::Octet *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_longdouble: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_longdouble_array - ((CORBA::LongDouble *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_wchar: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_wchar_array - ((CORBA::WChar *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - // handle all aggregate types here - case CORBA::tk_string: - case CORBA::tk_wstring: - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - // For those aggregate types whose size is - // constant, we compute it only once. - while (bounds-- && retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - retval = stream->decode (tc2.in (), - value, - 0, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - value += size; - } - // CORBA::release (tc2); - return retval; - - case CORBA::tk_objref: - { - size = sizeof (CORBA_Object_ptr); - while (bounds-- && - retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - CORBA_Object_ptr ptr; - retval = stream->decode (tc2.in (), - &ptr, - 0, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - seq->_downcast (value, ptr, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - CORBA::release (ptr); - value += size; - } - return retval; - } - - default: - break; - } // end of switch - } // length is > 0 - else - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - ACE_THROW_RETURN (CORBA::MARSHAL (), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// Decode array. - -CORBA::TypeCode::traverse_status -TAO_Marshal_Array::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - // Return status. - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - - // Typecode of the element. - CORBA::TypeCode_var tc2; - - // Size of element. - size_t size; - CORBA::ULong bounds; - char *value = (char *) data; - - // retrieve the bounds of the array - bounds = tc->length (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // get element typecode - tc2 = tc->content_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = tc2->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - case CORBA::tk_short: - case CORBA::tk_ushort: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_short_array - ((CORBA::Short *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_long_array - ((CORBA::Long *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_longlong_array - ((CORBA::LongLong *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_boolean: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_octet_array - ((CORBA::Octet *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_char: - case CORBA::tk_octet: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_octet_array - ((CORBA::Octet *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_longdouble: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_longdouble_array - ((CORBA::LongDouble *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_wchar: - // For primitives, compute the size only once - continue_decoding = continue_decoding && - stream->read_wchar_array - ((CORBA::WChar *) value, bounds); - if (continue_decoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - // handle all aggregate types here - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_string: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_wstring: - // For those aggregate types whose size is constant, we - // compute it only once - while (bounds-- && retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - retval = stream->decode (tc2.in (), value, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - value += size; - } - // CORBA::release (tc2); - return retval; - default: - break; - } // end of switch - - // error exit - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_Sequence::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// Decode alias. -CORBA::TypeCode::traverse_status -TAO_Marshal_Alias::decode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - // Typecode of the aliased type. - CORBA::TypeCode_var tc2; - CORBA::Boolean continue_decoding = 1; - - // Context is the CDR stream. - TAO_InputCDR *stream = (TAO_InputCDR *) context; - - // Status of decode operation. - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - char *value = (char *) data; - - tc2 = tc->content_type (ACE_TRY_ENV); - // @@EXC@@ Rethrow CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE)? - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // Switch on the data type and handle the cases for primitives - // here for efficiency rather than calling. - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_decoding = - stream->read_short (*(CORBA::Short *) value); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_decoding = - stream->read_long (*(CORBA::Long *) value); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_decoding = - stream->read_longlong (*(CORBA::LongLong *) value); - break; - case CORBA::tk_boolean: - continue_decoding = - stream->read_boolean (*(CORBA::Boolean *) value); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_decoding = - stream->read_char (*(CORBA::Char *) value); - break; - case CORBA::tk_longdouble: - continue_decoding = - stream->read_longdouble (*(CORBA::LongDouble *) value); - break; - case CORBA::tk_wchar: - continue_decoding = - stream->read_wchar (*(CORBA::WChar *) value); - break; - case CORBA::tk_string: - case CORBA::tk_wstring: - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - retval = stream->decode (tc2.in (), data, 0, ACE_TRY_ENV); - // @@EXC@@ Rethrow CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE)? - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - break; - default: - // anything else is an error - retval = CORBA::TypeCode::TRAVERSE_STOP; - } - - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE - || continue_decoding != 1) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_Except::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// Decode exception For exceptions, the "hidden" type ID near the -// front of the on-wire representation was previously unmarshaled and -// mapped to the "tc" typcode we're using to traverse the memory ... -// at the same time its vtable, refcount, and other state was -// established. -// -// NOTE: This is asymmetric with respect to encoding exceptions. -CORBA::TypeCode::traverse_status -TAO_Marshal_Except::decode (CORBA::TypeCode_ptr, - const void *, - const void *, - void *, - CORBA::Environment &ACE_TRY_ENV) -{ - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// decode wstring -CORBA::TypeCode::traverse_status -TAO_Marshal_WString::decode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_decoding = 1; - TAO_InputCDR *stream = (TAO_InputCDR *) context; - CORBA::WChar *str = *(CORBA::WChar **) data; - CORBA::ULong len; - - // On decode, omit the check against specified wstring bounds, and - // cope with illegal "zero length" strings (all lengths on the wire - // must include a NUL). - // - // This is on the principle of being gracious in what we accept; we - // don't generate messages that fail to comply with protocol specs, - // but we will accept them when it's clear how to do so. - - continue_decoding = stream->read_ulong (len); - - ACE_NEW_RETURN (str, - CORBA::WChar [(size_t) (len)], - CORBA::TypeCode::TRAVERSE_CONTINUE); - *((CORBA::WChar **) data) = str; - - if (len != 0) - while (continue_decoding != 0 && len--) - { - continue_decoding = stream->read_wchar (*str); - str++; - } - - if (continue_decoding != 1) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO_Marshal_WString::decode detected error\n"))); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} diff --git a/TAO/tao/encode.cpp b/TAO/tao/encode.cpp deleted file mode 100644 index 0d555abec6e..00000000000 --- a/TAO/tao/encode.cpp +++ /dev/null @@ -1,1140 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO -// -// = FILENAME -// encode.cpp -// -// = DESCRIPTION -// Code for encoding different data types -// -// The original code had a single static encoder function defined on -// the CDR class that called traverse to interpret the data types. -// This version defines a virtual method "encode" on each class and -// avoids calling traverse. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems Inc. -// and Aniruddha Gokhale -// -// ============================================================================ - -#include "tao/Marshal.h" -#include "tao/CDR.h" -#include "tao/Environment.h" -#include "tao/Any.h" -#include "tao/Object.h" -#include "tao/Stub.h" -#include "tao/Principal.h" -#include "tao/varout.h" -#include "tao/Union.h" -#include "tao/debug.h" - -ACE_RCSID(tao, encode, "$Id$") - -// Encode instances of arbitrary data types based only on typecode. -// "data" points to the data type; if it's not a primitve data type, -// the TypeCode interpreter is used to recursively encode its -// components. "context" is the marshaling stream on which to encode -// the data value. - -typedef TAO_Object_Field_T<CORBA::Object,CORBA::Object_var> TAO_Object_Field_Class; - -CORBA::TypeCode::traverse_status -TAO_Marshal_Primitive::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_encoding = 1; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; // status of encode operation - - switch (tc->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_encoding = stream->write_short (*(CORBA::Short *) data); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_encoding = stream->write_long (*(CORBA::Long *) data); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_encoding = stream->write_longlong (*(CORBA::LongLong *) data); - break; - case CORBA::tk_boolean: - continue_encoding = stream->write_boolean (*(CORBA::Boolean *) data); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_encoding = stream->write_char (*(CORBA::Char *) data); - break; - case CORBA::tk_longdouble: - continue_encoding = stream->write_longdouble (*(CORBA::LongDouble *) data); - break; - case CORBA::tk_wchar: - continue_encoding = stream->write_wchar (*(CORBA::WChar *) data); - break; - default: - retval = CORBA::TypeCode::TRAVERSE_STOP; - // we are not a primitive type - } - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE - && continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - else - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_Primitive::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } -} - -CORBA::TypeCode::traverse_status -TAO_Marshal_Any::encode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Any *any = (CORBA::Any *) data; - - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - - // Status of encode operation - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; - - // Typecode of the element that makes the Any. - CORBA::TypeCode_ptr elem_tc = any->type_; - - // Encode the typecode description for the element. - retval = stream->encode (CORBA::_tc_TypeCode, &elem_tc, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - // if the any owns the data, then the value is a CDR stream and - // we simply append the CDR stream - // The only exception is when the TypeCode is a tk_null, them - // both cdr_ and value_ are 0. - if (any->cdr_ != 0) - { - TAO_InputCDR in_strm (any->cdr_); - retval = stream->append (elem_tc, &in_strm, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - else if (any->value_ != 0) - { - // encode the value - retval = stream->encode (elem_tc, any->value_, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - } - } - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - else - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_Any::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } -} - -CORBA::TypeCode::traverse_status -TAO_Marshal_TypeCode::encode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_encoding = 1; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - CORBA::TypeCode_ptr tc2; // typecode to be encoded - - tc2 = *(CORBA::TypeCode_ptr *) data; // the data has to be a TypeCode_ptr - - // encode the "kind" field of the typecode - continue_encoding = stream->write_ulong ((CORBA::ULong) tc2->kind_); - if (continue_encoding == 1) - { - // now encode the parameters, if any - switch (tc2->kind_) - { - // Most TypeCodes have empty parameter lists - default: - break; - - // A few have "simple" parameter lists - case CORBA::tk_string: - case CORBA::tk_wstring: - continue_encoding = stream->write_ulong (tc2->length (ACE_TRY_ENV)); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - break; - - // Indirected typecodes can't occur at "top level" like - // this, only nested inside others! - case ~0u: - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "indirected typecode at top level!\n")); - continue_encoding = 0; - break; - - // The rest have "complex" parameter lists that are - // already encoded as bulk octets ... put length, then - // octets. - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_enum: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - { - // simply encode the encapsulation - continue_encoding = stream->write_ulong (tc2->length_); - continue_encoding = continue_encoding - && stream->write_octet_array ((CORBA::Octet*)tc2->buffer_, tc2->length_); - } - } - } - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - else - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_TypeCode::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } -} - -// encode Principal -CORBA::TypeCode::traverse_status -TAO_Marshal_Principal::encode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - - CORBA::Principal_ptr p = *(CORBA::Principal_ptr *) data; - - if ((*stream << p) == 0) - { - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// encode obj ref -CORBA::TypeCode::traverse_status -TAO_Marshal_ObjRef::encode (CORBA::TypeCode_ptr, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - - // Current version: objref is really an TAO_Stub. - // @@ But, it need not be. All IIOP specific processing has - // been move to the specific transport profile class! - // - // XXX this doesn't actually verify that the stuff got written - // OK to the "wire" ... - // @@ Seems to break here! - CORBA::Object_ptr obj = *(CORBA::Object_ptr *) data; - - if ((*stream << obj) == 0) - { - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - } - return CORBA::TypeCode::TRAVERSE_CONTINUE; -} - -// encode structs -CORBA::TypeCode::traverse_status -TAO_Marshal_Struct::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - CORBA::TypeCode::traverse_status retval = CORBA::TypeCode::TRAVERSE_CONTINUE; - CORBA::Boolean continue_encoding = 1; - CORBA::TypeCode_var param; - CORBA::Long size, alignment, align_offset; - - void *start_addr = (void *)data; - - int member_count = tc->member_count (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - for (int i = 0; - i < member_count && retval == CORBA::TypeCode::TRAVERSE_CONTINUE - && continue_encoding == 1; - i++) - { - param = tc->member_type (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = param->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - alignment = param->alignment (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - align_offset = - (ptr_arith_t) ACE_ptr_align_binary (data, alignment) - - (ptr_arith_t) data - - ((ptr_arith_t) ACE_ptr_align_binary (start_addr, alignment) - - (ptr_arith_t) start_addr); - if (align_offset < 0) - align_offset += alignment; - - // if both the start_addr and data are not aligned as per - // the alignment, we do not add the offset - data = (const void *) ((ptr_arith_t) data + - ((align_offset == alignment) ? - 0 : align_offset)); - switch (param->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_encoding = stream->write_short (*(CORBA::Short *) data); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_encoding = stream->write_long (*(CORBA::Long *) data); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_encoding = stream->write_longlong (*(CORBA::LongLong *) data); - break; - case CORBA::tk_boolean: - continue_encoding = stream->write_boolean (*(CORBA::Boolean *) data); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_encoding = stream->write_char (*(CORBA::Char *) data); - break; - case CORBA::tk_longdouble: - continue_encoding = stream->write_longdouble (*(CORBA::LongDouble *) data); - break; - case CORBA::tk_wchar: - continue_encoding = stream->write_wchar (*(CORBA::WChar *) data); - break; - case CORBA::tk_any: - case CORBA::tk_Principal: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_string: - case CORBA::tk_wstring: - case CORBA::tk_TypeCode: - retval = stream->encode (param.in (), data, 0, ACE_TRY_ENV); - break; - - case CORBA::tk_objref: - { - // we know that the object pointer is stored in a - // TAO_Object_Field_T parametrized type - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - ACE_const_cast (void *, data)); - CORBA::Object_ptr ptr = field->_upcast (); - retval = stream->encode (param.in (), &ptr, 0, ACE_TRY_ENV); - } - break; - - default: - break; - } - data = (char *) data + size; - } - - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE - && continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_Struct::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// encode unions -CORBA::TypeCode::traverse_status -TAO_Marshal_Union::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *data2, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - - CORBA::TypeCode_var discrim_tc = - tc->discriminator_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - // get the discriminator type - - CORBA::TypeCode_ptr default_tc = 0; - CORBA::Boolean discrim_matched = 0; - - TAO_Base_Union *base_union = (TAO_Base_Union *)data; - void *member_val; - - // encode the discriminator value - const void *discrim_val = base_union->_discriminant (); - CORBA::TypeCode::traverse_status retval = - stream->encode (discrim_tc.in (), discrim_val, data2, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (retval != CORBA::TypeCode::TRAVERSE_CONTINUE) - return retval; - - CORBA::ULong discrim_size_with_pad = - tc->TAO_discrim_pad_size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // move the pointer to point to the actual value - data = (char *) data + discrim_size_with_pad; - data2 = (char *) data2 + discrim_size_with_pad; - - // now get ready to marshal the actual union value - CORBA::Long default_index = - tc->default_index (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // get the member count - CORBA::ULong member_count = - tc->member_count (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // Check which label value matches with the - // discriminator value. Accordingly, marshal the - // corresponding member_type. If none match, - // check if default exists and marshal - // accordingly. Otherwise it is an error. - for (int i = 0; member_count-- != 0; i++) - { - CORBA::Any_ptr member_label = - tc->member_label (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // do the matching - CORBA::TypeCode_var type = member_label->type (); - CORBA::ULong kind = type->kind (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - switch (kind) - { - case CORBA::tk_short: - { - CORBA::Short s; - *member_label >>= s; - if (s == *(CORBA::Short *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_ushort: - { - CORBA::UShort s; - *member_label >>= s; - if (s == *(CORBA::UShort *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_long: - { - CORBA::Long l; - *member_label >>= l; - if (l == *(CORBA::Long *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_ulong: - { - CORBA::ULong l; - *member_label >>= l; - if (l == *(CORBA::ULong *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_enum: - { - CORBA::ULong ul; - TAO_InputCDR stream (member_label->_tao_get_cdr (), - member_label->_tao_byte_order ()); - (void)stream.decode (discrim_tc.in (), &ul, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - if (ul == *(CORBA::ULong *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_char: - { - CORBA::Char c; - *member_label >>= CORBA::Any::to_char (c); - if (c == *(CORBA::Char *) discrim_val) - discrim_matched = 1; - } - break; - - case CORBA::tk_wchar: - CORBA::WChar wc; - *member_label >>= CORBA::Any::to_wchar (wc); - if (wc == *(CORBA::WChar *) discrim_val) - discrim_matched = 1; - break; - - case CORBA::tk_boolean: - { - CORBA::Boolean b; - *member_label >>= CORBA::Any::to_boolean (b); - if (b == *(CORBA::Boolean *) discrim_val) - discrim_matched = 1; - } - break; - - default: - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "Union::encode - " - "Bad discriminant type\n")); - ACE_THROW_RETURN (CORBA::BAD_TYPECODE (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); - }// end of switch - - // get the member typecode - CORBA::TypeCode_var member_tc = - tc->member_type (i, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (default_index >= 0 && default_index-- == 0) - { - // have we reached the default label?, if so, - // save a handle to the typecode for the default - default_tc = member_tc.in (); - } - if (discrim_matched) - { - member_val = base_union->_access (0); - // marshal according to the matched typecode - - if (member_tc->kind () == CORBA::tk_objref) - { - // we know that the object pointer is stored in a - // TAO_Object_Field_T parametrized type - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - member_val); - CORBA::Object_ptr ptr = field->_upcast (); - return stream->encode (member_tc.in (), &ptr, data2, ACE_TRY_ENV); - } - else - { - return stream->encode (member_tc.in (), member_val, - data2, ACE_TRY_ENV); - } - } - } - // we are here only if there was no match - if (default_tc) - { - member_val = base_union->_access (0); - if (default_tc->kind () == CORBA::tk_objref) - { - // we know that the object pointer is stored in a - // TAO_Object_Field_T parametrized type - TAO_Object_Field_Class* field = - ACE_reinterpret_cast (TAO_Object_Field_Class *, - member_val); - CORBA::Object_ptr ptr = field->_upcast (); - return stream->encode (default_tc, &ptr, data2, ACE_TRY_ENV); - } - else - { - return stream->encode (default_tc, member_val, - data2, ACE_TRY_ENV); - } - } - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "Union::encode - failed. " - "No match and no default case\n")); - - ACE_THROW_RETURN (CORBA::MARSHAL (), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// encode string -CORBA::TypeCode::traverse_status -TAO_Marshal_String::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - char * str = *(char**) data; - - // Verify string satisfies bounds requirements. We're not so - // permissive as to send messages violating the interface spec - // by having excessively long strings! - CORBA::ULong bounds = tc->length (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - if (str != 0) - { - CORBA::ULong length = ACE_OS::strlen (str); - if (bounds == 0 || bounds >= length) - if (stream->write_string (length, str)) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - else - { - if (stream->write_string (0, 0)) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - return CORBA::TypeCode::TRAVERSE_STOP; -} - -// encode sequence -CORBA::TypeCode::traverse_status -TAO_Marshal_Sequence::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_encoding = 1; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - TAO_Base_Sequence *seq = (TAO_Base_Sequence *)data; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; // return status - CORBA::TypeCode_var tc2; // typecode of the element - size_t size; // size of element - CORBA::ULong len = seq ? seq->length_ : 0; - char *value; - - // First marshal the sequence length, verifying that it's within the - // sequence bounds ... - - if (len > 0) - { - // retrieve the bounds of the sequence - CORBA::ULong bounds = tc->length (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // encode only if it is an unbounded sequence or if length is - // less/equal to the bounds - if (bounds == 0 || len <= bounds) - { - // We just encode the current elements in the sequence - bounds = len; - continue_encoding = stream->write_ulong (bounds); - if (continue_encoding && bounds != 0) - { - // get element typecode - tc2 = tc->content_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = tc2->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - value = (char *) seq->buffer_; - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_encoding = continue_encoding && - stream->write_short_array - ((CORBA::Short*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_long_array - ((CORBA::Long*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_longlong_array - ((CORBA::LongLong*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_boolean: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_boolean_array - ((CORBA::Boolean*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_char: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_char_array - ((CORBA::Char*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_octet: -#if !defined (TAO_NO_COPY_OCTET_SEQUENCES) - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_octet_array - ((CORBA::Octet*)value, bounds); -#else - { - TAO_Unbounded_Sequence<CORBA::Octet> *oseq = - ACE_dynamic_cast(TAO_Unbounded_Sequence<CORBA::Octet>*,seq); - if (oseq->mb_ == 0) - { - continue_encoding = continue_encoding && - stream->write_octet_array - ((CORBA::Octet*)value, bounds); - } - else - { - continue_encoding = continue_encoding && - stream->write_octet_array_mb (oseq->mb ()); - } - } -#endif /* TAO_NO_COPY_OCTET_SEQUENCES */ - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_longdouble: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_longdouble_array - ((CORBA::LongDouble*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_wchar: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_wchar_array - ((CORBA::WChar*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - // handle all aggregate types here - - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_string: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_wstring: - // For those aggregate types whose size - // is constant, we compute it only once - while (bounds-- && retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - retval = stream->encode (tc2.in (), value, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - value += size; - } - // CORBA::release (tc2); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_objref: - { - size = sizeof (CORBA_Object_ptr); - while (bounds-- && - retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - CORBA_Object_ptr ptr = - seq->_upcast (value); - retval = stream->encode (tc2.in (), &ptr, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - value += size; - } - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - return retval; - } - break; - - default: - break; - } // end of switch - } // seq length not 0 - } // within bounds or unbounded - } // length is > 0 - else - { - // length is 0, encode it - continue_encoding = stream->write_ulong (len); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - } - - // If an error was detected but no exception was raised then raise a - // marshal exception. - ACE_THROW_RETURN (CORBA::MARSHAL (), - CORBA::TypeCode::TRAVERSE_STOP); -} - -// encode array -CORBA::TypeCode::traverse_status -TAO_Marshal_Array::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::Boolean continue_encoding = 1; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; // return status - size_t size; // size of element - CORBA::ULong bounds; - char *value = (char *) data; - - // retrieve the bounds of the array - bounds = tc->length (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // get element typecode. - CORBA::TypeCode_var tc2 = tc->content_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - size = tc2->size (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_encoding = continue_encoding && - stream->write_short_array - ((CORBA::Short*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_long_array - ((CORBA::Long*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_longlong_array - ((CORBA::LongLong*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_boolean: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_boolean_array - ((CORBA::Boolean*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_char: - case CORBA::tk_octet: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_octet_array - ((CORBA::Octet*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_longdouble: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_longdouble_array - ((CORBA::LongDouble*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_wchar: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_wchar_array - ((CORBA::WChar*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - - case CORBA::tk_enum: - // For primitives, compute the size only once - continue_encoding = continue_encoding && - stream->write_long_array - ((CORBA::Long*)value, bounds); - if (continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - // handle all aggregate types here - - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_string: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_wstring: - // For those aggregate types whose size is constant, we - // compute it only once - while (bounds-- && retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - { - retval = stream->encode (tc2.in (), value, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - value += size; - } - // CORBA::release (tc2); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - break; - default: - break; - } // end of switch - - // error exit - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_Sequence::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (), - CORBA::TypeCode::TRAVERSE_STOP); -} - -CORBA::TypeCode::traverse_status -TAO_Marshal_Alias::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::TypeCode_var tc2; // typecode of the aliased type - CORBA::Boolean continue_encoding = 1; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - CORBA::TypeCode::traverse_status retval = - CORBA::TypeCode::TRAVERSE_CONTINUE; // status of encode operation - char *value = (char *) data; - - tc2 = tc->content_type (ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - - // switch on the data type and handle the cases for primitives here for - // efficiency rather than calling - switch (tc2->kind_) - { - case CORBA::tk_null: - case CORBA::tk_void: - break; - case CORBA::tk_short: - case CORBA::tk_ushort: - continue_encoding = stream->write_short (*(CORBA::Short *) value); - break; - case CORBA::tk_long: - case CORBA::tk_ulong: - case CORBA::tk_float: - case CORBA::tk_enum: - continue_encoding = stream->write_long (*(CORBA::Long *) value); - break; - case CORBA::tk_double: - case CORBA::tk_longlong: - case CORBA::tk_ulonglong: - continue_encoding = stream->write_longlong (*(CORBA::LongLong *) value); - break; - case CORBA::tk_boolean: - continue_encoding = stream->write_boolean (*(CORBA::Boolean *) value); - break; - case CORBA::tk_char: - case CORBA::tk_octet: - continue_encoding = stream->write_char (*(CORBA::Char *) value); - break; - case CORBA::tk_longdouble: - continue_encoding = stream->write_longdouble (*(CORBA::LongDouble *) value); - break; - case CORBA::tk_wchar: - continue_encoding = stream->write_wchar (*(CORBA::WChar *) value); - break; - case CORBA::tk_any: - case CORBA::tk_TypeCode: - case CORBA::tk_Principal: - case CORBA::tk_objref: - case CORBA::tk_struct: - case CORBA::tk_union: - case CORBA::tk_string: - case CORBA::tk_sequence: - case CORBA::tk_array: - case CORBA::tk_alias: - case CORBA::tk_except: - case CORBA::tk_wstring: - retval = stream->encode (tc2.in (), data, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::TypeCode::TRAVERSE_STOP); - break; - default: - // anything else is an error - retval = CORBA::TypeCode::TRAVERSE_STOP; - } - - // tc2->_decr_refcnt (); - if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE - && continue_encoding == 1) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - "TAO_Marshal_Alias::encode detected error\n")); - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); -} - - -// encode exception -CORBA::TypeCode::traverse_status -TAO_Marshal_Except::encode (CORBA::TypeCode_ptr, - const void *, - const void *, - void *, - CORBA::Environment &ACE_TRY_ENV) -{ - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE), - CORBA::TypeCode::TRAVERSE_STOP); -} - - -// encode wstring -CORBA::TypeCode::traverse_status -TAO_Marshal_WString::encode (CORBA::TypeCode_ptr tc, - const void *data, - const void *, - void *context, - CORBA::Environment &ACE_TRY_ENV) -{ - CORBA::WChar *str = *(CORBA::WChar **) data; - TAO_OutputCDR *stream = (TAO_OutputCDR *) context; - - // Verify string satisfies bounds requirements. We're not so - // permissive as to send messages violating the interface spec - // by having excessively long strings! - CORBA::ULong bounds = tc->length (ACE_TRY_ENV); - - if (str != 0) - { - // get the actual length of the string - CORBA::ULong len = ACE_OS::wslen ((CORBA::WChar *) str); - - // if it is an unbounded string or if the length is less than the - // bounds for an unbounded string - if (bounds == 0 || len <= bounds) - if (stream->write_wstring (len, str)) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - else - { - if (stream->write_wstring (0, 0)) - return CORBA::TypeCode::TRAVERSE_CONTINUE; - } - return CORBA::TypeCode::TRAVERSE_STOP; -} diff --git a/TAO/tests/Param_Test/Makefile b/TAO/tests/Param_Test/Makefile index 512adb688c2..333e6972b1c 100644 --- a/TAO/tests/Param_Test/Makefile +++ b/TAO/tests/Param_Test/Makefile @@ -13186,4 +13186,560 @@ endif # ! ACE_HAS_GNUG_PRE_2_8 $(TAO_ROOT)/tao/BoundsC.i \ param_testCli.i complex_any.h +.obj/param_testCli.o .obj/param_testCli.so .shobj/param_testCli.o .shobj/param_testCli.so: param_testCli.cpp param_testCli.h \ + $(TAO_ROOT)/tao/corba.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/Min_Max.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/Log_Record.i \ + $(TAO_ROOT)/tao/corbafwd.h \ + $(ACE_ROOT)/ace/CDR_Stream.h \ + $(ACE_ROOT)/ace/Message_Block.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Based_Pointer_T.h \ + $(ACE_ROOT)/ace/Based_Pointer_T.i \ + $(ACE_ROOT)/ace/Based_Pointer_T.cpp \ + $(ACE_ROOT)/ace/Based_Pointer_Repository.h \ + $(ACE_ROOT)/ace/Singleton.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Singleton.i \ + $(ACE_ROOT)/ace/Singleton.cpp \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Message_Block.i \ + $(ACE_ROOT)/ace/Message_Block_T.h \ + $(ACE_ROOT)/ace/Message_Block_T.i \ + $(ACE_ROOT)/ace/Message_Block_T.cpp \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/CDR_Stream.i \ + $(TAO_ROOT)/tao/try_macros.h \ + $(TAO_ROOT)/tao/orbconf.h \ + $(ACE_ROOT)/ace/CORBA_macros.h \ + $(TAO_ROOT)/tao/corbafwd.i \ + $(TAO_ROOT)/tao/Environment.h \ + $(TAO_ROOT)/tao/Environment.i \ + $(TAO_ROOT)/tao/ORB.h \ + $(TAO_ROOT)/tao/Exception.h \ + $(TAO_ROOT)/tao/Exception.i \ + $(TAO_ROOT)/tao/IOR_LookupTable.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager.h \ + $(ACE_ROOT)/ace/Functor.h \ + $(ACE_ROOT)/ace/Functor.i \ + $(ACE_ROOT)/ace/Functor_T.h \ + $(ACE_ROOT)/ace/Functor_T.i \ + $(ACE_ROOT)/ace/Functor_T.cpp \ + $(ACE_ROOT)/ace/Hash_Map_Manager.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Service_Config.h \ + $(ACE_ROOT)/ace/Service_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.i \ + $(ACE_ROOT)/ace/Service_Object.i \ + $(ACE_ROOT)/ace/Service_Config.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h \ + $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ + $(TAO_ROOT)/tao/Services.h \ + $(TAO_ROOT)/tao/Sequence.h \ + $(TAO_ROOT)/tao/Managed_Types.h \ + $(TAO_ROOT)/tao/Managed_Types.i \ + $(TAO_ROOT)/tao/Sequence.i \ + $(TAO_ROOT)/tao/Sequence_T.h \ + $(TAO_ROOT)/tao/Sequence_T.i \ + $(TAO_ROOT)/tao/Sequence_T.cpp \ + $(TAO_ROOT)/tao/varout.h \ + $(TAO_ROOT)/tao/Object.h \ + $(TAO_ROOT)/tao/Object.i \ + $(TAO_ROOT)/tao/varout.i \ + $(TAO_ROOT)/tao/varout.cpp \ + $(TAO_ROOT)/tao/Services.i \ + $(TAO_ROOT)/tao/IORManipulation.h \ + $(TAO_ROOT)/tao/IORS.h \ + $(TAO_ROOT)/tao/IORC.h \ + $(TAO_ROOT)/tao/CDR.h \ + $(TAO_ROOT)/tao/Typecode.h \ + $(TAO_ROOT)/tao/Typecode.i \ + $(TAO_ROOT)/tao/CDR.i \ + $(TAO_ROOT)/tao/IORC.i \ + $(TAO_ROOT)/tao/Servant_Base.h \ + $(TAO_ROOT)/tao/POAC.h \ + $(TAO_ROOT)/tao/PolicyC.h \ + $(TAO_ROOT)/tao/CurrentC.h \ + $(TAO_ROOT)/tao/CurrentC.i \ + $(TAO_ROOT)/tao/PolicyC.i \ + $(TAO_ROOT)/tao/POAC.i \ + $(TAO_ROOT)/tao/Servant_Base.i \ + $(TAO_ROOT)/tao/IORS.i \ + $(TAO_ROOT)/tao/Interceptor.h \ + $(TAO_ROOT)/tao/InterceptorS.h \ + $(TAO_ROOT)/tao/InterceptorC.h \ + $(TAO_ROOT)/tao/IOPC.h \ + $(TAO_ROOT)/tao/IOPC.i \ + $(TAO_ROOT)/tao/Any.h \ + $(TAO_ROOT)/tao/Any.i \ + $(TAO_ROOT)/tao/InterceptorC.i \ + $(TAO_ROOT)/tao/Interceptor.i \ + $(TAO_ROOT)/tao/ORB.i \ + $(TAO_ROOT)/tao/NVList.h \ + $(TAO_ROOT)/tao/NVList.i \ + $(TAO_ROOT)/tao/Principal.h \ + $(TAO_ROOT)/tao/Principal.i \ + $(TAO_ROOT)/tao/Request.h \ + $(TAO_ROOT)/tao/Context.h \ + $(TAO_ROOT)/tao/Context.i \ + $(TAO_ROOT)/tao/MessagingC.h \ + $(TAO_ROOT)/tao/TimeBaseC.h \ + $(TAO_ROOT)/tao/TimeBaseC.i \ + $(TAO_ROOT)/tao/PollableC.h \ + $(TAO_ROOT)/tao/MessagingC.i \ + $(TAO_ROOT)/tao/Request.i \ + $(TAO_ROOT)/tao/Server_Request.h \ + $(TAO_ROOT)/tao/Object_KeyC.h \ + $(TAO_ROOT)/tao/Object_KeyC.i \ + $(TAO_ROOT)/tao/GIOP.h \ + $(TAO_ROOT)/tao/GIOP.i \ + $(TAO_ROOT)/tao/Server_Request.i \ + $(TAO_ROOT)/tao/Marshal.h \ + $(TAO_ROOT)/tao/Marshal.i \ + $(TAO_ROOT)/tao/singletons.h \ + $(TAO_ROOT)/tao/POA.h \ + $(TAO_ROOT)/tao/Object_Adapter.h \ + $(TAO_ROOT)/tao/Key_Adapters.h \ + $(ACE_ROOT)/ace/Map.h \ + $(ACE_ROOT)/ace/Map.i \ + $(ACE_ROOT)/ace/Map_T.h \ + $(ACE_ROOT)/ace/Pair.h \ + $(ACE_ROOT)/ace/Pair.i \ + $(ACE_ROOT)/ace/Pair_T.h \ + $(ACE_ROOT)/ace/Pair_T.i \ + $(ACE_ROOT)/ace/Pair_T.cpp \ + $(ACE_ROOT)/ace/Map_Manager.h \ + $(ACE_ROOT)/ace/Map_Manager.i \ + $(ACE_ROOT)/ace/Map_Manager.cpp \ + $(ACE_ROOT)/ace/Active_Map_Manager.h \ + $(ACE_ROOT)/ace/Active_Map_Manager.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Map_T.i \ + $(ACE_ROOT)/ace/Map_T.cpp \ + $(TAO_ROOT)/tao/Key_Adapters.i \ + $(TAO_ROOT)/tao/Server_Strategy_Factory.h \ + $(TAO_ROOT)/tao/poa_macros.h \ + $(TAO_ROOT)/tao/POAS.h \ + $(TAO_ROOT)/tao/POA_CORBA.h \ + $(TAO_ROOT)/tao/DynAnyC.h \ + $(TAO_ROOT)/tao/DynAnyC.i \ + $(TAO_ROOT)/tao/DomainC.h \ + $(TAO_ROOT)/tao/DomainC.i \ + $(TAO_ROOT)/tao/POAS.i \ + $(TAO_ROOT)/tao/Active_Object_Map.h \ + $(TAO_ROOT)/tao/Active_Object_Map.i \ + $(TAO_ROOT)/tao/Object_Adapter.i \ + $(TAO_ROOT)/tao/POAManager.h \ + $(TAO_ROOT)/tao/POAManager.i \ + $(TAO_ROOT)/tao/ImplRepoC.h \ + $(TAO_ROOT)/tao/Operation_Table.h \ + $(TAO_ROOT)/tao/Stub.h \ + $(TAO_ROOT)/tao/Pluggable.h \ + $(ACE_ROOT)/ace/Message_Queue.h \ + $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ + $(ACE_ROOT)/ace/Message_Queue_T.h \ + $(ACE_ROOT)/ace/Message_Queue_T.i \ + $(ACE_ROOT)/ace/Message_Queue_T.cpp \ + $(ACE_ROOT)/ace/Strategies.h \ + $(ACE_ROOT)/ace/Strategies_T.h \ + $(ACE_ROOT)/ace/Synch_Options.h \ + $(ACE_ROOT)/ace/Synch_Options.i \ + $(ACE_ROOT)/ace/Thread_Manager.h \ + $(ACE_ROOT)/ace/Thread_Manager.i \ + $(ACE_ROOT)/ace/Strategies_T.i \ + $(ACE_ROOT)/ace/Strategies_T.cpp \ + $(ACE_ROOT)/ace/Service_Repository.h \ + $(ACE_ROOT)/ace/Service_Types.h \ + $(ACE_ROOT)/ace/Service_Types.i \ + $(ACE_ROOT)/ace/Service_Repository.i \ + $(ACE_ROOT)/ace/WFMO_Reactor.h \ + $(ACE_ROOT)/ace/WFMO_Reactor.i \ + $(ACE_ROOT)/ace/Strategies.i \ + $(ACE_ROOT)/ace/Message_Queue.i \ + $(TAO_ROOT)/tao/Pluggable.i \ + $(TAO_ROOT)/tao/MProfile.h \ + $(TAO_ROOT)/tao/Profile.h \ + $(TAO_ROOT)/tao/Tagged_Components.h \ + $(TAO_ROOT)/tao/CONV_FRAMEC.h \ + $(TAO_ROOT)/tao/CONV_FRAMEC.i \ + $(TAO_ROOT)/tao/Tagged_Components.i \ + $(TAO_ROOT)/tao/Profile.i \ + $(TAO_ROOT)/tao/MProfile.i \ + $(TAO_ROOT)/tao/Stub.i \ + $(TAO_ROOT)/tao/ORB_Core.h \ + $(TAO_ROOT)/tao/Policy_Manager.h \ + $(TAO_ROOT)/tao/Policy_Manager.i \ + $(TAO_ROOT)/tao/Resource_Factory.h \ + $(TAO_ROOT)/tao/Protocol_Factory.h \ + $(TAO_ROOT)/tao/params.h \ + $(TAO_ROOT)/tao/params.i \ + $(TAO_ROOT)/tao/ORB_Core.i \ + $(ACE_ROOT)/ace/Dynamic_Service.h \ + $(ACE_ROOT)/ace/Dynamic_Service.cpp \ + $(TAO_ROOT)/tao/Invocation.h \ + $(TAO_ROOT)/tao/Reply_Dispatcher.h \ + $(TAO_ROOT)/tao/Reply_Dispatcher.i \ + $(TAO_ROOT)/tao/TAOC.h \ + $(TAO_ROOT)/tao/TAOC.i \ + $(TAO_ROOT)/tao/Invocation.i \ + $(TAO_ROOT)/tao/ImplRepoC.i \ + $(TAO_ROOT)/tao/POA.i \ + $(TAO_ROOT)/tao/debug.h \ + $(TAO_ROOT)/tao/Client_Strategy_Factory.h \ + $(TAO_ROOT)/tao/InconsistentTypeCodeC.h \ + $(TAO_ROOT)/tao/DynAny_i.h \ + $(TAO_ROOT)/tao/Union.h \ + $(TAO_ROOT)/tao/ValueBase.h \ + $(TAO_ROOT)/tao/ValueBase.i \ + $(TAO_ROOT)/tao/ValueFactory.h \ + $(TAO_ROOT)/tao/ValueFactory.i \ + $(TAO_ROOT)/tao/ObjectIDList.h \ + $(TAO_ROOT)/tao/ObjectIDList.i \ + $(TAO_ROOT)/tao/WrongTransactionC.h \ + $(TAO_ROOT)/tao/InterfaceC.h \ + $(TAO_ROOT)/tao/BoundsC.h \ + $(TAO_ROOT)/tao/BoundsC.i \ + param_testCli.i + +.obj/anyop.o .obj/anyop.so .shobj/anyop.o .shobj/anyop.so: anyop.cpp param_testCli.h \ + $(TAO_ROOT)/tao/corba.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/Min_Max.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/Log_Record.i \ + $(TAO_ROOT)/tao/corbafwd.h \ + $(ACE_ROOT)/ace/CDR_Stream.h \ + $(ACE_ROOT)/ace/Message_Block.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Based_Pointer_T.h \ + $(ACE_ROOT)/ace/Based_Pointer_T.i \ + $(ACE_ROOT)/ace/Based_Pointer_T.cpp \ + $(ACE_ROOT)/ace/Based_Pointer_Repository.h \ + $(ACE_ROOT)/ace/Singleton.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Singleton.i \ + $(ACE_ROOT)/ace/Singleton.cpp \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Message_Block.i \ + $(ACE_ROOT)/ace/Message_Block_T.h \ + $(ACE_ROOT)/ace/Message_Block_T.i \ + $(ACE_ROOT)/ace/Message_Block_T.cpp \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/CDR_Stream.i \ + $(TAO_ROOT)/tao/try_macros.h \ + $(TAO_ROOT)/tao/orbconf.h \ + $(ACE_ROOT)/ace/CORBA_macros.h \ + $(TAO_ROOT)/tao/corbafwd.i \ + $(TAO_ROOT)/tao/Environment.h \ + $(TAO_ROOT)/tao/Environment.i \ + $(TAO_ROOT)/tao/ORB.h \ + $(TAO_ROOT)/tao/Exception.h \ + $(TAO_ROOT)/tao/Exception.i \ + $(TAO_ROOT)/tao/IOR_LookupTable.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager.h \ + $(ACE_ROOT)/ace/Functor.h \ + $(ACE_ROOT)/ace/Functor.i \ + $(ACE_ROOT)/ace/Functor_T.h \ + $(ACE_ROOT)/ace/Functor_T.i \ + $(ACE_ROOT)/ace/Functor_T.cpp \ + $(ACE_ROOT)/ace/Hash_Map_Manager.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Service_Config.h \ + $(ACE_ROOT)/ace/Service_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.i \ + $(ACE_ROOT)/ace/Service_Object.i \ + $(ACE_ROOT)/ace/Service_Config.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h \ + $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ + $(TAO_ROOT)/tao/Services.h \ + $(TAO_ROOT)/tao/Sequence.h \ + $(TAO_ROOT)/tao/Managed_Types.h \ + $(TAO_ROOT)/tao/Managed_Types.i \ + $(TAO_ROOT)/tao/Sequence.i \ + $(TAO_ROOT)/tao/Sequence_T.h \ + $(TAO_ROOT)/tao/Sequence_T.i \ + $(TAO_ROOT)/tao/Sequence_T.cpp \ + $(TAO_ROOT)/tao/varout.h \ + $(TAO_ROOT)/tao/Object.h \ + $(TAO_ROOT)/tao/Object.i \ + $(TAO_ROOT)/tao/varout.i \ + $(TAO_ROOT)/tao/varout.cpp \ + $(TAO_ROOT)/tao/Services.i \ + $(TAO_ROOT)/tao/IORManipulation.h \ + $(TAO_ROOT)/tao/IORS.h \ + $(TAO_ROOT)/tao/IORC.h \ + $(TAO_ROOT)/tao/CDR.h \ + $(TAO_ROOT)/tao/Typecode.h \ + $(TAO_ROOT)/tao/Typecode.i \ + $(TAO_ROOT)/tao/CDR.i \ + $(TAO_ROOT)/tao/IORC.i \ + $(TAO_ROOT)/tao/Servant_Base.h \ + $(TAO_ROOT)/tao/POAC.h \ + $(TAO_ROOT)/tao/PolicyC.h \ + $(TAO_ROOT)/tao/CurrentC.h \ + $(TAO_ROOT)/tao/CurrentC.i \ + $(TAO_ROOT)/tao/PolicyC.i \ + $(TAO_ROOT)/tao/POAC.i \ + $(TAO_ROOT)/tao/Servant_Base.i \ + $(TAO_ROOT)/tao/IORS.i \ + $(TAO_ROOT)/tao/Interceptor.h \ + $(TAO_ROOT)/tao/InterceptorS.h \ + $(TAO_ROOT)/tao/InterceptorC.h \ + $(TAO_ROOT)/tao/IOPC.h \ + $(TAO_ROOT)/tao/IOPC.i \ + $(TAO_ROOT)/tao/Any.h \ + $(TAO_ROOT)/tao/Any.i \ + $(TAO_ROOT)/tao/InterceptorC.i \ + $(TAO_ROOT)/tao/Interceptor.i \ + $(TAO_ROOT)/tao/ORB.i \ + $(TAO_ROOT)/tao/NVList.h \ + $(TAO_ROOT)/tao/NVList.i \ + $(TAO_ROOT)/tao/Principal.h \ + $(TAO_ROOT)/tao/Principal.i \ + $(TAO_ROOT)/tao/Request.h \ + $(TAO_ROOT)/tao/Context.h \ + $(TAO_ROOT)/tao/Context.i \ + $(TAO_ROOT)/tao/MessagingC.h \ + $(TAO_ROOT)/tao/TimeBaseC.h \ + $(TAO_ROOT)/tao/TimeBaseC.i \ + $(TAO_ROOT)/tao/PollableC.h \ + $(TAO_ROOT)/tao/MessagingC.i \ + $(TAO_ROOT)/tao/Request.i \ + $(TAO_ROOT)/tao/Server_Request.h \ + $(TAO_ROOT)/tao/Object_KeyC.h \ + $(TAO_ROOT)/tao/Object_KeyC.i \ + $(TAO_ROOT)/tao/GIOP.h \ + $(TAO_ROOT)/tao/GIOP.i \ + $(TAO_ROOT)/tao/Server_Request.i \ + $(TAO_ROOT)/tao/Marshal.h \ + $(TAO_ROOT)/tao/Marshal.i \ + $(TAO_ROOT)/tao/singletons.h \ + $(TAO_ROOT)/tao/POA.h \ + $(TAO_ROOT)/tao/Object_Adapter.h \ + $(TAO_ROOT)/tao/Key_Adapters.h \ + $(ACE_ROOT)/ace/Map.h \ + $(ACE_ROOT)/ace/Map.i \ + $(ACE_ROOT)/ace/Map_T.h \ + $(ACE_ROOT)/ace/Pair.h \ + $(ACE_ROOT)/ace/Pair.i \ + $(ACE_ROOT)/ace/Pair_T.h \ + $(ACE_ROOT)/ace/Pair_T.i \ + $(ACE_ROOT)/ace/Pair_T.cpp \ + $(ACE_ROOT)/ace/Map_Manager.h \ + $(ACE_ROOT)/ace/Map_Manager.i \ + $(ACE_ROOT)/ace/Map_Manager.cpp \ + $(ACE_ROOT)/ace/Active_Map_Manager.h \ + $(ACE_ROOT)/ace/Active_Map_Manager.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Map_T.i \ + $(ACE_ROOT)/ace/Map_T.cpp \ + $(TAO_ROOT)/tao/Key_Adapters.i \ + $(TAO_ROOT)/tao/Server_Strategy_Factory.h \ + $(TAO_ROOT)/tao/poa_macros.h \ + $(TAO_ROOT)/tao/POAS.h \ + $(TAO_ROOT)/tao/POA_CORBA.h \ + $(TAO_ROOT)/tao/DynAnyC.h \ + $(TAO_ROOT)/tao/DynAnyC.i \ + $(TAO_ROOT)/tao/DomainC.h \ + $(TAO_ROOT)/tao/DomainC.i \ + $(TAO_ROOT)/tao/POAS.i \ + $(TAO_ROOT)/tao/Active_Object_Map.h \ + $(TAO_ROOT)/tao/Active_Object_Map.i \ + $(TAO_ROOT)/tao/Object_Adapter.i \ + $(TAO_ROOT)/tao/POAManager.h \ + $(TAO_ROOT)/tao/POAManager.i \ + $(TAO_ROOT)/tao/ImplRepoC.h \ + $(TAO_ROOT)/tao/Operation_Table.h \ + $(TAO_ROOT)/tao/Stub.h \ + $(TAO_ROOT)/tao/Pluggable.h \ + $(ACE_ROOT)/ace/Message_Queue.h \ + $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ + $(ACE_ROOT)/ace/Message_Queue_T.h \ + $(ACE_ROOT)/ace/Message_Queue_T.i \ + $(ACE_ROOT)/ace/Message_Queue_T.cpp \ + $(ACE_ROOT)/ace/Strategies.h \ + $(ACE_ROOT)/ace/Strategies_T.h \ + $(ACE_ROOT)/ace/Synch_Options.h \ + $(ACE_ROOT)/ace/Synch_Options.i \ + $(ACE_ROOT)/ace/Thread_Manager.h \ + $(ACE_ROOT)/ace/Thread_Manager.i \ + $(ACE_ROOT)/ace/Strategies_T.i \ + $(ACE_ROOT)/ace/Strategies_T.cpp \ + $(ACE_ROOT)/ace/Service_Repository.h \ + $(ACE_ROOT)/ace/Service_Types.h \ + $(ACE_ROOT)/ace/Service_Types.i \ + $(ACE_ROOT)/ace/Service_Repository.i \ + $(ACE_ROOT)/ace/WFMO_Reactor.h \ + $(ACE_ROOT)/ace/WFMO_Reactor.i \ + $(ACE_ROOT)/ace/Strategies.i \ + $(ACE_ROOT)/ace/Message_Queue.i \ + $(TAO_ROOT)/tao/Pluggable.i \ + $(TAO_ROOT)/tao/MProfile.h \ + $(TAO_ROOT)/tao/Profile.h \ + $(TAO_ROOT)/tao/Tagged_Components.h \ + $(TAO_ROOT)/tao/CONV_FRAMEC.h \ + $(TAO_ROOT)/tao/CONV_FRAMEC.i \ + $(TAO_ROOT)/tao/Tagged_Components.i \ + $(TAO_ROOT)/tao/Profile.i \ + $(TAO_ROOT)/tao/MProfile.i \ + $(TAO_ROOT)/tao/Stub.i \ + $(TAO_ROOT)/tao/ORB_Core.h \ + $(TAO_ROOT)/tao/Policy_Manager.h \ + $(TAO_ROOT)/tao/Policy_Manager.i \ + $(TAO_ROOT)/tao/Resource_Factory.h \ + $(TAO_ROOT)/tao/Protocol_Factory.h \ + $(TAO_ROOT)/tao/params.h \ + $(TAO_ROOT)/tao/params.i \ + $(TAO_ROOT)/tao/ORB_Core.i \ + $(ACE_ROOT)/ace/Dynamic_Service.h \ + $(ACE_ROOT)/ace/Dynamic_Service.cpp \ + $(TAO_ROOT)/tao/Invocation.h \ + $(TAO_ROOT)/tao/Reply_Dispatcher.h \ + $(TAO_ROOT)/tao/Reply_Dispatcher.i \ + $(TAO_ROOT)/tao/TAOC.h \ + $(TAO_ROOT)/tao/TAOC.i \ + $(TAO_ROOT)/tao/Invocation.i \ + $(TAO_ROOT)/tao/ImplRepoC.i \ + $(TAO_ROOT)/tao/POA.i \ + $(TAO_ROOT)/tao/debug.h \ + $(TAO_ROOT)/tao/Client_Strategy_Factory.h \ + $(TAO_ROOT)/tao/InconsistentTypeCodeC.h \ + $(TAO_ROOT)/tao/DynAny_i.h \ + $(TAO_ROOT)/tao/Union.h \ + $(TAO_ROOT)/tao/ValueBase.h \ + $(TAO_ROOT)/tao/ValueBase.i \ + $(TAO_ROOT)/tao/ValueFactory.h \ + $(TAO_ROOT)/tao/ValueFactory.i \ + $(TAO_ROOT)/tao/ObjectIDList.h \ + $(TAO_ROOT)/tao/ObjectIDList.i \ + $(TAO_ROOT)/tao/WrongTransactionC.h \ + $(TAO_ROOT)/tao/InterfaceC.h \ + $(TAO_ROOT)/tao/BoundsC.h \ + $(TAO_ROOT)/tao/BoundsC.i \ + param_testCli.i \ + $(ACE_ROOT)/ace/Get_Opt.h \ + $(ACE_ROOT)/ace/Get_Opt.i + # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/tests/Param_Test/any.cpp b/TAO/tests/Param_Test/any.cpp index d6fc87c19e1..6c90d73237c 100644 --- a/TAO/tests/Param_Test/any.cpp +++ b/TAO/tests/Param_Test/any.cpp @@ -266,7 +266,10 @@ CORBA::Boolean Test_Any::check_validity (void) { CORBA::Short short_in, short_inout, short_out, short_ret; - char *str_in, *str_inout, *str_out, *str_ret; + const char *str_in; + const char *str_inout; + const char *str_out; + const char *str_ret; Coffee_ptr obj_in, obj_inout, obj_out, obj_ret; Param_Test::Fixed_Array_forany array_in, array_inout, array_out, array_ret; Param_Test::Bounded_Short_Seq *bdss_in, *bdss_inout, *bdss_out, *bdss_ret; diff --git a/TAO/tests/Param_Test/anyop.cpp b/TAO/tests/Param_Test/anyop.cpp index d059d7eddec..9ae8a0f5c18 100644 --- a/TAO/tests/Param_Test/anyop.cpp +++ b/TAO/tests/Param_Test/anyop.cpp @@ -89,37 +89,49 @@ main (int argc, char *argv[]) { CORBA::Object_var obj = - orb->string_to_object ("iioploc://localhost:12345/TheKey", + orb->string_to_object ("IOR:010000001b00000049444c3a6f6d" + "672e6f72672f506172616d5f54657374" + "3a312e30000001000000000000009000" + "000001010100130000006b656c766172" + "2e6563652e7563692e6564750000e404" + "00003000000014010f004e5550000000" + "130000000001000000006368696c645f" + "706f6100000000000100000070617261" + "6d5f7465737403000000000000000800" + "000001000000004f4154010000001400" + "00000108b54001000100000000000901" + "010000000000004f4154040000000108" + "0000", ACE_TRY_ENV); ACE_TRY_CHECK; - Coffee_var coffee = - Coffee::_unchecked_narrow (obj.in (), + Param_Test_var param_test = + Param_Test::_unchecked_narrow (obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - any <<= coffee.in (); + any <<= param_test.in (); - Coffee_ptr o; + Param_Test_ptr o; if (!(any >>= o)) { ACE_DEBUG ((LM_DEBUG, - "Cannot extract Coffee (oh the horror)\n")); + "Cannot extract Param_Test (oh the horror)\n")); } CORBA::Boolean equiv = - coffee->_is_equivalent (o, ACE_TRY_ENV); + param_test->_is_equivalent (o, ACE_TRY_ENV); ACE_TRY_CHECK; if (!equiv) { ACE_DEBUG ((LM_DEBUG, - "Mismatched Coffee extraction\n")); + "Mismatched Param_Test extraction\n")); } - CORBA::Object_ptr other; - if (!(any >>= CORBA::Any::to_object (other))) + CORBA::Object_var other; + if (!(any >>= CORBA::Any::to_object (other.inout ()))) { ACE_DEBUG ((LM_DEBUG, - "Cannot extract Coffee as Object\n")); + "Cannot extract Param_Test as Object\n")); } } @@ -198,10 +210,10 @@ main (int argc, char *argv[]) } { - char *i = "123"; + const char i[] = "123"; any <<= i; - char * o; + const char *o; if (!(any >>= o) || ACE_OS::strcmp (i, o) != 0) { diff --git a/TAO/tests/Param_Test/bd_wstring.cpp b/TAO/tests/Param_Test/bd_wstring.cpp index ec9cbe4eabb..c69f3c266f7 100644 --- a/TAO/tests/Param_Test/bd_wstring.cpp +++ b/TAO/tests/Param_Test/bd_wstring.cpp @@ -2,174 +2,174 @@ // ============================================================================ // -// = Library -// Tao/Tests/Param_Test +// = LIBRARY +// TAO/tests/Param_Test // -// = Filename -// Bd_Wstring.Cpp +// = FILENAME +// bd_wstring.cpp // -// = Description -// Tests Bounded Wide Strings +// = DESCRIPTION +// tests bounded wide strings // -// = Authors +// = AUTHORS // Jeff Parsons // // ============================================================================ -#Include "Helper.H" -#Include "Bd_Wstring.H" +#include "helper.h" +#include "bd_wstring.h" -Ace_Rcsid(Param_Test, Bd_Wstring, "$id: Bd_Wstring.Cpp,V 1.3 1999/09/17 17:03:22 Parsons Exp $") +ACE_RCSID(Param_Test, bd_wstring, "$Id$") // ************************************************************************ -// Test_Bounded_Wstring +// Test_Bounded_WString // ************************************************************************ -Test_Bounded_Wstring::Test_Bounded_Wstring (Void) - : Opname_ (Corba::String_Dup ("Test_Bounded_Wstring")), - In_ (0), - Inout_ (0), - Out_ (0), - Ret_ (0) +Test_Bounded_WString::Test_Bounded_WString (void) + : opname_ (CORBA::string_dup ("test_bounded_wstring")), + in_ (0), + inout_ (0), + out_ (0), + ret_ (0) { } -Test_Bounded_Wstring::~Test_Bounded_Wstring (Void) +Test_Bounded_WString::~Test_Bounded_WString (void) { - Corba::String_Free (This->Opname_); - Corba::Wstring_Free (This->In_); - Corba::Wstring_Free (This->Inout_); - Corba::Wstring_Free (This->Out_); - Corba::Wstring_Free (This->Ret_); - This->Opname_ = 0; - This->In_ = 0; - This->Inout_ = 0; - This->Out_ = 0; - This->Ret_ = 0; + CORBA::string_free (this->opname_); + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->opname_ = 0; + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; } -Const Char * -Test_Bounded_Wstring::Opname (Void) Const +const char * +Test_Bounded_WString::opname (void) const { - Return This->Opname_; + return this->opname_; } -Void -Test_Bounded_Wstring::Dii_Req_Invoke (Corba::Request *Req, - Corba::Environment &Ace_Try_Env) +void +Test_Bounded_WString::dii_req_invoke (CORBA::Request *req, + CORBA::Environment &ACE_TRY_ENV) { - Req->Add_In_Arg ("S1") <<= Corba::Any::From_Wstring (This->In_, 128); - Req->Add_Inout_Arg ("S2") <<= Corba::Any::From_Wstring (This->Inout_, 128); - Req->Add_Out_Arg ("S3") <<= Corba::Any::From_Wstring (This->Out_, 128); - - Req->Set_Return_Type (Param_Test::_Tc_Short_Wstring); - - Req->Invoke (Ace_Try_Env); - Ace_Check; - - Corba::Wchar *Tmp; - Req->Return_Value () >>= Corba::Any::To_Wstring (Tmp, 128); - This->Ret_ = Corba::Wstring_Dup (Tmp); - - Corba::Namedvalue_Ptr Arg2 = - Req->Arguments ()->Item (1, Ace_Try_Env); - Ace_Check; - *Arg2->Value () >>= Corba::Any::To_Wstring (Tmp, 128); - This->Inout_ = Corba::Wstring_Dup (Tmp); - - Corba::Namedvalue_Ptr Arg3 = - Req->Arguments ()->Item (2, Ace_Try_Env); - Ace_Check; - *Arg3->Value () >>= Corba::Any::To_Wstring (Tmp, 128); - This->Out_ = Corba::Wstring_Dup (Tmp); + req->add_in_arg ("s1") <<= CORBA::Any::from_wstring (this->in_, 128); + req->add_inout_arg ("s2") <<= CORBA::Any::from_wstring (this->inout_, 128); + req->add_out_arg ("s3") <<= CORBA::Any::from_wstring (this->out_, 128); + + req->set_return_type (Param_Test::_tc_short_wstring); + + req->invoke (ACE_TRY_ENV); + ACE_CHECK; + + CORBA::WChar *tmp; + req->return_value () >>= CORBA::Any::to_wstring (tmp, 128); + this->ret_ = CORBA::wstring_dup (tmp); + + CORBA::NamedValue_ptr arg2 = + req->arguments ()->item (1, ACE_TRY_ENV); + ACE_CHECK; + *arg2->value () >>= CORBA::Any::to_wstring (tmp, 128); + this->inout_ = CORBA::wstring_dup (tmp); + + CORBA::NamedValue_ptr arg3 = + req->arguments ()->item (2, ACE_TRY_ENV); + ACE_CHECK; + *arg3->value () >>= CORBA::Any::to_wstring (tmp, 128); + this->out_ = CORBA::wstring_dup (tmp); } -Int -Test_Bounded_Wstring::Init_Parameters (Param_Test_Ptr, - Corba::Environment &) +int +Test_Bounded_WString::init_parameters (Param_Test_ptr, + CORBA::Environment &) { - Generator *Gen = Generator::Instance (); // Value Generator - - // Release Any Previously Occupied Values - Corba::Wstring_Free (This->In_); - Corba::Wstring_Free (This->Inout_); - Corba::Wstring_Free (This->Out_); - Corba::Wstring_Free (This->Ret_); - This->In_ = 0; - This->Inout_ = 0; - This->Out_ = 0; - This->Ret_ = 0; - - This->In_ = Gen->Gen_Wstring (32); - This->Inout_ = Corba::Wstring_Dup (This->In_); - Return 0; + Generator *gen = GENERATOR::instance (); // value generator + + // release any previously occupied values + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->in_ = gen->gen_wstring (32); + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; } -Int -Test_Bounded_Wstring::Reset_Parameters (Void) +int +Test_Bounded_WString::reset_parameters (void) { - // Release Any Previously Occupied Values - Corba::Wstring_Free (This->Inout_); - Corba::Wstring_Free (This->Out_); - Corba::Wstring_Free (This->Ret_); - This->Inout_ = 0; - This->Out_ = 0; - This->Ret_ = 0; - - This->Inout_ = Corba::Wstring_Dup (This->In_); - Return 0; + // release any previously occupied values + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; } -Int -Test_Bounded_Wstring::Run_Sii_Test (Param_Test_Ptr Objref, - Corba::Environment &Ace_Try_Env) +int +Test_Bounded_WString::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &ACE_TRY_ENV) { - Ace_Try + ACE_TRY { - Corba::Wstring_Out Str_Out (This->Out_); + CORBA::WString_out str_out (this->out_); - This->Ret_ = Objref->Test_Bounded_Wstring (This->In_, - This->Inout_, - Str_Out, - Ace_Try_Env); - Ace_Try_Check; + this->ret_ = objref->test_bounded_wstring (this->in_, + this->inout_, + str_out, + ACE_TRY_ENV); + ACE_TRY_CHECK; - Return 0; + return 0; } - Ace_Catchany + ACE_CATCHANY { - Ace_Print_Exception (Ace_Any_Exception, - "Test_Bounded_Wstring::Run_Sii_Test\N"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Bounded_WString::run_sii_test\n"); } - Ace_Endtry; - Return -1; + ACE_ENDTRY; + return -1; } -Corba::Boolean -Test_Bounded_Wstring::Check_Validity (Void) +CORBA::Boolean +Test_Bounded_WString::check_validity (void) { - Corba::Ulong Len = Ace_Os::Wslen (This->In_); + CORBA::ULong len = ACE_OS::wslen (this->in_); - If (!Ace_Os::Wscmp (This->In_, This->Out_) && - !Ace_Os::Wscmp (This->In_, This->Ret_) && - Ace_Os::Wslen (This->Inout_) == 2*Len && - !Ace_Os::Wsncmp (This->In_, This->Inout_, Len) && - !Ace_Os::Wsncmp (This->In_, &This->Inout_[Len], Len)) - Return 1; + if (!ACE_OS::wscmp (this->in_, this->out_) && + !ACE_OS::wscmp (this->in_, this->ret_) && + ACE_OS::wslen (this->inout_) == 2*len && + !ACE_OS::wsncmp (this->in_, this->inout_, len) && + !ACE_OS::wsncmp (this->in_, &this->inout_[len], len)) + return 1; - Return 0; // Otherwise + return 0; // otherwise } -Corba::Boolean -Test_Bounded_Wstring::Check_Validity (Corba::Request_Ptr) +CORBA::Boolean +Test_Bounded_WString::check_validity (CORBA::Request_ptr) { - // No Need To Retrieve Anything Because, For All The Args And - // The Return, We Provided The Memory And We Own It. - Return This->Check_Validity (); + // No need to retrieve anything because, for all the args and + // the return, we provided the memory and we own it. + return this->check_validity (); } -Void -Test_Bounded_Wstring::Print_Values (Void) +void +Test_Bounded_WString::print_values (void) { } diff --git a/TAO/tests/Param_Test/objref.cpp b/TAO/tests/Param_Test/objref.cpp index 63702fdb4da..16336c81869 100644 --- a/TAO/tests/Param_Test/objref.cpp +++ b/TAO/tests/Param_Test/objref.cpp @@ -121,15 +121,6 @@ Test_ObjRef::init_parameters (Param_Test_ptr objref, this->out_ = Coffee::_nil (); this->ret_ = Coffee::_nil (); - // DII - *this->in_courier = ACE_dynamic_cast (CORBA::Object_ptr, - this->in_.in ()); - *this->inout_courier = ACE_dynamic_cast (CORBA::Object_ptr, - this->inout_.in ()); - *this->out_courier = ACE_dynamic_cast (CORBA::Object_ptr, - this->out_.in ()); - *this->ret_courier = ACE_dynamic_cast (CORBA::Object_ptr, - this->ret_.in ()); return 0; } ACE_CATCHANY @@ -211,13 +202,6 @@ Test_ObjRef::check_validity (void) // Environemnt variable ACE_DECLARE_NEW_CORBA_ENV; - //CORBA::Environment env; - - Coffee::Desc_var ret_desc; - const char *in = 0; - const char *out = 0; - const char *inout = 0; - ACE_TRY { if (CORBA::is_nil (this->in_.in ()) @@ -229,21 +213,21 @@ Test_ObjRef::check_validity (void) this->in_->description (ACE_TRY_ENV); ACE_TRY_CHECK; - in = in_desc->name.in (); + const char *in = in_desc->name.in (); Coffee::Desc_var inout_desc = this->inout_->description (ACE_TRY_ENV); ACE_TRY_CHECK; - inout = inout_desc->name.in (); + const char *inout = inout_desc->name.in (); Coffee::Desc_var out_desc = this->out_->description (ACE_TRY_ENV); ACE_TRY_CHECK; - out = out_desc->name.in (); + const char *out = out_desc->name.in (); - ret_desc = this->out_->description (ACE_TRY_ENV); + Coffee::Desc_var ret_desc = this->out_->description (ACE_TRY_ENV); ACE_TRY_CHECK; const char* ret = ret_desc->name.in (); @@ -265,37 +249,9 @@ Test_ObjRef::check_validity (void) } CORBA::Boolean -Test_ObjRef::check_validity (CORBA::Request_ptr /*req*/) +Test_ObjRef::check_validity (CORBA::Request_ptr) { - //ACE_UNUSED_ARG (req); - //CORBA::Environment env; - ACE_DECLARE_NEW_CORBA_ENV; - - // Narrow each checked variable into its _var before - // calling check_validity(). - - ACE_TRY - { - this->inout_ = Coffee::_narrow (*this->inout_courier, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - this->out_ = Coffee::_narrow (*this->out_courier, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - this->ret_ = Coffee::_narrow (*this->ret_courier, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - return this->check_validity (); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "_narrow from DII result"); - } - ACE_ENDTRY; - return 0; + return this->check_validity (); } void diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 5e42830edd3..9b6581bdc54 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -762,7 +762,7 @@ Param_Test_i::test_any (const CORBA::Any &a1, { CORBA::Any *ret; CORBA::Short short_in; - char *str_in; + const char *str_in; Coffee_ptr coffee; Param_Test::Fixed_Array_forany array; Param_Test::Short_Seq_ptr ub_short_sequence; diff --git a/TAO/tests/Param_Test/recursive_union.cpp b/TAO/tests/Param_Test/recursive_union.cpp index bb0310d84ff..fa8ede8eed0 100644 --- a/TAO/tests/Param_Test/recursive_union.cpp +++ b/TAO/tests/Param_Test/recursive_union.cpp @@ -52,7 +52,7 @@ Test_Recursive_Union::dii_req_invoke (CORBA::Request *req, { req->add_in_arg ("s1") <<= this->in_; req->add_inout_arg ("s2") <<= this->inout_.in (); - req->add_out_arg ("s3") <<= this->out_.in (); + req->add_out_arg ("s3") = CORBA::Any (Param_Test::_tc_Recursive_Union); req->set_return_type (Param_Test::_tc_Recursive_Union); @@ -73,7 +73,7 @@ Test_Recursive_Union::dii_req_invoke (CORBA::Request *req, req->arguments ()->item (2, ACE_TRY_ENV); ACE_CHECK; *o3->value () >>= tmp; - this->inout_ = new Param_Test::Recursive_Union (*tmp); + this->out_ = new Param_Test::Recursive_Union (*tmp); } int diff --git a/TAO/tests/Param_Test/typecode.cpp b/TAO/tests/Param_Test/typecode.cpp index 7c725f46137..eab7f742e82 100644 --- a/TAO/tests/Param_Test/typecode.cpp +++ b/TAO/tests/Param_Test/typecode.cpp @@ -89,9 +89,7 @@ Test_TypeCode::init_parameters (Param_Test_ptr, Param_Test::_tc_Nested_Struct }; - Generator *gen = GENERATOR::instance (); // value generator static CORBA::ULong index = 0; - // (CORBA::ULong) (gen->gen_long () % sizeof(tc_table)/sizeof(tc_table[0])); this->tc_holder_ = CORBA::TypeCode::_duplicate (tc_table [index]); this->in_ = this->tc_holder_; diff --git a/TAO/tests/Param_Test/ub_any_seq.cpp b/TAO/tests/Param_Test/ub_any_seq.cpp index dd76733f011..94cd5638ed7 100644 --- a/TAO/tests/Param_Test/ub_any_seq.cpp +++ b/TAO/tests/Param_Test/ub_any_seq.cpp @@ -225,7 +225,10 @@ CORBA::Boolean Test_AnySeq::check_validity (void) { CORBA::Short short_in, short_inout, short_out, short_ret; - char *str_in, *str_inout, *str_out, *str_ret; + const char *str_in; + const char *str_inout; + const char *str_out; + const char *str_ret; Coffee_ptr obj_in, obj_inout, obj_out, obj_ret; for (CORBA::ULong i=0; i < this->in_->length (); i++) diff --git a/TAO/tests/Param_Test/ub_string.cpp b/TAO/tests/Param_Test/ub_string.cpp index 7227810e0ed..411afdcf050 100644 --- a/TAO/tests/Param_Test/ub_string.cpp +++ b/TAO/tests/Param_Test/ub_string.cpp @@ -67,7 +67,7 @@ Test_Unbounded_String::dii_req_invoke (CORBA::Request *req, req->invoke (ACE_TRY_ENV); ACE_CHECK; - char *tmp; + const char *tmp; req->return_value () >>= tmp; this->ret_ = CORBA::string_dup (tmp); diff --git a/TAO/tests/Param_Test/ub_wstring.cpp b/TAO/tests/Param_Test/ub_wstring.cpp index 100a2f9f691..8619e87fdd1 100644 --- a/TAO/tests/Param_Test/ub_wstring.cpp +++ b/TAO/tests/Param_Test/ub_wstring.cpp @@ -67,7 +67,7 @@ Test_Unbounded_WString::dii_req_invoke (CORBA::Request *req, req->invoke (ACE_TRY_ENV); ACE_CHECK; - CORBA::WChar *tmp; + const CORBA::WChar *tmp; req->return_value () >>= tmp; this->ret_ = CORBA::wstring_dup (tmp); |