summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicAny/DynStruct_i.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/DynamicAny/DynStruct_i.cpp')
-rw-r--r--TAO/tao/DynamicAny/DynStruct_i.cpp108
1 files changed, 48 insertions, 60 deletions
diff --git a/TAO/tao/DynamicAny/DynStruct_i.cpp b/TAO/tao/DynamicAny/DynStruct_i.cpp
index ee75bf1e13b..2cd93ecb739 100644
--- a/TAO/tao/DynamicAny/DynStruct_i.cpp
+++ b/TAO/tao/DynamicAny/DynStruct_i.cpp
@@ -86,26 +86,23 @@ TAO_DynStruct_i::set_from_any (const CORBA::Any & any
this->init_common ();
- // Get the CDR stream of the argument.
- ACE_Message_Block *mb = any._tao_get_cdr ();
- bool type_known = false;
+ // Get the CDR stream of the Any, if there isn't one, make one.
+ TAO::Any_Impl *impl = any.impl ();
+ TAO_OutputCDR out;
+ TAO_InputCDR in (static_cast<ACE_Message_Block *> (0));
+ TAO::Unknown_IDL_Type *unk = 0;
- if (mb == 0)
+ if (impl->encoded ())
{
- ACE_NEW (mb,
- ACE_Message_Block);
- TAO_OutputCDR out;
- any.impl ()->marshal_value (out);
- ACE_CDR::consolidate (mb, out.begin ());
- type_known = true;
+ unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
+
+ in = unk->_tao_get_cdr ();
}
-
- TAO_InputCDR cdr (mb,
- any._tao_byte_order ());
-
- if (type_known)
+ else
{
- mb->release ();
+ impl->marshal_value (out);
+ TAO_InputCDR tmp_in (out);
+ in = tmp_in;
}
// If we have an exception type, unmarshal the repository ID.
@@ -116,7 +113,7 @@ TAO_DynStruct_i::set_from_any (const CORBA::Any & any
if (kind == CORBA::tk_except)
{
CORBA::String_var str;
- cdr >> str.out ();
+ in >> str.out ();
}
for (CORBA::ULong i = 0; i < numfields; i++)
@@ -127,11 +124,9 @@ TAO_DynStruct_i::set_from_any (const CORBA::Any & any
ACE_CHECK;
CORBA::Any field_any;
- TAO::Unknown_IDL_Type *unk = 0;
ACE_NEW (unk,
TAO::Unknown_IDL_Type (field_tc.in (),
- cdr.start (),
- cdr.byte_order ()));
+ TAO_InputCDR (in)));
field_any.replace (unk);
// This recursive step will call the correct constructor
@@ -143,7 +138,7 @@ TAO_DynStruct_i::set_from_any (const CORBA::Any & any
// Move to the next field in the CDR stream.
(void) TAO_Marshal_Object::perform_skip (field_tc.in (),
- &cdr
+ &in
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
@@ -543,26 +538,23 @@ TAO_DynStruct_i::from_any (const CORBA::Any & any
if (equivalent)
{
- // Get the CDR stream of the argument.
- ACE_Message_Block* mb = any._tao_get_cdr ();
- bool type_known = false;
+ // Get the CDR stream of the Any, if there isn't one, make one.
+ TAO::Any_Impl *impl = any.impl ();
+ TAO_OutputCDR out;
+ TAO_InputCDR in (static_cast<ACE_Message_Block *> (0));
+ TAO::Unknown_IDL_Type *unk = 0;
- if (mb == 0)
+ if (impl->encoded ())
{
- ACE_NEW (mb,
- ACE_Message_Block);
- TAO_OutputCDR out;
- any.impl ()->marshal_value (out);
- ACE_CDR::consolidate (mb, out.begin ());
- type_known = true;
+ unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
+
+ in = unk->_tao_get_cdr ();
}
-
- TAO_InputCDR cdr (mb,
- any._tao_byte_order ());
-
- if (type_known)
+ else
{
- mb->release ();
+ impl->marshal_value (out);
+ TAO_InputCDR tmp_in (out);
+ in = tmp_in;
}
// If we have an exception type, unmarshal the repository ID.
@@ -574,7 +566,7 @@ TAO_DynStruct_i::from_any (const CORBA::Any & any
if (kind == CORBA::tk_except)
{
CORBA::String_var str;
- cdr >> str.out ();
+ in >> str.out ();
}
CORBA::TypeCode_var field_tc;
@@ -592,8 +584,7 @@ TAO_DynStruct_i::from_any (const CORBA::Any & any
TAO::Unknown_IDL_Type *unk = 0;
ACE_NEW (unk,
TAO::Unknown_IDL_Type (field_tc.in (),
- cdr.start (),
- cdr.byte_order ()));
+ TAO_InputCDR (in)));
field_any.replace (unk);
this->da_members_[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
@@ -606,7 +597,7 @@ TAO_DynStruct_i::from_any (const CORBA::Any & any
// Move to the next field in the CDR stream.
(void) TAO_Marshal_Object::perform_skip (field_tc.in (),
- &cdr
+ &in
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
@@ -644,6 +635,9 @@ TAO_DynStruct_i::to_any (ACE_ENV_SINGLE_ARG_DECL)
}
bool type_known = false;
+ TAO::Any_Impl *field_impl = 0;
+ TAO::Unknown_IDL_Type *field_unk = 0;
+ TAO_InputCDR field_in_cdr (static_cast<ACE_Message_Block *> (0));
for (CORBA::ULong i = 0; i < this->component_count_; ++i)
{
@@ -656,30 +650,25 @@ TAO_DynStruct_i::to_any (ACE_ENV_SINGLE_ARG_DECL)
this->da_members_[i]->to_any (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
- ACE_Message_Block *field_mb = field_any->_tao_get_cdr ();
+ TAO_OutputCDR field_out_cdr;
+ field_impl = field_any->impl ();
- if (field_mb == 0)
+ if (field_impl->encoded ())
{
- ACE_NEW_RETURN (field_mb,
- ACE_Message_Block,
- 0);
- TAO_OutputCDR out;
- field_any->impl ()->marshal_value (out);
- ACE_CDR::consolidate (field_mb, out.begin ());
- type_known = true;
+ field_unk =
+ dynamic_cast<TAO::Unknown_IDL_Type *> (field_impl);
+
+ field_in_cdr = field_unk->_tao_get_cdr ();
}
-
- TAO_InputCDR field_cdr (field_mb,
- field_any->_tao_byte_order ());
-
- if (type_known)
+ else
{
- field_mb->release ();
- type_known = false;
+ field_impl->marshal_value (field_out_cdr);
+ TAO_InputCDR tmp (field_out_cdr);
+ field_in_cdr = tmp;
}
(void) TAO_Marshal_Object::perform_append (field_tc.in (),
- &field_cdr,
+ &field_in_cdr,
&out_cdr
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
@@ -696,8 +685,7 @@ TAO_DynStruct_i::to_any (ACE_ENV_SINGLE_ARG_DECL)
TAO::Unknown_IDL_Type *unk = 0;
ACE_NEW_THROW_EX (unk,
TAO::Unknown_IDL_Type (this->type_.in (),
- in_cdr.start (),
- in_cdr.byte_order ()),
+ in_cdr),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (0);