1
// append.cpp,v 1.52 2003/10/28 18:29:21 bala Exp
3
// ============================================================================
12
// Appends a CDR stream to another CDR stream. Due to the
13
// stringent alignment requirements, it is not possible to simply
14
// append or memcpy. Instead we go thru the same CDR encoding rules
17
// Copyright 1994-1995 by Sun Microsystems Inc.
18
// and Aniruddha Gokhale
20
// ============================================================================
22
#include "Environment.h"
24
#include "Valuetype_Adapter.h"
29
#include "ace/Dynamic_Service.h"
33
"append.cpp,v 1.52 2003/10/28 18:29:21 bala Exp")
35
// Encode instances of arbitrary data types based only on typecode.
36
// "data" points to the data type; if it's not a primitve data type,
37
// the TypeCode interpreter is used to recursively encode its
38
// components. "context" is the marshaling stream on which to encode
42
TAO_Marshal_Primitive::append (CORBA::TypeCode_ptr tc,
47
CORBA::Boolean continue_append = 1;
48
TAO::traverse_status retval =
49
TAO::TRAVERSE_CONTINUE; // status of encode operation
57
case CORBA::tk_ushort:
58
continue_append = dest->append_short (*src);
64
continue_append = dest->append_long (*src);
66
case CORBA::tk_double:
67
case CORBA::tk_longlong:
68
case CORBA::tk_ulonglong:
69
continue_append = dest->append_double (*src);
71
case CORBA::tk_boolean:
72
continue_append = dest->append_boolean (*src);
76
continue_append = dest->append_octet (*src);
78
case CORBA::tk_longdouble:
79
continue_append = dest->append_longdouble (*src);
82
continue_append = dest->append_wchar (*src);
85
retval = TAO::TRAVERSE_STOP;
86
// we are not a primitive type
89
if (retval == TAO::TRAVERSE_CONTINUE
90
&& continue_append == 1)
91
return TAO::TRAVERSE_CONTINUE;
93
if (TAO_debug_level > 0)
96
ACE_TEXT ("TAO_Marshal_Primitive::append detected error\n")
99
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
100
CORBA::COMPLETED_MAYBE),
105
TAO_Marshal_Any::append (CORBA::TypeCode_ptr,
110
// Typecode of the element that makes the Any.
111
CORBA::TypeCode_var elem_tc;
113
if (!(*src >> elem_tc.inout ()))
114
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
115
CORBA::COMPLETED_MAYBE),
118
if (!(*dest << elem_tc.in ()))
119
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
120
CORBA::COMPLETED_MAYBE),
124
TAO::traverse_status retval =
125
TAO_Marshal_Object::perform_append (elem_tc.in (),
128
ACE_ENV_ARG_PARAMETER);
129
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
131
if (retval != TAO::TRAVERSE_CONTINUE)
133
if (TAO_debug_level > 0)
134
ACE_DEBUG ((LM_DEBUG,
135
ACE_TEXT ("TAO_Marshal_Any::append detected error\n")));
137
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
138
CORBA::COMPLETED_MAYBE),
146
TAO_Marshal_TypeCode::append (CORBA::TypeCode_ptr,
151
CORBA::Boolean continue_append = 1;
152
TAO::traverse_status retval =
153
TAO::TRAVERSE_CONTINUE;
156
// Decode the "kind" field of the typecode from the src for further
157
// use. However, also write it back into the destination
158
continue_append = (CORBA::Boolean) (src->read_ulong (kind)
159
? dest->write_ulong (kind)
162
if (continue_append == 1)
164
// Typecodes with empty parameter lists all have preallocated
165
// constants. We use those to reduce memory consumption and
166
// heap access ... also, to speed things up!
167
if ((kind < CORBA::TC_KIND_COUNT)
170
// Either a non-constant typecode or an indirected typecode.
173
// Need special handling for all kinds of typecodes that
174
// have nonempty parameter lists ...
176
// nothing to de done
178
case CORBA::tk_string:
179
case CORBA::tk_wstring:
181
// read and write the bounds
183
TAO_Marshal_Object::perform_append (CORBA::_tc_long,
186
ACE_ENV_ARG_PARAMETER);
187
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
191
// Indirected typecodes, illegal at "top level"
194
// read and write the negative offset
196
TAO_Marshal_Object::perform_append (CORBA::_tc_long,
199
ACE_ENV_ARG_PARAMETER);
200
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
204
// The rest have "complex" parameter lists that are
205
// encoded as bulk octets ...
206
case CORBA::tk_objref:
207
case CORBA::tk_struct:
208
case CORBA::tk_union:
210
case CORBA::tk_sequence:
211
case CORBA::tk_array:
212
case CORBA::tk_alias:
213
case CORBA::tk_except:
214
case CORBA::tk_value:
215
case CORBA::tk_value_box:
216
case CORBA::tk_native:
217
case CORBA::tk_abstract_interface:
218
case CORBA::tk_local_interface:
219
case CORBA::tk_component:
221
case CORBA::tk_event:
223
// write the encapsulation i.e., octet sequence
225
TAO_Marshal_Object::perform_append (TC_opaque,
228
ACE_ENV_ARG_PARAMETER);
229
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
233
else // bad kind_ value to be decoded
235
if (TAO_debug_level > 0)
237
ACE_DEBUG ((LM_DEBUG,
238
ACE_TEXT ("TAO_Marshal_TypeCode: ")
239
ACE_TEXT ("Bad kind_ value in CDR stream\n")));
242
ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
247
if (continue_append == 1 && retval == TAO::TRAVERSE_CONTINUE)
249
return TAO::TRAVERSE_CONTINUE;
252
if (TAO_debug_level > 0)
254
ACE_DEBUG ((LM_DEBUG,
255
ACE_TEXT ("TAO_Marshal_TypeCode::append detected error\n")));
258
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
259
CORBA::COMPLETED_MAYBE),
264
TAO_Marshal_Principal::append (CORBA::TypeCode_ptr,
269
// write the octet sequence representing the Principal
270
return TAO_Marshal_Object::perform_append (TC_opaque,
273
ACE_ENV_ARG_PARAMETER);
277
TAO_Marshal_ObjRef::append (CORBA::TypeCode_ptr,
282
CORBA::Boolean continue_append = 1;
284
// First, append the type hint. This will be the type_id encoded in an
286
dest->append_string (*src);
288
// Read the profiles, discarding all until an IIOP profile comes by.
289
// Once we see an IIOP profile, ignore any further ones.
291
// XXX this will need to change someday to let different protocol
292
// code be accessed, not just IIOP. Protocol modules will be
293
// dynamically loaded from shared libraries via ORB_init (), and we
294
// just need to be able to access such preloaded libraries here as
295
// we unmarshal objrefs.
297
CORBA::ULong profiles = 0;
299
// get the count of profiles that follow. This will tell us the
300
// length of the sequence
301
continue_append = (CORBA::Boolean) (src->read_ulong (profiles)
302
? dest->write_ulong (profiles)
305
// No profiles means a NIL objref.
306
while (profiles-- != 0 && continue_append)
308
CORBA::ULong tag = 0;
310
// get the profile ID tag
311
if ((continue_append = (CORBA::Boolean) (src->read_ulong (tag)
312
? dest->write_ulong (tag)
316
CORBA::ULong length = 0;
317
if ((continue_append = (CORBA::Boolean) (src->read_ulong (length)
318
? dest->write_ulong (length)
322
// @@ This can be optimized! Pre-allocating on the destination
323
// and then copying directly into that.
324
CORBA::Octet* body = 0;
325
ACE_NEW_RETURN (body,
326
CORBA::Octet[length],
329
(CORBA::Boolean) (src->read_octet_array (body, length)
330
? dest->write_octet_array (body, length)
335
if (continue_append == 1)
336
return TAO::TRAVERSE_CONTINUE;
338
if (TAO_debug_level > 0)
341
ACE_TEXT ("TAO_Marshal_ObjRef::append detected error\n")
344
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
345
CORBA::COMPLETED_MAYBE),
350
TAO_Marshal_Struct::append (CORBA::TypeCode_ptr tc,
355
TAO::traverse_status retval =
356
TAO::TRAVERSE_CONTINUE;
357
CORBA::TypeCode_var param;
359
// Number of fields in the struct.
360
int member_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
361
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
364
i < member_count && retval == TAO::TRAVERSE_CONTINUE;
368
param = tc->member_type (i ACE_ENV_ARG_PARAMETER);
369
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
372
TAO_Marshal_Object::perform_append (param.in (),
375
ACE_ENV_ARG_PARAMETER);
376
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
379
if (retval == TAO::TRAVERSE_CONTINUE)
380
return TAO::TRAVERSE_CONTINUE;
382
if (TAO_debug_level > 0)
383
ACE_DEBUG ((LM_DEBUG,
384
ACE_TEXT ("TAO_Marshal_Struct::append detected error\n")));
386
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
387
CORBA::COMPLETED_MAYBE),
392
TAO_Marshal_Union::append (CORBA::TypeCode_ptr tc,
397
CORBA::TypeCode_var discrim_tc =
398
tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER);
399
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
402
discrim_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
403
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
405
// Save the discriminator value in a temporary variable...
406
CORBA::Short short_v;
407
CORBA::UShort ushort_v;
409
CORBA::ULong ulong_v;
412
CORBA::WChar wchar_v;
413
CORBA::Boolean boolean_v;
417
case CORBA::tk_short:
419
if (!src->read_short (short_v)
420
|| !dest->write_short (short_v))
421
return TAO::TRAVERSE_STOP;
425
case CORBA::tk_ushort:
427
if (!src->read_ushort (ushort_v)
428
|| !dest->write_ushort (ushort_v))
429
return TAO::TRAVERSE_STOP;
435
if (!src->read_long (long_v)
436
|| !dest->write_long (long_v))
437
return TAO::TRAVERSE_STOP;
441
case CORBA::tk_ulong:
443
if (!src->read_ulong (ulong_v)
444
|| !dest->write_ulong (ulong_v))
445
return TAO::TRAVERSE_STOP;
451
if (!src->read_ulong (enum_v)
452
|| !dest->write_ulong (enum_v))
453
return TAO::TRAVERSE_STOP;
459
if (!src->read_char (char_v)
460
|| !dest->write_char (char_v))
461
return TAO::TRAVERSE_STOP;
465
case CORBA::tk_wchar:
467
if (!src->read_wchar (wchar_v)
468
|| !dest->write_wchar (wchar_v))
469
return TAO::TRAVERSE_STOP;
473
case CORBA::tk_boolean:
475
if (!src->read_boolean (boolean_v)
476
|| !dest->write_boolean (boolean_v))
477
return TAO::TRAVERSE_STOP;
482
return TAO::TRAVERSE_STOP;
485
CORBA::ULong member_count =
486
tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
487
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
489
const CORBA::ULong null_member = ~ACE_static_cast (CORBA::ULong, 0U);
491
CORBA::ULong current_member = null_member;
492
CORBA::ULong default_member = null_member;
494
for (CORBA::ULong i = 0;
495
i != member_count && current_member == null_member;
498
CORBA::Any_var any = tc->member_label (i
499
ACE_ENV_ARG_PARAMETER);
500
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
504
if ((any >>= CORBA::Any::to_octet (o)) && o == 0)
506
CORBA::ULong default_index =
507
tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
508
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
510
if (i != default_index)
511
ACE_THROW_RETURN (CORBA::BAD_TYPECODE (),
513
// Found the default branch, save its position and continue
514
// trying to find the current value...
521
case CORBA::tk_short:
524
if ((any >>= d) && d == short_v)
529
case CORBA::tk_ushort:
532
if ((any >>= d) && d == ushort_v)
540
if ((any >>= d) && d == long_v)
545
case CORBA::tk_ulong:
548
if ((any >>= d) && d == ulong_v)
555
ACE_Message_Block *mb = any->_tao_get_cdr ();
560
TAO_InputCDR cdr (mb->data_block (),
561
ACE_Message_Block::DONT_DELETE,
562
mb->rd_ptr () - mb->base (),
563
mb->wr_ptr () - mb->base (),
576
const CORBA::ULong *d =
577
ACE_reinterpret_cast (const CORBA::ULong *,
590
if ((any >>= CORBA::Any::to_char (d)) && d == char_v)
595
case CORBA::tk_wchar:
598
if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v)
603
case CORBA::tk_boolean:
606
if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v)
612
return TAO::TRAVERSE_STOP;
616
if (current_member == null_member)
618
// Cannot find the current member, check if there is a
620
if (default_member != null_member)
622
// Good, use the default to append...
623
CORBA::TypeCode_var member_tc =
624
tc->member_type (default_member ACE_ENV_ARG_PARAMETER);
625
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
626
return TAO_Marshal_Object::perform_append (member_tc.in (),
629
ACE_ENV_ARG_PARAMETER);
632
// If we're here, we have an implicit default case, and we
633
// should just return without appending anything, since no
634
// union member was marshaled in the first place.
635
return TAO::TRAVERSE_CONTINUE;
638
// If we found the member successfully then just use that one...
639
CORBA::TypeCode_var member_tc =
640
tc->member_type (current_member ACE_ENV_ARG_PARAMETER);
641
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
642
return TAO_Marshal_Object::perform_append (member_tc.in (),
645
ACE_ENV_ARG_PARAMETER);
649
TAO_Marshal_String::append (CORBA::TypeCode_ptr,
654
CORBA::Boolean continue_append = 1;
656
// On decode, omit the check against specified string bounds, and
657
// cope with illegal "zero length" strings (all lengths on the wire
658
// must include a NUL).
660
// This is on the principle of being gracious in what we accept; we
661
// don't generate messages that fail to comply with protocol specs,
662
// but we will accept them when it's clear how to do so.
664
continue_append = dest->append_string (*src);
665
if (continue_append == 1)
666
return TAO::TRAVERSE_CONTINUE;
668
if (TAO_debug_level > 0)
669
ACE_DEBUG ((LM_DEBUG,
670
ACE_TEXT ("TAO_Marshal_TypeCode::append detected error\n")));
672
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
673
CORBA::COMPLETED_MAYBE),
678
TAO_Marshal_Sequence::append (CORBA::TypeCode_ptr tc,
686
// First unmarshal the sequence length ... we trust it to be right
687
// here, on the "be gracious in what you accept" principle. We
688
// don't generate illegal sequences (i.e. length > bounds).
690
CORBA::Boolean continue_append =
691
(CORBA::Boolean) (src->read_ulong (bounds)
692
? dest->write_ulong (bounds)
695
if (!continue_append)
699
ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n")
701
ACE_THROW_RETURN (CORBA::MARSHAL (),
707
return TAO::TRAVERSE_CONTINUE;
712
// Get element typecode.
713
CORBA::TypeCode_var tc2 =
714
tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
715
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
717
TAO::traverse_status retval =
718
TAO::TRAVERSE_CONTINUE;
720
CORBA::TCKind kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
721
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
725
case CORBA::tk_octet:
728
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
729
ACE_CDR::OCTET_ALIGN, buf) == 0)
731
if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0)
732
retval = TAO::TRAVERSE_STOP;
736
case CORBA::tk_boolean:
739
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
740
ACE_CDR::OCTET_ALIGN, buf) == 0)
742
if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0)
743
retval = TAO::TRAVERSE_STOP;
750
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
751
ACE_CDR::OCTET_ALIGN, buf) == 0)
753
if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0)
754
retval = TAO::TRAVERSE_STOP;
758
case CORBA::tk_short:
761
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
762
ACE_CDR::SHORT_ALIGN, buf) == 0)
764
if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0)
765
retval = TAO::TRAVERSE_STOP;
769
case CORBA::tk_ushort:
772
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
773
ACE_CDR::SHORT_ALIGN, buf) == 0)
775
if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0)
776
retval = TAO::TRAVERSE_STOP;
780
case CORBA::tk_wchar:
783
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
784
ACE_CDR::SHORT_ALIGN, buf) == 0)
786
if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0)
787
retval = TAO::TRAVERSE_STOP;
794
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
795
ACE_CDR::LONG_ALIGN, buf) == 0)
797
if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0)
798
retval = TAO::TRAVERSE_STOP;
802
case CORBA::tk_ulong:
805
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
806
ACE_CDR::LONG_ALIGN, buf) == 0)
808
if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0)
809
retval = TAO::TRAVERSE_STOP;
813
case CORBA::tk_float:
816
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
817
ACE_CDR::LONG_ALIGN, buf) == 0)
819
if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0)
820
retval = TAO::TRAVERSE_STOP;
824
case CORBA::tk_double:
827
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
828
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
830
if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0)
831
retval = TAO::TRAVERSE_STOP;
835
case CORBA::tk_longlong:
838
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
839
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
841
if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0)
842
retval = TAO::TRAVERSE_STOP;
846
case CORBA::tk_ulonglong:
849
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
850
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
852
if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0)
853
retval = TAO::TRAVERSE_STOP;
857
case CORBA::tk_longdouble:
860
if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds,
861
ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0)
863
if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0)
864
retval = TAO::TRAVERSE_STOP;
870
while (bounds-- && retval == TAO::TRAVERSE_CONTINUE)
872
retval = TAO_Marshal_Object::perform_append (tc2.in (),
875
ACE_ENV_ARG_PARAMETER);
876
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
881
if (retval == TAO::TRAVERSE_CONTINUE)
882
return TAO::TRAVERSE_CONTINUE;
885
if (TAO_debug_level > 0)
888
ACE_TEXT ("marshaling TAO_Marshal_Sequence::append detected error\n")
891
ACE_THROW_RETURN (CORBA::MARSHAL (),
896
TAO_Marshal_Array::append (CORBA::TypeCode_ptr tc,
901
// retrieve the bounds of the array
902
CORBA::ULong bounds = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
903
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
905
// get element typecode
906
CORBA::TypeCode_var tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
907
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
909
// For CORBA basic types, the copy can be optimized
910
CORBA::TCKind kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
911
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
914
TAO::traverse_status retval =
915
TAO::TRAVERSE_CONTINUE;
919
case CORBA::tk_octet:
922
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
923
ACE_CDR::OCTET_ALIGN, buf) == 0)
925
if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0)
926
retval = TAO::TRAVERSE_STOP;
930
case CORBA::tk_boolean:
933
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
934
ACE_CDR::OCTET_ALIGN, buf) == 0)
936
if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0)
937
retval = TAO::TRAVERSE_STOP;
944
if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
945
ACE_CDR::OCTET_ALIGN, buf) == 0)
947
if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0)
948
retval = TAO::TRAVERSE_STOP;
952
case CORBA::tk_short:
955
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
956
ACE_CDR::SHORT_ALIGN, buf) == 0)
958
if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0)
959
retval = TAO::TRAVERSE_STOP;
963
case CORBA::tk_ushort:
966
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
967
ACE_CDR::SHORT_ALIGN, buf) == 0)
969
if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0)
970
retval = TAO::TRAVERSE_STOP;
974
case CORBA::tk_wchar:
977
if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
978
ACE_CDR::SHORT_ALIGN, buf) == 0)
980
if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0)
981
retval = TAO::TRAVERSE_STOP;
988
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
989
ACE_CDR::LONG_ALIGN, buf) == 0)
991
if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0)
992
retval = TAO::TRAVERSE_STOP;
996
case CORBA::tk_ulong:
999
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
1000
ACE_CDR::LONG_ALIGN, buf) == 0)
1002
if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0)
1003
retval = TAO::TRAVERSE_STOP;
1007
case CORBA::tk_float:
1010
if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
1011
ACE_CDR::LONG_ALIGN, buf) == 0)
1013
if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0)
1014
retval = TAO::TRAVERSE_STOP;
1018
case CORBA::tk_double:
1021
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
1022
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
1024
if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0)
1025
retval = TAO::TRAVERSE_STOP;
1029
case CORBA::tk_longlong:
1032
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
1033
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
1035
if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0)
1036
retval = TAO::TRAVERSE_STOP;
1040
case CORBA::tk_ulonglong:
1043
if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
1044
ACE_CDR::LONGLONG_ALIGN, buf) == 0)
1046
if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0)
1047
retval = TAO::TRAVERSE_STOP;
1051
case CORBA::tk_longdouble:
1054
if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds,
1055
ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0)
1057
if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0)
1058
retval = TAO::TRAVERSE_STOP;
1063
while (bounds-- && retval == TAO::TRAVERSE_CONTINUE)
1065
retval = TAO_Marshal_Object::perform_append (tc2.in (),
1068
ACE_ENV_ARG_PARAMETER);
1069
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1074
if (retval == TAO::TRAVERSE_CONTINUE)
1078
if (TAO_debug_level > 0)
1079
ACE_DEBUG ((LM_DEBUG,
1080
ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n")));
1082
ACE_THROW_RETURN (CORBA::MARSHAL (),
1083
TAO::TRAVERSE_STOP);
1086
TAO::traverse_status
1087
TAO_Marshal_Alias::append (CORBA::TypeCode_ptr tc,
1092
// Typecode of the aliased type.
1093
CORBA::TypeCode_var tc2;
1094
CORBA::Boolean continue_append = 1;
1096
// Status of decode operation.
1097
TAO::traverse_status retval =
1098
TAO::TRAVERSE_CONTINUE;
1100
tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
1101
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1103
retval = TAO_Marshal_Object::perform_append (tc2.in (),
1106
ACE_ENV_ARG_PARAMETER);
1107
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1109
if (retval == TAO::TRAVERSE_CONTINUE
1110
&& continue_append == 1)
1111
return TAO::TRAVERSE_CONTINUE;
1113
if (TAO_debug_level > 0)
1114
ACE_DEBUG ((LM_DEBUG,
1115
ACE_TEXT ("TAO_Marshal_Alias::append detected error\n")));
1116
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
1117
CORBA::COMPLETED_MAYBE),
1118
TAO::TRAVERSE_STOP);
1121
// Decode exception For exceptions, the "hidden" type ID near the
1122
// front of the on-wire representation was previously unmarshaled and
1123
// mapped to the "tc" typcode we're using to traverse the memory ...
1124
// at the same time its vtable, refcount, and other state was
1127
// NOTE: This is asymmetric with respect to encoding exceptions.
1128
TAO::traverse_status
1129
TAO_Marshal_Except::append (CORBA::TypeCode_ptr tc,
1134
TAO::traverse_status retval =
1135
TAO::TRAVERSE_CONTINUE;
1136
CORBA::Boolean continue_append = 1;
1137
CORBA::TypeCode_var param;
1139
// first append the RepositoryID
1140
continue_append = dest->append_string (*src);
1142
// Number of fields in the struct.
1143
int member_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
1144
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1146
for (int i = 0; i < member_count
1147
&& retval == TAO::TRAVERSE_CONTINUE
1148
&& continue_append == 1; i++)
1150
param = tc->member_type (i ACE_ENV_ARG_PARAMETER);
1151
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1153
retval = TAO_Marshal_Object::perform_append (param.in (),
1156
ACE_ENV_ARG_PARAMETER);
1159
if (retval == TAO::TRAVERSE_CONTINUE
1160
&& continue_append == 1)
1161
return TAO::TRAVERSE_CONTINUE;
1163
if (TAO_debug_level > 0)
1164
ACE_DEBUG ((LM_DEBUG,
1165
ACE_TEXT ("TAO_Marshal_Except::append detected error\n")));
1166
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
1167
CORBA::COMPLETED_MAYBE),
1168
TAO::TRAVERSE_STOP);
1171
TAO::traverse_status
1172
TAO_Marshal_WString::append (CORBA::TypeCode_ptr,
1177
CORBA::Boolean continue_append = 1;
1179
// On decode, omit the check against specified wstring bounds, and
1180
// cope with illegal "zero length" strings (all lengths on the wire
1181
// must include a NUL).
1183
// This is on the principle of being gracious in what we accept; we
1184
// don't generate messages that fail to comply with protocol specs,
1185
// but we will accept them when it's clear how to do so.
1187
continue_append = dest->append_wstring (*src);
1189
if (continue_append == 1)
1190
return TAO::TRAVERSE_CONTINUE;
1192
if (TAO_debug_level > 0)
1193
ACE_DEBUG ((LM_DEBUG,
1194
ACE_TEXT ("TAO_Marshal_WString::append detected error\n")));
1195
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
1196
CORBA::COMPLETED_MAYBE),
1197
TAO::TRAVERSE_STOP);
1200
TAO::traverse_status
1201
TAO_Marshal_Value::append (CORBA::TypeCode_ptr tc,
1206
TAO::traverse_status retval =
1207
TAO::TRAVERSE_CONTINUE;
1208
CORBA::TypeCode_var param;
1210
// Use the same method to append our base valuetype.
1211
// To achive this we'll need to distinguish between
1212
// first-time/nested appends so that we won't attempt to
1213
// append rep_id several times.
1215
if (nested_processing_ == 0)
1217
nested_processing_ = 1;
1219
CORBA::ULong value_tag;
1221
if (!src->read_ulong (value_tag) ||
1222
!dest->write_ulong (value_tag))
1224
return TAO::TRAVERSE_STOP;
1227
TAO_Valuetype_Adapter *adapter =
1228
ACE_Dynamic_Service<TAO_Valuetype_Adapter>::instance (
1229
TAO_ORB_Core::valuetype_adapter_name ()
1234
ACE_THROW_RETURN (CORBA::INTERNAL (),
1235
TAO::TRAVERSE_STOP);
1238
if (value_tag == 0) // Null value type pointer.
1243
else if (value_tag & adapter->type_info_single ())
1245
// Append repository id which is of type string.
1246
dest->append_string (*src);
1251
return TAO::TRAVERSE_STOP;
1255
// Handle our base valuetype if any.
1256
param = tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER);
1257
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1259
if (param->kind () != CORBA::tk_null)
1261
retval = this->append (param.in (),
1264
ACE_ENV_ARG_PARAMETER);
1265
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1267
if (retval != TAO::TRAVERSE_CONTINUE)
1273
// Number of fields in the struct.
1274
int member_count = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER);
1275
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1278
i < member_count && retval == TAO::TRAVERSE_CONTINUE;
1282
param = tc->member_type (i ACE_ENV_ARG_PARAMETER);
1283
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1286
TAO_Marshal_Object::perform_append (param.in (),
1289
ACE_ENV_ARG_PARAMETER);
1290
ACE_CHECK_RETURN (TAO::TRAVERSE_STOP);
1293
if (retval == TAO::TRAVERSE_CONTINUE)
1294
return TAO::TRAVERSE_CONTINUE;
1296
if (TAO_debug_level > 0)
1297
ACE_DEBUG ((LM_DEBUG,
1298
ACE_TEXT ("TAO_Marshal_Value::append detected error\n")));
1300
ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
1301
CORBA::COMPLETED_MAYBE),
1302
TAO::TRAVERSE_STOP);