2 #include "tao/DynamicAny/DynUnion_i.h"
3 #include "tao/DynamicAny/DynEnum_i.h"
4 #include "tao/DynamicAny/DynAnyFactory.h"
5 #include "tao/DynamicAny/DynAnyUtils_T.h"
7 #include "tao/AnyTypeCode/Marshal.h"
8 #include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h"
9 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
13 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 TAO_DynUnion_i::TAO_DynUnion_i (CORBA::Boolean allow_truncation
)
16 : TAO_DynCommon (allow_truncation
)
21 TAO_DynUnion_i::~TAO_DynUnion_i ()
26 TAO_DynUnion_i::init_common ()
28 this->ref_to_component_
= false;
29 this->container_is_destroying_
= false;
30 this->has_components_
= true;
31 this->destroyed_
= false;
32 this->component_count_
= 2;
33 this->current_position_
= 0;
34 this->member_slot_
= 0;
38 TAO_DynUnion_i::init (const CORBA::Any
& any
)
40 CORBA::TypeCode_var tc
= any
.type ();
42 CORBA::TCKind kind
= TAO_DynAnyFactory::unalias (tc
.in ());
44 if (kind
!= CORBA::tk_union
)
46 throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
49 // Initialize the typecode holder.
54 // Set the from_factory arg to TRUE, so any problems will throw
55 // InconsistentTypeCode.
56 this->set_from_any (any
);
60 TAO_DynUnion_i::init (CORBA::TypeCode_ptr tc
)
62 CORBA::TCKind kind
= TAO_DynAnyFactory::unalias (tc
);
64 if (kind
!= CORBA::tk_union
)
66 throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
69 // Initialize the typecode holder and current index.
70 this->type_
= CORBA::TypeCode::_duplicate (tc
);
74 // member_type()/member_label() do not work with aliased type codes.
75 CORBA::TypeCode_var unaliased_tc
=
76 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
78 CORBA::Any_var first_label
=
79 unaliased_tc
->member_label (this->current_position_
);
81 // Initialize the discriminator to the label value of the first member.
82 CORBA::TypeCode_var disc_tc
= unaliased_tc
->discriminator_type ();
83 CORBA::TCKind disc_kind
= TAO_DynAnyFactory::unalias (disc_tc
.in ());
84 CORBA::TCKind label_kind
= TAO_DynAnyFactory::unalias (first_label
->_tao_get_typecode ());
85 if (disc_kind
== CORBA::tk_enum
&&
86 label_kind
== CORBA::tk_ulong
)
88 // incase the discriminator is an enum type we have to walk
89 // a slightly more complex path because enum labels are
90 // stored as ulong in the union tc
91 this->discriminator_
=
92 TAO::MakeDynAnyUtils::make_dyn_any_t
<CORBA::TypeCode_ptr
> (
95 this->allow_truncation_
);
96 CORBA::ULong label_val
;
97 first_label
>>= label_val
;
98 TAO_DynEnum_i::_narrow (this->discriminator_
.in ())
99 ->set_as_ulong (label_val
);
103 this->discriminator_
=
104 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
105 first_label
.in ()._tao_get_typecode (),
107 this->allow_truncation_
);
110 CORBA::TypeCode_var first_type
=
111 unaliased_tc
->member_type (this->current_position_
);
113 // Recursively initialize the member to its default value.
115 TAO::MakeDynAnyUtils::make_dyn_any_t
<CORBA::TypeCode_ptr
> (
118 this->allow_truncation_
);
121 // ****************************************************************
124 TAO_DynUnion_i::_narrow (CORBA::Object_ptr _tao_objref
)
126 if (CORBA::is_nil (_tao_objref
))
131 return dynamic_cast<TAO_DynUnion_i
*> (_tao_objref
);
134 // This code is common to from_any() and the init() overload that takes
137 TAO_DynUnion_i::set_from_any (const CORBA::Any
& any
)
139 // discriminator_type () does not work with aliased type codes,
140 // only on unions, so strip the alias out of the type code
142 CORBA::TypeCode_var tc
=
143 TAO_DynAnyFactory::strip_alias (any
._tao_get_typecode ());
145 CORBA::TypeCode_var disc_tc
=
146 tc
->discriminator_type ();
149 TAO::Unknown_IDL_Type
*unk
= 0;
151 // Get a CDR stream - if the Any doesn't have one, make one.
152 TAO::Any_Impl
*impl
= any
.impl ();
154 TAO_InputCDR
in (static_cast<ACE_Message_Block
*> (0));
156 if (impl
->encoded ())
158 TAO::Unknown_IDL_Type
* const tmp
=
159 dynamic_cast<TAO::Unknown_IDL_Type
*> (impl
);
162 throw CORBA::INTERNAL ();
164 in
= tmp
->_tao_get_cdr ();
168 impl
->marshal_value (out
);
169 TAO_InputCDR
tmp_in (out
);
173 TAO_InputCDR
unk_in (in
);
175 TAO::Unknown_IDL_Type (disc_tc
.in (),
178 disc_any
.replace (unk
);
180 // Need this here because we might have been called from init().
181 if (!CORBA::is_nil (this->discriminator_
.in ()))
183 this->discriminator_
->destroy ();
186 // Set the discriminator.
187 this->discriminator_
=
188 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
189 disc_any
._tao_get_typecode (),
191 this->allow_truncation_
);
193 // Move to the next field in the CDR stream.
194 (void) TAO_Marshal_Object::perform_skip (disc_tc
.in (), &in
);
196 CORBA::TypeCode_var unaliased
=
197 TAO_DynAnyFactory::strip_alias (tc
.in ());
199 CORBA::ULong
const count
= unaliased
->member_count ();
201 CORBA::Boolean match
= false;
205 for (i
= 0; i
< count
; ++i
)
207 CORBA::Any_var label_any
= tc
->member_label (i
);
209 match
= this->label_match (label_any
.in (), disc_any
);
217 // Need this here because we might have been called from init().
218 if (!CORBA::is_nil (this->member_
.in ()))
220 this->member_
->destroy ();
225 CORBA::TypeCode_var member_tc
= tc
->member_type (i
);
227 CORBA::Any member_any
;
228 TAO::Unknown_IDL_Type
*unk
= 0;
230 TAO::Unknown_IDL_Type (member_tc
.in (),
232 member_any
.replace (unk
);
235 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
236 member_any
._tao_get_typecode (),
238 this->allow_truncation_
);
240 this->member_slot_
= i
;
244 // If no match, either the Any contains the default member or the
245 // type code was bad.
247 // default_index() does not work with aliased type codes.
248 CORBA::TypeCode_var unaliased_tc
=
249 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
251 CORBA::Long default_index
=
252 unaliased_tc
->default_index ();
254 if (default_index
== -1)
256 set_to_no_active_member ();
260 CORBA::ULong index
= static_cast<CORBA::ULong
> (default_index
);
262 CORBA::TypeCode_var default_tc
=
263 tc
->member_type (index
);
265 CORBA::Any default_any
;
266 TAO::Unknown_IDL_Type
*unk
= 0;
268 TAO::Unknown_IDL_Type (default_tc
.in (),
270 default_any
.replace (unk
);
273 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
274 default_any
._tao_get_typecode (),
276 this->allow_truncation_
);
278 this->member_slot_
= index
;
283 // ****************************************************************
285 DynamicAny::DynAny_ptr
286 TAO_DynUnion_i::get_discriminator ()
288 if (this->destroyed_
)
290 throw ::CORBA::OBJECT_NOT_EXIST ();
293 // A deep copy is made only by copy() (CORBA 2.4.2 section 9.2.3.6).
294 // Set the flag so the caller can't destroy.
295 this->set_flag (this->discriminator_
.in (), 0);
297 return DynamicAny::DynAny::_duplicate (this->discriminator_
.in ());
301 TAO_DynUnion_i::set_discriminator (DynamicAny::DynAny_ptr value
)
303 if (this->destroyed_
)
305 throw ::CORBA::OBJECT_NOT_EXIST ();
308 CORBA::TypeCode_var tc
= value
->type ();
310 CORBA::TypeCode_var disc_tc
=
311 this->discriminator_
->type ();
313 CORBA::Boolean equivalent
= disc_tc
->equivalent (tc
.in ());
317 throw DynamicAny::DynAny::TypeMismatch ();
320 CORBA::Any_var value_any
= value
->to_any ();
322 CORBA::ULong length
=
323 this->type_
->member_count ();
325 CORBA::Any_var label_any
;
328 // member_label() does not work with aliased type codes.
329 CORBA::TypeCode_var unaliased_tc
=
330 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
332 CORBA::Boolean match
= 0;
334 for (i
= 0; i
< length
; ++i
)
336 label_any
= unaliased_tc
->member_label (i
);
338 match
= this->label_match (label_any
.in (), value_any
.in ());
348 // If the incoming label value matches the one we already
349 // have, we do nothing.
350 if (i
== this->member_slot_
)
355 // If we got a match, a named member will be active.
356 CORBA::TCKind disc_kind
= TAO_DynAnyFactory::unalias (disc_tc
.in ());
357 CORBA::TCKind label_kind
= TAO_DynAnyFactory::unalias (label_any
->_tao_get_typecode ());
358 if (disc_kind
== CORBA::tk_enum
&&
359 label_kind
== CORBA::tk_ulong
)
361 // incase the discriminator is an enum type we have to walk
362 // a slightly more complex path because enum labels are
363 // stored as ulong in the union tc
364 CORBA::ULong label_val
;
365 label_any
>>= label_val
;
366 TAO_DynEnum_i::_narrow (this->discriminator_
.in ())
367 ->set_as_ulong (label_val
);
371 this->discriminator_
->from_any (label_any
.in ());
374 // member_type() does not work with aliased type codes.
375 CORBA::TypeCode_var member_tc
= unaliased_tc
->member_type (i
);
377 this->member_
->destroy ();
379 // Initialize member to default value.
381 TAO::MakeDynAnyUtils::make_dyn_any_t
<CORBA::TypeCode_ptr
> (
384 this->allow_truncation_
);
386 // Named active member (CORBA 2.3.1).
387 this->current_position_
= 1;
388 this->component_count_
= 2;
390 this->member_slot_
= i
;
392 // we're through, disc, value has already been set
393 // no need for the copy operation below.
398 // default_index() does not work with aliased type codes.
399 CORBA::TypeCode_var unaliased_tc
=
400 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
402 // If no match, either the default member or no member is active.
403 CORBA::Long default_index
=
404 unaliased_tc
->default_index ();
406 if (default_index
== -1)
408 // This can't throw InvalidValue - if there's no default case
409 // and all possible labels are used, we'd have had a match above.
410 this->set_to_no_active_member ();
414 this->set_to_default_member ();
416 this->member_slot_
= static_cast<CORBA::ULong
> (default_index
);
420 // If we get here, we update the discriminator no matter what.
421 // Any value will correspond to one of the three cases above.
422 this->discriminator_
->destroy ();
424 this->discriminator_
= value
->copy ();
428 TAO_DynUnion_i::set_to_default_member ()
430 if (this->destroyed_
)
432 throw ::CORBA::OBJECT_NOT_EXIST ();
435 // default_index() does not work with aliased type codes.
436 CORBA::TypeCode_var unaliased_tc
=
437 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
439 CORBA::Long default_index
=
440 unaliased_tc
->default_index ();
442 if (default_index
== -1)
444 // No explicit default case.
445 throw DynamicAny::DynAny::TypeMismatch ();
449 CORBA::ULong index
= static_cast<CORBA::ULong
> (default_index
);
451 CORBA::TypeCode_var default_tc
=
452 unaliased_tc
->member_type (index
);
454 this->member_
->destroy ();
457 TAO::MakeDynAnyUtils::make_dyn_any_t
<CORBA::TypeCode_ptr
> (
460 this->allow_truncation_
);
462 // Default member active (CORBA 2.3.1).
463 this->current_position_
= 0;
464 this->component_count_
= 2;
466 this->member_slot_
= index
;
471 TAO_DynUnion_i::set_to_no_active_member ()
473 if (this->destroyed_
)
475 throw ::CORBA::OBJECT_NOT_EXIST ();
478 // default_index() does not work with aliased type codes.
479 CORBA::TypeCode_var unaliased_tc
=
480 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
482 CORBA::Long default_index
=
483 unaliased_tc
->default_index ();
485 // Throw an exception is there is an explicit default case or if all
486 // possible case label values are used.
487 if (default_index
!= -1)
489 throw DynamicAny::DynAny::TypeMismatch ();
493 CORBA::TypeCode_var disc_tc
=
494 this->discriminator_
->type ();
497 TAO_DynAnyFactory::unalias (disc_tc
.in ());
499 if (kind
== CORBA::tk_enum
)
501 CORBA::ULong
const member_count
=
502 this->type_
->member_count ();
504 CORBA::ULong
const label_count
=
505 disc_tc
->member_count ();
507 if (member_count
== label_count
)
509 throw DynamicAny::DynAny::TypeMismatch ();
514 // No active member (CORBA 2.3.1).
515 this->current_position_
= 0;
516 this->component_count_
= 1;
520 TAO_DynUnion_i::has_no_active_member ()
522 if (this->destroyed_
)
524 throw ::CORBA::OBJECT_NOT_EXIST ();
527 // No active member (CORBA 2.3.1).
528 return (this->current_position_
== 0 && this->component_count_
== 1);
532 TAO_DynUnion_i::discriminator_kind ()
534 if (this->destroyed_
)
536 throw ::CORBA::OBJECT_NOT_EXIST ();
539 CORBA::TypeCode_var tc
=
540 this->discriminator_
->type ();
542 return TAO_DynAnyFactory::unalias (tc
.in ());
545 DynamicAny::DynAny_ptr
546 TAO_DynUnion_i::member ()
548 if (this->destroyed_
)
550 throw ::CORBA::OBJECT_NOT_EXIST ();
553 CORBA::Boolean has_no_active_member
=
554 this->has_no_active_member ();
556 if (has_no_active_member
)
558 throw DynamicAny::DynAny::InvalidValue ();
561 // A deep copy is made only by copy() (CORBA 2.4.2 section 9.2.3.6).
562 // Set the flag so the caller can't destroy.
563 this->set_flag (this->member_
.in (), 0);
565 return DynamicAny::DynAny::_duplicate (this->member_
.in ());
569 TAO_DynUnion_i::member_name ()
571 if (this->destroyed_
)
573 throw ::CORBA::OBJECT_NOT_EXIST ();
576 CORBA::Boolean has_no_active_member
=
577 this->has_no_active_member ();
579 if (has_no_active_member
)
581 throw DynamicAny::DynAny::InvalidValue ();
584 const char *retval
= this->type_
->member_name (this->member_slot_
);
586 return CORBA::string_dup (retval
);
590 TAO_DynUnion_i::member_kind ()
592 if (this->destroyed_
)
594 throw ::CORBA::OBJECT_NOT_EXIST ();
597 CORBA::Boolean has_no_active_member
=
598 this->has_no_active_member ();
600 if (has_no_active_member
)
602 throw DynamicAny::DynAny::InvalidValue ();
605 CORBA::TypeCode_var tc
= this->member_
->type ();
607 return TAO_DynAnyFactory::unalias (tc
.in ());
610 // ****************************************************************
613 TAO_DynUnion_i::from_any (const CORBA::Any
& any
)
615 if (this->destroyed_
)
617 throw ::CORBA::OBJECT_NOT_EXIST ();
620 CORBA::TypeCode_var tc
= any
.type ();
621 CORBA::Boolean equivalent
=
622 this->type_
.in ()->equivalent (tc
.in ());
626 // CORBA 2.3.1 section 9.2.3.3.
627 this->current_position_
= 0;
629 // May be changed in set_from_any().
630 this->component_count_
= 2;
632 // Set the from_factory arg to FALSE, so any problems will throw
634 this->set_from_any (any
);
638 throw DynamicAny::DynAny::TypeMismatch ();
643 TAO_DynUnion_i::to_any ()
645 if (this->destroyed_
)
647 throw ::CORBA::OBJECT_NOT_EXIST ();
650 TAO_OutputCDR out_cdr
;
652 // Add the discriminator to the CDR stream.
654 CORBA::TypeCode_var disc_tc
=
655 this->discriminator_
->type ();
657 CORBA::Any_var disc_any
=
658 this->discriminator_
->to_any ();
660 TAO::Any_Impl
*disc_any_impl
= disc_any
->impl ();
661 TAO_OutputCDR disc_out_cdr
;
662 TAO_InputCDR
disc_in_cdr (static_cast<ACE_Message_Block
*> (0));
664 if (disc_any_impl
->encoded ())
666 TAO::Unknown_IDL_Type
* const disc_unk
=
667 dynamic_cast<TAO::Unknown_IDL_Type
*> (disc_any_impl
);
670 throw CORBA::INTERNAL ();
672 disc_in_cdr
= disc_unk
->_tao_get_cdr ();
676 disc_any_impl
->marshal_value (disc_out_cdr
);
677 TAO_InputCDR
disc_tmp_in_cdr (disc_out_cdr
);
678 disc_in_cdr
= disc_tmp_in_cdr
;
681 (void) TAO_Marshal_Object::perform_append (disc_tc
.in (),
685 // Add the member to the CDR stream unless it has no active member.
686 if (this->has_no_active_member () == 0)
688 CORBA::TypeCode_var member_tc
=
689 this->member_
->type ();
691 CORBA::Any_var member_any
=
692 this->member_
->to_any ();
694 TAO::Any_Impl
*member_any_impl
= member_any
->impl ();
695 TAO_OutputCDR member_out_cdr
;
696 TAO_InputCDR
member_in_cdr (static_cast<ACE_Message_Block
*> (0));
698 if (member_any_impl
->encoded ())
700 TAO::Unknown_IDL_Type
* const member_unk
=
701 dynamic_cast<TAO::Unknown_IDL_Type
*> (member_any_impl
);
704 throw CORBA::INTERNAL ();
706 member_in_cdr
= member_unk
->_tao_get_cdr ();
710 member_any_impl
->marshal_value (member_out_cdr
);
711 TAO_InputCDR
member_tmp_in_cdr (member_out_cdr
);
712 member_in_cdr
= member_tmp_in_cdr
;
715 (void) TAO_Marshal_Object::perform_append (member_tc
.in (),
721 TAO_InputCDR
in_cdr (out_cdr
);
723 CORBA::Any_ptr retval
= 0;
724 ACE_NEW_THROW_EX (retval
,
726 CORBA::NO_MEMORY ());
728 TAO::Unknown_IDL_Type
*unk
= 0;
729 ACE_NEW_THROW_EX (unk
,
730 TAO::Unknown_IDL_Type (this->type_
.in (),
732 CORBA::NO_MEMORY ());
734 retval
->replace (unk
);
739 TAO_DynUnion_i::equal (DynamicAny::DynAny_ptr rhs
)
741 if (this->destroyed_
)
743 throw ::CORBA::OBJECT_NOT_EXIST ();
746 TAO_DynUnion_i
*impl
= TAO_DynUnion_i::_narrow (rhs
);
753 CORBA::Boolean equivalent
=
754 this->type_
->equivalent (impl
->type_
.in ());
761 CORBA::Boolean member_equal
=
762 this->member_
->equal (impl
->member_
.in ());
764 CORBA::Boolean disc_equal
=
765 this->discriminator_
->equal (impl
->discriminator_
.in ());
767 impl
->_remove_ref ();
769 return (member_equal
&& disc_equal
);
773 TAO_DynUnion_i::destroy ()
775 if (this->destroyed_
)
777 throw ::CORBA::OBJECT_NOT_EXIST ();
780 if (!this->ref_to_component_
|| this->container_is_destroying_
)
782 // Free the two components.
784 if (! CORBA::is_nil (this->member_
.in ()))
786 this->set_flag (this->member_
.in (), 1);
788 this->member_
->destroy ();
791 this->set_flag (this->discriminator_
.in (), 1);
793 this->discriminator_
->destroy ();
795 this->destroyed_
= 1;
799 DynamicAny::DynAny_ptr
800 TAO_DynUnion_i::current_component ()
802 if (this->destroyed_
)
804 throw ::CORBA::OBJECT_NOT_EXIST ();
807 if (this->current_position_
== 1)
809 this->set_flag (this->member_
.in (), 0);
811 return DynamicAny::DynAny::_duplicate (this->member_
.in ());
815 this->set_flag (this->discriminator_
.in (), 0);
817 return DynamicAny::DynAny::_duplicate (this->discriminator_
.in ());
821 // ****************************************************************
824 TAO_DynUnion_i::label_match (const CORBA::Any
&my_any
,
825 const CORBA::Any
&other_any
)
827 // Use my_any so we can detect a default case label,
828 // if we are iterating through the union type code's
829 // member_label() calls.
830 CORBA::TypeCode_var tc
= my_any
.type ();
832 CORBA::TCKind kind
= TAO_DynAnyFactory::unalias (tc
.in ());
834 // No need to do any type checking - it was done before this
838 case CORBA::tk_octet
:
839 // Default case label - just skip it.
841 case CORBA::tk_short
:
844 CORBA::Short other_val
;
846 other_any
>>= other_val
;
847 return my_val
== other_val
;
852 CORBA::Long other_val
;
854 other_any
>>= other_val
;
855 return my_val
== other_val
;
857 case CORBA::tk_ushort
:
859 CORBA::UShort my_val
;
860 CORBA::UShort other_val
;
862 other_any
>>= other_val
;
863 return my_val
== other_val
;
865 case CORBA::tk_ulong
:
868 CORBA::ULong other_val
;
871 // check whether the discriminator is possibly an enum type
872 // since these get stored as ulong label values as well
873 CORBA::TypeCode_var other_tc
= other_any
.type ();
874 CORBA::TCKind kind
= TAO_DynAnyFactory::unalias (other_tc
.in ());
875 if (kind
== CORBA::tk_enum
)
877 TAO::Any_Impl
*other_impl
= other_any
.impl ();
879 if (other_impl
->encoded ())
881 TAO::Unknown_IDL_Type
*other_unk
=
882 dynamic_cast<TAO::Unknown_IDL_Type
*> (other_impl
);
884 // We don't want unk's rd_ptr to move, in case we are
885 // shared by another Any, so we use this to copy the
886 // state, not the buffer.
887 TAO_InputCDR
for_reading (other_unk
->_tao_get_cdr ());
888 for_reading
.read_ulong (other_val
);
892 TAO_OutputCDR other_out
;
893 other_impl
->marshal_value (other_out
);
894 TAO_InputCDR
other_in (other_out
);
895 other_in
.read_ulong (other_val
);
899 other_any
>>= other_val
;
901 return my_val
== other_val
;
903 case CORBA::tk_boolean
:
905 CORBA::Boolean my_val
;
906 CORBA::Boolean other_val
;
907 my_any
>>= CORBA::Any::to_boolean (my_val
);
908 other_any
>>= CORBA::Any::to_boolean (other_val
);
909 return my_val
== other_val
;
914 CORBA::Char other_val
;
915 my_any
>>= CORBA::Any::to_char (my_val
);
916 other_any
>>= CORBA::Any::to_char (other_val
);
917 return my_val
== other_val
;
919 // For platforms without native 64-bit ints.
920 case CORBA::tk_longlong
:
922 CORBA::LongLong my_val
;
923 CORBA::LongLong other_val
;
925 other_any
>>= other_val
;
926 return my_val
== other_val
;
928 case CORBA::tk_ulonglong
:
930 CORBA::ULongLong my_val
;
931 CORBA::ULongLong other_val
;
933 other_any
>>= other_val
;
934 return my_val
== other_val
;
936 case CORBA::tk_wchar
:
939 CORBA::WChar other_val
;
940 my_any
>>= CORBA::Any::to_wchar (my_val
);
941 other_any
>>= CORBA::Any::to_wchar (other_val
);
942 return my_val
== other_val
;
947 CORBA::ULong other_val
;
949 TAO::Any_Impl
*my_impl
= my_any
.impl ();
951 if (my_impl
->encoded ())
953 TAO::Unknown_IDL_Type
* const my_unk
=
954 dynamic_cast<TAO::Unknown_IDL_Type
*> (my_impl
);
957 throw CORBA::INTERNAL ();
959 // We don't want unk's rd_ptr to move, in case we are shared by
960 // another Any, so we use this to copy the state, not the buffer.
961 TAO_InputCDR
for_reading (my_unk
->_tao_get_cdr ());
962 for_reading
.read_ulong (my_val
);
966 TAO_OutputCDR my_out
;
967 my_impl
->marshal_value (my_out
);
968 TAO_InputCDR
my_in (my_out
);
969 my_in
.read_ulong (my_val
);
972 TAO::Any_Impl
*other_impl
= other_any
.impl ();
974 if (other_impl
->encoded ())
976 TAO::Unknown_IDL_Type
* const other_unk
=
977 dynamic_cast<TAO::Unknown_IDL_Type
*> (other_impl
);
980 throw CORBA::INTERNAL ();
982 // We don't want unk's rd_ptr to move, in case we are shared by
983 // another Any, so we use this to copy the state, not the buffer.
984 TAO_InputCDR
for_reading (other_unk
->_tao_get_cdr ());
985 for_reading
.read_ulong (other_val
);
989 TAO_OutputCDR other_out
;
990 other_impl
->marshal_value (other_out
);
991 TAO_InputCDR
other_in (other_out
);
992 other_in
.read_ulong (other_val
);
995 return my_val
== other_val
;
997 // Cannot happen - we've covered all the legal discriminator types.
1003 TAO_END_VERSIONED_NAMESPACE_DECL