diff options
Diffstat (limited to 'TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp')
-rw-r--r-- | TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp | 302 |
1 files changed, 112 insertions, 190 deletions
diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp index 769d6760258..3ad634f15a7 100644 --- a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp +++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp @@ -1,38 +1,35 @@ // $Id$ -#include "tao/AnyTypeCode/TypeCode_CDR_Extraction.h" +#include "TypeCode_CDR_Extraction.h" -#include "tao/AnyTypeCode/TypeCode_Constants.h" -#include "tao/AnyTypeCode/True_RefCount_Policy.h" +#include "TypeCode_Constants.h" +#include "True_RefCount_Policy.h" -#include "tao/AnyTypeCode/Alias_TypeCode.h" -#include "tao/AnyTypeCode/Enum_TypeCode.h" -#include "tao/AnyTypeCode/Fixed_TypeCode.h" -#include "tao/AnyTypeCode/Objref_TypeCode.h" -#include "tao/AnyTypeCode/Sequence_TypeCode.h" -#include "tao/AnyTypeCode/String_TypeCode.h" -#include "tao/AnyTypeCode/Struct_TypeCode.h" -#include "tao/AnyTypeCode/Union_TypeCode.h" -#include "tao/AnyTypeCode/Value_TypeCode.h" -#include "tao/AnyTypeCode/Any.h" +#include "Alias_TypeCode.h" +#include "Enum_TypeCode.h" +#include "Fixed_TypeCode.h" +#include "Objref_TypeCode.h" +#include "Sequence_TypeCode.h" +#include "String_TypeCode.h" +#include "Struct_TypeCode.h" +#include "Union_TypeCode.h" +#include "Value_TypeCode.h" -#include "tao/AnyTypeCode/Recursive_Type_TypeCode.h" +#include "Recursive_Type_TypeCode.h" -#include "tao/AnyTypeCode/TypeCode_Case_T.h" -#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" -#include "tao/AnyTypeCode/TypeCode_Value_Field.h" +#include "TypeCode_Case_T.h" +#include "TypeCode_Struct_Field.h" +#include "TypeCode_Value_Field.h" #include "tao/CDR.h" #include "ace/Array_Base.h" -#include "ace/Value_Ptr.h" ACE_RCSID (tao, TypeCode_CDR_Extraction, "$Id$") -TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { @@ -105,7 +102,7 @@ namespace TAO::TypeCodeFactory::TC_Info_List & infos); bool find_recursive_tc (char const * id, - TAO::TypeCodeFactory::TC_Info_List & tcs, + CORBA::TypeCode_ptr & tc, TAO::TypeCodeFactory::TC_Info_List & infos) { // See comments above for rationale behind using an array instead @@ -119,18 +116,12 @@ namespace if (ACE_OS::strcmp (info.id, id) == 0) { - // We have a mathing id, so store the typecode in the out array - // and then compare the others. - size_t const old_size = tcs.size (); - if (tcs.size (old_size + 1) == -1) // Incremental growth -- *sigh* - return false; - - TAO::TypeCodeFactory::TC_Info & new_info = tcs[old_size]; - new_info.type = info.type; + tc = info.type; + return true; } } - return (tcs.size () > 0) ; + return false; } } @@ -415,8 +406,7 @@ TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, // Check if struct TypeCode is recursive. - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (kind == CORBA::tk_struct && find_recursive_tc (id.in (), recursive_tc, infos)) + if (kind == CORBA::tk_struct && find_recursive_tc (id.in (), tc, infos)) { // Set remaining parameters. @@ -425,23 +415,14 @@ TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, member_array_type> recursive_typecode_type; - size_t const len = recursive_tc.size (); - - for (size_t i = 0; i < len; ++i) - { - TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; - - recursive_typecode_type * const rtc = - dynamic_cast<recursive_typecode_type *> (info.type); + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (tc); - ACE_ASSERT (rtc); + ACE_ASSERT (rtc); - rtc->struct_parameters (name.in (), - fields, - nfields); - } - - tc = recursive_tc[0].type; + rtc->struct_parameters (name.in (), + fields, + nfields); } else { @@ -512,7 +493,7 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, { elem_type & member = cases[i]; - TAO::TypeCode::Case<CORBA::String_var, CORBA::TypeCode_var> * the_case = 0; + TAO::TypeCode::Case<CORBA::String_var, CORBA::TypeCode_var> * the_case; // Ugly. *sigh* switch (discriminant_kind) @@ -663,9 +644,8 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, case_array_type, TAO::True_RefCount_Policy> typecode_type; - // Check if we have recursive members, this could be multiple - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (find_recursive_tc (id.in (), recursive_tc, infos)) + // Check if union TypeCode is recursive. + if (find_recursive_tc (id.in (), tc, infos)) { // Set remaining parameters. @@ -674,25 +654,16 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, case_array_type> recursive_typecode_type; - size_t const len = recursive_tc.size (); - - for (size_t i = 0; i < len; ++i) - { - TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; - - recursive_typecode_type * const rtc = - dynamic_cast<recursive_typecode_type *> (info.type); + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (tc); - ACE_ASSERT (rtc); + ACE_ASSERT (rtc); - rtc->union_parameters (name.in (), - discriminant_type, - cases, // Will be copied. - ncases, - default_index); - } - - tc = recursive_tc[0].type; + rtc->union_parameters (name.in (), + discriminant_type, + cases, // Will be copied. + ncases, + default_index); } else { @@ -1019,8 +990,7 @@ TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, TAO::True_RefCount_Policy> typecode_type; // Check if valuetype/eventtype TypeCode is recursive. - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (find_recursive_tc (id.in (), recursive_tc, infos)) + if (find_recursive_tc (id.in (), tc, infos)) { // Set remaining parameters. @@ -1029,24 +999,16 @@ TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, member_array_type> recursive_typecode_type; - size_t const len = recursive_tc.size (); - - for (size_t i = 0; i < len; ++i) - { - TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; - - recursive_typecode_type * const rtc = - dynamic_cast<recursive_typecode_type *> (info.type); + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (tc); - ACE_ASSERT (rtc); + ACE_ASSERT (rtc); - rtc->valuetype_parameters (name.in (), - type_modifier, - concrete_base, - fields, // Will be copied. - nfields); - } - tc = recursive_tc[0].type; + rtc->valuetype_parameters (name.in (), + type_modifier, + concrete_base, + fields, // Will be copied. + nfields); } else { @@ -1258,132 +1220,94 @@ namespace // Don't bother demarshaling the rest of the parameters. They will // be handled by the top-level TypeCode demarshaling call. - bool new_tc = false; switch (kind) { case CORBA::tk_struct: { - // Check if we already have a tc for this type, if yes, use that - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (find_recursive_tc (id.in (), recursive_tc, infos)) - { - tc = recursive_tc[0].type; - } - else - { - new_tc = true; - - typedef ACE_Array_Base< - TAO::TypeCode::Struct_Field< - CORBA::String_var, - CORBA::TypeCode_var> > member_array_type; - - typedef TAO::TypeCode::Struct< - CORBA::String_var, - CORBA::TypeCode_var, - member_array_type, - TAO::True_RefCount_Policy> typecode_type; - - typedef TAO::TypeCode::Recursive_Type<typecode_type, - CORBA::TypeCode_var, - member_array_type> - recursive_typecode_type; - - ACE_NEW_RETURN (tc, - recursive_typecode_type (kind, - id.in ()), - false); - } + typedef ACE_Array_Base< + TAO::TypeCode::Struct_Field< + CORBA::String_var, + CORBA::TypeCode_var> > member_array_type; + + typedef TAO::TypeCode::Struct< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); } break; case CORBA::tk_union: { - // Check if we already have a tc for this type, if yes, use that - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (find_recursive_tc (id.in (), recursive_tc, infos)) - { - tc = recursive_tc[0].type; - } - else - { - new_tc = true; - - typedef union_case_array_type member_array_type; - - typedef TAO::TypeCode::Union< - CORBA::String_var, - CORBA::TypeCode_var, - member_array_type, - TAO::True_RefCount_Policy> typecode_type; - - typedef TAO::TypeCode::Recursive_Type<typecode_type, - CORBA::TypeCode_var, - member_array_type> - recursive_typecode_type; - - ACE_NEW_RETURN (tc, - recursive_typecode_type (kind, - id.in ()), - false); - } + typedef union_case_array_type member_array_type; + + typedef TAO::TypeCode::Union< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); } break; case CORBA::tk_value: case CORBA::tk_event: { - // Check if we already have a tc for this type, if yes, use that - TAO::TypeCodeFactory::TC_Info_List recursive_tc; - if (find_recursive_tc (id.in (), recursive_tc, infos)) - { - tc = recursive_tc[0].type; - } - else - { - new_tc = true; - - typedef ACE_Array_Base< - TAO::TypeCode::Value_Field< - CORBA::String_var, - CORBA::TypeCode_var> > member_array_type; - - typedef TAO::TypeCode::Value< - CORBA::String_var, - CORBA::TypeCode_var, - member_array_type, - TAO::True_RefCount_Policy> typecode_type; - - typedef TAO::TypeCode::Recursive_Type<typecode_type, - CORBA::TypeCode_var, - member_array_type> - recursive_typecode_type; - - ACE_NEW_RETURN (tc, - recursive_typecode_type (kind, - id.in ()), - false); - } + typedef ACE_Array_Base< + TAO::TypeCode::Value_Field< + CORBA::String_var, + CORBA::TypeCode_var> > member_array_type; + + typedef TAO::TypeCode::Value< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); } break; default: return false; // We should never get here. }; - // Only when we created a new tc add it to the list. - if (new_tc) - { - size_t const old_size = infos.size (); - if (infos.size (old_size + 1) == -1) // Incremental growth -- *sigh* - return false; + size_t const old_size = infos.size (); + if (infos.size (old_size + 1) == -1) // Incremental growth -- *sigh* + return false; - TAO::TypeCodeFactory::TC_Info & info = infos[old_size]; + TAO::TypeCodeFactory::TC_Info & info = infos[old_size]; - ACE_DECLARE_NEW_CORBA_ENV; - info.id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (false); // Should never throw! + ACE_DECLARE_NEW_CORBA_ENV; + info.id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); // Should never throw! - info.type = tc; - } + info.type = tc; return true; } @@ -1399,5 +1323,3 @@ operator>> (TAO_InputCDR & cdr, return tc_demarshal (cdr, tc, infos); } - -TAO_END_VERSIONED_NAMESPACE_DECL |